repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiAuthUser
public function filterByApiAuthUser($apiAuthUser = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUser)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUser)) { $apiAuthUser = str_replace('*', '%', $apiAuthUser); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_USER, $apiAuthUser, $comparison); }
php
public function filterByApiAuthUser($apiAuthUser = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUser)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUser)) { $apiAuthUser = str_replace('*', '%', $apiAuthUser); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_USER, $apiAuthUser, $comparison); }
[ "public", "function", "filterByApiAuthUser", "(", "$", "apiAuthUser", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "apiAuthUser", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "apiAuthUser", ")", ")", "{", "$", "apiAuthUser", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "apiAuthUser", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "API_AUTH_USER", ",", "$", "apiAuthUser", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the api_auth_user column Example usage: <code> $query->filterByApiAuthUser('fooValue'); // WHERE api_auth_user = 'fooValue' $query->filterByApiAuthUser('%fooValue%'); // WHERE api_auth_user LIKE '%fooValue%' </code> @param string $apiAuthUser The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "api_auth_user", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L598-L610
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiAuthPassword
public function filterByApiAuthPassword($apiAuthPassword = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthPassword)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthPassword)) { $apiAuthPassword = str_replace('*', '%', $apiAuthPassword); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_PASSWORD, $apiAuthPassword, $comparison); }
php
public function filterByApiAuthPassword($apiAuthPassword = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthPassword)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthPassword)) { $apiAuthPassword = str_replace('*', '%', $apiAuthPassword); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_PASSWORD, $apiAuthPassword, $comparison); }
[ "public", "function", "filterByApiAuthPassword", "(", "$", "apiAuthPassword", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "apiAuthPassword", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "apiAuthPassword", ")", ")", "{", "$", "apiAuthPassword", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "apiAuthPassword", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "API_AUTH_PASSWORD", ",", "$", "apiAuthPassword", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the api_auth_password column Example usage: <code> $query->filterByApiAuthPassword('fooValue'); // WHERE api_auth_password = 'fooValue' $query->filterByApiAuthPassword('%fooValue%'); // WHERE api_auth_password LIKE '%fooValue%' </code> @param string $apiAuthPassword The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "api_auth_password", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L627-L639
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiAuthToken
public function filterByApiAuthToken($apiAuthToken = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthToken)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthToken)) { $apiAuthToken = str_replace('*', '%', $apiAuthToken); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_TOKEN, $apiAuthToken, $comparison); }
php
public function filterByApiAuthToken($apiAuthToken = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthToken)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthToken)) { $apiAuthToken = str_replace('*', '%', $apiAuthToken); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_TOKEN, $apiAuthToken, $comparison); }
[ "public", "function", "filterByApiAuthToken", "(", "$", "apiAuthToken", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "apiAuthToken", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "apiAuthToken", ")", ")", "{", "$", "apiAuthToken", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "apiAuthToken", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "API_AUTH_TOKEN", ",", "$", "apiAuthToken", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the api_auth_token column Example usage: <code> $query->filterByApiAuthToken('fooValue'); // WHERE api_auth_token = 'fooValue' $query->filterByApiAuthToken('%fooValue%'); // WHERE api_auth_token LIKE '%fooValue%' </code> @param string $apiAuthToken The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "api_auth_token", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L656-L668
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiAuthUrlUserKey
public function filterByApiAuthUrlUserKey($apiAuthUrlUserKey = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUrlUserKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUrlUserKey)) { $apiAuthUrlUserKey = str_replace('*', '%', $apiAuthUrlUserKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_URL_USER_KEY, $apiAuthUrlUserKey, $comparison); }
php
public function filterByApiAuthUrlUserKey($apiAuthUrlUserKey = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUrlUserKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUrlUserKey)) { $apiAuthUrlUserKey = str_replace('*', '%', $apiAuthUrlUserKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_URL_USER_KEY, $apiAuthUrlUserKey, $comparison); }
[ "public", "function", "filterByApiAuthUrlUserKey", "(", "$", "apiAuthUrlUserKey", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "apiAuthUrlUserKey", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "apiAuthUrlUserKey", ")", ")", "{", "$", "apiAuthUrlUserKey", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "apiAuthUrlUserKey", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "API_AUTH_URL_USER_KEY", ",", "$", "apiAuthUrlUserKey", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the api_auth_url_user_key column Example usage: <code> $query->filterByApiAuthUrlUserKey('fooValue'); // WHERE api_auth_url_user_key = 'fooValue' $query->filterByApiAuthUrlUserKey('%fooValue%'); // WHERE api_auth_url_user_key LIKE '%fooValue%' </code> @param string $apiAuthUrlUserKey The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "api_auth_url_user_key", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L685-L697
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiAuthUrlPwKey
public function filterByApiAuthUrlPwKey($apiAuthUrlPwKey = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUrlPwKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUrlPwKey)) { $apiAuthUrlPwKey = str_replace('*', '%', $apiAuthUrlPwKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_URL_PW_KEY, $apiAuthUrlPwKey, $comparison); }
php
public function filterByApiAuthUrlPwKey($apiAuthUrlPwKey = null, $comparison = null) { if (null === $comparison) { if (is_array($apiAuthUrlPwKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $apiAuthUrlPwKey)) { $apiAuthUrlPwKey = str_replace('*', '%', $apiAuthUrlPwKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::API_AUTH_URL_PW_KEY, $apiAuthUrlPwKey, $comparison); }
[ "public", "function", "filterByApiAuthUrlPwKey", "(", "$", "apiAuthUrlPwKey", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "apiAuthUrlPwKey", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "apiAuthUrlPwKey", ")", ")", "{", "$", "apiAuthUrlPwKey", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "apiAuthUrlPwKey", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "API_AUTH_URL_PW_KEY", ",", "$", "apiAuthUrlPwKey", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the api_auth_url_pw_key column Example usage: <code> $query->filterByApiAuthUrlPwKey('fooValue'); // WHERE api_auth_url_pw_key = 'fooValue' $query->filterByApiAuthUrlPwKey('%fooValue%'); // WHERE api_auth_url_pw_key LIKE '%fooValue%' </code> @param string $apiAuthUrlPwKey The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "api_auth_url_pw_key", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L714-L726
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByCron
public function filterByCron($cron = null, $comparison = null) { if (null === $comparison) { if (is_array($cron)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $cron)) { $cron = str_replace('*', '%', $cron); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::CRON, $cron, $comparison); }
php
public function filterByCron($cron = null, $comparison = null) { if (null === $comparison) { if (is_array($cron)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $cron)) { $cron = str_replace('*', '%', $cron); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::CRON, $cron, $comparison); }
[ "public", "function", "filterByCron", "(", "$", "cron", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "cron", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "cron", ")", ")", "{", "$", "cron", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "cron", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "CRON", ",", "$", "cron", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the cron column Example usage: <code> $query->filterByCron('fooValue'); // WHERE cron = 'fooValue' $query->filterByCron('%fooValue%'); // WHERE cron LIKE '%fooValue%' </code> @param string $cron The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "cron", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L743-L755
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByCustomerId
public function filterByCustomerId($customerId = null, $comparison = null) { if (is_array($customerId)) { $useMinMax = false; if (isset($customerId['min'])) { $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerId['max'])) { $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId, $comparison); }
php
public function filterByCustomerId($customerId = null, $comparison = null) { if (is_array($customerId)) { $useMinMax = false; if (isset($customerId['min'])) { $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerId['max'])) { $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RemoteAppPeer::CUSTOMER_ID, $customerId, $comparison); }
[ "public", "function", "filterByCustomerId", "(", "$", "customerId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "customerId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "customerId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "CUSTOMER_ID", ",", "$", "customerId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "customerId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "CUSTOMER_ID", ",", "$", "customerId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "CUSTOMER_ID", ",", "$", "customerId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the customer_id column Example usage: <code> $query->filterByCustomerId(1234); // WHERE customer_id = 1234 $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34) $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12 $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12 </code> @see filterByCustomer() @param mixed $customerId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "customer_id", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L778-L799
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByLastRun
public function filterByLastRun($lastRun = null, $comparison = null) { if (is_array($lastRun)) { $useMinMax = false; if (isset($lastRun['min'])) { $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($lastRun['max'])) { $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun, $comparison); }
php
public function filterByLastRun($lastRun = null, $comparison = null) { if (is_array($lastRun)) { $useMinMax = false; if (isset($lastRun['min'])) { $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($lastRun['max'])) { $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(RemoteAppPeer::LAST_RUN, $lastRun, $comparison); }
[ "public", "function", "filterByLastRun", "(", "$", "lastRun", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "lastRun", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "lastRun", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "LAST_RUN", ",", "$", "lastRun", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "lastRun", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "LAST_RUN", ",", "$", "lastRun", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "LAST_RUN", ",", "$", "lastRun", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the last_run column Example usage: <code> $query->filterByLastRun('2011-03-14'); // WHERE last_run = '2011-03-14' $query->filterByLastRun('now'); // WHERE last_run = '2011-03-14' $query->filterByLastRun(array('max' => 'yesterday')); // WHERE last_run < '2011-03-13' </code> @param mixed $lastRun The value to use as filter. Values can be integers (unix timestamps), DateTime objects, or strings. Empty strings are treated as NULL. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "last_run", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L877-L898
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByIncludelog
public function filterByIncludelog($includelog = null, $comparison = null) { if (is_string($includelog)) { $includelog = in_array(strtolower($includelog), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::INCLUDELOG, $includelog, $comparison); }
php
public function filterByIncludelog($includelog = null, $comparison = null) { if (is_string($includelog)) { $includelog = in_array(strtolower($includelog), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::INCLUDELOG, $includelog, $comparison); }
[ "public", "function", "filterByIncludelog", "(", "$", "includelog", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "includelog", ")", ")", "{", "$", "includelog", "=", "in_array", "(", "strtolower", "(", "$", "includelog", ")", ",", "array", "(", "'false'", ",", "'off'", ",", "'-'", ",", "'no'", ",", "'n'", ",", "'0'", ",", "''", ")", ")", "?", "false", ":", "true", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "INCLUDELOG", ",", "$", "includelog", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the includeLog column Example usage: <code> $query->filterByIncludelog(true); // WHERE includeLog = true $query->filterByIncludelog('yes'); // WHERE includeLog = true </code> @param boolean|string $includelog The value to use as filter. Non-boolean arguments are converted using the following rules: * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * 0, '0', 'false', 'off', and 'no' are converted to boolean false Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "includeLog", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L918-L925
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByPublicKey
public function filterByPublicKey($publicKey = null, $comparison = null) { if (null === $comparison) { if (is_array($publicKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $publicKey)) { $publicKey = str_replace('*', '%', $publicKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::PUBLIC_KEY, $publicKey, $comparison); }
php
public function filterByPublicKey($publicKey = null, $comparison = null) { if (null === $comparison) { if (is_array($publicKey)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $publicKey)) { $publicKey = str_replace('*', '%', $publicKey); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::PUBLIC_KEY, $publicKey, $comparison); }
[ "public", "function", "filterByPublicKey", "(", "$", "publicKey", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "publicKey", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "publicKey", ")", ")", "{", "$", "publicKey", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "publicKey", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "PUBLIC_KEY", ",", "$", "publicKey", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the public_key column Example usage: <code> $query->filterByPublicKey('fooValue'); // WHERE public_key = 'fooValue' $query->filterByPublicKey('%fooValue%'); // WHERE public_key LIKE '%fooValue%' </code> @param string $publicKey The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "public_key", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L942-L954
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByWebsiteHash
public function filterByWebsiteHash($websiteHash = null, $comparison = null) { if (null === $comparison) { if (is_array($websiteHash)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $websiteHash)) { $websiteHash = str_replace('*', '%', $websiteHash); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::WEBSITE_HASH, $websiteHash, $comparison); }
php
public function filterByWebsiteHash($websiteHash = null, $comparison = null) { if (null === $comparison) { if (is_array($websiteHash)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $websiteHash)) { $websiteHash = str_replace('*', '%', $websiteHash); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::WEBSITE_HASH, $websiteHash, $comparison); }
[ "public", "function", "filterByWebsiteHash", "(", "$", "websiteHash", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "websiteHash", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "websiteHash", ")", ")", "{", "$", "websiteHash", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "websiteHash", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "WEBSITE_HASH", ",", "$", "websiteHash", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the website_hash column Example usage: <code> $query->filterByWebsiteHash('fooValue'); // WHERE website_hash = 'fooValue' $query->filterByWebsiteHash('%fooValue%'); // WHERE website_hash LIKE '%fooValue%' </code> @param string $websiteHash The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "website_hash", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L971-L983
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByNotificationRecipient
public function filterByNotificationRecipient($notificationRecipient = null, $comparison = null) { if (null === $comparison) { if (is_array($notificationRecipient)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $notificationRecipient)) { $notificationRecipient = str_replace('*', '%', $notificationRecipient); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_RECIPIENT, $notificationRecipient, $comparison); }
php
public function filterByNotificationRecipient($notificationRecipient = null, $comparison = null) { if (null === $comparison) { if (is_array($notificationRecipient)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $notificationRecipient)) { $notificationRecipient = str_replace('*', '%', $notificationRecipient); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_RECIPIENT, $notificationRecipient, $comparison); }
[ "public", "function", "filterByNotificationRecipient", "(", "$", "notificationRecipient", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "notificationRecipient", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "notificationRecipient", ")", ")", "{", "$", "notificationRecipient", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "notificationRecipient", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "NOTIFICATION_RECIPIENT", ",", "$", "notificationRecipient", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the notification_recipient column Example usage: <code> $query->filterByNotificationRecipient('fooValue'); // WHERE notification_recipient = 'fooValue' $query->filterByNotificationRecipient('%fooValue%'); // WHERE notification_recipient LIKE '%fooValue%' </code> @param string $notificationRecipient The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "notification_recipient", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1000-L1012
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByNotificationSender
public function filterByNotificationSender($notificationSender = null, $comparison = null) { if (null === $comparison) { if (is_array($notificationSender)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $notificationSender)) { $notificationSender = str_replace('*', '%', $notificationSender); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_SENDER, $notificationSender, $comparison); }
php
public function filterByNotificationSender($notificationSender = null, $comparison = null) { if (null === $comparison) { if (is_array($notificationSender)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $notificationSender)) { $notificationSender = str_replace('*', '%', $notificationSender); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_SENDER, $notificationSender, $comparison); }
[ "public", "function", "filterByNotificationSender", "(", "$", "notificationSender", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "notificationSender", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "notificationSender", ")", ")", "{", "$", "notificationSender", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "notificationSender", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "NOTIFICATION_SENDER", ",", "$", "notificationSender", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the notification_sender column Example usage: <code> $query->filterByNotificationSender('fooValue'); // WHERE notification_sender = 'fooValue' $query->filterByNotificationSender('%fooValue%'); // WHERE notification_sender LIKE '%fooValue%' </code> @param string $notificationSender The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "notification_sender", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1029-L1041
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByNotificationChange
public function filterByNotificationChange($notificationChange = null, $comparison = null) { if (is_string($notificationChange)) { $notificationChange = in_array(strtolower($notificationChange), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_CHANGE, $notificationChange, $comparison); }
php
public function filterByNotificationChange($notificationChange = null, $comparison = null) { if (is_string($notificationChange)) { $notificationChange = in_array(strtolower($notificationChange), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_CHANGE, $notificationChange, $comparison); }
[ "public", "function", "filterByNotificationChange", "(", "$", "notificationChange", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "notificationChange", ")", ")", "{", "$", "notificationChange", "=", "in_array", "(", "strtolower", "(", "$", "notificationChange", ")", ",", "array", "(", "'false'", ",", "'off'", ",", "'-'", ",", "'no'", ",", "'n'", ",", "'0'", ",", "''", ")", ")", "?", "false", ":", "true", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "NOTIFICATION_CHANGE", ",", "$", "notificationChange", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the notification_change column Example usage: <code> $query->filterByNotificationChange(true); // WHERE notification_change = true $query->filterByNotificationChange('yes'); // WHERE notification_change = true </code> @param boolean|string $notificationChange The value to use as filter. Non-boolean arguments are converted using the following rules: * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * 0, '0', 'false', 'off', and 'no' are converted to boolean false Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "notification_change", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1061-L1068
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByNotificationError
public function filterByNotificationError($notificationError = null, $comparison = null) { if (is_string($notificationError)) { $notificationError = in_array(strtolower($notificationError), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_ERROR, $notificationError, $comparison); }
php
public function filterByNotificationError($notificationError = null, $comparison = null) { if (is_string($notificationError)) { $notificationError = in_array(strtolower($notificationError), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(RemoteAppPeer::NOTIFICATION_ERROR, $notificationError, $comparison); }
[ "public", "function", "filterByNotificationError", "(", "$", "notificationError", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "notificationError", ")", ")", "{", "$", "notificationError", "=", "in_array", "(", "strtolower", "(", "$", "notificationError", ")", ",", "array", "(", "'false'", ",", "'off'", ",", "'-'", ",", "'no'", ",", "'n'", ",", "'0'", ",", "''", ")", ")", "?", "false", ":", "true", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "NOTIFICATION_ERROR", ",", "$", "notificationError", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the notification_error column Example usage: <code> $query->filterByNotificationError(true); // WHERE notification_error = true $query->filterByNotificationError('yes'); // WHERE notification_error = true </code> @param boolean|string $notificationError The value to use as filter. Non-boolean arguments are converted using the following rules: * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * 0, '0', 'false', 'off', and 'no' are converted to boolean false Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "notification_error", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1088-L1095
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByApiLog
public function filterByApiLog($apiLog, $comparison = null) { if ($apiLog instanceof ApiLog) { return $this ->addUsingAlias(RemoteAppPeer::ID, $apiLog->getRemoteAppId(), $comparison); } elseif ($apiLog instanceof PropelObjectCollection) { return $this ->useApiLogQuery() ->filterByPrimaryKeys($apiLog->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByApiLog() only accepts arguments of type ApiLog or PropelCollection'); } }
php
public function filterByApiLog($apiLog, $comparison = null) { if ($apiLog instanceof ApiLog) { return $this ->addUsingAlias(RemoteAppPeer::ID, $apiLog->getRemoteAppId(), $comparison); } elseif ($apiLog instanceof PropelObjectCollection) { return $this ->useApiLogQuery() ->filterByPrimaryKeys($apiLog->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByApiLog() only accepts arguments of type ApiLog or PropelCollection'); } }
[ "public", "function", "filterByApiLog", "(", "$", "apiLog", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "apiLog", "instanceof", "ApiLog", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "ID", ",", "$", "apiLog", "->", "getRemoteAppId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "apiLog", "instanceof", "PropelObjectCollection", ")", "{", "return", "$", "this", "->", "useApiLogQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "apiLog", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByApiLog() only accepts arguments of type ApiLog or PropelCollection'", ")", ";", "}", "}" ]
Filter the query by a related ApiLog object @param ApiLog|PropelObjectCollection $apiLog the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface @throws PropelException - if the provided filter is invalid.
[ "Filter", "the", "query", "by", "a", "related", "ApiLog", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1182-L1195
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.useApiLogQuery
public function useApiLogQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinApiLog($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'ApiLog', '\Slashworks\AppBundle\Model\ApiLogQuery'); }
php
public function useApiLogQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinApiLog($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'ApiLog', '\Slashworks\AppBundle\Model\ApiLogQuery'); }
[ "public", "function", "useApiLogQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinApiLog", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'ApiLog'", ",", "'\\Slashworks\\AppBundle\\Model\\ApiLogQuery'", ")", ";", "}" ]
Use the ApiLog relation ApiLog object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Slashworks\AppBundle\Model\ApiLogQuery A secondary query class using the current class as primary query
[ "Use", "the", "ApiLog", "relation", "ApiLog", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1240-L1245
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.filterByRemoteHistoryContao
public function filterByRemoteHistoryContao($remoteHistoryContao, $comparison = null) { if ($remoteHistoryContao instanceof RemoteHistoryContao) { return $this ->addUsingAlias(RemoteAppPeer::ID, $remoteHistoryContao->getRemoteAppId(), $comparison); } elseif ($remoteHistoryContao instanceof PropelObjectCollection) { return $this ->useRemoteHistoryContaoQuery() ->filterByPrimaryKeys($remoteHistoryContao->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByRemoteHistoryContao() only accepts arguments of type RemoteHistoryContao or PropelCollection'); } }
php
public function filterByRemoteHistoryContao($remoteHistoryContao, $comparison = null) { if ($remoteHistoryContao instanceof RemoteHistoryContao) { return $this ->addUsingAlias(RemoteAppPeer::ID, $remoteHistoryContao->getRemoteAppId(), $comparison); } elseif ($remoteHistoryContao instanceof PropelObjectCollection) { return $this ->useRemoteHistoryContaoQuery() ->filterByPrimaryKeys($remoteHistoryContao->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByRemoteHistoryContao() only accepts arguments of type RemoteHistoryContao or PropelCollection'); } }
[ "public", "function", "filterByRemoteHistoryContao", "(", "$", "remoteHistoryContao", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "remoteHistoryContao", "instanceof", "RemoteHistoryContao", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "ID", ",", "$", "remoteHistoryContao", "->", "getRemoteAppId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "remoteHistoryContao", "instanceof", "PropelObjectCollection", ")", "{", "return", "$", "this", "->", "useRemoteHistoryContaoQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "remoteHistoryContao", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByRemoteHistoryContao() only accepts arguments of type RemoteHistoryContao or PropelCollection'", ")", ";", "}", "}" ]
Filter the query by a related RemoteHistoryContao object @param RemoteHistoryContao|PropelObjectCollection $remoteHistoryContao the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return RemoteAppQuery The current query, for fluid interface @throws PropelException - if the provided filter is invalid.
[ "Filter", "the", "query", "by", "a", "related", "RemoteHistoryContao", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1256-L1269
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.useRemoteHistoryContaoQuery
public function useRemoteHistoryContaoQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRemoteHistoryContao($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'RemoteHistoryContao', '\Slashworks\AppBundle\Model\RemoteHistoryContaoQuery'); }
php
public function useRemoteHistoryContaoQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinRemoteHistoryContao($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'RemoteHistoryContao', '\Slashworks\AppBundle\Model\RemoteHistoryContaoQuery'); }
[ "public", "function", "useRemoteHistoryContaoQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinRemoteHistoryContao", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'RemoteHistoryContao'", ",", "'\\Slashworks\\AppBundle\\Model\\RemoteHistoryContaoQuery'", ")", ";", "}" ]
Use the RemoteHistoryContao relation RemoteHistoryContao object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Slashworks\AppBundle\Model\RemoteHistoryContaoQuery A secondary query class using the current class as primary query
[ "Use", "the", "RemoteHistoryContao", "relation", "RemoteHistoryContao", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1314-L1319
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php
BaseRemoteAppQuery.prune
public function prune($remoteApp = null) { if ($remoteApp) { $this->addUsingAlias(RemoteAppPeer::ID, $remoteApp->getId(), Criteria::NOT_EQUAL); } return $this; }
php
public function prune($remoteApp = null) { if ($remoteApp) { $this->addUsingAlias(RemoteAppPeer::ID, $remoteApp->getId(), Criteria::NOT_EQUAL); } return $this; }
[ "public", "function", "prune", "(", "$", "remoteApp", "=", "null", ")", "{", "if", "(", "$", "remoteApp", ")", "{", "$", "this", "->", "addUsingAlias", "(", "RemoteAppPeer", "::", "ID", ",", "$", "remoteApp", "->", "getId", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Exclude object from result @param RemoteApp $remoteApp Object to remove from the list of results @return RemoteAppQuery The current query, for fluid interface
[ "Exclude", "object", "from", "result" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L1328-L1335
praxisnetau/silverware-spam-guard
src/Guards/SimpleSpamGuard.php
SimpleSpamGuard.getFormField
public function getFormField($name = null, $title = null, $value = null) { return SimpleSpamGuardField::create($name, $title, $value)->setTimeLimit($this->timeLimit); }
php
public function getFormField($name = null, $title = null, $value = null) { return SimpleSpamGuardField::create($name, $title, $value)->setTimeLimit($this->timeLimit); }
[ "public", "function", "getFormField", "(", "$", "name", "=", "null", ",", "$", "title", "=", "null", ",", "$", "value", "=", "null", ")", "{", "return", "SimpleSpamGuardField", "::", "create", "(", "$", "name", ",", "$", "title", ",", "$", "value", ")", "->", "setTimeLimit", "(", "$", "this", "->", "timeLimit", ")", ";", "}" ]
Answers the form field used for implementing the spam guard. @param string $name @param string $title @param mixed $value @return SimpleSpamGuardField
[ "Answers", "the", "form", "field", "used", "for", "implementing", "the", "spam", "guard", "." ]
train
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Guards/SimpleSpamGuard.php#L136-L139
nexusnetsoftgmbh/nexuscli
src/Nexus/Shell/Business/Model/Executor/ShellExec.php
ShellExec.execute
public function execute(string $command): string { $result = shell_exec($command); if ($result === null) { $result = ''; } return $result; }
php
public function execute(string $command): string { $result = shell_exec($command); if ($result === null) { $result = ''; } return $result; }
[ "public", "function", "execute", "(", "string", "$", "command", ")", ":", "string", "{", "$", "result", "=", "shell_exec", "(", "$", "command", ")", ";", "if", "(", "$", "result", "===", "null", ")", "{", "$", "result", "=", "''", ";", "}", "return", "$", "result", ";", "}" ]
@param string $command @return string
[ "@param", "string", "$command" ]
train
https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/Shell/Business/Model/Executor/ShellExec.php#L14-L21
PortaText/php-sdk
src/PortaText/Command/Api/Tariffs.php
Tariffs.getEndpoint
protected function getEndpoint($method) { $endpoint = "tariffs"; $countryIso = $this->getArgument("id"); if (!is_null($countryIso)) { $endpoint .= "/$countryIso"; $this->delArgument("id"); } return $endpoint; }
php
protected function getEndpoint($method) { $endpoint = "tariffs"; $countryIso = $this->getArgument("id"); if (!is_null($countryIso)) { $endpoint .= "/$countryIso"; $this->delArgument("id"); } return $endpoint; }
[ "protected", "function", "getEndpoint", "(", "$", "method", ")", "{", "$", "endpoint", "=", "\"tariffs\"", ";", "$", "countryIso", "=", "$", "this", "->", "getArgument", "(", "\"id\"", ")", ";", "if", "(", "!", "is_null", "(", "$", "countryIso", ")", ")", "{", "$", "endpoint", ".=", "\"/$countryIso\"", ";", "$", "this", "->", "delArgument", "(", "\"id\"", ")", ";", "}", "return", "$", "endpoint", ";", "}" ]
Returns a string with the endpoint for the given command. @param string $method Method for this command. @return string
[ "Returns", "a", "string", "with", "the", "endpoint", "for", "the", "given", "command", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Tariffs.php#L38-L47
phpmob/changmin
src/PhpMob/MediaBundle/DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_media'); $this->addImageFiltersSection($rootNode); $this->addImagineSection($rootNode); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->end() ; return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('phpmob_media'); $this->addImageFiltersSection($rootNode); $this->addImagineSection($rootNode); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->end() ; return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'phpmob_media'", ")", ";", "$", "this", "->", "addImageFiltersSection", "(", "$", "rootNode", ")", ";", "$", "this", "->", "addImagineSection", "(", "$", "rootNode", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "scalarNode", "(", "'driver'", ")", "->", "defaultValue", "(", "SyliusResourceBundle", "::", "DRIVER_DOCTRINE_ORM", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/DependencyInjection/Configuration.php#L27-L42
wikimedia/CLDRPluralRuleParser
src/Converter.php
Converter.doConvert
protected function doConvert() { $expectOperator = true; // Iterate through all tokens, saving the operators and operands to a // stack per Dijkstra's shunting yard algorithm. /** @var Operator $token */ while ( false !== ( $token = $this->nextToken() ) ) { // In this grammar, there are only binary operators, so every valid // rule string will alternate between operator and operand tokens. $expectOperator = !$expectOperator; if ( $token instanceof Expression ) { // Operand if ( $expectOperator ) { $token->error( 'unexpected operand' ); } $this->operands[] = $token; continue; } else { // Operator if ( !$expectOperator ) { $token->error( 'unexpected operator' ); } // Resolve higher precedence levels $lastOp = end( $this->operators ); while ( $lastOp && self::$precedence[$token->name] <= self::$precedence[$lastOp->name] ) { $this->doOperation( $lastOp ); array_pop( $this->operators ); $lastOp = end( $this->operators ); } $this->operators[] = $token; } } // Finish off the stack while ( $op = array_pop( $this->operators ) ) { $this->doOperation( $op ); } // Make sure the result is sane. The first case is possible for an empty // string input, the second should be unreachable. if ( !count( $this->operands ) ) { $this->error( 'condition expected' ); } elseif ( count( $this->operands ) > 1 ) { $this->error( 'missing operator or too many operands' ); } $value = $this->operands[0]; if ( $value->type !== 'boolean' ) { $this->error( 'the result must have a boolean type' ); } return $this->operands[0]->rpn; }
php
protected function doConvert() { $expectOperator = true; // Iterate through all tokens, saving the operators and operands to a // stack per Dijkstra's shunting yard algorithm. /** @var Operator $token */ while ( false !== ( $token = $this->nextToken() ) ) { // In this grammar, there are only binary operators, so every valid // rule string will alternate between operator and operand tokens. $expectOperator = !$expectOperator; if ( $token instanceof Expression ) { // Operand if ( $expectOperator ) { $token->error( 'unexpected operand' ); } $this->operands[] = $token; continue; } else { // Operator if ( !$expectOperator ) { $token->error( 'unexpected operator' ); } // Resolve higher precedence levels $lastOp = end( $this->operators ); while ( $lastOp && self::$precedence[$token->name] <= self::$precedence[$lastOp->name] ) { $this->doOperation( $lastOp ); array_pop( $this->operators ); $lastOp = end( $this->operators ); } $this->operators[] = $token; } } // Finish off the stack while ( $op = array_pop( $this->operators ) ) { $this->doOperation( $op ); } // Make sure the result is sane. The first case is possible for an empty // string input, the second should be unreachable. if ( !count( $this->operands ) ) { $this->error( 'condition expected' ); } elseif ( count( $this->operands ) > 1 ) { $this->error( 'missing operator or too many operands' ); } $value = $this->operands[0]; if ( $value->type !== 'boolean' ) { $this->error( 'the result must have a boolean type' ); } return $this->operands[0]->rpn; }
[ "protected", "function", "doConvert", "(", ")", "{", "$", "expectOperator", "=", "true", ";", "// Iterate through all tokens, saving the operators and operands to a", "// stack per Dijkstra's shunting yard algorithm.", "/** @var Operator $token */", "while", "(", "false", "!==", "(", "$", "token", "=", "$", "this", "->", "nextToken", "(", ")", ")", ")", "{", "// In this grammar, there are only binary operators, so every valid", "// rule string will alternate between operator and operand tokens.", "$", "expectOperator", "=", "!", "$", "expectOperator", ";", "if", "(", "$", "token", "instanceof", "Expression", ")", "{", "// Operand", "if", "(", "$", "expectOperator", ")", "{", "$", "token", "->", "error", "(", "'unexpected operand'", ")", ";", "}", "$", "this", "->", "operands", "[", "]", "=", "$", "token", ";", "continue", ";", "}", "else", "{", "// Operator", "if", "(", "!", "$", "expectOperator", ")", "{", "$", "token", "->", "error", "(", "'unexpected operator'", ")", ";", "}", "// Resolve higher precedence levels", "$", "lastOp", "=", "end", "(", "$", "this", "->", "operators", ")", ";", "while", "(", "$", "lastOp", "&&", "self", "::", "$", "precedence", "[", "$", "token", "->", "name", "]", "<=", "self", "::", "$", "precedence", "[", "$", "lastOp", "->", "name", "]", ")", "{", "$", "this", "->", "doOperation", "(", "$", "lastOp", ")", ";", "array_pop", "(", "$", "this", "->", "operators", ")", ";", "$", "lastOp", "=", "end", "(", "$", "this", "->", "operators", ")", ";", "}", "$", "this", "->", "operators", "[", "]", "=", "$", "token", ";", "}", "}", "// Finish off the stack", "while", "(", "$", "op", "=", "array_pop", "(", "$", "this", "->", "operators", ")", ")", "{", "$", "this", "->", "doOperation", "(", "$", "op", ")", ";", "}", "// Make sure the result is sane. The first case is possible for an empty", "// string input, the second should be unreachable.", "if", "(", "!", "count", "(", "$", "this", "->", "operands", ")", ")", "{", "$", "this", "->", "error", "(", "'condition expected'", ")", ";", "}", "elseif", "(", "count", "(", "$", "this", "->", "operands", ")", ">", "1", ")", "{", "$", "this", "->", "error", "(", "'missing operator or too many operands'", ")", ";", "}", "$", "value", "=", "$", "this", "->", "operands", "[", "0", "]", ";", "if", "(", "$", "value", "->", "type", "!==", "'boolean'", ")", "{", "$", "this", "->", "error", "(", "'the result must have a boolean type'", ")", ";", "}", "return", "$", "this", "->", "operands", "[", "0", "]", "->", "rpn", ";", "}" ]
Do the operation. @return string The RPN representation of the rule (e.g. "5 3 mod n is")
[ "Do", "the", "operation", "." ]
train
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Converter.php#L121-L174
wikimedia/CLDRPluralRuleParser
src/Converter.php
Converter.nextToken
protected function nextToken() { if ( $this->pos >= $this->end ) { return false; } // Whitespace $length = strspn( $this->rule, self::WHITESPACE_CLASS, $this->pos ); $this->pos += $length; if ( $this->pos >= $this->end ) { return false; } // Number $length = strspn( $this->rule, self::NUMBER_CLASS, $this->pos ); if ( $length !== 0 ) { $token = $this->newNumber( substr( $this->rule, $this->pos, $length ), $this->pos ); $this->pos += $length; return $token; } // Two-character operators $op2 = substr( $this->rule, $this->pos, 2 ); if ( $op2 === '..' || $op2 === '!=' ) { $token = $this->newOperator( $op2, $this->pos, 2 ); $this->pos += 2; return $token; } // Single-character operators $op1 = $this->rule[$this->pos]; if ( $op1 === ',' || $op1 === '=' || $op1 === '%' ) { $token = $this->newOperator( $op1, $this->pos, 1 ); $this->pos++; return $token; } // Word if ( !preg_match( self::WORD_REGEX, $this->rule, $m, 0, $this->pos ) ) { $this->error( 'unexpected character "' . $this->rule[$this->pos] . '"' ); } $word1 = strtolower( $m[0] ); $word2 = ''; $nextTokenPos = $this->pos + strlen( $word1 ); if ( $word1 === 'not' || $word1 === 'is' ) { // Look ahead one word $nextTokenPos += strspn( $this->rule, self::WHITESPACE_CLASS, $nextTokenPos ); if ( $nextTokenPos < $this->end && preg_match( self::WORD_REGEX, $this->rule, $m, 0, $nextTokenPos ) ) { $word2 = strtolower( $m[0] ); $nextTokenPos += strlen( $word2 ); } } // Two-word operators like "is not" take precedence over single-word operators like "is" if ( $word2 !== '' ) { $bothWords = "{$word1}-{$word2}"; if ( isset( self::$precedence[$bothWords] ) ) { $token = $this->newOperator( $bothWords, $this->pos, $nextTokenPos - $this->pos ); $this->pos = $nextTokenPos; return $token; } } // Single-word operators if ( isset( self::$precedence[$word1] ) ) { $token = $this->newOperator( $word1, $this->pos, strlen( $word1 ) ); $this->pos += strlen( $word1 ); return $token; } // The single-character operand symbols if ( strpos( self::OPERAND_SYMBOLS, $word1 ) !== false ) { $token = $this->newNumber( $word1, $this->pos ); $this->pos++; return $token; } // Samples if ( $word1 === '@integer' || $word1 === '@decimal' ) { // Samples are like comments, they have no effect on rule evaluation. // They run from the first sample indicator to the end of the string. $this->pos = $this->end; return false; } $this->error( 'unrecognised word' ); }
php
protected function nextToken() { if ( $this->pos >= $this->end ) { return false; } // Whitespace $length = strspn( $this->rule, self::WHITESPACE_CLASS, $this->pos ); $this->pos += $length; if ( $this->pos >= $this->end ) { return false; } // Number $length = strspn( $this->rule, self::NUMBER_CLASS, $this->pos ); if ( $length !== 0 ) { $token = $this->newNumber( substr( $this->rule, $this->pos, $length ), $this->pos ); $this->pos += $length; return $token; } // Two-character operators $op2 = substr( $this->rule, $this->pos, 2 ); if ( $op2 === '..' || $op2 === '!=' ) { $token = $this->newOperator( $op2, $this->pos, 2 ); $this->pos += 2; return $token; } // Single-character operators $op1 = $this->rule[$this->pos]; if ( $op1 === ',' || $op1 === '=' || $op1 === '%' ) { $token = $this->newOperator( $op1, $this->pos, 1 ); $this->pos++; return $token; } // Word if ( !preg_match( self::WORD_REGEX, $this->rule, $m, 0, $this->pos ) ) { $this->error( 'unexpected character "' . $this->rule[$this->pos] . '"' ); } $word1 = strtolower( $m[0] ); $word2 = ''; $nextTokenPos = $this->pos + strlen( $word1 ); if ( $word1 === 'not' || $word1 === 'is' ) { // Look ahead one word $nextTokenPos += strspn( $this->rule, self::WHITESPACE_CLASS, $nextTokenPos ); if ( $nextTokenPos < $this->end && preg_match( self::WORD_REGEX, $this->rule, $m, 0, $nextTokenPos ) ) { $word2 = strtolower( $m[0] ); $nextTokenPos += strlen( $word2 ); } } // Two-word operators like "is not" take precedence over single-word operators like "is" if ( $word2 !== '' ) { $bothWords = "{$word1}-{$word2}"; if ( isset( self::$precedence[$bothWords] ) ) { $token = $this->newOperator( $bothWords, $this->pos, $nextTokenPos - $this->pos ); $this->pos = $nextTokenPos; return $token; } } // Single-word operators if ( isset( self::$precedence[$word1] ) ) { $token = $this->newOperator( $word1, $this->pos, strlen( $word1 ) ); $this->pos += strlen( $word1 ); return $token; } // The single-character operand symbols if ( strpos( self::OPERAND_SYMBOLS, $word1 ) !== false ) { $token = $this->newNumber( $word1, $this->pos ); $this->pos++; return $token; } // Samples if ( $word1 === '@integer' || $word1 === '@decimal' ) { // Samples are like comments, they have no effect on rule evaluation. // They run from the first sample indicator to the end of the string. $this->pos = $this->end; return false; } $this->error( 'unrecognised word' ); }
[ "protected", "function", "nextToken", "(", ")", "{", "if", "(", "$", "this", "->", "pos", ">=", "$", "this", "->", "end", ")", "{", "return", "false", ";", "}", "// Whitespace", "$", "length", "=", "strspn", "(", "$", "this", "->", "rule", ",", "self", "::", "WHITESPACE_CLASS", ",", "$", "this", "->", "pos", ")", ";", "$", "this", "->", "pos", "+=", "$", "length", ";", "if", "(", "$", "this", "->", "pos", ">=", "$", "this", "->", "end", ")", "{", "return", "false", ";", "}", "// Number", "$", "length", "=", "strspn", "(", "$", "this", "->", "rule", ",", "self", "::", "NUMBER_CLASS", ",", "$", "this", "->", "pos", ")", ";", "if", "(", "$", "length", "!==", "0", ")", "{", "$", "token", "=", "$", "this", "->", "newNumber", "(", "substr", "(", "$", "this", "->", "rule", ",", "$", "this", "->", "pos", ",", "$", "length", ")", ",", "$", "this", "->", "pos", ")", ";", "$", "this", "->", "pos", "+=", "$", "length", ";", "return", "$", "token", ";", "}", "// Two-character operators", "$", "op2", "=", "substr", "(", "$", "this", "->", "rule", ",", "$", "this", "->", "pos", ",", "2", ")", ";", "if", "(", "$", "op2", "===", "'..'", "||", "$", "op2", "===", "'!='", ")", "{", "$", "token", "=", "$", "this", "->", "newOperator", "(", "$", "op2", ",", "$", "this", "->", "pos", ",", "2", ")", ";", "$", "this", "->", "pos", "+=", "2", ";", "return", "$", "token", ";", "}", "// Single-character operators", "$", "op1", "=", "$", "this", "->", "rule", "[", "$", "this", "->", "pos", "]", ";", "if", "(", "$", "op1", "===", "','", "||", "$", "op1", "===", "'='", "||", "$", "op1", "===", "'%'", ")", "{", "$", "token", "=", "$", "this", "->", "newOperator", "(", "$", "op1", ",", "$", "this", "->", "pos", ",", "1", ")", ";", "$", "this", "->", "pos", "++", ";", "return", "$", "token", ";", "}", "// Word", "if", "(", "!", "preg_match", "(", "self", "::", "WORD_REGEX", ",", "$", "this", "->", "rule", ",", "$", "m", ",", "0", ",", "$", "this", "->", "pos", ")", ")", "{", "$", "this", "->", "error", "(", "'unexpected character \"'", ".", "$", "this", "->", "rule", "[", "$", "this", "->", "pos", "]", ".", "'\"'", ")", ";", "}", "$", "word1", "=", "strtolower", "(", "$", "m", "[", "0", "]", ")", ";", "$", "word2", "=", "''", ";", "$", "nextTokenPos", "=", "$", "this", "->", "pos", "+", "strlen", "(", "$", "word1", ")", ";", "if", "(", "$", "word1", "===", "'not'", "||", "$", "word1", "===", "'is'", ")", "{", "// Look ahead one word", "$", "nextTokenPos", "+=", "strspn", "(", "$", "this", "->", "rule", ",", "self", "::", "WHITESPACE_CLASS", ",", "$", "nextTokenPos", ")", ";", "if", "(", "$", "nextTokenPos", "<", "$", "this", "->", "end", "&&", "preg_match", "(", "self", "::", "WORD_REGEX", ",", "$", "this", "->", "rule", ",", "$", "m", ",", "0", ",", "$", "nextTokenPos", ")", ")", "{", "$", "word2", "=", "strtolower", "(", "$", "m", "[", "0", "]", ")", ";", "$", "nextTokenPos", "+=", "strlen", "(", "$", "word2", ")", ";", "}", "}", "// Two-word operators like \"is not\" take precedence over single-word operators like \"is\"", "if", "(", "$", "word2", "!==", "''", ")", "{", "$", "bothWords", "=", "\"{$word1}-{$word2}\"", ";", "if", "(", "isset", "(", "self", "::", "$", "precedence", "[", "$", "bothWords", "]", ")", ")", "{", "$", "token", "=", "$", "this", "->", "newOperator", "(", "$", "bothWords", ",", "$", "this", "->", "pos", ",", "$", "nextTokenPos", "-", "$", "this", "->", "pos", ")", ";", "$", "this", "->", "pos", "=", "$", "nextTokenPos", ";", "return", "$", "token", ";", "}", "}", "// Single-word operators", "if", "(", "isset", "(", "self", "::", "$", "precedence", "[", "$", "word1", "]", ")", ")", "{", "$", "token", "=", "$", "this", "->", "newOperator", "(", "$", "word1", ",", "$", "this", "->", "pos", ",", "strlen", "(", "$", "word1", ")", ")", ";", "$", "this", "->", "pos", "+=", "strlen", "(", "$", "word1", ")", ";", "return", "$", "token", ";", "}", "// The single-character operand symbols", "if", "(", "strpos", "(", "self", "::", "OPERAND_SYMBOLS", ",", "$", "word1", ")", "!==", "false", ")", "{", "$", "token", "=", "$", "this", "->", "newNumber", "(", "$", "word1", ",", "$", "this", "->", "pos", ")", ";", "$", "this", "->", "pos", "++", ";", "return", "$", "token", ";", "}", "// Samples", "if", "(", "$", "word1", "===", "'@integer'", "||", "$", "word1", "===", "'@decimal'", ")", "{", "// Samples are like comments, they have no effect on rule evaluation.", "// They run from the first sample indicator to the end of the string.", "$", "this", "->", "pos", "=", "$", "this", "->", "end", ";", "return", "false", ";", "}", "$", "this", "->", "error", "(", "'unrecognised word'", ")", ";", "}" ]
Fetch the next token from the input string. @return Fragment The next token
[ "Fetch", "the", "next", "token", "from", "the", "input", "string", "." ]
train
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Converter.php#L181-L276
wikimedia/CLDRPluralRuleParser
src/Converter.php
Converter.doOperation
protected function doOperation( Operator $op ) { if ( count( $this->operands ) < 2 ) { $op->error( 'missing operand' ); } $right = array_pop( $this->operands ); $left = array_pop( $this->operands ); $result = $op->operate( $left, $right ); $this->operands[] = $result; }
php
protected function doOperation( Operator $op ) { if ( count( $this->operands ) < 2 ) { $op->error( 'missing operand' ); } $right = array_pop( $this->operands ); $left = array_pop( $this->operands ); $result = $op->operate( $left, $right ); $this->operands[] = $result; }
[ "protected", "function", "doOperation", "(", "Operator", "$", "op", ")", "{", "if", "(", "count", "(", "$", "this", "->", "operands", ")", "<", "2", ")", "{", "$", "op", "->", "error", "(", "'missing operand'", ")", ";", "}", "$", "right", "=", "array_pop", "(", "$", "this", "->", "operands", ")", ";", "$", "left", "=", "array_pop", "(", "$", "this", "->", "operands", ")", ";", "$", "result", "=", "$", "op", "->", "operate", "(", "$", "left", ",", "$", "right", ")", ";", "$", "this", "->", "operands", "[", "]", "=", "$", "result", ";", "}" ]
For the binary operator $op, pop its operands off the stack and push a fragment with rpn and type members describing the result of that operation. @param Operator $op
[ "For", "the", "binary", "operator", "$op", "pop", "its", "operands", "off", "the", "stack", "and", "push", "a", "fragment", "with", "rpn", "and", "type", "members", "describing", "the", "result", "of", "that", "operation", "." ]
train
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Converter.php#L285-L293
parsnick/steak
src/Build/Publishers/Compile.php
Compile.handle
public function handle(Source $source, Closure $next, ...$extensions) { if ($this->isPublishable($source, $extensions)) { $view = new View( $this->factory, $this->factory->getEngineFromPath($source->getPathname()), $this->files->get($source->getPathname()), $source->getPathname() ); $source->changeExtension(['.blade.php' => '.html']) ->changeExtension(['.php' => '.html']); $this->write( $source->getOutputPathname(), $view->render() ); } $next($source); }
php
public function handle(Source $source, Closure $next, ...$extensions) { if ($this->isPublishable($source, $extensions)) { $view = new View( $this->factory, $this->factory->getEngineFromPath($source->getPathname()), $this->files->get($source->getPathname()), $source->getPathname() ); $source->changeExtension(['.blade.php' => '.html']) ->changeExtension(['.php' => '.html']); $this->write( $source->getOutputPathname(), $view->render() ); } $next($source); }
[ "public", "function", "handle", "(", "Source", "$", "source", ",", "Closure", "$", "next", ",", "...", "$", "extensions", ")", "{", "if", "(", "$", "this", "->", "isPublishable", "(", "$", "source", ",", "$", "extensions", ")", ")", "{", "$", "view", "=", "new", "View", "(", "$", "this", "->", "factory", ",", "$", "this", "->", "factory", "->", "getEngineFromPath", "(", "$", "source", "->", "getPathname", "(", ")", ")", ",", "$", "this", "->", "files", "->", "get", "(", "$", "source", "->", "getPathname", "(", ")", ")", ",", "$", "source", "->", "getPathname", "(", ")", ")", ";", "$", "source", "->", "changeExtension", "(", "[", "'.blade.php'", "=>", "'.html'", "]", ")", "->", "changeExtension", "(", "[", "'.php'", "=>", "'.html'", "]", ")", ";", "$", "this", "->", "write", "(", "$", "source", "->", "getOutputPathname", "(", ")", ",", "$", "view", "->", "render", "(", ")", ")", ";", "}", "$", "next", "(", "$", "source", ")", ";", "}" ]
Publish a source file and/or pass to $next. @param Source $source @param Closure $next @param array $extensions @return mixed
[ "Publish", "a", "source", "file", "and", "/", "or", "pass", "to", "$next", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Publishers/Compile.php#L44-L66
parsnick/steak
src/Build/Publishers/Compile.php
Compile.write
protected function write($destination, $content) { $directory = dirname($destination); if ( ! $this->files->exists($directory)) { $this->files->makeDirectory($directory, 0755, true); } return (bool) $this->files->put($destination, $content); }
php
protected function write($destination, $content) { $directory = dirname($destination); if ( ! $this->files->exists($directory)) { $this->files->makeDirectory($directory, 0755, true); } return (bool) $this->files->put($destination, $content); }
[ "protected", "function", "write", "(", "$", "destination", ",", "$", "content", ")", "{", "$", "directory", "=", "dirname", "(", "$", "destination", ")", ";", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "directory", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "return", "(", "bool", ")", "$", "this", "->", "files", "->", "put", "(", "$", "destination", ",", "$", "content", ")", ";", "}" ]
Write file contents, creating any necessary subdirectories. @param string $destination @param string $content @return bool
[ "Write", "file", "contents", "creating", "any", "necessary", "subdirectories", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Build/Publishers/Compile.php#L87-L96
vorbind/influx-analytics
src/Mapper/ImportMysqlMapper.php
ImportMysqlMapper.getRows
public function getRows($query) { try { $stmt = $this->db->query($query); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { return []; } }
php
public function getRows($query) { try { $stmt = $this->db->query($query); return $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (Exception $e) { return []; } }
[ "public", "function", "getRows", "(", "$", "query", ")", "{", "try", "{", "$", "stmt", "=", "$", "this", "->", "db", "->", "query", "(", "$", "query", ")", ";", "return", "$", "stmt", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "[", "]", ";", "}", "}" ]
Get rows of data by query @param string $query
[ "Get", "rows", "of", "data", "by", "query" ]
train
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Mapper/ImportMysqlMapper.php#L46-L53
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->setIo($input, $output); $repo = $this->prepareRepository(); $this->rebuild(); $this->deployWithGit($repo); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->setIo($input, $output); $repo = $this->prepareRepository(); $this->rebuild(); $this->deployWithGit($repo); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "setIo", "(", "$", "input", ",", "$", "output", ")", ";", "$", "repo", "=", "$", "this", "->", "prepareRepository", "(", ")", ";", "$", "this", "->", "rebuild", "(", ")", ";", "$", "this", "->", "deployWithGit", "(", "$", "repo", ")", ";", "}" ]
Execute the command. @param InputInterface $input @param OutputInterface $output @return void
[ "Execute", "the", "command", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L66-L75
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.prepareRepository
protected function prepareRepository() { $config = $this->container['config']; $this->builder->clean($config['build.directory']); // clear out everything, including .git metadata $workingCopy = $this->git->workingCopy($config['build.directory']); $this->doGitInit($workingCopy, $config['deploy.git.url'], $config['deploy.git.branch']); // start again at last commit $this->builder->clean($config['build.directory'], true); // clear the old content but keep .git folder return $workingCopy; }
php
protected function prepareRepository() { $config = $this->container['config']; $this->builder->clean($config['build.directory']); // clear out everything, including .git metadata $workingCopy = $this->git->workingCopy($config['build.directory']); $this->doGitInit($workingCopy, $config['deploy.git.url'], $config['deploy.git.branch']); // start again at last commit $this->builder->clean($config['build.directory'], true); // clear the old content but keep .git folder return $workingCopy; }
[ "protected", "function", "prepareRepository", "(", ")", "{", "$", "config", "=", "$", "this", "->", "container", "[", "'config'", "]", ";", "$", "this", "->", "builder", "->", "clean", "(", "$", "config", "[", "'build.directory'", "]", ")", ";", "// clear out everything, including .git metadata", "$", "workingCopy", "=", "$", "this", "->", "git", "->", "workingCopy", "(", "$", "config", "[", "'build.directory'", "]", ")", ";", "$", "this", "->", "doGitInit", "(", "$", "workingCopy", ",", "$", "config", "[", "'deploy.git.url'", "]", ",", "$", "config", "[", "'deploy.git.branch'", "]", ")", ";", "// start again at last commit", "$", "this", "->", "builder", "->", "clean", "(", "$", "config", "[", "'build.directory'", "]", ",", "true", ")", ";", "// clear the old content but keep .git folder", "return", "$", "workingCopy", ";", "}" ]
Prepare the build directory as a git repository. Maybe there's already a git repo in the build folder, but is it pointing to the correct origin and is it on the correct branch? Instead of checking for things that might be wrong, we'll just start from scratch. @returns GitWorkingCopy @throws RuntimeException
[ "Prepare", "the", "build", "directory", "as", "a", "git", "repository", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L87-L100
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.doGitInit
protected function doGitInit(GitWorkingCopy $workingCopy, $url, $branch) { $workingCopy->init(); $workingCopy->remote('add', 'origin', $url); try { $this->output->writeln("Attempting to fetch <path>origin/{$branch}</path>", OutputInterface::VERBOSITY_VERBOSE); $workingCopy ->fetch('origin', $branch) ->checkout('-f', $branch); } catch (GitException $exception) { $this->output->writeln("Fetch failed, creating new branch instead", OutputInterface::VERBOSITY_VERBOSE); $workingCopy ->checkout('--orphan', $branch) ->run(['commit', '--allow-empty', '-m', "Branch created by steak"]) ->push('-u', 'origin', $branch); } return $workingCopy->clearOutput(); }
php
protected function doGitInit(GitWorkingCopy $workingCopy, $url, $branch) { $workingCopy->init(); $workingCopy->remote('add', 'origin', $url); try { $this->output->writeln("Attempting to fetch <path>origin/{$branch}</path>", OutputInterface::VERBOSITY_VERBOSE); $workingCopy ->fetch('origin', $branch) ->checkout('-f', $branch); } catch (GitException $exception) { $this->output->writeln("Fetch failed, creating new branch instead", OutputInterface::VERBOSITY_VERBOSE); $workingCopy ->checkout('--orphan', $branch) ->run(['commit', '--allow-empty', '-m', "Branch created by steak"]) ->push('-u', 'origin', $branch); } return $workingCopy->clearOutput(); }
[ "protected", "function", "doGitInit", "(", "GitWorkingCopy", "$", "workingCopy", ",", "$", "url", ",", "$", "branch", ")", "{", "$", "workingCopy", "->", "init", "(", ")", ";", "$", "workingCopy", "->", "remote", "(", "'add'", ",", "'origin'", ",", "$", "url", ")", ";", "try", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"Attempting to fetch <path>origin/{$branch}</path>\"", ",", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", ";", "$", "workingCopy", "->", "fetch", "(", "'origin'", ",", "$", "branch", ")", "->", "checkout", "(", "'-f'", ",", "$", "branch", ")", ";", "}", "catch", "(", "GitException", "$", "exception", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"Fetch failed, creating new branch instead\"", ",", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", ";", "$", "workingCopy", "->", "checkout", "(", "'--orphan'", ",", "$", "branch", ")", "->", "run", "(", "[", "'commit'", ",", "'--allow-empty'", ",", "'-m'", ",", "\"Branch created by steak\"", "]", ")", "->", "push", "(", "'-u'", ",", "'origin'", ",", "$", "branch", ")", ";", "}", "return", "$", "workingCopy", "->", "clearOutput", "(", ")", ";", "}" ]
Set up the git repository for our build. @param GitWorkingCopy $workingCopy @param string $url @param string $branch @return mixed
[ "Set", "up", "the", "git", "repository", "for", "our", "build", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L110-L135
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.rebuild
protected function rebuild() { $command = $this->getApplication()->find('build'); $input = new ArrayInput([ '--no-clean' => true, ]); return $command->run($input, $this->output) === 0; }
php
protected function rebuild() { $command = $this->getApplication()->find('build'); $input = new ArrayInput([ '--no-clean' => true, ]); return $command->run($input, $this->output) === 0; }
[ "protected", "function", "rebuild", "(", ")", "{", "$", "command", "=", "$", "this", "->", "getApplication", "(", ")", "->", "find", "(", "'build'", ")", ";", "$", "input", "=", "new", "ArrayInput", "(", "[", "'--no-clean'", "=>", "true", ",", "]", ")", ";", "return", "$", "command", "->", "run", "(", "$", "input", ",", "$", "this", "->", "output", ")", "===", "0", ";", "}" ]
Delegate to the build command to rebuild the site. @return bool
[ "Delegate", "to", "the", "build", "command", "to", "rebuild", "the", "site", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L142-L151
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.deployWithGit
protected function deployWithGit(GitWorkingCopy $workingCopy) { if ( ! $workingCopy->hasChanges()) { return $this->output->writeln('<comment>No changes to deploy!</comment>'); } $this->output->writeln('<info>Ready to deploy changes:</info>'); $this->output->write($workingCopy->getStatus()); if ( ! $this->input->getOption('force')) { if ( ! $this->askForChangesConfirmation($workingCopy)) { return $this->output->writeln('<error>Aborted!</error>'); } } $this->output->writeln('<info>Deploying...</info>'); $this->output->write( $workingCopy->add('.')->commit($this->getCommitMessage())->push()->getOutput(), OutputInterface::VERBOSITY_VERBOSE ); }
php
protected function deployWithGit(GitWorkingCopy $workingCopy) { if ( ! $workingCopy->hasChanges()) { return $this->output->writeln('<comment>No changes to deploy!</comment>'); } $this->output->writeln('<info>Ready to deploy changes:</info>'); $this->output->write($workingCopy->getStatus()); if ( ! $this->input->getOption('force')) { if ( ! $this->askForChangesConfirmation($workingCopy)) { return $this->output->writeln('<error>Aborted!</error>'); } } $this->output->writeln('<info>Deploying...</info>'); $this->output->write( $workingCopy->add('.')->commit($this->getCommitMessage())->push()->getOutput(), OutputInterface::VERBOSITY_VERBOSE ); }
[ "protected", "function", "deployWithGit", "(", "GitWorkingCopy", "$", "workingCopy", ")", "{", "if", "(", "!", "$", "workingCopy", "->", "hasChanges", "(", ")", ")", "{", "return", "$", "this", "->", "output", "->", "writeln", "(", "'<comment>No changes to deploy!</comment>'", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", "'<info>Ready to deploy changes:</info>'", ")", ";", "$", "this", "->", "output", "->", "write", "(", "$", "workingCopy", "->", "getStatus", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "input", "->", "getOption", "(", "'force'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "askForChangesConfirmation", "(", "$", "workingCopy", ")", ")", "{", "return", "$", "this", "->", "output", "->", "writeln", "(", "'<error>Aborted!</error>'", ")", ";", "}", "}", "$", "this", "->", "output", "->", "writeln", "(", "'<info>Deploying...</info>'", ")", ";", "$", "this", "->", "output", "->", "write", "(", "$", "workingCopy", "->", "add", "(", "'.'", ")", "->", "commit", "(", "$", "this", "->", "getCommitMessage", "(", ")", ")", "->", "push", "(", ")", "->", "getOutput", "(", ")", ",", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", ";", "}" ]
Deploy the current contents of our working copy. @param GitWorkingCopy $workingCopy
[ "Deploy", "the", "current", "contents", "of", "our", "working", "copy", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L158-L179
parsnick/steak
src/Console/DeployCommand.php
DeployCommand.askForChangesConfirmation
protected function askForChangesConfirmation(GitWorkingCopy $workingCopy) { $deployTo = "{$this->container['config']['deploy.git.url']}#{$this->container['config']['deploy.git.branch']}"; $confirm = new ConfirmationQuestion("<comment>Commit all and push to <path>{$deployTo}</path>?</comment> [Yn] "); return $this->getHelper('question')->ask($this->input, $this->output, $confirm); }
php
protected function askForChangesConfirmation(GitWorkingCopy $workingCopy) { $deployTo = "{$this->container['config']['deploy.git.url']}#{$this->container['config']['deploy.git.branch']}"; $confirm = new ConfirmationQuestion("<comment>Commit all and push to <path>{$deployTo}</path>?</comment> [Yn] "); return $this->getHelper('question')->ask($this->input, $this->output, $confirm); }
[ "protected", "function", "askForChangesConfirmation", "(", "GitWorkingCopy", "$", "workingCopy", ")", "{", "$", "deployTo", "=", "\"{$this->container['config']['deploy.git.url']}#{$this->container['config']['deploy.git.branch']}\"", ";", "$", "confirm", "=", "new", "ConfirmationQuestion", "(", "\"<comment>Commit all and push to <path>{$deployTo}</path>?</comment> [Yn] \"", ")", ";", "return", "$", "this", "->", "getHelper", "(", "'question'", ")", "->", "ask", "(", "$", "this", "->", "input", ",", "$", "this", "->", "output", ",", "$", "confirm", ")", ";", "}" ]
Ask user to confirm changes listed by git status. @param GitWorkingCopy $workingCopy @return bool
[ "Ask", "user", "to", "confirm", "changes", "listed", "by", "git", "status", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Console/DeployCommand.php#L187-L194
stanislav-web/phalcon-ulogin
src/ULogin/Auth.php
Auth.hasSession
private function hasSession() { if(DI::getDefault()->has('session') === true) { // get instance of session class $this->session = DI::getDefault()->getSession(); if($this->session->getId() === '') { $this->session->start(); } return true; } return false; }
php
private function hasSession() { if(DI::getDefault()->has('session') === true) { // get instance of session class $this->session = DI::getDefault()->getSession(); if($this->session->getId() === '') { $this->session->start(); } return true; } return false; }
[ "private", "function", "hasSession", "(", ")", "{", "if", "(", "DI", "::", "getDefault", "(", ")", "->", "has", "(", "'session'", ")", "===", "true", ")", "{", "// get instance of session class", "$", "this", "->", "session", "=", "DI", "::", "getDefault", "(", ")", "->", "getSession", "(", ")", ";", "if", "(", "$", "this", "->", "session", "->", "getId", "(", ")", "===", "''", ")", "{", "$", "this", "->", "session", "->", "start", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if \Phalcon\Di has session service @return bool
[ "Check", "if", "\\", "Phalcon", "\\", "Di", "has", "session", "service" ]
train
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Auth.php#L63-L78
stanislav-web/phalcon-ulogin
src/ULogin/Auth.php
Auth.getUser
public function getUser() { if($this->user === false) { $this->session->remove(self::KEY); $this->session->set(self::KEY, parent::getUser()); } return $this->user; }
php
public function getUser() { if($this->user === false) { $this->session->remove(self::KEY); $this->session->set(self::KEY, parent::getUser()); } return $this->user; }
[ "public", "function", "getUser", "(", ")", "{", "if", "(", "$", "this", "->", "user", "===", "false", ")", "{", "$", "this", "->", "session", "->", "remove", "(", "self", "::", "KEY", ")", ";", "$", "this", "->", "session", "->", "set", "(", "self", "::", "KEY", ",", "parent", "::", "getUser", "(", ")", ")", ";", "}", "return", "$", "this", "->", "user", ";", "}" ]
Returns an associative array with the data about the user. Fields array described in the method Init::setFields @example <code> $this->getUser(); </code> @return boolean|array data provided by the ISP authentication
[ "Returns", "an", "associative", "array", "with", "the", "data", "about", "the", "user", ".", "Fields", "array", "described", "in", "the", "method", "Init", "::", "setFields" ]
train
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Auth.php#L90-L99
titon/db
src/Titon/Db/Driver/Dialect/Statement.php
Statement.render
public function render(array $params = []) { return trim(String::insert($this->getStatement(), $params + $this->getParams(), ['escape' => false])) . ';'; }
php
public function render(array $params = []) { return trim(String::insert($this->getStatement(), $params + $this->getParams(), ['escape' => false])) . ';'; }
[ "public", "function", "render", "(", "array", "$", "params", "=", "[", "]", ")", "{", "return", "trim", "(", "String", "::", "insert", "(", "$", "this", "->", "getStatement", "(", ")", ",", "$", "params", "+", "$", "this", "->", "getParams", "(", ")", ",", "[", "'escape'", "=>", "false", "]", ")", ")", ".", "';'", ";", "}" ]
Render the statement by injecting custom parameters. Merge with the default parameters to fill in any missing keys. @param array $params @return string
[ "Render", "the", "statement", "by", "injecting", "custom", "parameters", ".", "Merge", "with", "the", "default", "parameters", "to", "fill", "in", "any", "missing", "keys", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Dialect/Statement.php#L75-L77
webforge-labs/psc-cms
lib/Psc/SimpleObject.php
SimpleObject.invalidArgument
protected function invalidArgument($num, $actual, $expected, $function) { $class = Code::getClass($this); $namespace = Code::getNamespace($class); $context = $class.'::'.$function.'()'; $expandType = function ($type) use ($class, $namespace) { if (is_string($type)) { $type = Type::create($type); if ($type instanceof ObjectType) { $type->expandNamespace($namespace); } } return $type; }; if (is_array($expected)) { $composite = Type::create('Composite'); foreach ($expected as $type) { $composite->addComponent($expandType($type)); } $expected = $composite; } else { $expected = $expandType($expected); } return Exception::invalidArgument($num, $context, $actual, $expected); }
php
protected function invalidArgument($num, $actual, $expected, $function) { $class = Code::getClass($this); $namespace = Code::getNamespace($class); $context = $class.'::'.$function.'()'; $expandType = function ($type) use ($class, $namespace) { if (is_string($type)) { $type = Type::create($type); if ($type instanceof ObjectType) { $type->expandNamespace($namespace); } } return $type; }; if (is_array($expected)) { $composite = Type::create('Composite'); foreach ($expected as $type) { $composite->addComponent($expandType($type)); } $expected = $composite; } else { $expected = $expandType($expected); } return Exception::invalidArgument($num, $context, $actual, $expected); }
[ "protected", "function", "invalidArgument", "(", "$", "num", ",", "$", "actual", ",", "$", "expected", ",", "$", "function", ")", "{", "$", "class", "=", "Code", "::", "getClass", "(", "$", "this", ")", ";", "$", "namespace", "=", "Code", "::", "getNamespace", "(", "$", "class", ")", ";", "$", "context", "=", "$", "class", ".", "'::'", ".", "$", "function", ".", "'()'", ";", "$", "expandType", "=", "function", "(", "$", "type", ")", "use", "(", "$", "class", ",", "$", "namespace", ")", "{", "if", "(", "is_string", "(", "$", "type", ")", ")", "{", "$", "type", "=", "Type", "::", "create", "(", "$", "type", ")", ";", "if", "(", "$", "type", "instanceof", "ObjectType", ")", "{", "$", "type", "->", "expandNamespace", "(", "$", "namespace", ")", ";", "}", "}", "return", "$", "type", ";", "}", ";", "if", "(", "is_array", "(", "$", "expected", ")", ")", "{", "$", "composite", "=", "Type", "::", "create", "(", "'Composite'", ")", ";", "foreach", "(", "$", "expected", "as", "$", "type", ")", "{", "$", "composite", "->", "addComponent", "(", "$", "expandType", "(", "$", "type", ")", ")", ";", "}", "$", "expected", "=", "$", "composite", ";", "}", "else", "{", "$", "expected", "=", "$", "expandType", "(", "$", "expected", ")", ";", "}", "return", "Exception", "::", "invalidArgument", "(", "$", "num", ",", "$", "context", ",", "$", "actual", ",", "$", "expected", ")", ";", "}" ]
$this->invalidArgument(1, $param1, 'PositiveInteger', __FUNCTION__); @param string|Type $expected der Type oder ein String der den Typ beschreibt @cc-ignore
[ "$this", "-", ">", "invalidArgument", "(", "1", "$param1", "PositiveInteger", "__FUNCTION__", ")", ";" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/SimpleObject.php#L21-L47
javiacei/IdeupSimplePaginatorBundle
Paginator/Paginator.php
Paginator.setFallbackValues
private function setFallbackValues() { $hash = md5(null); $this->currentPage[$hash] = 0; $this->itemsPerPage[$hash] = 10; $this->maxPagerItems[$hash] = 3; $this->totalItems[$hash] = 0; }
php
private function setFallbackValues() { $hash = md5(null); $this->currentPage[$hash] = 0; $this->itemsPerPage[$hash] = 10; $this->maxPagerItems[$hash] = 3; $this->totalItems[$hash] = 0; }
[ "private", "function", "setFallbackValues", "(", ")", "{", "$", "hash", "=", "md5", "(", "null", ")", ";", "$", "this", "->", "currentPage", "[", "$", "hash", "]", "=", "0", ";", "$", "this", "->", "itemsPerPage", "[", "$", "hash", "]", "=", "10", ";", "$", "this", "->", "maxPagerItems", "[", "$", "hash", "]", "=", "3", ";", "$", "this", "->", "totalItems", "[", "$", "hash", "]", "=", "0", ";", "}" ]
Sets default values @return void
[ "Sets", "default", "values" ]
train
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Paginator/Paginator.php#L71-L78
javiacei/IdeupSimplePaginatorBundle
Paginator/Paginator.php
Paginator.paginate
public function paginate($collection, $id = null) { $adapter = $this->adapterFactory->createAdapter($collection); $this->totalItems[md5($id)] = $adapter->getTotalResults(); $offset = $this->calculateOffset($id); return $adapter->setOffset($offset)->setLength($this->getItemsPerPage($id)); }
php
public function paginate($collection, $id = null) { $adapter = $this->adapterFactory->createAdapter($collection); $this->totalItems[md5($id)] = $adapter->getTotalResults(); $offset = $this->calculateOffset($id); return $adapter->setOffset($offset)->setLength($this->getItemsPerPage($id)); }
[ "public", "function", "paginate", "(", "$", "collection", ",", "$", "id", "=", "null", ")", "{", "$", "adapter", "=", "$", "this", "->", "adapterFactory", "->", "createAdapter", "(", "$", "collection", ")", ";", "$", "this", "->", "totalItems", "[", "md5", "(", "$", "id", ")", "]", "=", "$", "adapter", "->", "getTotalResults", "(", ")", ";", "$", "offset", "=", "$", "this", "->", "calculateOffset", "(", "$", "id", ")", ";", "return", "$", "adapter", "->", "setOffset", "(", "$", "offset", ")", "->", "setLength", "(", "$", "this", "->", "getItemsPerPage", "(", "$", "id", ")", ")", ";", "}" ]
Transforms the given Doctrine DQL into a paginated query If you need to paginate various queries in the same controller, you need to specify an $id @param mixed $collection @param string $id @return Doctrine\ORM\Query
[ "Transforms", "the", "given", "Doctrine", "DQL", "into", "a", "paginated", "query", "If", "you", "need", "to", "paginate", "various", "queries", "in", "the", "same", "controller", "you", "need", "to", "specify", "an", "$id" ]
train
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Paginator/Paginator.php#L129-L137
javiacei/IdeupSimplePaginatorBundle
Paginator/Paginator.php
Paginator.getTotalItems
public function getTotalItems($id = null) { $hash = md5($id); return isset($this->totalItems[$hash]) ? $this->totalItems[$hash] : 0; }
php
public function getTotalItems($id = null) { $hash = md5($id); return isset($this->totalItems[$hash]) ? $this->totalItems[$hash] : 0; }
[ "public", "function", "getTotalItems", "(", "$", "id", "=", "null", ")", "{", "$", "hash", "=", "md5", "(", "$", "id", ")", ";", "return", "isset", "(", "$", "this", "->", "totalItems", "[", "$", "hash", "]", ")", "?", "$", "this", "->", "totalItems", "[", "$", "hash", "]", ":", "0", ";", "}" ]
Get the total items in the non-paginated version of the query @param string $id @return int
[ "Get", "the", "total", "items", "in", "the", "non", "-", "paginated", "version", "of", "the", "query" ]
train
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Paginator/Paginator.php#L241-L245
javiacei/IdeupSimplePaginatorBundle
Paginator/Paginator.php
Paginator.getLastPage
public function getLastPage($id = null) { $totalItems = ($this->getTotalItems($id) > 0) ? $this->getTotalItems($id) : 1; return (int)ceil($totalItems / $this->getItemsPerPage($id)); }
php
public function getLastPage($id = null) { $totalItems = ($this->getTotalItems($id) > 0) ? $this->getTotalItems($id) : 1; return (int)ceil($totalItems / $this->getItemsPerPage($id)); }
[ "public", "function", "getLastPage", "(", "$", "id", "=", "null", ")", "{", "$", "totalItems", "=", "(", "$", "this", "->", "getTotalItems", "(", "$", "id", ")", ">", "0", ")", "?", "$", "this", "->", "getTotalItems", "(", "$", "id", ")", ":", "1", ";", "return", "(", "int", ")", "ceil", "(", "$", "totalItems", "/", "$", "this", "->", "getItemsPerPage", "(", "$", "id", ")", ")", ";", "}" ]
Gets the last page number @param string $id @return int
[ "Gets", "the", "last", "page", "number" ]
train
https://github.com/javiacei/IdeupSimplePaginatorBundle/blob/12639a9c75bc403649fc2b2881e190a017d8c5b2/Paginator/Paginator.php#L253-L257
netgen/metadata-bundle
bundle/Core/FieldType/Metadata/Type.php
Type.isEmptyValue
public function isEmptyValue(SPIValue $value) { return $value === null || $value->xml->saveXML() == $this->getEmptyValue()->xml->saveXML(); }
php
public function isEmptyValue(SPIValue $value) { return $value === null || $value->xml->saveXML() == $this->getEmptyValue()->xml->saveXML(); }
[ "public", "function", "isEmptyValue", "(", "SPIValue", "$", "value", ")", "{", "return", "$", "value", "===", "null", "||", "$", "value", "->", "xml", "->", "saveXML", "(", ")", "==", "$", "this", "->", "getEmptyValue", "(", ")", "->", "xml", "->", "saveXML", "(", ")", ";", "}" ]
Returns if the given $value is considered empty by the field type. Default implementation, which performs a "==" check with the value returned by {@link getEmptyValue()}. Overwrite in the specific field type, if necessary. @param \eZ\Publish\Core\FieldType\Value $value @return bool
[ "Returns", "if", "the", "given", "$value", "is", "considered", "empty", "by", "the", "field", "type", "." ]
train
https://github.com/netgen/metadata-bundle/blob/12bfca68e8e8f4be409c7151f99dff665c53755b/bundle/Core/FieldType/Metadata/Type.php#L56-L59
netgen/metadata-bundle
bundle/Core/FieldType/Metadata/Type.php
Type.fromHash
public function fromHash($hash) { if (empty($hash) || empty($hash['xml'])) { return $this->getEmptyValue(); } return new Value($hash['xml']); }
php
public function fromHash($hash) { if (empty($hash) || empty($hash['xml'])) { return $this->getEmptyValue(); } return new Value($hash['xml']); }
[ "public", "function", "fromHash", "(", "$", "hash", ")", "{", "if", "(", "empty", "(", "$", "hash", ")", "||", "empty", "(", "$", "hash", "[", "'xml'", "]", ")", ")", "{", "return", "$", "this", "->", "getEmptyValue", "(", ")", ";", "}", "return", "new", "Value", "(", "$", "hash", "[", "'xml'", "]", ")", ";", "}" ]
Converts an $hash to the Value defined by the field type. This is the reverse operation to {@link toHash()}. At least the hash format generated by {@link toHash()} must be converted in reverse. Additional formats might be supported in the rare case that this is necessary. See the class description for more details on a hash format. @param mixed $hash @throws \Exception @return \eZ\Publish\SPI\FieldType\Value
[ "Converts", "an", "$hash", "to", "the", "Value", "defined", "by", "the", "field", "type", "." ]
train
https://github.com/netgen/metadata-bundle/blob/12bfca68e8e8f4be409c7151f99dff665c53755b/bundle/Core/FieldType/Metadata/Type.php#L75-L82
netgen/metadata-bundle
bundle/Core/FieldType/Metadata/Type.php
Type.createValueFromInput
protected function createValueFromInput($inputValue) { if (is_array($inputValue) && !empty($inputValue)) { $title = !empty($inputValue['title']) ? $inputValue['title'] : ''; $keywords = !empty($inputValue['keywords']) ? $inputValue['keywords'] : array(); $description = !empty($inputValue['description']) ? $inputValue['description'] : ''; if (empty($inputValue['priority'])) { $priority = null; } else { $priority = $inputValue['priority']; } if (empty($inputValue['change'])) { $change = 'daily'; } else { $change = $inputValue['change']; } if ($inputValue['sitemap_use'] === false) { $sitemap_use = '1'; } elseif (empty($inputValue['sitemap_use'])) { $sitemap_use = '0'; } else { $sitemap_use = '1'; } $xml = new DOMDocument('1.0', 'UTF-8'); $xmldom = $xml->createElement('MetaData'); $node = $xml->createElement('title', htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('keywords', htmlspecialchars(implode(',', $keywords), ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('description', htmlspecialchars($description, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); if (!empty($priority)) { $node = $xml->createElement('priority', htmlspecialchars($priority, ENT_QUOTES, 'UTF-8')); } else { $node = $xml->createElement('priority'); } $xmldom->appendChild($node); $node = $xml->createElement('change', htmlspecialchars($change, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('sitemap_use', htmlspecialchars($sitemap_use, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $xml->appendChild($xmldom); return new Value($xml); } if ($inputValue === null) { return $this->getEmptyValue(); } return $inputValue; }
php
protected function createValueFromInput($inputValue) { if (is_array($inputValue) && !empty($inputValue)) { $title = !empty($inputValue['title']) ? $inputValue['title'] : ''; $keywords = !empty($inputValue['keywords']) ? $inputValue['keywords'] : array(); $description = !empty($inputValue['description']) ? $inputValue['description'] : ''; if (empty($inputValue['priority'])) { $priority = null; } else { $priority = $inputValue['priority']; } if (empty($inputValue['change'])) { $change = 'daily'; } else { $change = $inputValue['change']; } if ($inputValue['sitemap_use'] === false) { $sitemap_use = '1'; } elseif (empty($inputValue['sitemap_use'])) { $sitemap_use = '0'; } else { $sitemap_use = '1'; } $xml = new DOMDocument('1.0', 'UTF-8'); $xmldom = $xml->createElement('MetaData'); $node = $xml->createElement('title', htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('keywords', htmlspecialchars(implode(',', $keywords), ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('description', htmlspecialchars($description, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); if (!empty($priority)) { $node = $xml->createElement('priority', htmlspecialchars($priority, ENT_QUOTES, 'UTF-8')); } else { $node = $xml->createElement('priority'); } $xmldom->appendChild($node); $node = $xml->createElement('change', htmlspecialchars($change, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $node = $xml->createElement('sitemap_use', htmlspecialchars($sitemap_use, ENT_QUOTES, 'UTF-8')); $xmldom->appendChild($node); $xml->appendChild($xmldom); return new Value($xml); } if ($inputValue === null) { return $this->getEmptyValue(); } return $inputValue; }
[ "protected", "function", "createValueFromInput", "(", "$", "inputValue", ")", "{", "if", "(", "is_array", "(", "$", "inputValue", ")", "&&", "!", "empty", "(", "$", "inputValue", ")", ")", "{", "$", "title", "=", "!", "empty", "(", "$", "inputValue", "[", "'title'", "]", ")", "?", "$", "inputValue", "[", "'title'", "]", ":", "''", ";", "$", "keywords", "=", "!", "empty", "(", "$", "inputValue", "[", "'keywords'", "]", ")", "?", "$", "inputValue", "[", "'keywords'", "]", ":", "array", "(", ")", ";", "$", "description", "=", "!", "empty", "(", "$", "inputValue", "[", "'description'", "]", ")", "?", "$", "inputValue", "[", "'description'", "]", ":", "''", ";", "if", "(", "empty", "(", "$", "inputValue", "[", "'priority'", "]", ")", ")", "{", "$", "priority", "=", "null", ";", "}", "else", "{", "$", "priority", "=", "$", "inputValue", "[", "'priority'", "]", ";", "}", "if", "(", "empty", "(", "$", "inputValue", "[", "'change'", "]", ")", ")", "{", "$", "change", "=", "'daily'", ";", "}", "else", "{", "$", "change", "=", "$", "inputValue", "[", "'change'", "]", ";", "}", "if", "(", "$", "inputValue", "[", "'sitemap_use'", "]", "===", "false", ")", "{", "$", "sitemap_use", "=", "'1'", ";", "}", "elseif", "(", "empty", "(", "$", "inputValue", "[", "'sitemap_use'", "]", ")", ")", "{", "$", "sitemap_use", "=", "'0'", ";", "}", "else", "{", "$", "sitemap_use", "=", "'1'", ";", "}", "$", "xml", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "xmldom", "=", "$", "xml", "->", "createElement", "(", "'MetaData'", ")", ";", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'title'", ",", "htmlspecialchars", "(", "$", "title", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'keywords'", ",", "htmlspecialchars", "(", "implode", "(", "','", ",", "$", "keywords", ")", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'description'", ",", "htmlspecialchars", "(", "$", "description", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "if", "(", "!", "empty", "(", "$", "priority", ")", ")", "{", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'priority'", ",", "htmlspecialchars", "(", "$", "priority", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "}", "else", "{", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'priority'", ")", ";", "}", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'change'", ",", "htmlspecialchars", "(", "$", "change", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "$", "node", "=", "$", "xml", "->", "createElement", "(", "'sitemap_use'", ",", "htmlspecialchars", "(", "$", "sitemap_use", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ")", ";", "$", "xmldom", "->", "appendChild", "(", "$", "node", ")", ";", "$", "xml", "->", "appendChild", "(", "$", "xmldom", ")", ";", "return", "new", "Value", "(", "$", "xml", ")", ";", "}", "if", "(", "$", "inputValue", "===", "null", ")", "{", "return", "$", "this", "->", "getEmptyValue", "(", ")", ";", "}", "return", "$", "inputValue", ";", "}" ]
Inspects given $inputValue and potentially converts it into a dedicated value object. If given $inputValue could not be converted or is already an instance of dedicate value object, the method should simply return it. This is an operation method for {@see acceptValue()}. Example implementation: <code> protected function createValueFromInput( $inputValue ) { if ( is_array( $inputValue ) ) { $inputValue = \eZ\Publish\Core\FieldType\CookieJar\Value( $inputValue ); } return $inputValue; } </code> @param mixed $inputValue @return mixed the potentially converted input value
[ "Inspects", "given", "$inputValue", "and", "potentially", "converts", "it", "into", "a", "dedicated", "value", "object", "." ]
train
https://github.com/netgen/metadata-bundle/blob/12bfca68e8e8f4be409c7151f99dff665c53755b/bundle/Core/FieldType/Metadata/Type.php#L126-L180
yuncms/framework
src/rest/models/UserMobileRegistrationForm.php
UserMobileRegistrationForm.register
public function register() { if ($this->validate()) { /** @var User $user */ $user = new User(); $user->setScenario(User::SCENARIO_MOBILE_REGISTER); $this->loadAttributes($user); if ($user->createUser()) { return $user; } } return false; }
php
public function register() { if ($this->validate()) { /** @var User $user */ $user = new User(); $user->setScenario(User::SCENARIO_MOBILE_REGISTER); $this->loadAttributes($user); if ($user->createUser()) { return $user; } } return false; }
[ "public", "function", "register", "(", ")", "{", "if", "(", "$", "this", "->", "validate", "(", ")", ")", "{", "/** @var User $user */", "$", "user", "=", "new", "User", "(", ")", ";", "$", "user", "->", "setScenario", "(", "User", "::", "SCENARIO_MOBILE_REGISTER", ")", ";", "$", "this", "->", "loadAttributes", "(", "$", "user", ")", ";", "if", "(", "$", "user", "->", "createUser", "(", ")", ")", "{", "return", "$", "user", ";", "}", "}", "return", "false", ";", "}" ]
Registers a new user account. If registration was successful it will set flash message. @return User|false
[ "Registers", "a", "new", "user", "account", ".", "If", "registration", "was", "successful", "it", "will", "set", "flash", "message", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/models/UserMobileRegistrationForm.php#L92-L104
ClanCats/Core
src/bundles/Session/Manager.php
Manager.default_data_provider
public static function default_data_provider() { return array( 'last_active' => time(), 'current_lang' => \CCLang::current(), 'client_agent' => \CCServer::client( 'agent' ), 'client_ip' => \CCServer::client( 'ip' ), 'client_port' => \CCServer::client( 'port' ), 'client_lang' => \CCServer::client( 'language' ), ); }
php
public static function default_data_provider() { return array( 'last_active' => time(), 'current_lang' => \CCLang::current(), 'client_agent' => \CCServer::client( 'agent' ), 'client_ip' => \CCServer::client( 'ip' ), 'client_port' => \CCServer::client( 'port' ), 'client_lang' => \CCServer::client( 'language' ), ); }
[ "public", "static", "function", "default_data_provider", "(", ")", "{", "return", "array", "(", "'last_active'", "=>", "time", "(", ")", ",", "'current_lang'", "=>", "\\", "CCLang", "::", "current", "(", ")", ",", "'client_agent'", "=>", "\\", "CCServer", "::", "client", "(", "'agent'", ")", ",", "'client_ip'", "=>", "\\", "CCServer", "::", "client", "(", "'ip'", ")", ",", "'client_port'", "=>", "\\", "CCServer", "::", "client", "(", "'port'", ")", ",", "'client_lang'", "=>", "\\", "CCServer", "::", "client", "(", "'language'", ")", ",", ")", ";", "}" ]
Some default values for our session @return array
[ "Some", "default", "values", "for", "our", "session" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L60-L70
ClanCats/Core
src/bundles/Session/Manager.php
Manager.valid_fingerprint
public function valid_fingerprint( $fingerprint = null ) { if ( is_null( $fingerprint ) ) { $fingerprint = \CCIn::get( \ClanCats::$config->get( 'session.default_fingerprint_parameter' ), false ); } return $this->fingerprint === $fingerprint; }
php
public function valid_fingerprint( $fingerprint = null ) { if ( is_null( $fingerprint ) ) { $fingerprint = \CCIn::get( \ClanCats::$config->get( 'session.default_fingerprint_parameter' ), false ); } return $this->fingerprint === $fingerprint; }
[ "public", "function", "valid_fingerprint", "(", "$", "fingerprint", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "fingerprint", ")", ")", "{", "$", "fingerprint", "=", "\\", "CCIn", "::", "get", "(", "\\", "ClanCats", "::", "$", "config", "->", "get", "(", "'session.default_fingerprint_parameter'", ")", ",", "false", ")", ";", "}", "return", "$", "this", "->", "fingerprint", "===", "$", "fingerprint", ";", "}" ]
Does the current session fingerprint match a parameter When no parameter is given we use GET->s as default parameter @param string $fingerprint @return string
[ "Does", "the", "current", "session", "fingerprint", "match", "a", "parameter" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L247-L255
ClanCats/Core
src/bundles/Session/Manager.php
Manager.once
public function once( $key, $default = null ) { $value = \CCArr::get( $key, $this->_data, $default ); \CCArr::delete( $key, $this->_data ); return $value; }
php
public function once( $key, $default = null ) { $value = \CCArr::get( $key, $this->_data, $default ); \CCArr::delete( $key, $this->_data ); return $value; }
[ "public", "function", "once", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "\\", "CCArr", "::", "get", "(", "$", "key", ",", "$", "this", "->", "_data", ",", "$", "default", ")", ";", "\\", "CCArr", "::", "delete", "(", "$", "key", ",", "$", "this", "->", "_data", ")", ";", "return", "$", "value", ";", "}" ]
Get a value from data and remove it afterwards @param string $key @param mixed $default @return mixed
[ "Get", "a", "value", "from", "data", "and", "remove", "it", "afterwards" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L264-L269
ClanCats/Core
src/bundles/Session/Manager.php
Manager.read
public function read() { // Do we already have a session id if not we regenerate // the session and assign the default data. if ( $this->id ) { if ( !$this->_data = $this->_driver->read( $this->id ) ) { $this->regenerate(); $this->_data = array(); } if ( !is_array( $this->_data ) ) { $this->_data = array(); } $this->_data = array_merge( $this->_data, $this->default_data() ); } else { $this->regenerate(); $this->_data = $this->default_data(); } }
php
public function read() { // Do we already have a session id if not we regenerate // the session and assign the default data. if ( $this->id ) { if ( !$this->_data = $this->_driver->read( $this->id ) ) { $this->regenerate(); $this->_data = array(); } if ( !is_array( $this->_data ) ) { $this->_data = array(); } $this->_data = array_merge( $this->_data, $this->default_data() ); } else { $this->regenerate(); $this->_data = $this->default_data(); } }
[ "public", "function", "read", "(", ")", "{", "// Do we already have a session id if not we regenerate", "// the session and assign the default data.", "if", "(", "$", "this", "->", "id", ")", "{", "if", "(", "!", "$", "this", "->", "_data", "=", "$", "this", "->", "_driver", "->", "read", "(", "$", "this", "->", "id", ")", ")", "{", "$", "this", "->", "regenerate", "(", ")", ";", "$", "this", "->", "_data", "=", "array", "(", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "this", "->", "_data", ")", ")", "{", "$", "this", "->", "_data", "=", "array", "(", ")", ";", "}", "$", "this", "->", "_data", "=", "array_merge", "(", "$", "this", "->", "_data", ",", "$", "this", "->", "default_data", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "regenerate", "(", ")", ";", "$", "this", "->", "_data", "=", "$", "this", "->", "default_data", "(", ")", ";", "}", "}" ]
Read data from the session driver. This overwrite's any changes made on runtime. @return void
[ "Read", "data", "from", "the", "session", "driver", ".", "This", "overwrite", "s", "any", "changes", "made", "on", "runtime", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L277-L301
ClanCats/Core
src/bundles/Session/Manager.php
Manager.write
public function write() { $this->_driver->write( $this->id, $this->_data ); // We also have to set the cookie again to keep it alive \CCCookie::set( $this->cookie_name(), $this->id, \CCArr::get( 'lifetime', $this->_config, \CCDate::minutes( 5 ) ) ); }
php
public function write() { $this->_driver->write( $this->id, $this->_data ); // We also have to set the cookie again to keep it alive \CCCookie::set( $this->cookie_name(), $this->id, \CCArr::get( 'lifetime', $this->_config, \CCDate::minutes( 5 ) ) ); }
[ "public", "function", "write", "(", ")", "{", "$", "this", "->", "_driver", "->", "write", "(", "$", "this", "->", "id", ",", "$", "this", "->", "_data", ")", ";", "// We also have to set the cookie again to keep it alive", "\\", "CCCookie", "::", "set", "(", "$", "this", "->", "cookie_name", "(", ")", ",", "$", "this", "->", "id", ",", "\\", "CCArr", "::", "get", "(", "'lifetime'", ",", "$", "this", "->", "_config", ",", "\\", "CCDate", "::", "minutes", "(", "5", ")", ")", ")", ";", "}" ]
Write the session to the driver @return void
[ "Write", "the", "session", "to", "the", "driver" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L308-L314
ClanCats/Core
src/bundles/Session/Manager.php
Manager.regenerate
public function regenerate() { do { $id = \CCStr::random( 32 ); } while ( $this->_driver->has( $id ) ); $this->fingerprint = sha1( $id ); return $this->id = $id; }
php
public function regenerate() { do { $id = \CCStr::random( 32 ); } while ( $this->_driver->has( $id ) ); $this->fingerprint = sha1( $id ); return $this->id = $id; }
[ "public", "function", "regenerate", "(", ")", "{", "do", "{", "$", "id", "=", "\\", "CCStr", "::", "random", "(", "32", ")", ";", "}", "while", "(", "$", "this", "->", "_driver", "->", "has", "(", "$", "id", ")", ")", ";", "$", "this", "->", "fingerprint", "=", "sha1", "(", "$", "id", ")", ";", "return", "$", "this", "->", "id", "=", "$", "id", ";", "}" ]
Generate a new session id and checks the dirver for dublicates. @return string The new generated session id.
[ "Generate", "a", "new", "session", "id", "and", "checks", "the", "dirver", "for", "dublicates", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L321-L331
ClanCats/Core
src/bundles/Session/Manager.php
Manager.gc
public function gc() { $lifetime = \CCArr::get( 'lifetime', $this->_config, \CCDate::minutes( 5 ) ); if ( $lifetime < ( $min_lifetime = \CCArr::get( 'min_lifetime', $this->_config, \CCDate::minutes( 5 ) ) ) ) { $lifetime = $min_lifetime; } $this->_driver->gc( $lifetime ); }
php
public function gc() { $lifetime = \CCArr::get( 'lifetime', $this->_config, \CCDate::minutes( 5 ) ); if ( $lifetime < ( $min_lifetime = \CCArr::get( 'min_lifetime', $this->_config, \CCDate::minutes( 5 ) ) ) ) { $lifetime = $min_lifetime; } $this->_driver->gc( $lifetime ); }
[ "public", "function", "gc", "(", ")", "{", "$", "lifetime", "=", "\\", "CCArr", "::", "get", "(", "'lifetime'", ",", "$", "this", "->", "_config", ",", "\\", "CCDate", "::", "minutes", "(", "5", ")", ")", ";", "if", "(", "$", "lifetime", "<", "(", "$", "min_lifetime", "=", "\\", "CCArr", "::", "get", "(", "'min_lifetime'", ",", "$", "this", "->", "_config", ",", "\\", "CCDate", "::", "minutes", "(", "5", ")", ")", ")", ")", "{", "$", "lifetime", "=", "$", "min_lifetime", ";", "}", "$", "this", "->", "_driver", "->", "gc", "(", "$", "lifetime", ")", ";", "}" ]
Garbage collection, delete all outdated sessions @return void
[ "Garbage", "collection", "delete", "all", "outdated", "sessions" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Session/Manager.php#L347-L357
webforge-labs/psc-cms
lib/Psc/Exception.php
Exception.handler
public static function handler (\Exception $e) { try { $project = PSC::getProject(); } catch (\Exception $noProjet) { $project = NULL; } $format = PHP_SAPI === 'cli' ? 'text' : 'html'; $text = self::getExceptionText($e, $format, $project); print $text; PSC::getEnvironment()->getErrorHandler()->handleCaughtException($e); }
php
public static function handler (\Exception $e) { try { $project = PSC::getProject(); } catch (\Exception $noProjet) { $project = NULL; } $format = PHP_SAPI === 'cli' ? 'text' : 'html'; $text = self::getExceptionText($e, $format, $project); print $text; PSC::getEnvironment()->getErrorHandler()->handleCaughtException($e); }
[ "public", "static", "function", "handler", "(", "\\", "Exception", "$", "e", ")", "{", "try", "{", "$", "project", "=", "PSC", "::", "getProject", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "noProjet", ")", "{", "$", "project", "=", "NULL", ";", "}", "$", "format", "=", "PHP_SAPI", "===", "'cli'", "?", "'text'", ":", "'html'", ";", "$", "text", "=", "self", "::", "getExceptionText", "(", "$", "e", ",", "$", "format", ",", "$", "project", ")", ";", "print", "$", "text", ";", "PSC", "::", "getEnvironment", "(", ")", "->", "getErrorHandler", "(", ")", "->", "handleCaughtException", "(", "$", "e", ")", ";", "}" ]
/* public function __construct ($message = "", $code = 0, Exception $previous = NULL) { parent::__construct($message,$code,$previous); }
[ "/", "*", "public", "function", "__construct", "(", "$message", "=", "$code", "=", "0", "Exception", "$previous", "=", "NULL", ")", "{", "parent", "::", "__construct", "(", "$message", "$code", "$previous", ")", ";", "}" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Exception.php#L69-L83
fubhy/graphql-php
src/Schema.php
Schema.getDirective
public function getDirective($name) { foreach ($this->getDirectives() as $directive) { if ($directive->getName() === $name) { return $directive; } } return NULL; }
php
public function getDirective($name) { foreach ($this->getDirectives() as $directive) { if ($directive->getName() === $name) { return $directive; } } return NULL; }
[ "public", "function", "getDirective", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "getDirectives", "(", ")", "as", "$", "directive", ")", "{", "if", "(", "$", "directive", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "directive", ";", "}", "}", "return", "NULL", ";", "}" ]
@param string $name @return \Fubhy\GraphQL\Type\Directives\DirectiveInterface|null
[ "@param", "string", "$name" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Schema.php#L77-L85
fubhy/graphql-php
src/Schema.php
Schema.getType
public function getType($name) { $map = $this->getTypeMap(); return isset($map[$name]) ? $map[$name] : NULL; }
php
public function getType($name) { $map = $this->getTypeMap(); return isset($map[$name]) ? $map[$name] : NULL; }
[ "public", "function", "getType", "(", "$", "name", ")", "{", "$", "map", "=", "$", "this", "->", "getTypeMap", "(", ")", ";", "return", "isset", "(", "$", "map", "[", "$", "name", "]", ")", "?", "$", "map", "[", "$", "name", "]", ":", "NULL", ";", "}" ]
@param string $name @return \Fubhy\GraphQL\Type\Definition\Types\TypeInterface
[ "@param", "string", "$name" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Schema.php#L129-L133
fubhy/graphql-php
src/Schema.php
Schema.typeMapReducer
protected function typeMapReducer(array $map, $type) { if ($type instanceof ModifierInterface) { return $this->typeMapReducer($map, $type->getWrappedType()); } if (!$type instanceof TypeInterface) { return $map; } if (!empty($map[$type->getName()])) { if ($type instanceof ObjectType || $type instanceof InterfaceType) { $type->setFields($map[$type->getName()]->getFields()); } return $map; } $reducedMap = array_merge($map, [$type->getName() => $type]); if ($type instanceof InterfaceType || $type instanceof UnionType) { $reducedMap = array_reduce( $type->getPossibleTypes(), [$this, 'typeMapReducer'], $reducedMap ); } if ($type instanceof ObjectType) { $reducedMap = array_reduce( $type->getInterfaces(), [$this, 'typeMapReducer'], $reducedMap ); } if ($type instanceof ObjectType || $type instanceof InterfaceType) { foreach ($type->getFields() as $fieldName => $field) { $args = $field->getArguments(); $reducedMap = array_reduce(array_map(function (FieldArgument $arg) { return $arg->getType(); }, $args), [$this, 'typeMapReducer'], $reducedMap); $reducedMap = $this->typeMapReducer($reducedMap, $field->getType()); } } return $reducedMap; }
php
protected function typeMapReducer(array $map, $type) { if ($type instanceof ModifierInterface) { return $this->typeMapReducer($map, $type->getWrappedType()); } if (!$type instanceof TypeInterface) { return $map; } if (!empty($map[$type->getName()])) { if ($type instanceof ObjectType || $type instanceof InterfaceType) { $type->setFields($map[$type->getName()]->getFields()); } return $map; } $reducedMap = array_merge($map, [$type->getName() => $type]); if ($type instanceof InterfaceType || $type instanceof UnionType) { $reducedMap = array_reduce( $type->getPossibleTypes(), [$this, 'typeMapReducer'], $reducedMap ); } if ($type instanceof ObjectType) { $reducedMap = array_reduce( $type->getInterfaces(), [$this, 'typeMapReducer'], $reducedMap ); } if ($type instanceof ObjectType || $type instanceof InterfaceType) { foreach ($type->getFields() as $fieldName => $field) { $args = $field->getArguments(); $reducedMap = array_reduce(array_map(function (FieldArgument $arg) { return $arg->getType(); }, $args), [$this, 'typeMapReducer'], $reducedMap); $reducedMap = $this->typeMapReducer($reducedMap, $field->getType()); } } return $reducedMap; }
[ "protected", "function", "typeMapReducer", "(", "array", "$", "map", ",", "$", "type", ")", "{", "if", "(", "$", "type", "instanceof", "ModifierInterface", ")", "{", "return", "$", "this", "->", "typeMapReducer", "(", "$", "map", ",", "$", "type", "->", "getWrappedType", "(", ")", ")", ";", "}", "if", "(", "!", "$", "type", "instanceof", "TypeInterface", ")", "{", "return", "$", "map", ";", "}", "if", "(", "!", "empty", "(", "$", "map", "[", "$", "type", "->", "getName", "(", ")", "]", ")", ")", "{", "if", "(", "$", "type", "instanceof", "ObjectType", "||", "$", "type", "instanceof", "InterfaceType", ")", "{", "$", "type", "->", "setFields", "(", "$", "map", "[", "$", "type", "->", "getName", "(", ")", "]", "->", "getFields", "(", ")", ")", ";", "}", "return", "$", "map", ";", "}", "$", "reducedMap", "=", "array_merge", "(", "$", "map", ",", "[", "$", "type", "->", "getName", "(", ")", "=>", "$", "type", "]", ")", ";", "if", "(", "$", "type", "instanceof", "InterfaceType", "||", "$", "type", "instanceof", "UnionType", ")", "{", "$", "reducedMap", "=", "array_reduce", "(", "$", "type", "->", "getPossibleTypes", "(", ")", ",", "[", "$", "this", ",", "'typeMapReducer'", "]", ",", "$", "reducedMap", ")", ";", "}", "if", "(", "$", "type", "instanceof", "ObjectType", ")", "{", "$", "reducedMap", "=", "array_reduce", "(", "$", "type", "->", "getInterfaces", "(", ")", ",", "[", "$", "this", ",", "'typeMapReducer'", "]", ",", "$", "reducedMap", ")", ";", "}", "if", "(", "$", "type", "instanceof", "ObjectType", "||", "$", "type", "instanceof", "InterfaceType", ")", "{", "foreach", "(", "$", "type", "->", "getFields", "(", ")", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "$", "args", "=", "$", "field", "->", "getArguments", "(", ")", ";", "$", "reducedMap", "=", "array_reduce", "(", "array_map", "(", "function", "(", "FieldArgument", "$", "arg", ")", "{", "return", "$", "arg", "->", "getType", "(", ")", ";", "}", ",", "$", "args", ")", ",", "[", "$", "this", ",", "'typeMapReducer'", "]", ",", "$", "reducedMap", ")", ";", "$", "reducedMap", "=", "$", "this", "->", "typeMapReducer", "(", "$", "reducedMap", ",", "$", "field", "->", "getType", "(", ")", ")", ";", "}", "}", "return", "$", "reducedMap", ";", "}" ]
@param \Fubhy\GraphQL\Type\Definition\Types\TypeInterface[] $map @param mixed $type @return \Fubhy\GraphQL\Type\Definition\Types\TypeInterface[]
[ "@param", "\\", "Fubhy", "\\", "GraphQL", "\\", "Type", "\\", "Definition", "\\", "Types", "\\", "TypeInterface", "[]", "$map", "@param", "mixed", "$type" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Schema.php#L141-L184
webforge-labs/psc-cms
lib/Psc/DateTime/TimeBenchmark.php
TimeBenchmark.getTime
public function getTime($format = self::MILLISECONDS) { $end = (isset($this->end)) ? $this->end : microtime(); list ($endSeconds, $endMicro) = $end; list ($startSeconds, $startMicro) = $this->start; $microseconds = ($endSeconds - $startSeconds) * pow(10,6) + abs($endMicro - $startMicro); if ($format == self::MICROSECONDS) { return $microseconds; } elseif ($format == self::MILLISECONDS) { return $microseconds / pow(10,3); } elseif ($format == self::SECONDS) { return $microseconds / pow(10,6); } else { throw new \Psc\Exception('Falscher Parameter für format'); } }
php
public function getTime($format = self::MILLISECONDS) { $end = (isset($this->end)) ? $this->end : microtime(); list ($endSeconds, $endMicro) = $end; list ($startSeconds, $startMicro) = $this->start; $microseconds = ($endSeconds - $startSeconds) * pow(10,6) + abs($endMicro - $startMicro); if ($format == self::MICROSECONDS) { return $microseconds; } elseif ($format == self::MILLISECONDS) { return $microseconds / pow(10,3); } elseif ($format == self::SECONDS) { return $microseconds / pow(10,6); } else { throw new \Psc\Exception('Falscher Parameter für format'); } }
[ "public", "function", "getTime", "(", "$", "format", "=", "self", "::", "MILLISECONDS", ")", "{", "$", "end", "=", "(", "isset", "(", "$", "this", "->", "end", ")", ")", "?", "$", "this", "->", "end", ":", "microtime", "(", ")", ";", "list", "(", "$", "endSeconds", ",", "$", "endMicro", ")", "=", "$", "end", ";", "list", "(", "$", "startSeconds", ",", "$", "startMicro", ")", "=", "$", "this", "->", "start", ";", "$", "microseconds", "=", "(", "$", "endSeconds", "-", "$", "startSeconds", ")", "*", "pow", "(", "10", ",", "6", ")", "+", "abs", "(", "$", "endMicro", "-", "$", "startMicro", ")", ";", "if", "(", "$", "format", "==", "self", "::", "MICROSECONDS", ")", "{", "return", "$", "microseconds", ";", "}", "elseif", "(", "$", "format", "==", "self", "::", "MILLISECONDS", ")", "{", "return", "$", "microseconds", "/", "pow", "(", "10", ",", "3", ")", ";", "}", "elseif", "(", "$", "format", "==", "self", "::", "SECONDS", ")", "{", "return", "$", "microseconds", "/", "pow", "(", "10", ",", "6", ")", ";", "}", "else", "{", "throw", "new", "\\", "Psc", "\\", "Exception", "(", "'Falscher Parameter für format')", ";", "", "}", "}" ]
Gibt die verganene Zeit des Benchmarks zurück Ist vorher nicht end() aufgerufen worden, wird die aktuelle Zeit als Timestamp benutzt und der Benchmark läuft weiter @return float
[ "Gibt", "die", "verganene", "Zeit", "des", "Benchmarks", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DateTime/TimeBenchmark.php#L67-L84
phrest/sdk
src/Generator.php
Generator.generate
public function generate() { $this->printMessage(''); $this->printMessage( 'Creating Collection config' ); Files::saveCollectionConfig((new ConfigGenerator($this->config))->create()); $this->printMessage( 'Creating Models, Controllers, Requests, Responses, and Exceptions' ); /** * @var string $name * @var Config $entity */ foreach ($this->config->versions as $version => $api) { $requests = []; $this->printMessage($version . '...'); foreach ($api as $entityName => $entity) { $entity = $this->vaidateEntityConfig($entityName, $entity); Files::initializeFolders($version, $entityName); if (isset($entity->model)) { $columns = $entity->model->columns; // Models Files::saveModel( new ModelGenerator($version, $entityName, $columns) ); // Requests foreach ($entity->requests as $requestMethod => $actions) { foreach ($actions as $actionName => $action) { if (empty($action)) { continue; } $requests[] = Files::saveRequest( new RequestGenerator( $version, $entityName, $entity->model, $requestMethod, $actionName, $action ) ); } } // Responses Files::saveResponse( new ResponseGenerator($version, $entityName, $columns) ); } // Exceptions $exceptions = $this->getExceptionsFromEntityConfig($entity); foreach ($exceptions as $exception) { Files::saveException( new ExceptionGenerator($version, $entityName, $exception) ); } // Controllers Files::saveController( new ControllerGenerator($version, $entityName, $entity) ); } Files::saveSDK( new SDKGenerator($version, $this->config->name, $requests) ); } $this->printMessage("All done, Remember to add the files to VCS!"); }
php
public function generate() { $this->printMessage(''); $this->printMessage( 'Creating Collection config' ); Files::saveCollectionConfig((new ConfigGenerator($this->config))->create()); $this->printMessage( 'Creating Models, Controllers, Requests, Responses, and Exceptions' ); /** * @var string $name * @var Config $entity */ foreach ($this->config->versions as $version => $api) { $requests = []; $this->printMessage($version . '...'); foreach ($api as $entityName => $entity) { $entity = $this->vaidateEntityConfig($entityName, $entity); Files::initializeFolders($version, $entityName); if (isset($entity->model)) { $columns = $entity->model->columns; // Models Files::saveModel( new ModelGenerator($version, $entityName, $columns) ); // Requests foreach ($entity->requests as $requestMethod => $actions) { foreach ($actions as $actionName => $action) { if (empty($action)) { continue; } $requests[] = Files::saveRequest( new RequestGenerator( $version, $entityName, $entity->model, $requestMethod, $actionName, $action ) ); } } // Responses Files::saveResponse( new ResponseGenerator($version, $entityName, $columns) ); } // Exceptions $exceptions = $this->getExceptionsFromEntityConfig($entity); foreach ($exceptions as $exception) { Files::saveException( new ExceptionGenerator($version, $entityName, $exception) ); } // Controllers Files::saveController( new ControllerGenerator($version, $entityName, $entity) ); } Files::saveSDK( new SDKGenerator($version, $this->config->name, $requests) ); } $this->printMessage("All done, Remember to add the files to VCS!"); }
[ "public", "function", "generate", "(", ")", "{", "$", "this", "->", "printMessage", "(", "''", ")", ";", "$", "this", "->", "printMessage", "(", "'Creating Collection config'", ")", ";", "Files", "::", "saveCollectionConfig", "(", "(", "new", "ConfigGenerator", "(", "$", "this", "->", "config", ")", ")", "->", "create", "(", ")", ")", ";", "$", "this", "->", "printMessage", "(", "'Creating Models, Controllers, Requests, Responses, and Exceptions'", ")", ";", "/**\n * @var string $name\n * @var Config $entity\n */", "foreach", "(", "$", "this", "->", "config", "->", "versions", "as", "$", "version", "=>", "$", "api", ")", "{", "$", "requests", "=", "[", "]", ";", "$", "this", "->", "printMessage", "(", "$", "version", ".", "'...'", ")", ";", "foreach", "(", "$", "api", "as", "$", "entityName", "=>", "$", "entity", ")", "{", "$", "entity", "=", "$", "this", "->", "vaidateEntityConfig", "(", "$", "entityName", ",", "$", "entity", ")", ";", "Files", "::", "initializeFolders", "(", "$", "version", ",", "$", "entityName", ")", ";", "if", "(", "isset", "(", "$", "entity", "->", "model", ")", ")", "{", "$", "columns", "=", "$", "entity", "->", "model", "->", "columns", ";", "// Models", "Files", "::", "saveModel", "(", "new", "ModelGenerator", "(", "$", "version", ",", "$", "entityName", ",", "$", "columns", ")", ")", ";", "// Requests", "foreach", "(", "$", "entity", "->", "requests", "as", "$", "requestMethod", "=>", "$", "actions", ")", "{", "foreach", "(", "$", "actions", "as", "$", "actionName", "=>", "$", "action", ")", "{", "if", "(", "empty", "(", "$", "action", ")", ")", "{", "continue", ";", "}", "$", "requests", "[", "]", "=", "Files", "::", "saveRequest", "(", "new", "RequestGenerator", "(", "$", "version", ",", "$", "entityName", ",", "$", "entity", "->", "model", ",", "$", "requestMethod", ",", "$", "actionName", ",", "$", "action", ")", ")", ";", "}", "}", "// Responses", "Files", "::", "saveResponse", "(", "new", "ResponseGenerator", "(", "$", "version", ",", "$", "entityName", ",", "$", "columns", ")", ")", ";", "}", "// Exceptions", "$", "exceptions", "=", "$", "this", "->", "getExceptionsFromEntityConfig", "(", "$", "entity", ")", ";", "foreach", "(", "$", "exceptions", "as", "$", "exception", ")", "{", "Files", "::", "saveException", "(", "new", "ExceptionGenerator", "(", "$", "version", ",", "$", "entityName", ",", "$", "exception", ")", ")", ";", "}", "// Controllers", "Files", "::", "saveController", "(", "new", "ControllerGenerator", "(", "$", "version", ",", "$", "entityName", ",", "$", "entity", ")", ")", ";", "}", "Files", "::", "saveSDK", "(", "new", "SDKGenerator", "(", "$", "version", ",", "$", "this", "->", "config", "->", "name", ",", "$", "requests", ")", ")", ";", "}", "$", "this", "->", "printMessage", "(", "\"All done, Remember to add the files to VCS!\"", ")", ";", "}" ]
Generate the SDK
[ "Generate", "the", "SDK" ]
train
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator.php#L69-L156
phrest/sdk
src/Generator.php
Generator.vaidateEntityConfig
public function vaidateEntityConfig($entityName, $entity) { if (empty($entity->requests)) { $this->printMessage( "Entity: {$entityName} doesn't have any requests set up for it." . " Controllers, exceptions, requests will be skipped." ); } else { foreach ($entity->requests as $requestMethod => $actions) { foreach ($actions as $actionName => $action) { if (empty($action->url)) { $this->printMessage( "Entity: {$entityName}::{$actionName} doesn't have a url set." . " This action will be skipped." ); $entity->requests->$requestMethod->$actionName = false; } if (!empty($action->throws)) { if (!empty($action->throws->extends)) { if (!class_exists("Phrest\\API\\Exceptions\\" . $action->throws->extends)) { $this->printMessage( "Entity: {$entityName}::{$actionName} Unknown exception: " . "Phrest\\API\\Exceptions\\" . $action->throws->extends . ". This extension will be removed." ); $action->throws->extends = false; } } } } } } if (empty($entity->model)) { $this->printMessage( "Entity: {$entityName} doesn't have a model definition. Models and " . "responses will be skipped." ); } return $entity; }
php
public function vaidateEntityConfig($entityName, $entity) { if (empty($entity->requests)) { $this->printMessage( "Entity: {$entityName} doesn't have any requests set up for it." . " Controllers, exceptions, requests will be skipped." ); } else { foreach ($entity->requests as $requestMethod => $actions) { foreach ($actions as $actionName => $action) { if (empty($action->url)) { $this->printMessage( "Entity: {$entityName}::{$actionName} doesn't have a url set." . " This action will be skipped." ); $entity->requests->$requestMethod->$actionName = false; } if (!empty($action->throws)) { if (!empty($action->throws->extends)) { if (!class_exists("Phrest\\API\\Exceptions\\" . $action->throws->extends)) { $this->printMessage( "Entity: {$entityName}::{$actionName} Unknown exception: " . "Phrest\\API\\Exceptions\\" . $action->throws->extends . ". This extension will be removed." ); $action->throws->extends = false; } } } } } } if (empty($entity->model)) { $this->printMessage( "Entity: {$entityName} doesn't have a model definition. Models and " . "responses will be skipped." ); } return $entity; }
[ "public", "function", "vaidateEntityConfig", "(", "$", "entityName", ",", "$", "entity", ")", "{", "if", "(", "empty", "(", "$", "entity", "->", "requests", ")", ")", "{", "$", "this", "->", "printMessage", "(", "\"Entity: {$entityName} doesn't have any requests set up for it.\"", ".", "\" Controllers, exceptions, requests will be skipped.\"", ")", ";", "}", "else", "{", "foreach", "(", "$", "entity", "->", "requests", "as", "$", "requestMethod", "=>", "$", "actions", ")", "{", "foreach", "(", "$", "actions", "as", "$", "actionName", "=>", "$", "action", ")", "{", "if", "(", "empty", "(", "$", "action", "->", "url", ")", ")", "{", "$", "this", "->", "printMessage", "(", "\"Entity: {$entityName}::{$actionName} doesn't have a url set.\"", ".", "\" This action will be skipped.\"", ")", ";", "$", "entity", "->", "requests", "->", "$", "requestMethod", "->", "$", "actionName", "=", "false", ";", "}", "if", "(", "!", "empty", "(", "$", "action", "->", "throws", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "action", "->", "throws", "->", "extends", ")", ")", "{", "if", "(", "!", "class_exists", "(", "\"Phrest\\\\API\\\\Exceptions\\\\\"", ".", "$", "action", "->", "throws", "->", "extends", ")", ")", "{", "$", "this", "->", "printMessage", "(", "\"Entity: {$entityName}::{$actionName} Unknown exception: \"", ".", "\"Phrest\\\\API\\\\Exceptions\\\\\"", ".", "$", "action", "->", "throws", "->", "extends", ".", "\". This extension will be removed.\"", ")", ";", "$", "action", "->", "throws", "->", "extends", "=", "false", ";", "}", "}", "}", "}", "}", "}", "if", "(", "empty", "(", "$", "entity", "->", "model", ")", ")", "{", "$", "this", "->", "printMessage", "(", "\"Entity: {$entityName} doesn't have a model definition. Models and \"", ".", "\"responses will be skipped.\"", ")", ";", "}", "return", "$", "entity", ";", "}" ]
@param string $entityName @param Config $entity @returns Config
[ "@param", "string", "$entityName", "@param", "Config", "$entity" ]
train
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator.php#L164-L217
phrest/sdk
src/Generator.php
Generator.getExceptionsFromEntityConfig
public function getExceptionsFromEntityConfig($entity) { $exceptions = []; foreach ($entity->requests as $request) { foreach ($request as $action) { if (isset($action->throws)) { $exceptions[] = $action->throws; } } } return $exceptions; }
php
public function getExceptionsFromEntityConfig($entity) { $exceptions = []; foreach ($entity->requests as $request) { foreach ($request as $action) { if (isset($action->throws)) { $exceptions[] = $action->throws; } } } return $exceptions; }
[ "public", "function", "getExceptionsFromEntityConfig", "(", "$", "entity", ")", "{", "$", "exceptions", "=", "[", "]", ";", "foreach", "(", "$", "entity", "->", "requests", "as", "$", "request", ")", "{", "foreach", "(", "$", "request", "as", "$", "action", ")", "{", "if", "(", "isset", "(", "$", "action", "->", "throws", ")", ")", "{", "$", "exceptions", "[", "]", "=", "$", "action", "->", "throws", ";", "}", "}", "}", "return", "$", "exceptions", ";", "}" ]
@param Config $entity @return \stdClass[]
[ "@param", "Config", "$entity" ]
train
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator.php#L224-L240
Lansoweb/LosReCaptcha
src/Captcha/ReCaptcha.php
ReCaptcha.isValid
public function isValid($value, $context = null) { if (! is_array($value) && ! is_array($context)) { $this->error(self::MISSING_VALUE); return false; } if (! is_array($value) && is_array($context)) { $value = $context; } if (empty($value[$this->responseField])) { $this->error(self::MISSING_VALUE); return false; } $service = $this->getService(); $res = $service->verify($value[$this->responseField]); if (! $res) { $this->error(self::ERR_CAPTCHA); return false; } if (! $res->isSuccess()) { $result = $res->getErrorCodes(); $this->error(self::BAD_CAPTCHA, end($result)); return false; } return true; }
php
public function isValid($value, $context = null) { if (! is_array($value) && ! is_array($context)) { $this->error(self::MISSING_VALUE); return false; } if (! is_array($value) && is_array($context)) { $value = $context; } if (empty($value[$this->responseField])) { $this->error(self::MISSING_VALUE); return false; } $service = $this->getService(); $res = $service->verify($value[$this->responseField]); if (! $res) { $this->error(self::ERR_CAPTCHA); return false; } if (! $res->isSuccess()) { $result = $res->getErrorCodes(); $this->error(self::BAD_CAPTCHA, end($result)); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "context", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "context", ")", ")", "{", "$", "this", "->", "error", "(", "self", "::", "MISSING_VALUE", ")", ";", "return", "false", ";", "}", "if", "(", "!", "is_array", "(", "$", "value", ")", "&&", "is_array", "(", "$", "context", ")", ")", "{", "$", "value", "=", "$", "context", ";", "}", "if", "(", "empty", "(", "$", "value", "[", "$", "this", "->", "responseField", "]", ")", ")", "{", "$", "this", "->", "error", "(", "self", "::", "MISSING_VALUE", ")", ";", "return", "false", ";", "}", "$", "service", "=", "$", "this", "->", "getService", "(", ")", ";", "$", "res", "=", "$", "service", "->", "verify", "(", "$", "value", "[", "$", "this", "->", "responseField", "]", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "error", "(", "self", "::", "ERR_CAPTCHA", ")", ";", "return", "false", ";", "}", "if", "(", "!", "$", "res", "->", "isSuccess", "(", ")", ")", "{", "$", "result", "=", "$", "res", "->", "getErrorCodes", "(", ")", ";", "$", "this", "->", "error", "(", "self", "::", "BAD_CAPTCHA", ",", "end", "(", "$", "result", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate captcha @see \Zend\Validator\ValidatorInterface::isValid() @param mixed $value @param mixed $context @return bool
[ "Validate", "captcha" ]
train
https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Captcha/ReCaptcha.php#L79-L110
okitcom/ok-lib-php
src/Service/Ticketing.php
Ticketing.create
public function create(TicketObject $ticket) { $response = $this->client->post('tickets', array('ticket' => $ticket)); return new TicketObject($response); }
php
public function create(TicketObject $ticket) { $response = $this->client->post('tickets', array('ticket' => $ticket)); return new TicketObject($response); }
[ "public", "function", "create", "(", "TicketObject", "$", "ticket", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "'tickets'", ",", "array", "(", "'ticket'", "=>", "$", "ticket", ")", ")", ";", "return", "new", "TicketObject", "(", "$", "response", ")", ";", "}" ]
Creates a ticket @param TicketObject $ticket @return TicketObject @throws \OK\Model\Network\Exception\NetworkException
[ "Creates", "a", "ticket" ]
train
https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/Ticketing.php#L33-L36
okitcom/ok-lib-php
src/Service/Ticketing.php
Ticketing.update
public function update(TicketObject $ticket) { return new TicketObject($this->client->post('tickets/' . $ticket->guid, array("ticket" => $ticket))); }
php
public function update(TicketObject $ticket) { return new TicketObject($this->client->post('tickets/' . $ticket->guid, array("ticket" => $ticket))); }
[ "public", "function", "update", "(", "TicketObject", "$", "ticket", ")", "{", "return", "new", "TicketObject", "(", "$", "this", "->", "client", "->", "post", "(", "'tickets/'", ".", "$", "ticket", "->", "guid", ",", "array", "(", "\"ticket\"", "=>", "$", "ticket", ")", ")", ")", ";", "}" ]
Updates the ticket @param TicketObject $ticket @return mixed @throws \OK\Model\Network\Exception\NetworkException
[ "Updates", "the", "ticket" ]
train
https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/Ticketing.php#L44-L46
okitcom/ok-lib-php
src/Service/Ticketing.php
Ticketing.check
public function check($eventId, $barcode, $terminalId = null, Location $location = null) { return new TicketCheckIn($this->client->post('check', [ 'event' => $eventId, 'barcode' => $barcode, 'terminalId' => $terminalId, 'location' => $location ])); }
php
public function check($eventId, $barcode, $terminalId = null, Location $location = null) { return new TicketCheckIn($this->client->post('check', [ 'event' => $eventId, 'barcode' => $barcode, 'terminalId' => $terminalId, 'location' => $location ])); }
[ "public", "function", "check", "(", "$", "eventId", ",", "$", "barcode", ",", "$", "terminalId", "=", "null", ",", "Location", "$", "location", "=", "null", ")", "{", "return", "new", "TicketCheckIn", "(", "$", "this", "->", "client", "->", "post", "(", "'check'", ",", "[", "'event'", "=>", "$", "eventId", ",", "'barcode'", "=>", "$", "barcode", ",", "'terminalId'", "=>", "$", "terminalId", ",", "'location'", "=>", "$", "location", "]", ")", ")", ";", "}" ]
Check a ticket barcode for an event. @param $eventId integer event id @param $barcode string barcode @param $terminalId integer _optional_ terminal id @param $location Location _optional_ location @return TicketCheckIn result @throws \OK\Model\Network\Exception\NetworkException
[ "Check", "a", "ticket", "barcode", "for", "an", "event", "." ]
train
https://github.com/okitcom/ok-lib-php/blob/1f441f3d216af7c952788e864bfe66bc4f089467/src/Service/Ticketing.php#L70-L77
anime-db/app-bundle
src/Controller/FormController.php
FormController.localPathAction
public function localPathAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } $form = $this->createForm( new ChoiceLocalPath(), ['path' => $request->get('path') ?: ''] ); return $this->render('AnimeDbAppBundle:Form:local_path.html.twig', [ 'form' => $form->createView(), ], $response); }
php
public function localPathAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } $form = $this->createForm( new ChoiceLocalPath(), ['path' => $request->get('path') ?: ''] ); return $this->render('AnimeDbAppBundle:Form:local_path.html.twig', [ 'form' => $form->createView(), ], $response); }
[ "public", "function", "localPathAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ChoiceLocalPath", "(", ")", ",", "[", "'path'", "=>", "$", "request", "->", "get", "(", "'path'", ")", "?", ":", "''", "]", ")", ";", "return", "$", "this", "->", "render", "(", "'AnimeDbAppBundle:Form:local_path.html.twig'", ",", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ",", "$", "response", ")", ";", "}" ]
Form field local path. @param Request $request @return Response
[ "Form", "field", "local", "path", "." ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/FormController.php#L29-L45
anime-db/app-bundle
src/Controller/FormController.php
FormController.localPathFoldersAction
public function localPathFoldersAction(Request $request) { $form = $this->createForm(new ChoiceLocalPath()); $form->handleRequest($request); $path = $form->get('path')->getData() ?: Filesystem::getUserHomeDir(); if (($root = $request->get('root')) && strpos($path, $root) !== 0) { $path = $root; } /* @var $response JsonResponse */ $response = $this->getCacheTimeKeeper() ->getResponse([(new \DateTime())->setTimestamp(filemtime($path))], -1, new JsonResponse()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } return $response->setData([ 'path' => $path, 'folders' => Filesystem::scandir($path, Filesystem::DIRECTORY), ]); }
php
public function localPathFoldersAction(Request $request) { $form = $this->createForm(new ChoiceLocalPath()); $form->handleRequest($request); $path = $form->get('path')->getData() ?: Filesystem::getUserHomeDir(); if (($root = $request->get('root')) && strpos($path, $root) !== 0) { $path = $root; } /* @var $response JsonResponse */ $response = $this->getCacheTimeKeeper() ->getResponse([(new \DateTime())->setTimestamp(filemtime($path))], -1, new JsonResponse()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } return $response->setData([ 'path' => $path, 'folders' => Filesystem::scandir($path, Filesystem::DIRECTORY), ]); }
[ "public", "function", "localPathFoldersAction", "(", "Request", "$", "request", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "ChoiceLocalPath", "(", ")", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "path", "=", "$", "form", "->", "get", "(", "'path'", ")", "->", "getData", "(", ")", "?", ":", "Filesystem", "::", "getUserHomeDir", "(", ")", ";", "if", "(", "(", "$", "root", "=", "$", "request", "->", "get", "(", "'root'", ")", ")", "&&", "strpos", "(", "$", "path", ",", "$", "root", ")", "!==", "0", ")", "{", "$", "path", "=", "$", "root", ";", "}", "/* @var $response JsonResponse */", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", "[", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setTimestamp", "(", "filemtime", "(", "$", "path", ")", ")", "]", ",", "-", "1", ",", "new", "JsonResponse", "(", ")", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "return", "$", "response", "->", "setData", "(", "[", "'path'", "=>", "$", "path", ",", "'folders'", "=>", "Filesystem", "::", "scandir", "(", "$", "path", ",", "Filesystem", "::", "DIRECTORY", ")", ",", "]", ")", ";", "}" ]
Return list folders for path. @param Request $request @return JsonResponse
[ "Return", "list", "folders", "for", "path", "." ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/FormController.php#L54-L76
anime-db/app-bundle
src/Controller/FormController.php
FormController.imageAction
public function imageAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } return $this->render('AnimeDbAppBundle:Form:image.html.twig', [ 'form' => $this->createForm(new UploadImage())->createView(), 'change' => (bool) $request->get('change', false), ], $response); }
php
public function imageAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse(); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } return $this->render('AnimeDbAppBundle:Form:image.html.twig', [ 'form' => $this->createForm(new UploadImage())->createView(), 'change' => (bool) $request->get('change', false), ], $response); }
[ "public", "function", "imageAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbAppBundle:Form:image.html.twig'", ",", "[", "'form'", "=>", "$", "this", "->", "createForm", "(", "new", "UploadImage", "(", ")", ")", "->", "createView", "(", ")", ",", "'change'", "=>", "(", "bool", ")", "$", "request", "->", "get", "(", "'change'", ",", "false", ")", ",", "]", ",", "$", "response", ")", ";", "}" ]
Form field image. @param Request $request @return Response
[ "Form", "field", "image", "." ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/FormController.php#L85-L97
anime-db/app-bundle
src/Controller/FormController.php
FormController.imageUploadAction
public function imageUploadAction(Request $request) { $image = new ImageField(); /* @var $form Form */ $form = $this->createForm(new UploadImage(), $image); $form->handleRequest($request); if (!$form->isValid()) { $errors = $form->getErrors(); return new JsonResponse(['error' => $this->get('translator')->trans($errors[0]->getMessage())], 404); } // try upload file try { $this->get('anime_db.downloader')->imageField($image); return new JsonResponse([ 'path' => $image->getFilename(), 'image' => $image->getWebPath(), ]); } catch (\InvalidArgumentException $e) { return new JsonResponse(['error' => $this->get('translator')->trans($e->getMessage())], 404); } }
php
public function imageUploadAction(Request $request) { $image = new ImageField(); /* @var $form Form */ $form = $this->createForm(new UploadImage(), $image); $form->handleRequest($request); if (!$form->isValid()) { $errors = $form->getErrors(); return new JsonResponse(['error' => $this->get('translator')->trans($errors[0]->getMessage())], 404); } // try upload file try { $this->get('anime_db.downloader')->imageField($image); return new JsonResponse([ 'path' => $image->getFilename(), 'image' => $image->getWebPath(), ]); } catch (\InvalidArgumentException $e) { return new JsonResponse(['error' => $this->get('translator')->trans($e->getMessage())], 404); } }
[ "public", "function", "imageUploadAction", "(", "Request", "$", "request", ")", "{", "$", "image", "=", "new", "ImageField", "(", ")", ";", "/* @var $form Form */", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "UploadImage", "(", ")", ",", "$", "image", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "!", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "errors", "=", "$", "form", "->", "getErrors", "(", ")", ";", "return", "new", "JsonResponse", "(", "[", "'error'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "$", "errors", "[", "0", "]", "->", "getMessage", "(", ")", ")", "]", ",", "404", ")", ";", "}", "// try upload file", "try", "{", "$", "this", "->", "get", "(", "'anime_db.downloader'", ")", "->", "imageField", "(", "$", "image", ")", ";", "return", "new", "JsonResponse", "(", "[", "'path'", "=>", "$", "image", "->", "getFilename", "(", ")", ",", "'image'", "=>", "$", "image", "->", "getWebPath", "(", ")", ",", "]", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "return", "new", "JsonResponse", "(", "[", "'error'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "$", "e", "->", "getMessage", "(", ")", ")", "]", ",", "404", ")", ";", "}", "}" ]
@param Request $request @return JsonResponse
[ "@param", "Request", "$request" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/FormController.php#L104-L128
ClanCats/Core
src/classes/CCLang.php
CCLang.set_current
public static function set_current( $lang ) { $lang = static::parse( $lang ); if ( !array_key_exists( $lang, static::$data ) ) { static::$data[$lang] = array(); } return static::$current_language = $lang; }
php
public static function set_current( $lang ) { $lang = static::parse( $lang ); if ( !array_key_exists( $lang, static::$data ) ) { static::$data[$lang] = array(); } return static::$current_language = $lang; }
[ "public", "static", "function", "set_current", "(", "$", "lang", ")", "{", "$", "lang", "=", "static", "::", "parse", "(", "$", "lang", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "lang", ",", "static", "::", "$", "data", ")", ")", "{", "static", "::", "$", "data", "[", "$", "lang", "]", "=", "array", "(", ")", ";", "}", "return", "static", "::", "$", "current_language", "=", "$", "lang", ";", "}" ]
Set the current language The passed string wil be parsed also the parsed / used language will be returnd. @param string $lang @return string
[ "Set", "the", "current", "language", "The", "passed", "string", "wil", "be", "parsed", "also", "the", "parsed", "/", "used", "language", "will", "be", "returnd", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLang.php#L74-L84
ClanCats/Core
src/classes/CCLang.php
CCLang.parse
public static function parse( $lang ) { $conf = ClanCats::$config->language; if ( isset( $lang ) && strlen( $lang ) > 1 ) { $lang = explode( ',', strtolower( $lang ) ); $lang = explode( '-', $lang[0] ); if ( !isset( $lang[1] ) ) { $lang[1] = $lang[0]; } $available = $conf['available']; if ( array_key_exists( $lang[0], $available ) ) { // does even the region match? if ( in_array( $lang[1], $available[$lang[0]] ) ) { return $lang[0].'-'.$lang[1]; } // return the first region else { $locales = $available[$lang[0]]; return $lang[0].'-'.$locales[key($locales)]; } } } // Return the default language when nothing coul be matched return $conf['default']; }
php
public static function parse( $lang ) { $conf = ClanCats::$config->language; if ( isset( $lang ) && strlen( $lang ) > 1 ) { $lang = explode( ',', strtolower( $lang ) ); $lang = explode( '-', $lang[0] ); if ( !isset( $lang[1] ) ) { $lang[1] = $lang[0]; } $available = $conf['available']; if ( array_key_exists( $lang[0], $available ) ) { // does even the region match? if ( in_array( $lang[1], $available[$lang[0]] ) ) { return $lang[0].'-'.$lang[1]; } // return the first region else { $locales = $available[$lang[0]]; return $lang[0].'-'.$locales[key($locales)]; } } } // Return the default language when nothing coul be matched return $conf['default']; }
[ "public", "static", "function", "parse", "(", "$", "lang", ")", "{", "$", "conf", "=", "ClanCats", "::", "$", "config", "->", "language", ";", "if", "(", "isset", "(", "$", "lang", ")", "&&", "strlen", "(", "$", "lang", ")", ">", "1", ")", "{", "$", "lang", "=", "explode", "(", "','", ",", "strtolower", "(", "$", "lang", ")", ")", ";", "$", "lang", "=", "explode", "(", "'-'", ",", "$", "lang", "[", "0", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "lang", "[", "1", "]", ")", ")", "{", "$", "lang", "[", "1", "]", "=", "$", "lang", "[", "0", "]", ";", "}", "$", "available", "=", "$", "conf", "[", "'available'", "]", ";", "if", "(", "array_key_exists", "(", "$", "lang", "[", "0", "]", ",", "$", "available", ")", ")", "{", "// does even the region match?", "if", "(", "in_array", "(", "$", "lang", "[", "1", "]", ",", "$", "available", "[", "$", "lang", "[", "0", "]", "]", ")", ")", "{", "return", "$", "lang", "[", "0", "]", ".", "'-'", ".", "$", "lang", "[", "1", "]", ";", "}", "// return the first region", "else", "{", "$", "locales", "=", "$", "available", "[", "$", "lang", "[", "0", "]", "]", ";", "return", "$", "lang", "[", "0", "]", ".", "'-'", ".", "$", "locales", "[", "key", "(", "$", "locales", ")", "]", ";", "}", "}", "}", "// Return the default language when nothing coul be matched", "return", "$", "conf", "[", "'default'", "]", ";", "}" ]
Match an language code with the aviable languages CCLang::parse( 'de' ); CCLang::parse( 'EN-US' ); CCLang::parse( 'de-DE,en,fr' ); @param string $lang @return string
[ "Match", "an", "language", "code", "with", "the", "aviable", "languages" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLang.php#L113-L147
ClanCats/Core
src/classes/CCLang.php
CCLang.load
public static function load( $path, $overwrite = false ) { if ( array_key_exists( $path, static::$data[static::$current_language] ) && $overwrite === false ) { return; } $file_path = CCPath::get( $path, CCDIR_LANGUAGE.static::$current_language.'/', EXT ); if ( !file_exists( $file_path ) ) { // as fallback try to load the language file of the default language if ( static::$current_language !== ( $default_lang = ClanCats::$config->get( 'language.default' ) ) ) { $file_path = CCPath::get( $path, CCDIR_LANGUAGE.$default_lang.'/', EXT ); if ( !file_exists( $file_path ) ) { throw new CCException( "CCLang::load - could not find language file: ".$file_path ); } } else { throw new CCException( "CCLang::load - could not find language file: ".$file_path ); } } static::$data[static::$current_language][$path] = require( $file_path ); }
php
public static function load( $path, $overwrite = false ) { if ( array_key_exists( $path, static::$data[static::$current_language] ) && $overwrite === false ) { return; } $file_path = CCPath::get( $path, CCDIR_LANGUAGE.static::$current_language.'/', EXT ); if ( !file_exists( $file_path ) ) { // as fallback try to load the language file of the default language if ( static::$current_language !== ( $default_lang = ClanCats::$config->get( 'language.default' ) ) ) { $file_path = CCPath::get( $path, CCDIR_LANGUAGE.$default_lang.'/', EXT ); if ( !file_exists( $file_path ) ) { throw new CCException( "CCLang::load - could not find language file: ".$file_path ); } } else { throw new CCException( "CCLang::load - could not find language file: ".$file_path ); } } static::$data[static::$current_language][$path] = require( $file_path ); }
[ "public", "static", "function", "load", "(", "$", "path", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "array_key_exists", "(", "$", "path", ",", "static", "::", "$", "data", "[", "static", "::", "$", "current_language", "]", ")", "&&", "$", "overwrite", "===", "false", ")", "{", "return", ";", "}", "$", "file_path", "=", "CCPath", "::", "get", "(", "$", "path", ",", "CCDIR_LANGUAGE", ".", "static", "::", "$", "current_language", ".", "'/'", ",", "EXT", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file_path", ")", ")", "{", "// as fallback try to load the language file of the default language", "if", "(", "static", "::", "$", "current_language", "!==", "(", "$", "default_lang", "=", "ClanCats", "::", "$", "config", "->", "get", "(", "'language.default'", ")", ")", ")", "{", "$", "file_path", "=", "CCPath", "::", "get", "(", "$", "path", ",", "CCDIR_LANGUAGE", ".", "$", "default_lang", ".", "'/'", ",", "EXT", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file_path", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCLang::load - could not find language file: \"", ".", "$", "file_path", ")", ";", "}", "}", "else", "{", "throw", "new", "CCException", "(", "\"CCLang::load - could not find language file: \"", ".", "$", "file_path", ")", ";", "}", "}", "static", "::", "$", "data", "[", "static", "::", "$", "current_language", "]", "[", "$", "path", "]", "=", "require", "(", "$", "file_path", ")", ";", "}" ]
Load a language file into the appliaction CCLang::load( 'some/path/to/file' ); CCLang::load( 'controller/example' ); CCLang::load( 'Blog::controller/dashboard' ); @param string $path @param bool $overwrite @return void
[ "Load", "a", "language", "file", "into", "the", "appliaction" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLang.php#L170-L198
ClanCats/Core
src/classes/CCLang.php
CCLang.line
public static function line( $key, $params = array() ) { $path = substr( $key, 0, strpos( $key, '.' ) ); $key = substr( $key, strpos( $key, '.' )+1 ); // if there is a namespace replace the path with it if ( isset( static::$aliases[$path] ) ) { return static::line( static::$aliases[$path].'.'.$key, $params ); } // find the language file behind the path if ( !isset( static::$data[static::$current_language][$path] ) ) { // Autoload the language file // The load function will throw an exception if the // file doesnt exists so we dont have to care for that here. CCLang::load( $path ); } // Does the line exist in the language file? if ( !isset( static::$data[static::$current_language][$path][$key] ) ) { // We simply return the key to the user and log the missing language file line CCLog::add( 'CCLang::line - No such line "'.$key.'" ('.static::$current_language.') in file: '.$path, 'warning' ); return $key; } $line = static::$data[static::$current_language][$path][$key]; // replace the params inside the line foreach ( $params as $param => $value ) { $line = str_replace( ':'.$param, $value, $line ); } return $line; }
php
public static function line( $key, $params = array() ) { $path = substr( $key, 0, strpos( $key, '.' ) ); $key = substr( $key, strpos( $key, '.' )+1 ); // if there is a namespace replace the path with it if ( isset( static::$aliases[$path] ) ) { return static::line( static::$aliases[$path].'.'.$key, $params ); } // find the language file behind the path if ( !isset( static::$data[static::$current_language][$path] ) ) { // Autoload the language file // The load function will throw an exception if the // file doesnt exists so we dont have to care for that here. CCLang::load( $path ); } // Does the line exist in the language file? if ( !isset( static::$data[static::$current_language][$path][$key] ) ) { // We simply return the key to the user and log the missing language file line CCLog::add( 'CCLang::line - No such line "'.$key.'" ('.static::$current_language.') in file: '.$path, 'warning' ); return $key; } $line = static::$data[static::$current_language][$path][$key]; // replace the params inside the line foreach ( $params as $param => $value ) { $line = str_replace( ':'.$param, $value, $line ); } return $line; }
[ "public", "static", "function", "line", "(", "$", "key", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "path", "=", "substr", "(", "$", "key", ",", "0", ",", "strpos", "(", "$", "key", ",", "'.'", ")", ")", ";", "$", "key", "=", "substr", "(", "$", "key", ",", "strpos", "(", "$", "key", ",", "'.'", ")", "+", "1", ")", ";", "// if there is a namespace replace the path with it", "if", "(", "isset", "(", "static", "::", "$", "aliases", "[", "$", "path", "]", ")", ")", "{", "return", "static", "::", "line", "(", "static", "::", "$", "aliases", "[", "$", "path", "]", ".", "'.'", ".", "$", "key", ",", "$", "params", ")", ";", "}", "// find the language file behind the path", "if", "(", "!", "isset", "(", "static", "::", "$", "data", "[", "static", "::", "$", "current_language", "]", "[", "$", "path", "]", ")", ")", "{", "// Autoload the language file", "// The load function will throw an exception if the ", "// file doesnt exists so we dont have to care for that here.", "CCLang", "::", "load", "(", "$", "path", ")", ";", "}", "// Does the line exist in the language file?", "if", "(", "!", "isset", "(", "static", "::", "$", "data", "[", "static", "::", "$", "current_language", "]", "[", "$", "path", "]", "[", "$", "key", "]", ")", ")", "{", "// We simply return the key to the user and log the missing language file line", "CCLog", "::", "add", "(", "'CCLang::line - No such line \"'", ".", "$", "key", ".", "'\" ('", ".", "static", "::", "$", "current_language", ".", "') in file: '", ".", "$", "path", ",", "'warning'", ")", ";", "return", "$", "key", ";", "}", "$", "line", "=", "static", "::", "$", "data", "[", "static", "::", "$", "current_language", "]", "[", "$", "path", "]", "[", "$", "key", "]", ";", "// replace the params inside the line", "foreach", "(", "$", "params", "as", "$", "param", "=>", "$", "value", ")", "{", "$", "line", "=", "str_replace", "(", "':'", ".", "$", "param", ",", "$", "value", ",", "$", "line", ")", ";", "}", "return", "$", "line", ";", "}" ]
Recive a translated line __( 'some/path.to.my.label' ); __( 'user.welcome', array( 'name' => 'Jeff' ) ) @param string $key @param array $params @return string
[ "Recive", "a", "translated", "line" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLang.php#L210-L246
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanner.php
CoverFishScanner.addCoverageValidatorPoolForCover
public function addCoverageValidatorPoolForCover($coverToken) { // covers ClassName::methodName $this->addValidator(new ValidatorClassNameMethodName($coverToken)); // covers ::methodName $this->addValidator(new ValidatorMethodName($coverToken)); // covers ClassName $this->addValidator(new ValidatorClassName($coverToken)); // covers ClassName::accessor (for public, protected, private, !public, !protected, !private) $this->addValidator(new ValidatorClassNameMethodAccess($coverToken)); }
php
public function addCoverageValidatorPoolForCover($coverToken) { // covers ClassName::methodName $this->addValidator(new ValidatorClassNameMethodName($coverToken)); // covers ::methodName $this->addValidator(new ValidatorMethodName($coverToken)); // covers ClassName $this->addValidator(new ValidatorClassName($coverToken)); // covers ClassName::accessor (for public, protected, private, !public, !protected, !private) $this->addValidator(new ValidatorClassNameMethodAccess($coverToken)); }
[ "public", "function", "addCoverageValidatorPoolForCover", "(", "$", "coverToken", ")", "{", "// covers ClassName::methodName", "$", "this", "->", "addValidator", "(", "new", "ValidatorClassNameMethodName", "(", "$", "coverToken", ")", ")", ";", "// covers ::methodName", "$", "this", "->", "addValidator", "(", "new", "ValidatorMethodName", "(", "$", "coverToken", ")", ")", ";", "// covers ClassName", "$", "this", "->", "addValidator", "(", "new", "ValidatorClassName", "(", "$", "coverToken", ")", ")", ";", "// covers ClassName::accessor (for public, protected, private, !public, !protected, !private)", "$", "this", "->", "addValidator", "(", "new", "ValidatorClassNameMethodAccess", "(", "$", "coverToken", ")", ")", ";", "}" ]
init all available cover validator classes use incoming coverToken as parameter @param $coverToken
[ "init", "all", "available", "cover", "validator", "classes", "use", "incoming", "coverToken", "as", "parameter" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanner.php#L54-L64
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanner.php
CoverFishScanner.analysePHPUnitFiles
public function analysePHPUnitFiles() { $testFiles = $this->scanFilesInPath($this->testSourcePath); foreach ($testFiles as $file) { $this->analyseClassesInFile($file); } return $this->coverFishOutput->writeResult($this->coverFishResult); }
php
public function analysePHPUnitFiles() { $testFiles = $this->scanFilesInPath($this->testSourcePath); foreach ($testFiles as $file) { $this->analyseClassesInFile($file); } return $this->coverFishOutput->writeResult($this->coverFishResult); }
[ "public", "function", "analysePHPUnitFiles", "(", ")", "{", "$", "testFiles", "=", "$", "this", "->", "scanFilesInPath", "(", "$", "this", "->", "testSourcePath", ")", ";", "foreach", "(", "$", "testFiles", "as", "$", "file", ")", "{", "$", "this", "->", "analyseClassesInFile", "(", "$", "file", ")", ";", "}", "return", "$", "this", "->", "coverFishOutput", "->", "writeResult", "(", "$", "this", "->", "coverFishResult", ")", ";", "}" ]
scan all unit-test files inside specific path @return string
[ "scan", "all", "unit", "-", "test", "files", "inside", "specific", "path" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanner.php#L71-L79
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanner.php
CoverFishScanner.analyseCoverAnnotations
public function analyseCoverAnnotations($phpDocBlock, CoverFishPHPUnitTest $phpUnitTest) { $this->validatorCollection->clear(); $phpUnitTest->clearCoverMappings(); $phpUnitTest->clearCoverAnnotation(); /** @var string $cover */ foreach ($phpDocBlock['covers'] as $cover) { $phpUnitTest->addCoverAnnotation($cover); $this->addCoverageValidatorPoolForCover($cover); } $phpUnitTest = $this->validateAndReturnMapping($phpUnitTest); $this->phpUnitFile->addTest($phpUnitTest); }
php
public function analyseCoverAnnotations($phpDocBlock, CoverFishPHPUnitTest $phpUnitTest) { $this->validatorCollection->clear(); $phpUnitTest->clearCoverMappings(); $phpUnitTest->clearCoverAnnotation(); /** @var string $cover */ foreach ($phpDocBlock['covers'] as $cover) { $phpUnitTest->addCoverAnnotation($cover); $this->addCoverageValidatorPoolForCover($cover); } $phpUnitTest = $this->validateAndReturnMapping($phpUnitTest); $this->phpUnitFile->addTest($phpUnitTest); }
[ "public", "function", "analyseCoverAnnotations", "(", "$", "phpDocBlock", ",", "CoverFishPHPUnitTest", "$", "phpUnitTest", ")", "{", "$", "this", "->", "validatorCollection", "->", "clear", "(", ")", ";", "$", "phpUnitTest", "->", "clearCoverMappings", "(", ")", ";", "$", "phpUnitTest", "->", "clearCoverAnnotation", "(", ")", ";", "/** @var string $cover */", "foreach", "(", "$", "phpDocBlock", "[", "'covers'", "]", "as", "$", "cover", ")", "{", "$", "phpUnitTest", "->", "addCoverAnnotation", "(", "$", "cover", ")", ";", "$", "this", "->", "addCoverageValidatorPoolForCover", "(", "$", "cover", ")", ";", "}", "$", "phpUnitTest", "=", "$", "this", "->", "validateAndReturnMapping", "(", "$", "phpUnitTest", ")", ";", "$", "this", "->", "phpUnitFile", "->", "addTest", "(", "$", "phpUnitTest", ")", ";", "}" ]
scan all annotations inside one single unit test file @param array $phpDocBlock @param CoverFishPHPUnitTest $phpUnitTest
[ "scan", "all", "annotations", "inside", "one", "single", "unit", "test", "file" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanner.php#L87-L101
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanner.php
CoverFishScanner.analyseClassesInFile
public function analyseClassesInFile($file) { $ts = new PHP_Token_Stream($file); $this->phpUnitFile = new CoverFishPHPUnitFile(); foreach ($ts->getClasses() as $className => $classData) { $fqnClass = sprintf('%s\\%s', $this->coverFishHelper->getAttributeByKey('namespace', $classData['package']), $className ); if (false === $this->coverFishHelper->isValidTestClass($fqnClass)) { continue; } $classData['className'] = $className; $classData['classFile'] = $file; $this->analyseClass($classData); } }
php
public function analyseClassesInFile($file) { $ts = new PHP_Token_Stream($file); $this->phpUnitFile = new CoverFishPHPUnitFile(); foreach ($ts->getClasses() as $className => $classData) { $fqnClass = sprintf('%s\\%s', $this->coverFishHelper->getAttributeByKey('namespace', $classData['package']), $className ); if (false === $this->coverFishHelper->isValidTestClass($fqnClass)) { continue; } $classData['className'] = $className; $classData['classFile'] = $file; $this->analyseClass($classData); } }
[ "public", "function", "analyseClassesInFile", "(", "$", "file", ")", "{", "$", "ts", "=", "new", "PHP_Token_Stream", "(", "$", "file", ")", ";", "$", "this", "->", "phpUnitFile", "=", "new", "CoverFishPHPUnitFile", "(", ")", ";", "foreach", "(", "$", "ts", "->", "getClasses", "(", ")", "as", "$", "className", "=>", "$", "classData", ")", "{", "$", "fqnClass", "=", "sprintf", "(", "'%s\\\\%s'", ",", "$", "this", "->", "coverFishHelper", "->", "getAttributeByKey", "(", "'namespace'", ",", "$", "classData", "[", "'package'", "]", ")", ",", "$", "className", ")", ";", "if", "(", "false", "===", "$", "this", "->", "coverFishHelper", "->", "isValidTestClass", "(", "$", "fqnClass", ")", ")", "{", "continue", ";", "}", "$", "classData", "[", "'className'", "]", "=", "$", "className", ";", "$", "classData", "[", "'classFile'", "]", "=", "$", "file", ";", "$", "this", "->", "analyseClass", "(", "$", "classData", ")", ";", "}", "}" ]
scan all classes inside one defined unit test file @param string $file @return array
[ "scan", "all", "classes", "inside", "one", "defined", "unit", "test", "file" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanner.php#L110-L129
dunkelfrosch/phpcoverfish
src/PHPCoverFish/CoverFishScanner.php
CoverFishScanner.analyseClass
public function analyseClass(array $classData) { // scan main test class annotation $this->analyseCoverAnnotations( $this->coverFishHelper->parseCoverAnnotationDocBlock($classData['docblock']), $this->setPHPUnitTestByClassData($classData) ); // iterate through all available methods in give test class ignore all "non-test" methods foreach ($classData['methods'] as $methodName => $methodData) { // ignore all non-test- and docblock free methods for deep scan process if (false === $this->getCoverFishHelper()->isValidTestMethod($methodName) || false === array_key_exists('docblock', $methodData)) { continue; } $methodData['classFile'] = (string) $classData['classFile']; // scan unit test method annotation $this->analyseCoverAnnotations( $this->coverFishHelper->parseCoverAnnotationDocBlock($methodData['docblock']), $this->setPHPUnitTestByMethodData($methodData) ); } // add final phpUnitFile structure including mapping result to our coverFishResult $this->coverFishResult->addUnit($this->phpUnitFile); }
php
public function analyseClass(array $classData) { // scan main test class annotation $this->analyseCoverAnnotations( $this->coverFishHelper->parseCoverAnnotationDocBlock($classData['docblock']), $this->setPHPUnitTestByClassData($classData) ); // iterate through all available methods in give test class ignore all "non-test" methods foreach ($classData['methods'] as $methodName => $methodData) { // ignore all non-test- and docblock free methods for deep scan process if (false === $this->getCoverFishHelper()->isValidTestMethod($methodName) || false === array_key_exists('docblock', $methodData)) { continue; } $methodData['classFile'] = (string) $classData['classFile']; // scan unit test method annotation $this->analyseCoverAnnotations( $this->coverFishHelper->parseCoverAnnotationDocBlock($methodData['docblock']), $this->setPHPUnitTestByMethodData($methodData) ); } // add final phpUnitFile structure including mapping result to our coverFishResult $this->coverFishResult->addUnit($this->phpUnitFile); }
[ "public", "function", "analyseClass", "(", "array", "$", "classData", ")", "{", "// scan main test class annotation", "$", "this", "->", "analyseCoverAnnotations", "(", "$", "this", "->", "coverFishHelper", "->", "parseCoverAnnotationDocBlock", "(", "$", "classData", "[", "'docblock'", "]", ")", ",", "$", "this", "->", "setPHPUnitTestByClassData", "(", "$", "classData", ")", ")", ";", "// iterate through all available methods in give test class ignore all \"non-test\" methods", "foreach", "(", "$", "classData", "[", "'methods'", "]", "as", "$", "methodName", "=>", "$", "methodData", ")", "{", "// ignore all non-test- and docblock free methods for deep scan process", "if", "(", "false", "===", "$", "this", "->", "getCoverFishHelper", "(", ")", "->", "isValidTestMethod", "(", "$", "methodName", ")", "||", "false", "===", "array_key_exists", "(", "'docblock'", ",", "$", "methodData", ")", ")", "{", "continue", ";", "}", "$", "methodData", "[", "'classFile'", "]", "=", "(", "string", ")", "$", "classData", "[", "'classFile'", "]", ";", "// scan unit test method annotation", "$", "this", "->", "analyseCoverAnnotations", "(", "$", "this", "->", "coverFishHelper", "->", "parseCoverAnnotationDocBlock", "(", "$", "methodData", "[", "'docblock'", "]", ")", ",", "$", "this", "->", "setPHPUnitTestByMethodData", "(", "$", "methodData", ")", ")", ";", "}", "// add final phpUnitFile structure including mapping result to our coverFishResult", "$", "this", "->", "coverFishResult", "->", "addUnit", "(", "$", "this", "->", "phpUnitFile", ")", ";", "}" ]
scan (test) class and add result to our coverFishResultCollection @param array $classData @return array
[ "scan", "(", "test", ")", "class", "and", "add", "result", "to", "our", "coverFishResultCollection" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/CoverFishScanner.php#L138-L164
steeffeen/FancyManiaLinks
FML/Script/Features/ToggleInterface.php
ToggleInterface.setKeyCode
public function setKeyCode($keyCode) { $this->keyCode = (int)$keyCode; $this->keyName = null; return $this; }
php
public function setKeyCode($keyCode) { $this->keyCode = (int)$keyCode; $this->keyName = null; return $this; }
[ "public", "function", "setKeyCode", "(", "$", "keyCode", ")", "{", "$", "this", "->", "keyCode", "=", "(", "int", ")", "$", "keyCode", ";", "$", "this", "->", "keyName", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set the key code @api @param int $keyCode Key code @return static
[ "Set", "the", "key", "code" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ToggleInterface.php#L200-L205
steeffeen/FancyManiaLinks
FML/Script/Features/ToggleInterface.php
ToggleInterface.getOnInitScriptText
protected function getOnInitScriptText() { $scriptText = null; if ($this->control) { $controlId = Builder::escapeText($this->control->getId()); $scriptText = "declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});"; } else { $scriptText = "declare ToggleInterfaceControl <=> Page.MainFrame;"; } $stateVariableName = $this::VAR_STATE; return $scriptText . " declare persistent {$stateVariableName} as CurrentState for LocalUser = True; ToggleInterfaceControl.Visible = CurrentState; "; }
php
protected function getOnInitScriptText() { $scriptText = null; if ($this->control) { $controlId = Builder::escapeText($this->control->getId()); $scriptText = "declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});"; } else { $scriptText = "declare ToggleInterfaceControl <=> Page.MainFrame;"; } $stateVariableName = $this::VAR_STATE; return $scriptText . " declare persistent {$stateVariableName} as CurrentState for LocalUser = True; ToggleInterfaceControl.Visible = CurrentState; "; }
[ "protected", "function", "getOnInitScriptText", "(", ")", "{", "$", "scriptText", "=", "null", ";", "if", "(", "$", "this", "->", "control", ")", "{", "$", "controlId", "=", "Builder", "::", "escapeText", "(", "$", "this", "->", "control", "->", "getId", "(", ")", ")", ";", "$", "scriptText", "=", "\"declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});\"", ";", "}", "else", "{", "$", "scriptText", "=", "\"declare ToggleInterfaceControl <=> Page.MainFrame;\"", ";", "}", "$", "stateVariableName", "=", "$", "this", "::", "VAR_STATE", ";", "return", "$", "scriptText", ".", "\"\ndeclare persistent {$stateVariableName} as CurrentState for LocalUser = True;\nToggleInterfaceControl.Visible = CurrentState;\n\"", ";", "}" ]
Get the on init script text @return string
[ "Get", "the", "on", "init", "script", "text" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ToggleInterface.php#L248-L262
steeffeen/FancyManiaLinks
FML/Script/Features/ToggleInterface.php
ToggleInterface.getKeyPressScriptText
protected function getKeyPressScriptText() { $scriptText = null; $keyProperty = null; $keyValue = null; if ($this->keyName) { $keyProperty = "KeyName"; $keyValue = Builder::getText($this->keyName); } else if ($this->keyCode) { $keyProperty = "KeyCode"; $keyValue = Builder::getInteger($this->keyCode); } $scriptText = " if (Event.{$keyProperty} == {$keyValue}) { "; if ($this->control) { $controlId = Builder::escapeText($this->control->getId()); $scriptText .= " declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});"; } else { $scriptText .= " declare ToggleInterfaceControl <=> Page.MainFrame;"; } $scriptText .= " ToggleInterfaceControl.Visible = !ToggleInterfaceControl.Visible;"; if ($this->rememberState) { $stateVariableName = static::VAR_STATE; $scriptText .= " declare persistent {$stateVariableName} as CurrentState for LocalUser = True; CurrentState = ToggleInterfaceControl.Visible; "; } return $scriptText . " }"; }
php
protected function getKeyPressScriptText() { $scriptText = null; $keyProperty = null; $keyValue = null; if ($this->keyName) { $keyProperty = "KeyName"; $keyValue = Builder::getText($this->keyName); } else if ($this->keyCode) { $keyProperty = "KeyCode"; $keyValue = Builder::getInteger($this->keyCode); } $scriptText = " if (Event.{$keyProperty} == {$keyValue}) { "; if ($this->control) { $controlId = Builder::escapeText($this->control->getId()); $scriptText .= " declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});"; } else { $scriptText .= " declare ToggleInterfaceControl <=> Page.MainFrame;"; } $scriptText .= " ToggleInterfaceControl.Visible = !ToggleInterfaceControl.Visible;"; if ($this->rememberState) { $stateVariableName = static::VAR_STATE; $scriptText .= " declare persistent {$stateVariableName} as CurrentState for LocalUser = True; CurrentState = ToggleInterfaceControl.Visible; "; } return $scriptText . " }"; }
[ "protected", "function", "getKeyPressScriptText", "(", ")", "{", "$", "scriptText", "=", "null", ";", "$", "keyProperty", "=", "null", ";", "$", "keyValue", "=", "null", ";", "if", "(", "$", "this", "->", "keyName", ")", "{", "$", "keyProperty", "=", "\"KeyName\"", ";", "$", "keyValue", "=", "Builder", "::", "getText", "(", "$", "this", "->", "keyName", ")", ";", "}", "else", "if", "(", "$", "this", "->", "keyCode", ")", "{", "$", "keyProperty", "=", "\"KeyCode\"", ";", "$", "keyValue", "=", "Builder", "::", "getInteger", "(", "$", "this", "->", "keyCode", ")", ";", "}", "$", "scriptText", "=", "\"\nif (Event.{$keyProperty} == {$keyValue}) {\n\"", ";", "if", "(", "$", "this", "->", "control", ")", "{", "$", "controlId", "=", "Builder", "::", "escapeText", "(", "$", "this", "->", "control", "->", "getId", "(", ")", ")", ";", "$", "scriptText", ".=", "\"\n declare ToggleInterfaceControl <=> Page.GetFirstChild({$controlId});\"", ";", "}", "else", "{", "$", "scriptText", ".=", "\"\n declare ToggleInterfaceControl <=> Page.MainFrame;\"", ";", "}", "$", "scriptText", ".=", "\"\n ToggleInterfaceControl.Visible = !ToggleInterfaceControl.Visible;\"", ";", "if", "(", "$", "this", "->", "rememberState", ")", "{", "$", "stateVariableName", "=", "static", "::", "VAR_STATE", ";", "$", "scriptText", ".=", "\"\n declare persistent {$stateVariableName} as CurrentState for LocalUser = True;\n CurrentState = ToggleInterfaceControl.Visible;\n\"", ";", "}", "return", "$", "scriptText", ".", "\"\n}\"", ";", "}" ]
Get the key press script text @return string
[ "Get", "the", "key", "press", "script", "text" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ToggleInterface.php#L269-L303
ClanCats/Core
src/classes/CCEvent.php
CCEvent.clear
public static function clear( $event, $what = null ) { if ( is_null( $what ) ) { unset( static::$events[$event] ); return; } if ( array_key_exists( $what, static::$events[$event][$what] ) ) { unset( static::$events[$event][$what] ); } }
php
public static function clear( $event, $what = null ) { if ( is_null( $what ) ) { unset( static::$events[$event] ); return; } if ( array_key_exists( $what, static::$events[$event][$what] ) ) { unset( static::$events[$event][$what] ); } }
[ "public", "static", "function", "clear", "(", "$", "event", ",", "$", "what", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "what", ")", ")", "{", "unset", "(", "static", "::", "$", "events", "[", "$", "event", "]", ")", ";", "return", ";", "}", "if", "(", "array_key_exists", "(", "$", "what", ",", "static", "::", "$", "events", "[", "$", "event", "]", "[", "$", "what", "]", ")", ")", "{", "unset", "(", "static", "::", "$", "events", "[", "$", "event", "]", "[", "$", "what", "]", ")", ";", "}", "}" ]
clear an event @param string $event @param mixed $callback @return void
[ "clear", "an", "event" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L58-L66
ClanCats/Core
src/classes/CCEvent.php
CCEvent.ready
public static function ready( $event, $params = array() ) { $responses = static::fire( $event, $params ); foreach( static::pack( $responses ) as $response ) { if ( $response !== true ) { return false; } } return true; }
php
public static function ready( $event, $params = array() ) { $responses = static::fire( $event, $params ); foreach( static::pack( $responses ) as $response ) { if ( $response !== true ) { return false; } } return true; }
[ "public", "static", "function", "ready", "(", "$", "event", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "responses", "=", "static", "::", "fire", "(", "$", "event", ",", "$", "params", ")", ";", "foreach", "(", "static", "::", "pack", "(", "$", "responses", ")", "as", "$", "response", ")", "{", "if", "(", "$", "response", "!==", "true", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
also fires an event but returns a bool positiv only if all responses where positiv, like all system ready YESS! @param string $event @param array $params @return array
[ "also", "fires", "an", "event", "but", "returns", "a", "bool", "positiv", "only", "if", "all", "responses", "where", "positiv", "like", "all", "system", "ready", "YESS!" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L76-L86
ClanCats/Core
src/classes/CCEvent.php
CCEvent.fire
public static function fire( $event, $params = array() ) { if ( !array_key_exists( $event, static::$events ) ) { return; } $event = static::$events[$event]; $return = array(); if ( array_key_exists( 'before', $event ) ) { $return['before'] = static::call( $event['before'], $params ); } if ( array_key_exists( 'callbacks', $event ) ) { $return['main'] = static::call( $event['callbacks'], $params ); } if ( array_key_exists( 'after', $event ) ) { $return['after'] = static::call( $event['after'], $params ); } return static::pack( $return ); }
php
public static function fire( $event, $params = array() ) { if ( !array_key_exists( $event, static::$events ) ) { return; } $event = static::$events[$event]; $return = array(); if ( array_key_exists( 'before', $event ) ) { $return['before'] = static::call( $event['before'], $params ); } if ( array_key_exists( 'callbacks', $event ) ) { $return['main'] = static::call( $event['callbacks'], $params ); } if ( array_key_exists( 'after', $event ) ) { $return['after'] = static::call( $event['after'], $params ); } return static::pack( $return ); }
[ "public", "static", "function", "fire", "(", "$", "event", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "event", ",", "static", "::", "$", "events", ")", ")", "{", "return", ";", "}", "$", "event", "=", "static", "::", "$", "events", "[", "$", "event", "]", ";", "$", "return", "=", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "'before'", ",", "$", "event", ")", ")", "{", "$", "return", "[", "'before'", "]", "=", "static", "::", "call", "(", "$", "event", "[", "'before'", "]", ",", "$", "params", ")", ";", "}", "if", "(", "array_key_exists", "(", "'callbacks'", ",", "$", "event", ")", ")", "{", "$", "return", "[", "'main'", "]", "=", "static", "::", "call", "(", "$", "event", "[", "'callbacks'", "]", ",", "$", "params", ")", ";", "}", "if", "(", "array_key_exists", "(", "'after'", ",", "$", "event", ")", ")", "{", "$", "return", "[", "'after'", "]", "=", "static", "::", "call", "(", "$", "event", "[", "'after'", "]", ",", "$", "params", ")", ";", "}", "return", "static", "::", "pack", "(", "$", "return", ")", ";", "}" ]
fire an event @param string $event @param array $params @return array
[ "fire", "an", "event" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L95-L117
ClanCats/Core
src/classes/CCEvent.php
CCEvent.pass
public static function pass( $event, $param = null ) { if ( !array_key_exists( $event, static::$events ) ) { return $param; } $event = static::$events[$event]; if ( array_key_exists( 'before', $event ) ) { $param = static::call( $event['before'], $param, true ); } if ( array_key_exists( 'callbacks', $event ) ) { $param = static::call( $event['callbacks'], $param, true ); } if ( array_key_exists( 'after', $event ) ) { $param = static::call( $event['after'], $param, true ); } return $param; }
php
public static function pass( $event, $param = null ) { if ( !array_key_exists( $event, static::$events ) ) { return $param; } $event = static::$events[$event]; if ( array_key_exists( 'before', $event ) ) { $param = static::call( $event['before'], $param, true ); } if ( array_key_exists( 'callbacks', $event ) ) { $param = static::call( $event['callbacks'], $param, true ); } if ( array_key_exists( 'after', $event ) ) { $param = static::call( $event['after'], $param, true ); } return $param; }
[ "public", "static", "function", "pass", "(", "$", "event", ",", "$", "param", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "event", ",", "static", "::", "$", "events", ")", ")", "{", "return", "$", "param", ";", "}", "$", "event", "=", "static", "::", "$", "events", "[", "$", "event", "]", ";", "if", "(", "array_key_exists", "(", "'before'", ",", "$", "event", ")", ")", "{", "$", "param", "=", "static", "::", "call", "(", "$", "event", "[", "'before'", "]", ",", "$", "param", ",", "true", ")", ";", "}", "if", "(", "array_key_exists", "(", "'callbacks'", ",", "$", "event", ")", ")", "{", "$", "param", "=", "static", "::", "call", "(", "$", "event", "[", "'callbacks'", "]", ",", "$", "param", ",", "true", ")", ";", "}", "if", "(", "array_key_exists", "(", "'after'", ",", "$", "event", ")", ")", "{", "$", "param", "=", "static", "::", "call", "(", "$", "event", "[", "'after'", "]", ",", "$", "param", ",", "true", ")", ";", "}", "return", "$", "param", ";", "}" ]
pass an var to an event the diffrence to fire is that the param gets modified by each event @param string $event @param mixed $param @return mixed
[ "pass", "an", "var", "to", "an", "event", "the", "diffrence", "to", "fire", "is", "that", "the", "param", "gets", "modified", "by", "each", "event" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L127-L148
ClanCats/Core
src/classes/CCEvent.php
CCEvent.call
protected static function call( $callbacks, $params, $pass = false ) { $response = array(); if ( $pass ) { $response = $params; } foreach ( $callbacks as $callback ) { if ( $pass ) { $response = call_user_func_array( $callback, array( $response ) ); } else { $response[] = call_user_func_array( $callback, $params ); } } return $response; }
php
protected static function call( $callbacks, $params, $pass = false ) { $response = array(); if ( $pass ) { $response = $params; } foreach ( $callbacks as $callback ) { if ( $pass ) { $response = call_user_func_array( $callback, array( $response ) ); } else { $response[] = call_user_func_array( $callback, $params ); } } return $response; }
[ "protected", "static", "function", "call", "(", "$", "callbacks", ",", "$", "params", ",", "$", "pass", "=", "false", ")", "{", "$", "response", "=", "array", "(", ")", ";", "if", "(", "$", "pass", ")", "{", "$", "response", "=", "$", "params", ";", "}", "foreach", "(", "$", "callbacks", "as", "$", "callback", ")", "{", "if", "(", "$", "pass", ")", "{", "$", "response", "=", "call_user_func_array", "(", "$", "callback", ",", "array", "(", "$", "response", ")", ")", ";", "}", "else", "{", "$", "response", "[", "]", "=", "call_user_func_array", "(", "$", "callback", ",", "$", "params", ")", ";", "}", "}", "return", "$", "response", ";", "}" ]
call an callback array @param array $callbacks @param array $params @param bool $pass @retrun array
[ "call", "an", "callback", "array" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L158-L176
ClanCats/Core
src/classes/CCEvent.php
CCEvent.pack
protected static function pack( $responses ) { return array_merge( CCArr::get( 'before', $responses, array() ), CCArr::get( 'main', $responses, array() ), CCArr::get( 'after', $responses, array() ) ); }
php
protected static function pack( $responses ) { return array_merge( CCArr::get( 'before', $responses, array() ), CCArr::get( 'main', $responses, array() ), CCArr::get( 'after', $responses, array() ) ); }
[ "protected", "static", "function", "pack", "(", "$", "responses", ")", "{", "return", "array_merge", "(", "CCArr", "::", "get", "(", "'before'", ",", "$", "responses", ",", "array", "(", ")", ")", ",", "CCArr", "::", "get", "(", "'main'", ",", "$", "responses", ",", "array", "(", ")", ")", ",", "CCArr", "::", "get", "(", "'after'", ",", "$", "responses", ",", "array", "(", ")", ")", ")", ";", "}" ]
packs all responses into one array @param array $responses @return array
[ "packs", "all", "responses", "into", "one", "array" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCEvent.php#L184-L186
titon/db
src/Titon/Db/Behavior/TimestampBehavior.php
TimestampBehavior.preSave
public function preSave(Event $event, Query $query, $id, array &$data) { $data[$this->getConfig($query->getType() === Query::UPDATE ? 'updateField' : 'createField')] = time(); return true; }
php
public function preSave(Event $event, Query $query, $id, array &$data) { $data[$this->getConfig($query->getType() === Query::UPDATE ? 'updateField' : 'createField')] = time(); return true; }
[ "public", "function", "preSave", "(", "Event", "$", "event", ",", "Query", "$", "query", ",", "$", "id", ",", "array", "&", "$", "data", ")", "{", "$", "data", "[", "$", "this", "->", "getConfig", "(", "$", "query", "->", "getType", "(", ")", "===", "Query", "::", "UPDATE", "?", "'updateField'", ":", "'createField'", ")", "]", "=", "time", "(", ")", ";", "return", "true", ";", "}" ]
Append the current timestamp to the data. @param \Titon\Event\Event $event @param \Titon\Db\Query $query @param int|int[] $id @param array $data @return bool
[ "Append", "the", "current", "timestamp", "to", "the", "data", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Behavior/TimestampBehavior.php#L42-L46
thienhungho/yii2-order-management
src/modules/OrderBase/Order.php
Order.beforeSave
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if (!$this->isNewRecord) { $this->total_price = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('total_price'); $this->real_value = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('real_value'); $this->discount_value = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('discount_value'); } return true; } return false; }
php
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if (!$this->isNewRecord) { $this->total_price = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('total_price'); $this->real_value = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('real_value'); $this->discount_value = \thienhungho\OrderManagement\models\OrderItem::find() ->where(['order' => $this->id]) ->sum('discount_value'); } return true; } return false; }
[ "public", "function", "beforeSave", "(", "$", "insert", ")", "{", "if", "(", "parent", "::", "beforeSave", "(", "$", "insert", ")", ")", "{", "if", "(", "!", "$", "this", "->", "isNewRecord", ")", "{", "$", "this", "->", "total_price", "=", "\\", "thienhungho", "\\", "OrderManagement", "\\", "models", "\\", "OrderItem", "::", "find", "(", ")", "->", "where", "(", "[", "'order'", "=>", "$", "this", "->", "id", "]", ")", "->", "sum", "(", "'total_price'", ")", ";", "$", "this", "->", "real_value", "=", "\\", "thienhungho", "\\", "OrderManagement", "\\", "models", "\\", "OrderItem", "::", "find", "(", ")", "->", "where", "(", "[", "'order'", "=>", "$", "this", "->", "id", "]", ")", "->", "sum", "(", "'real_value'", ")", ";", "$", "this", "->", "discount_value", "=", "\\", "thienhungho", "\\", "OrderManagement", "\\", "models", "\\", "OrderItem", "::", "find", "(", ")", "->", "where", "(", "[", "'order'", "=>", "$", "this", "->", "id", "]", ")", "->", "sum", "(", "'discount_value'", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
@param bool $insert @return bool @throws \yii\base\Exception @throws \yii\base\InvalidConfigException
[ "@param", "bool", "$insert" ]
train
https://github.com/thienhungho/yii2-order-management/blob/f263f0b2168d6f5e99cee2e20a5878d09d4e81c0/src/modules/OrderBase/Order.php#L65-L84
site4y/grid
Grid.php
Grid.header
public function header() { $head = ''; if ($this->options['rownum']) { $rownumTh = Html::el('th', ['style' => 'width:1px']); if (isset($this->options['rownum']['header']['rowspan'])) { $rownumTh->rowspan($this->options['rownum']['header']['rowspan']); } if (isset($this->options['rownum']['header']['before'])) { $head .= $this->options['rownum']['header']['before']; } $head .= $rownumTh; if (isset($this->options['rownum']['header']['after'])) { $head .= $this->options['rownum']['header']['after']; } } foreach ($this->columns as $colId => &$col) { $this->_prepareCol($colId); if (isset($col['header']['before'])) $head .= $col['header']['before']; if (!isset($col['header']['visible']) || $col['header']['visible']) { $head .= $col['th']; } if (isset($col['header']['after'])) $head .= $col['header']['after']; } unset($col); if ($this->options['edit'] || $this->options['delete'] || $this->options['actions']) { $head .= '<th style="width:1px; white-space:nowrap;"></th>'; } if (!empty($this->_filters)) { $head .= '</tr><tr class="filters">'; if ($this->options['rownum']) { $head .= '<th style="width:1px"></th>'; } foreach ($this->columns as $colId => &$col) { if (isset($this->_filters[$colId]) && $this->_filters[$colId]->isActive()) { $head .= '<th class="filter-active">'; } else { $head .= '<th>'; } if (isset($this->_filters[$colId])) { $head .= $this->_filters[$colId]->renderFilter(); } $head .= '</th>'; } unset($col); if (!$this->options['edit'] && !$this->options['delete'] && !$this->options['actions']) { if (substr($head, strlen($head)-9, 9) == '<th></th>') { $head = substr($head,0, strlen($head)-9); } } //if ($this->options['edit'] || $this->options['delete']) { $head .= '<th style="width:1px; white-space:nowrap; vertical-align: middle">'. '<button class="btn btn-info btn-xs" type="submit" onclick="return $.S4Y.grid.filter(this)"><i class="glyphicon glyphicon-filter"></i></button> '. '<button class="btn btn-link btn-xs" type="reset" onclick="return $.S4Y.grid.clearFilters(this);"><i class="glyphicon glyphicon-remove"></i></button>'. '</th>'; //} } return '<tr>'.$head.'</tr>'; }
php
public function header() { $head = ''; if ($this->options['rownum']) { $rownumTh = Html::el('th', ['style' => 'width:1px']); if (isset($this->options['rownum']['header']['rowspan'])) { $rownumTh->rowspan($this->options['rownum']['header']['rowspan']); } if (isset($this->options['rownum']['header']['before'])) { $head .= $this->options['rownum']['header']['before']; } $head .= $rownumTh; if (isset($this->options['rownum']['header']['after'])) { $head .= $this->options['rownum']['header']['after']; } } foreach ($this->columns as $colId => &$col) { $this->_prepareCol($colId); if (isset($col['header']['before'])) $head .= $col['header']['before']; if (!isset($col['header']['visible']) || $col['header']['visible']) { $head .= $col['th']; } if (isset($col['header']['after'])) $head .= $col['header']['after']; } unset($col); if ($this->options['edit'] || $this->options['delete'] || $this->options['actions']) { $head .= '<th style="width:1px; white-space:nowrap;"></th>'; } if (!empty($this->_filters)) { $head .= '</tr><tr class="filters">'; if ($this->options['rownum']) { $head .= '<th style="width:1px"></th>'; } foreach ($this->columns as $colId => &$col) { if (isset($this->_filters[$colId]) && $this->_filters[$colId]->isActive()) { $head .= '<th class="filter-active">'; } else { $head .= '<th>'; } if (isset($this->_filters[$colId])) { $head .= $this->_filters[$colId]->renderFilter(); } $head .= '</th>'; } unset($col); if (!$this->options['edit'] && !$this->options['delete'] && !$this->options['actions']) { if (substr($head, strlen($head)-9, 9) == '<th></th>') { $head = substr($head,0, strlen($head)-9); } } //if ($this->options['edit'] || $this->options['delete']) { $head .= '<th style="width:1px; white-space:nowrap; vertical-align: middle">'. '<button class="btn btn-info btn-xs" type="submit" onclick="return $.S4Y.grid.filter(this)"><i class="glyphicon glyphicon-filter"></i></button> '. '<button class="btn btn-link btn-xs" type="reset" onclick="return $.S4Y.grid.clearFilters(this);"><i class="glyphicon glyphicon-remove"></i></button>'. '</th>'; //} } return '<tr>'.$head.'</tr>'; }
[ "public", "function", "header", "(", ")", "{", "$", "head", "=", "''", ";", "if", "(", "$", "this", "->", "options", "[", "'rownum'", "]", ")", "{", "$", "rownumTh", "=", "Html", "::", "el", "(", "'th'", ",", "[", "'style'", "=>", "'width:1px'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'rowspan'", "]", ")", ")", "{", "$", "rownumTh", "->", "rowspan", "(", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'rowspan'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'before'", "]", ")", ")", "{", "$", "head", ".=", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'before'", "]", ";", "}", "$", "head", ".=", "$", "rownumTh", ";", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'after'", "]", ")", ")", "{", "$", "head", ".=", "$", "this", "->", "options", "[", "'rownum'", "]", "[", "'header'", "]", "[", "'after'", "]", ";", "}", "}", "foreach", "(", "$", "this", "->", "columns", "as", "$", "colId", "=>", "&", "$", "col", ")", "{", "$", "this", "->", "_prepareCol", "(", "$", "colId", ")", ";", "if", "(", "isset", "(", "$", "col", "[", "'header'", "]", "[", "'before'", "]", ")", ")", "$", "head", ".=", "$", "col", "[", "'header'", "]", "[", "'before'", "]", ";", "if", "(", "!", "isset", "(", "$", "col", "[", "'header'", "]", "[", "'visible'", "]", ")", "||", "$", "col", "[", "'header'", "]", "[", "'visible'", "]", ")", "{", "$", "head", ".=", "$", "col", "[", "'th'", "]", ";", "}", "if", "(", "isset", "(", "$", "col", "[", "'header'", "]", "[", "'after'", "]", ")", ")", "$", "head", ".=", "$", "col", "[", "'header'", "]", "[", "'after'", "]", ";", "}", "unset", "(", "$", "col", ")", ";", "if", "(", "$", "this", "->", "options", "[", "'edit'", "]", "||", "$", "this", "->", "options", "[", "'delete'", "]", "||", "$", "this", "->", "options", "[", "'actions'", "]", ")", "{", "$", "head", ".=", "'<th style=\"width:1px; white-space:nowrap;\"></th>'", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_filters", ")", ")", "{", "$", "head", ".=", "'</tr><tr class=\"filters\">'", ";", "if", "(", "$", "this", "->", "options", "[", "'rownum'", "]", ")", "{", "$", "head", ".=", "'<th style=\"width:1px\"></th>'", ";", "}", "foreach", "(", "$", "this", "->", "columns", "as", "$", "colId", "=>", "&", "$", "col", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_filters", "[", "$", "colId", "]", ")", "&&", "$", "this", "->", "_filters", "[", "$", "colId", "]", "->", "isActive", "(", ")", ")", "{", "$", "head", ".=", "'<th class=\"filter-active\">'", ";", "}", "else", "{", "$", "head", ".=", "'<th>'", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_filters", "[", "$", "colId", "]", ")", ")", "{", "$", "head", ".=", "$", "this", "->", "_filters", "[", "$", "colId", "]", "->", "renderFilter", "(", ")", ";", "}", "$", "head", ".=", "'</th>'", ";", "}", "unset", "(", "$", "col", ")", ";", "if", "(", "!", "$", "this", "->", "options", "[", "'edit'", "]", "&&", "!", "$", "this", "->", "options", "[", "'delete'", "]", "&&", "!", "$", "this", "->", "options", "[", "'actions'", "]", ")", "{", "if", "(", "substr", "(", "$", "head", ",", "strlen", "(", "$", "head", ")", "-", "9", ",", "9", ")", "==", "'<th></th>'", ")", "{", "$", "head", "=", "substr", "(", "$", "head", ",", "0", ",", "strlen", "(", "$", "head", ")", "-", "9", ")", ";", "}", "}", "//if ($this->options['edit'] || $this->options['delete']) {", "$", "head", ".=", "'<th style=\"width:1px; white-space:nowrap; vertical-align: middle\">'", ".", "'<button class=\"btn btn-info btn-xs\" type=\"submit\" onclick=\"return $.S4Y.grid.filter(this)\"><i class=\"glyphicon glyphicon-filter\"></i></button> '", ".", "'<button class=\"btn btn-link btn-xs\" type=\"reset\" onclick=\"return $.S4Y.grid.clearFilters(this);\"><i class=\"glyphicon glyphicon-remove\"></i></button>'", ".", "'</th>'", ";", "//}", "}", "return", "'<tr>'", ".", "$", "head", ".", "'</tr>'", ";", "}" ]
Возвращает HTML для вывода заголовка таблицы @return string
[ "Возвращает", "HTML", "для", "вывода", "заголовка", "таблицы" ]
train
https://github.com/site4y/grid/blob/9b2c9a9becab1d556d85ce818df228020280726c/Grid.php#L306-L374
site4y/grid
Grid.php
Grid._prepareCol
protected function _prepareCol($colId) { if (isset($this->columns[$colId]['td'])) return; $col = &$this->columns[$colId]; $colClass = str_replace(',','',$colId); $className = 's4y-grid-'.$this->_id.'-col-'.$colClass; $th = Html::el('th', ['class' => $className]); $td = Html::el('td', ['class' => $className]); $tdstyle = Assets::newStyle(); $thstyle = Assets::newStyle(); if (isset($col['width'])) { //$tdstyle->width = $col['width'].'px'; $thstyle->width = $col['width'].'px'; } if (isset($col['style'])) { $tdstyle->add($col['style']); } if (isset($col['nowrap']) && $col['nowrap']) $tdstyle->whiteSpace = 'nowrap'; if (isset($col['align'])) { $tdstyle->textAlign = $col['align']; $thstyle->textAlign = $col['align']; } if (isset($col['header']['rowspan'])) { $th->rowspan($col['header']['rowspan']); } //if ($className = $tdstyle->saveClass('s4y-grid-'.$this->_id.'-td-'.$colClass)) { // $td->_class($className); //} //if ($className = $thstyle->saveClass('s4y-grid-'.$this->_id.'-th-'.$colClass)) { // $th->_class($className); //} $tdstyle->save('td.'.$className); $thstyle->save('th.'.$className); $th->addHtml($this->_colHeader($colId)); if (isset($col['href'])) { $a = Html::el('a', '%%content%%')->href($col['href']); if (isset($col['hrefTarget'])) $a->target($col['hrefTarget']); $td->addHtml($a); } else { $td->addText('%%content%%'); } $col['td'] = strval($td); $col['th'] = strval($th); }
php
protected function _prepareCol($colId) { if (isset($this->columns[$colId]['td'])) return; $col = &$this->columns[$colId]; $colClass = str_replace(',','',$colId); $className = 's4y-grid-'.$this->_id.'-col-'.$colClass; $th = Html::el('th', ['class' => $className]); $td = Html::el('td', ['class' => $className]); $tdstyle = Assets::newStyle(); $thstyle = Assets::newStyle(); if (isset($col['width'])) { //$tdstyle->width = $col['width'].'px'; $thstyle->width = $col['width'].'px'; } if (isset($col['style'])) { $tdstyle->add($col['style']); } if (isset($col['nowrap']) && $col['nowrap']) $tdstyle->whiteSpace = 'nowrap'; if (isset($col['align'])) { $tdstyle->textAlign = $col['align']; $thstyle->textAlign = $col['align']; } if (isset($col['header']['rowspan'])) { $th->rowspan($col['header']['rowspan']); } //if ($className = $tdstyle->saveClass('s4y-grid-'.$this->_id.'-td-'.$colClass)) { // $td->_class($className); //} //if ($className = $thstyle->saveClass('s4y-grid-'.$this->_id.'-th-'.$colClass)) { // $th->_class($className); //} $tdstyle->save('td.'.$className); $thstyle->save('th.'.$className); $th->addHtml($this->_colHeader($colId)); if (isset($col['href'])) { $a = Html::el('a', '%%content%%')->href($col['href']); if (isset($col['hrefTarget'])) $a->target($col['hrefTarget']); $td->addHtml($a); } else { $td->addText('%%content%%'); } $col['td'] = strval($td); $col['th'] = strval($th); }
[ "protected", "function", "_prepareCol", "(", "$", "colId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "columns", "[", "$", "colId", "]", "[", "'td'", "]", ")", ")", "return", ";", "$", "col", "=", "&", "$", "this", "->", "columns", "[", "$", "colId", "]", ";", "$", "colClass", "=", "str_replace", "(", "','", ",", "''", ",", "$", "colId", ")", ";", "$", "className", "=", "'s4y-grid-'", ".", "$", "this", "->", "_id", ".", "'-col-'", ".", "$", "colClass", ";", "$", "th", "=", "Html", "::", "el", "(", "'th'", ",", "[", "'class'", "=>", "$", "className", "]", ")", ";", "$", "td", "=", "Html", "::", "el", "(", "'td'", ",", "[", "'class'", "=>", "$", "className", "]", ")", ";", "$", "tdstyle", "=", "Assets", "::", "newStyle", "(", ")", ";", "$", "thstyle", "=", "Assets", "::", "newStyle", "(", ")", ";", "if", "(", "isset", "(", "$", "col", "[", "'width'", "]", ")", ")", "{", "//$tdstyle->width = $col['width'].'px';", "$", "thstyle", "->", "width", "=", "$", "col", "[", "'width'", "]", ".", "'px'", ";", "}", "if", "(", "isset", "(", "$", "col", "[", "'style'", "]", ")", ")", "{", "$", "tdstyle", "->", "add", "(", "$", "col", "[", "'style'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "col", "[", "'nowrap'", "]", ")", "&&", "$", "col", "[", "'nowrap'", "]", ")", "$", "tdstyle", "->", "whiteSpace", "=", "'nowrap'", ";", "if", "(", "isset", "(", "$", "col", "[", "'align'", "]", ")", ")", "{", "$", "tdstyle", "->", "textAlign", "=", "$", "col", "[", "'align'", "]", ";", "$", "thstyle", "->", "textAlign", "=", "$", "col", "[", "'align'", "]", ";", "}", "if", "(", "isset", "(", "$", "col", "[", "'header'", "]", "[", "'rowspan'", "]", ")", ")", "{", "$", "th", "->", "rowspan", "(", "$", "col", "[", "'header'", "]", "[", "'rowspan'", "]", ")", ";", "}", "//if ($className = $tdstyle->saveClass('s4y-grid-'.$this->_id.'-td-'.$colClass)) {", "// $td->_class($className);", "//}", "//if ($className = $thstyle->saveClass('s4y-grid-'.$this->_id.'-th-'.$colClass)) {", "// $th->_class($className);", "//}", "$", "tdstyle", "->", "save", "(", "'td.'", ".", "$", "className", ")", ";", "$", "thstyle", "->", "save", "(", "'th.'", ".", "$", "className", ")", ";", "$", "th", "->", "addHtml", "(", "$", "this", "->", "_colHeader", "(", "$", "colId", ")", ")", ";", "if", "(", "isset", "(", "$", "col", "[", "'href'", "]", ")", ")", "{", "$", "a", "=", "Html", "::", "el", "(", "'a'", ",", "'%%content%%'", ")", "->", "href", "(", "$", "col", "[", "'href'", "]", ")", ";", "if", "(", "isset", "(", "$", "col", "[", "'hrefTarget'", "]", ")", ")", "$", "a", "->", "target", "(", "$", "col", "[", "'hrefTarget'", "]", ")", ";", "$", "td", "->", "addHtml", "(", "$", "a", ")", ";", "}", "else", "{", "$", "td", "->", "addText", "(", "'%%content%%'", ")", ";", "}", "$", "col", "[", "'td'", "]", "=", "strval", "(", "$", "td", ")", ";", "$", "col", "[", "'th'", "]", "=", "strval", "(", "$", "th", ")", ";", "}" ]
Выполняет подготовку шаблона вывода ячейки и заголовка колонки @param $colId
[ "Выполняет", "подготовку", "шаблона", "вывода", "ячейки", "и", "заголовка", "колонки" ]
train
https://github.com/site4y/grid/blob/9b2c9a9becab1d556d85ce818df228020280726c/Grid.php#L534-L582
andrelohmann/silverstripe-geolocation
code/models/fieldtypes/Location.php
Location.getSQLFilter
public function getSQLFilter($radius, $scale = 'km'){ // set Latitude and Longditude Columnnames GeoFunctions::$Latitude = $this->name.'Latitude'; GeoFunctions::$Longditude = $this->name.'Longditude'; return GeoFunctions::getSQLSquare($this->getLatitude(), $this->getLongditude(), $radius, $scale); }
php
public function getSQLFilter($radius, $scale = 'km'){ // set Latitude and Longditude Columnnames GeoFunctions::$Latitude = $this->name.'Latitude'; GeoFunctions::$Longditude = $this->name.'Longditude'; return GeoFunctions::getSQLSquare($this->getLatitude(), $this->getLongditude(), $radius, $scale); }
[ "public", "function", "getSQLFilter", "(", "$", "radius", ",", "$", "scale", "=", "'km'", ")", "{", "// set Latitude and Longditude Columnnames", "GeoFunctions", "::", "$", "Latitude", "=", "$", "this", "->", "name", ".", "'Latitude'", ";", "GeoFunctions", "::", "$", "Longditude", "=", "$", "this", "->", "name", ".", "'Longditude'", ";", "return", "GeoFunctions", "::", "getSQLSquare", "(", "$", "this", "->", "getLatitude", "(", ")", ",", "$", "this", "->", "getLongditude", "(", ")", ",", "$", "radius", ",", "$", "scale", ")", ";", "}" ]
return a SQL Bounce for WHERE Clause
[ "return", "a", "SQL", "Bounce", "for", "WHERE", "Clause" ]
train
https://github.com/andrelohmann/silverstripe-geolocation/blob/124062008d8fa25b631bf5bb69b2ca79b53ef81b/code/models/fieldtypes/Location.php#L194-L200
andrelohmann/silverstripe-geolocation
code/models/fieldtypes/Location.php
Location.getDistance
public function getDistance($lat, $lng, $scale = 'km'){ return GeoFunctions::getDistance($this->getLatitude(), $this->getLongditude(), $lat, $long, $scale); }
php
public function getDistance($lat, $lng, $scale = 'km'){ return GeoFunctions::getDistance($this->getLatitude(), $this->getLongditude(), $lat, $long, $scale); }
[ "public", "function", "getDistance", "(", "$", "lat", ",", "$", "lng", ",", "$", "scale", "=", "'km'", ")", "{", "return", "GeoFunctions", "::", "getDistance", "(", "$", "this", "->", "getLatitude", "(", ")", ",", "$", "this", "->", "getLongditude", "(", ")", ",", "$", "lat", ",", "$", "long", ",", "$", "scale", ")", ";", "}" ]
return the Distance to the given lat/lng
[ "return", "the", "Distance", "to", "the", "given", "lat", "/", "lng" ]
train
https://github.com/andrelohmann/silverstripe-geolocation/blob/124062008d8fa25b631bf5bb69b2ca79b53ef81b/code/models/fieldtypes/Location.php#L213-L215
andrelohmann/silverstripe-geolocation
code/models/fieldtypes/Location.php
Location.getDistanceFromLocation
public function getDistanceFromLocation(Location $location, $scale = 'km'){ return GeoFunctions::getDistance($this->getLatitude(), $this->getLongditude(), $location->getLatitude(), $location->getLongditude(), $scale); }
php
public function getDistanceFromLocation(Location $location, $scale = 'km'){ return GeoFunctions::getDistance($this->getLatitude(), $this->getLongditude(), $location->getLatitude(), $location->getLongditude(), $scale); }
[ "public", "function", "getDistanceFromLocation", "(", "Location", "$", "location", ",", "$", "scale", "=", "'km'", ")", "{", "return", "GeoFunctions", "::", "getDistance", "(", "$", "this", "->", "getLatitude", "(", ")", ",", "$", "this", "->", "getLongditude", "(", ")", ",", "$", "location", "->", "getLatitude", "(", ")", ",", "$", "location", "->", "getLongditude", "(", ")", ",", "$", "scale", ")", ";", "}" ]
return the Distance to the given location
[ "return", "the", "Distance", "to", "the", "given", "location" ]
train
https://github.com/andrelohmann/silverstripe-geolocation/blob/124062008d8fa25b631bf5bb69b2ca79b53ef81b/code/models/fieldtypes/Location.php#L220-L222
ClanCats/Core
src/classes/CCContainer.php
CCContainer.is_callable
public static function is_callable( $key ) { if ( is_callable( $key ) ) { return true; } if ( array_key_exists( $key, static::$_container ) ) { return true; } return false; }
php
public static function is_callable( $key ) { if ( is_callable( $key ) ) { return true; } if ( array_key_exists( $key, static::$_container ) ) { return true; } return false; }
[ "public", "static", "function", "is_callable", "(", "$", "key", ")", "{", "if", "(", "is_callable", "(", "$", "key", ")", ")", "{", "return", "true", ";", "}", "if", "(", "array_key_exists", "(", "$", "key", ",", "static", "::", "$", "_container", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is this callable @param string $key @return bool
[ "Is", "this", "callable" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCContainer.php#L49-L62
ClanCats/Core
src/classes/CCContainer.php
CCContainer.call
public static function call() { $arguments = func_get_args(); // get the key $key = array_shift( $arguments ); // container call if ( is_string( $key ) && array_key_exists( $key, static::$_container ) && is_callable( static::$_container[$key] ) ) { return call_user_func_array( static::$_container[$key], $arguments ); } if ( !is_callable( $key ) ) { throw new CCException( "CCContainer::call - Cannot call '".$key."' invalid callback." ); } // default callback return call_user_func_array( $key, $arguments ); }
php
public static function call() { $arguments = func_get_args(); // get the key $key = array_shift( $arguments ); // container call if ( is_string( $key ) && array_key_exists( $key, static::$_container ) && is_callable( static::$_container[$key] ) ) { return call_user_func_array( static::$_container[$key], $arguments ); } if ( !is_callable( $key ) ) { throw new CCException( "CCContainer::call - Cannot call '".$key."' invalid callback." ); } // default callback return call_user_func_array( $key, $arguments ); }
[ "public", "static", "function", "call", "(", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "// get the key", "$", "key", "=", "array_shift", "(", "$", "arguments", ")", ";", "// container call", "if", "(", "is_string", "(", "$", "key", ")", "&&", "array_key_exists", "(", "$", "key", ",", "static", "::", "$", "_container", ")", "&&", "is_callable", "(", "static", "::", "$", "_container", "[", "$", "key", "]", ")", ")", "{", "return", "call_user_func_array", "(", "static", "::", "$", "_container", "[", "$", "key", "]", ",", "$", "arguments", ")", ";", "}", "if", "(", "!", "is_callable", "(", "$", "key", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCContainer::call - Cannot call '\"", ".", "$", "key", ".", "\"' invalid callback.\"", ")", ";", "}", "// default callback", "return", "call_user_func_array", "(", "$", "key", ",", "$", "arguments", ")", ";", "}" ]
call a container @param string $key @param mixed $callback @return void
[ "call", "a", "container" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCContainer.php#L71-L91
phrest/sdk
src/Generator/SDK/SDKGenerator.php
SDKGenerator.create
public function create() { $uses = [ 'Phrest\API\DI\PhrestDIInterface', 'Phrest\SDK\PhrestSDK', 'Phrest\SDK\Request\AbstractRequest', $this->namespace . '\\' . Generator::$name . 'API' ]; foreach($this->requests as $request) { $uses[] = $request->getNamespace() . '\\' . $request->getName(); } $class = ClassGen::classGen( $this->name, $this->namespace . '\\' . $this->version, $uses, 'PhrestSDK' ); $di = new ParameterGenerator('di', 'PhrestDIInterface'); $constructor = ClassGen::constructor([$di]); $constructor->setBody($this->getConstructorBody()); $class->addMethodFromGenerator($constructor); $abstractRequest = new ParameterGenerator('request', 'AbstractRequest'); $injectDependencies = ClassGen::method( 'injectDependencies', [$abstractRequest], 'private', 'return $request;' ); $docBlock = $injectDependencies->getDocBlock(); $docBlock->setTag(new GenericTag('return', 'AbstractRequest')); $class->addMethodFromGenerator($injectDependencies); foreach($this->requests as $request) { $getRequest = ClassGen::method( 'get' . ucfirst($request->getName()), [], 'public', 'return $this->injectDependencies(new ' . $request->getName() . '());' ); $getRequest->getDocBlock()->setTag(new GenericTag('return', $request->getName())); $class->addMethodFromGenerator($getRequest); } return $class; }
php
public function create() { $uses = [ 'Phrest\API\DI\PhrestDIInterface', 'Phrest\SDK\PhrestSDK', 'Phrest\SDK\Request\AbstractRequest', $this->namespace . '\\' . Generator::$name . 'API' ]; foreach($this->requests as $request) { $uses[] = $request->getNamespace() . '\\' . $request->getName(); } $class = ClassGen::classGen( $this->name, $this->namespace . '\\' . $this->version, $uses, 'PhrestSDK' ); $di = new ParameterGenerator('di', 'PhrestDIInterface'); $constructor = ClassGen::constructor([$di]); $constructor->setBody($this->getConstructorBody()); $class->addMethodFromGenerator($constructor); $abstractRequest = new ParameterGenerator('request', 'AbstractRequest'); $injectDependencies = ClassGen::method( 'injectDependencies', [$abstractRequest], 'private', 'return $request;' ); $docBlock = $injectDependencies->getDocBlock(); $docBlock->setTag(new GenericTag('return', 'AbstractRequest')); $class->addMethodFromGenerator($injectDependencies); foreach($this->requests as $request) { $getRequest = ClassGen::method( 'get' . ucfirst($request->getName()), [], 'public', 'return $this->injectDependencies(new ' . $request->getName() . '());' ); $getRequest->getDocBlock()->setTag(new GenericTag('return', $request->getName())); $class->addMethodFromGenerator($getRequest); } return $class; }
[ "public", "function", "create", "(", ")", "{", "$", "uses", "=", "[", "'Phrest\\API\\DI\\PhrestDIInterface'", ",", "'Phrest\\SDK\\PhrestSDK'", ",", "'Phrest\\SDK\\Request\\AbstractRequest'", ",", "$", "this", "->", "namespace", ".", "'\\\\'", ".", "Generator", "::", "$", "name", ".", "'API'", "]", ";", "foreach", "(", "$", "this", "->", "requests", "as", "$", "request", ")", "{", "$", "uses", "[", "]", "=", "$", "request", "->", "getNamespace", "(", ")", ".", "'\\\\'", ".", "$", "request", "->", "getName", "(", ")", ";", "}", "$", "class", "=", "ClassGen", "::", "classGen", "(", "$", "this", "->", "name", ",", "$", "this", "->", "namespace", ".", "'\\\\'", ".", "$", "this", "->", "version", ",", "$", "uses", ",", "'PhrestSDK'", ")", ";", "$", "di", "=", "new", "ParameterGenerator", "(", "'di'", ",", "'PhrestDIInterface'", ")", ";", "$", "constructor", "=", "ClassGen", "::", "constructor", "(", "[", "$", "di", "]", ")", ";", "$", "constructor", "->", "setBody", "(", "$", "this", "->", "getConstructorBody", "(", ")", ")", ";", "$", "class", "->", "addMethodFromGenerator", "(", "$", "constructor", ")", ";", "$", "abstractRequest", "=", "new", "ParameterGenerator", "(", "'request'", ",", "'AbstractRequest'", ")", ";", "$", "injectDependencies", "=", "ClassGen", "::", "method", "(", "'injectDependencies'", ",", "[", "$", "abstractRequest", "]", ",", "'private'", ",", "'return $request;'", ")", ";", "$", "docBlock", "=", "$", "injectDependencies", "->", "getDocBlock", "(", ")", ";", "$", "docBlock", "->", "setTag", "(", "new", "GenericTag", "(", "'return'", ",", "'AbstractRequest'", ")", ")", ";", "$", "class", "->", "addMethodFromGenerator", "(", "$", "injectDependencies", ")", ";", "foreach", "(", "$", "this", "->", "requests", "as", "$", "request", ")", "{", "$", "getRequest", "=", "ClassGen", "::", "method", "(", "'get'", ".", "ucfirst", "(", "$", "request", "->", "getName", "(", ")", ")", ",", "[", "]", ",", "'public'", ",", "'return $this->injectDependencies(new '", ".", "$", "request", "->", "getName", "(", ")", ".", "'());'", ")", ";", "$", "getRequest", "->", "getDocBlock", "(", ")", "->", "setTag", "(", "new", "GenericTag", "(", "'return'", ",", "$", "request", "->", "getName", "(", ")", ")", ")", ";", "$", "class", "->", "addMethodFromGenerator", "(", "$", "getRequest", ")", ";", "}", "return", "$", "class", ";", "}" ]
Process and create code/files
[ "Process", "and", "create", "code", "/", "files" ]
train
https://github.com/phrest/sdk/blob/e9f2812ad517b07ca4d284512b530f615305eb47/src/Generator/SDK/SDKGenerator.php#L44-L94
maniaplanet/matchmaking-lobby
MatchMakingLobby/Lobby/MatchMakers/AbstractDistance.php
AbstractDistance.buildGraph
protected function buildGraph(&$graph, $distanceComputeCallback, array $objects) { $graph = new Helpers\Graph(); while($object = array_shift($objects)) { $graph->addNode( $object, $this->computeDistances($object, $objects, $distanceComputeCallback) ); } }
php
protected function buildGraph(&$graph, $distanceComputeCallback, array $objects) { $graph = new Helpers\Graph(); while($object = array_shift($objects)) { $graph->addNode( $object, $this->computeDistances($object, $objects, $distanceComputeCallback) ); } }
[ "protected", "function", "buildGraph", "(", "&", "$", "graph", ",", "$", "distanceComputeCallback", ",", "array", "$", "objects", ")", "{", "$", "graph", "=", "new", "Helpers", "\\", "Graph", "(", ")", ";", "while", "(", "$", "object", "=", "array_shift", "(", "$", "objects", ")", ")", "{", "$", "graph", "->", "addNode", "(", "$", "object", ",", "$", "this", "->", "computeDistances", "(", "$", "object", ",", "$", "objects", ",", "$", "distanceComputeCallback", ")", ")", ";", "}", "}" ]
Create a graph where each ready player is a node @param DistanciableObject[] $bannedPlayers @return type
[ "Create", "a", "graph", "where", "each", "ready", "player", "is", "a", "node" ]
train
https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Lobby/MatchMakers/AbstractDistance.php#L188-L199