repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orLike
public function orLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->orAdd($value, [$like]); }
php
public function orLike($key, $like) { $value = sprintf('%s LIKE ?', $key); return $this->orAdd($value, [$like]); }
[ "public", "function", "orLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",", "[", "$", "like", "]", ")", ...
or like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L315-L319
train
samurai-fw/samurai
src/Onikiri/Criteria/WhereCondition.php
WhereCondition.orNotLike
public function orNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->orAdd($value, [$like]); }
php
public function orNotLike($key, $like) { $value = sprintf('%s NOT LIKE ?', $key); return $this->orAdd($value, [$like]); }
[ "public", "function", "orNotLike", "(", "$", "key", ",", "$", "like", ")", "{", "$", "value", "=", "sprintf", "(", "'%s NOT LIKE ?'", ",", "$", "key", ")", ";", "return", "$", "this", "->", "orAdd", "(", "$", "value", ",", "[", "$", "like", "]", ...
or not like condition. @param string $key @param string $like @return Samurai\Onikiri\Criteria\WhereCondition
[ "or", "not", "like", "condition", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Criteria/WhereCondition.php#L328-L332
train
antarctica/laravel-base-exceptions
src/Exception/InvalidArgumentValueException.php
InvalidArgumentValueException.constructException
private function constructException(array $details) { $this->details['argument_value_error'][$this->argument] = $this->details['argument_value_error']['ARG']; $this->details['argument_value_error'][$this->argument] = $details; unset($this->details['argument_value_error']['ARG']); }
php
private function constructException(array $details) { $this->details['argument_value_error'][$this->argument] = $this->details['argument_value_error']['ARG']; $this->details['argument_value_error'][$this->argument] = $details; unset($this->details['argument_value_error']['ARG']); }
[ "private", "function", "constructException", "(", "array", "$", "details", ")", "{", "$", "this", "->", "details", "[", "'argument_value_error'", "]", "[", "$", "this", "->", "argument", "]", "=", "$", "this", "->", "details", "[", "'argument_value_error'", ...
Fill in exception details @param array $details
[ "Fill", "in", "exception", "details" ]
c5747b51dcf31e91ccc038302a0bb9a74d3daefc
https://github.com/antarctica/laravel-base-exceptions/blob/c5747b51dcf31e91ccc038302a0bb9a74d3daefc/src/Exception/InvalidArgumentValueException.php#L43-L48
train
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.parseColumnNames
public function parseColumnNames($string, ContextAwareInterface $context = null) { $matchArray = []; preg_match_all("#~([a-zA-Z0-9_]\\.{0,1})+#", $string, $matchArray); $matchArray = array_unique($matchArray[0]); foreach ($matchArray as $match) { if($context){ $nsMatch = $context->getNameInContext($match); }else{ $nsMatch = $match; } $path=ltrim($nsMatch, "~"); $tablePath = rtrim(substr($nsMatch, 1, strrpos($nsMatch, ".")), "."); $replace= $this->_doFQLTableName($tablePath, null, true) . "." . $this->getBaseFace() ->getElement($path) ->getSqlColumnName(true); $string = str_replace($match, $replace, $string); } return $string; }
php
public function parseColumnNames($string, ContextAwareInterface $context = null) { $matchArray = []; preg_match_all("#~([a-zA-Z0-9_]\\.{0,1})+#", $string, $matchArray); $matchArray = array_unique($matchArray[0]); foreach ($matchArray as $match) { if($context){ $nsMatch = $context->getNameInContext($match); }else{ $nsMatch = $match; } $path=ltrim($nsMatch, "~"); $tablePath = rtrim(substr($nsMatch, 1, strrpos($nsMatch, ".")), "."); $replace= $this->_doFQLTableName($tablePath, null, true) . "." . $this->getBaseFace() ->getElement($path) ->getSqlColumnName(true); $string = str_replace($match, $replace, $string); } return $string; }
[ "public", "function", "parseColumnNames", "(", "$", "string", ",", "ContextAwareInterface", "$", "context", "=", "null", ")", "{", "$", "matchArray", "=", "[", "]", ";", "preg_match_all", "(", "\"#~([a-zA-Z0-9_]\\\\.{0,1})+#\"", ",", "$", "string", ",", "$", "...
replaces the waved string by the sql-valid column name @param $string
[ "replaces", "the", "waved", "string", "by", "the", "sql", "-", "valid", "column", "name" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L51-L78
train
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.execute
public function execute($config = null) { if(null == $config){ $pdo = Config::getDefault()->getPdo(); }else if($config instanceof \PDO){ $pdo = $config; }else if($config instanceof Config){ $pdo = $config->getPdo(); }else{ throw new BadParameterException('First parameter of FQuery::execute is not correct'); } $stmt = $this->getPdoStatement($pdo); if ($stmt->execute()) { return $stmt; } else { // TODO : handle errors ".__FILE__.":".__LINE__; throw new QueryFailedException($stmt); //return false; } }
php
public function execute($config = null) { if(null == $config){ $pdo = Config::getDefault()->getPdo(); }else if($config instanceof \PDO){ $pdo = $config; }else if($config instanceof Config){ $pdo = $config->getPdo(); }else{ throw new BadParameterException('First parameter of FQuery::execute is not correct'); } $stmt = $this->getPdoStatement($pdo); if ($stmt->execute()) { return $stmt; } else { // TODO : handle errors ".__FILE__.":".__LINE__; throw new QueryFailedException($stmt); //return false; } }
[ "public", "function", "execute", "(", "$", "config", "=", "null", ")", "{", "if", "(", "null", "==", "$", "config", ")", "{", "$", "pdo", "=", "Config", "::", "getDefault", "(", ")", "->", "getPdo", "(", ")", ";", "}", "else", "if", "(", "$", "...
Executes the query from the given pdo object @param \PDO|Config|null $pdo @return \PDOStatement the pdo statement ready to fetch
[ "Executes", "the", "query", "from", "the", "given", "pdo", "object" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L94-L118
train
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.getPdoStatement
public function getPdoStatement(\PDO $pdo) { $stmt = $pdo->prepare($this->getSqlString()); $bound = $this->getBoundValues(); foreach ($bound as $name => $bind) { $stmt->bindValue($name, $bind[0], $bind[1]); } return $stmt; }
php
public function getPdoStatement(\PDO $pdo) { $stmt = $pdo->prepare($this->getSqlString()); $bound = $this->getBoundValues(); foreach ($bound as $name => $bind) { $stmt->bindValue($name, $bind[0], $bind[1]); } return $stmt; }
[ "public", "function", "getPdoStatement", "(", "\\", "PDO", "$", "pdo", ")", "{", "$", "stmt", "=", "$", "pdo", "->", "prepare", "(", "$", "this", "->", "getSqlString", "(", ")", ")", ";", "$", "bound", "=", "$", "this", "->", "getBoundValues", "(", ...
get a statement for the given pdo object, values are already bound @param \PDO $pdo
[ "get", "a", "statement", "for", "the", "given", "pdo", "object", "values", "are", "already", "bound" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L124-L135
train
face-orm/face
lib/Face/Sql/Query/FQuery.php
FQuery.__doFQLTableNameStatic
public static function __doFQLTableNameStatic($path, $token = null, $escape = false) { if (null===$token) { $token=self::$DOT_TOKEN; } if ("this"===$path || empty($path)) { if($escape){ return "`this`"; }else{ return "this"; } } if ( ! StringUtils::beginsWith("this.", $path)) { // if doesn't begin with "this." then we prepend "this." $path = "this.".$path; } $name = str_replace(".", $token, $path); if($escape){ return "`$name`"; }else{ return $name; } }
php
public static function __doFQLTableNameStatic($path, $token = null, $escape = false) { if (null===$token) { $token=self::$DOT_TOKEN; } if ("this"===$path || empty($path)) { if($escape){ return "`this`"; }else{ return "this"; } } if ( ! StringUtils::beginsWith("this.", $path)) { // if doesn't begin with "this." then we prepend "this." $path = "this.".$path; } $name = str_replace(".", $token, $path); if($escape){ return "`$name`"; }else{ return $name; } }
[ "public", "static", "function", "__doFQLTableNameStatic", "(", "$", "path", ",", "$", "token", "=", "null", ",", "$", "escape", "=", "false", ")", "{", "if", "(", "null", "===", "$", "token", ")", "{", "$", "token", "=", "self", "::", "$", "DOT_TOKEN...
reserved for internal usage @param $path @param null $token @return mixed|string
[ "reserved", "for", "internal", "usage" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/FQuery.php#L194-L220
train
ellipsephp/http
src/Handlers/DetailledJsonExceptionRequestHandler.php
DetailledJsonExceptionRequestHandler.handle
public function handle(ServerRequestInterface $request): ResponseInterface { $details = new Inspector($this->e); $contents = json_encode([ 'type' => get_class($details->inner()), 'message' => $details->inner()->getMessage(), 'context' => [ 'type' => get_class($details->current()), 'message' => $details->current()->getMessage(), ], 'trace' => $details->inner()->getTrace(), ]); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'application/json'); $response->getBody()->write($contents); return $response; }
php
public function handle(ServerRequestInterface $request): ResponseInterface { $details = new Inspector($this->e); $contents = json_encode([ 'type' => get_class($details->inner()), 'message' => $details->inner()->getMessage(), 'context' => [ 'type' => get_class($details->current()), 'message' => $details->current()->getMessage(), ], 'trace' => $details->inner()->getTrace(), ]); $response = $this->factory ->createResponse(500) ->withHeader('Content-type', 'application/json'); $response->getBody()->write($contents); return $response; }
[ "public", "function", "handle", "(", "ServerRequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "$", "details", "=", "new", "Inspector", "(", "$", "this", "->", "e", ")", ";", "$", "contents", "=", "json_encode", "(", "[", "'type'", "=>"...
Return a detailled json response for the exception. @param \Psr\Http\Message\ServerRequestInterface $request @return \Psr\Http\Message\ResponseInterface
[ "Return", "a", "detailled", "json", "response", "for", "the", "exception", "." ]
20a2b0ae1d3a149a905b93ae0993203eb7d414e1
https://github.com/ellipsephp/http/blob/20a2b0ae1d3a149a905b93ae0993203eb7d414e1/src/Handlers/DetailledJsonExceptionRequestHandler.php#L50-L71
train
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php
Builder.compileWhereBasic
protected function compileWhereBasic($where) { extract($where); // Replace like with MongoRegex if ($operator == 'like') { $operator = '='; $regex = str_replace('%', '', $value); // Prepare regex if (substr($value, 0, 1) != '%') $regex = '^' . $regex; if (substr($value, -1) != '%') $regex = $regex . '$'; $value = array('$regex' => "$regex"); } if (!isset($operator) || $operator == '=') { $query = array( $column => $value ); } elseif (array_key_exists($operator, $this->conversion)) { $query = array( $column => array( $this->conversion[$operator] => $value ) ); } else { $query = array( $column => array( '$' . $operator => $value ) ); } return $query; }
php
protected function compileWhereBasic($where) { extract($where); // Replace like with MongoRegex if ($operator == 'like') { $operator = '='; $regex = str_replace('%', '', $value); // Prepare regex if (substr($value, 0, 1) != '%') $regex = '^' . $regex; if (substr($value, -1) != '%') $regex = $regex . '$'; $value = array('$regex' => "$regex"); } if (!isset($operator) || $operator == '=') { $query = array( $column => $value ); } elseif (array_key_exists($operator, $this->conversion)) { $query = array( $column => array( $this->conversion[$operator] => $value ) ); } else { $query = array( $column => array( '$' . $operator => $value ) ); } return $query; }
[ "protected", "function", "compileWhereBasic", "(", "$", "where", ")", "{", "extract", "(", "$", "where", ")", ";", "// Replace like with MongoRegex", "if", "(", "$", "operator", "==", "'like'", ")", "{", "$", "operator", "=", "'='", ";", "$", "regex", "=",...
Compile the query's where clauses. @param array $where @return array
[ "Compile", "the", "query", "s", "where", "clauses", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php#L310-L352
train
GovTribe/laravel-kinvey
src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php
Builder.formatQuery
public function formatQuery(array $data, array $formatted = array()) { // Convert dot notation to multidimensional array elements. foreach ($data as $key => $value) { array_set($formatted, $key, $value); } return $formatted; }
php
public function formatQuery(array $data, array $formatted = array()) { // Convert dot notation to multidimensional array elements. foreach ($data as $key => $value) { array_set($formatted, $key, $value); } return $formatted; }
[ "public", "function", "formatQuery", "(", "array", "$", "data", ",", "array", "$", "formatted", "=", "array", "(", ")", ")", "{", "// Convert dot notation to multidimensional array elements.", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ...
Format a query. @param array $data @param array $formatted @return array
[ "Format", "a", "query", "." ]
8a25dafdf80a933384dfcfe8b70b0a7663fe9289
https://github.com/GovTribe/laravel-kinvey/blob/8a25dafdf80a933384dfcfe8b70b0a7663fe9289/src/GovTribe/LaravelKinvey/Database/Eloquent/Builder.php#L361-L369
train
AlexHowansky/ork-base
src/Utility/Collection.php
Collection.getFirstNonEmptyElement
public static function getFirstNonEmptyElement($list, $default = null) { foreach ($list as $item) { if (empty($item) === false) { return $item; } } return $default; }
php
public static function getFirstNonEmptyElement($list, $default = null) { foreach ($list as $item) { if (empty($item) === false) { return $item; } } return $default; }
[ "public", "static", "function", "getFirstNonEmptyElement", "(", "$", "list", ",", "$", "default", "=", "null", ")", "{", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "empty", "(", "$", "item", ")", "===", "false", ")", "{", ...
Get the first non-empty element of a list. @param array $list The list to scan. @param mixed $default If no non-empty element is found, return this value. @return mixed The first non-empty element in the list.
[ "Get", "the", "first", "non", "-", "empty", "element", "of", "a", "list", "." ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Utility/Collection.php#L28-L36
train
AlexHowansky/ork-base
src/Utility/Collection.php
Collection.inCsv
public static function inCsv($item, $list, $delimiter = ',', $enclosure = '"', $escape = '\\') { return in_array($item, str_getcsv($list, $delimiter, $enclosure, $escape)); }
php
public static function inCsv($item, $list, $delimiter = ',', $enclosure = '"', $escape = '\\') { return in_array($item, str_getcsv($list, $delimiter, $enclosure, $escape)); }
[ "public", "static", "function", "inCsv", "(", "$", "item", ",", "$", "list", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape", "=", "'\\\\'", ")", "{", "return", "in_array", "(", "$", "item", ",", "str_getcsv"...
Is an item in a CSV-formatted string list? @param string $item The item to scan for. @param string $list The list to scan. @param type $delimiter The delimiter character to use. @param type $enclosure The enclosure character to use. @param type $escape The escape character to use. @return boolean True if the item is in the list.
[ "Is", "an", "item", "in", "a", "CSV", "-", "formatted", "string", "list?" ]
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Utility/Collection.php#L49-L52
train
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.i18n
public static function i18n($pattern, array $options = array()) { // Trim the pattern $pattern = rtrim($pattern, '/ '); // Do the default options $options = array_merge(array( "controller" => "\\ChickenWire\\I18n\\I18nController" ), $options); // Create basic route for all Route::match($pattern, array_merge(array( "action" => "all" ), $options)); // Get current language Route::match($pattern . '/current', array_merge(array( "action" => "current" ), $options)); // All sub requests Route::match($pattern . '/current/{*path}', array_merge(array( "action" => "current" ), $options)); // All sub requests with a language Route::match($pattern . '/{*path}', array_merge(array( "action" => "all" ), $options)); }
php
public static function i18n($pattern, array $options = array()) { // Trim the pattern $pattern = rtrim($pattern, '/ '); // Do the default options $options = array_merge(array( "controller" => "\\ChickenWire\\I18n\\I18nController" ), $options); // Create basic route for all Route::match($pattern, array_merge(array( "action" => "all" ), $options)); // Get current language Route::match($pattern . '/current', array_merge(array( "action" => "current" ), $options)); // All sub requests Route::match($pattern . '/current/{*path}', array_merge(array( "action" => "current" ), $options)); // All sub requests with a language Route::match($pattern . '/{*path}', array_merge(array( "action" => "all" ), $options)); }
[ "public", "static", "function", "i18n", "(", "$", "pattern", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Trim the pattern", "$", "pattern", "=", "rtrim", "(", "$", "pattern", ",", "'/ '", ")", ";", "// Do the default options", "$", ...
Create a pattern for client-side I18n requests @param string The base pattern to link to the I18n controller @param array Additional options @return void
[ "Create", "a", "pattern", "for", "client", "-", "side", "I18n", "requests" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L60-L91
train
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.request
public static function request($request, &$httpStatus, &$urlParams) { // We will look for a best match $status = 404; $foundRoute = null; $foundParams = null; // Loop through routes foreach (self::$_routes as $route) { // Already done? if ($route->checked) continue; // Do the regex! preg_match_all($route->_regexPattern, $request->uri, $matches); // Set flag that this route has been matched $route->checked = true; // Does the route match? if (count($matches[0]) == 1) { // Is the method correct as well? if (Arry::Contains($request->method, $route->methods, false)) { //@TODO Check SSL config // We have a method and path match! $foundRoute = $route; $status = 200; // Get parameters $foundParams = array(); if (count($matches) > 1) { for ($q = 1; $q < count($matches); $q++) { $foundParams[] = $matches[$q][0]; } } // That's all we need break; } else { // Wrong method; is this the best yet? if (is_null($foundRoute) || $status !== 200) { // This is the best yet... $foundRoute = $route; $status = 405; } } } } // Parse params if (sizeof($foundParams) > 0) { // Look up the param names in the route $urlParams = array(); foreach ($route->_patternVariables as $index =>$varName) { // #'ed param? $value = $foundParams[$index]; if (substr($varName, 0, 1) == '#') { $value = intval($value); $varName = substr($varName, 1); } // *'ed param? if (substr($varName, 0, 1) == '*') { $varName = substr($varName, 1); } $urlParams[$varName] = $value; } } else { $urlParams = array(); } // Store it! $httpStatus = $status; self::$_currentRoute = $foundRoute; return $foundRoute; }
php
public static function request($request, &$httpStatus, &$urlParams) { // We will look for a best match $status = 404; $foundRoute = null; $foundParams = null; // Loop through routes foreach (self::$_routes as $route) { // Already done? if ($route->checked) continue; // Do the regex! preg_match_all($route->_regexPattern, $request->uri, $matches); // Set flag that this route has been matched $route->checked = true; // Does the route match? if (count($matches[0]) == 1) { // Is the method correct as well? if (Arry::Contains($request->method, $route->methods, false)) { //@TODO Check SSL config // We have a method and path match! $foundRoute = $route; $status = 200; // Get parameters $foundParams = array(); if (count($matches) > 1) { for ($q = 1; $q < count($matches); $q++) { $foundParams[] = $matches[$q][0]; } } // That's all we need break; } else { // Wrong method; is this the best yet? if (is_null($foundRoute) || $status !== 200) { // This is the best yet... $foundRoute = $route; $status = 405; } } } } // Parse params if (sizeof($foundParams) > 0) { // Look up the param names in the route $urlParams = array(); foreach ($route->_patternVariables as $index =>$varName) { // #'ed param? $value = $foundParams[$index]; if (substr($varName, 0, 1) == '#') { $value = intval($value); $varName = substr($varName, 1); } // *'ed param? if (substr($varName, 0, 1) == '*') { $varName = substr($varName, 1); } $urlParams[$varName] = $value; } } else { $urlParams = array(); } // Store it! $httpStatus = $status; self::$_currentRoute = $foundRoute; return $foundRoute; }
[ "public", "static", "function", "request", "(", "$", "request", ",", "&", "$", "httpStatus", ",", "&", "$", "urlParams", ")", "{", "// We will look for a best match", "$", "status", "=", "404", ";", "$", "foundRoute", "=", "null", ";", "$", "foundParams", ...
Match the given request on all configured routes and return first match @param ChickenWire\Request $request The request to match @param Number &$httpStatus This param will be filled with the resulting HTTP status code @param Array &$urlParams This will be an array containing the matched URL parameters @return Route|number The matched, orfalse when no match was found
[ "Match", "the", "given", "request", "on", "all", "configured", "routes", "and", "return", "first", "match" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L101-L192
train
rseyferth/chickenwire
src/ChickenWire/Route.php
Route.replaceFields
public function replaceFields($models) { // Loop through my fields $url = $this->_pattern; foreach ($this->_patternVariables as $var) { // Look up $varName = $var[0] == '#' ? substr($var, 1) : $var; // Was there a dot (.) in it, signifying a different model? if (strstr($varName, '.')) { // Split it! list($modelName, $varName) = explode(".", $varName); // Loop through model instances to see if we have a match for the model name $model = null; foreach ($models as $m) { if (Str::removeNamespace(get_class($m)) == $modelName) { // Use this model instead $model = $m; break; } } // !Found? if (is_null($model)) { // Too bad... throw new \Exception("You need to pass an Model instance of $modelName to generate a url for " . $this->_pattern, 1); } } else { // Use last model $model = $models[count($models) - 1]; } // Is there a slug var available? $sluggedVarName = $varName . "Slug"; if ($model->hasAttribute($sluggedVarName)) { $value = $model->$sluggedVarName; } else { $value = $model->$varName; } // Replace! $url = str_replace('{' . $var . '}', strval($value), $url); } return $url; }
php
public function replaceFields($models) { // Loop through my fields $url = $this->_pattern; foreach ($this->_patternVariables as $var) { // Look up $varName = $var[0] == '#' ? substr($var, 1) : $var; // Was there a dot (.) in it, signifying a different model? if (strstr($varName, '.')) { // Split it! list($modelName, $varName) = explode(".", $varName); // Loop through model instances to see if we have a match for the model name $model = null; foreach ($models as $m) { if (Str::removeNamespace(get_class($m)) == $modelName) { // Use this model instead $model = $m; break; } } // !Found? if (is_null($model)) { // Too bad... throw new \Exception("You need to pass an Model instance of $modelName to generate a url for " . $this->_pattern, 1); } } else { // Use last model $model = $models[count($models) - 1]; } // Is there a slug var available? $sluggedVarName = $varName . "Slug"; if ($model->hasAttribute($sluggedVarName)) { $value = $model->$sluggedVarName; } else { $value = $model->$varName; } // Replace! $url = str_replace('{' . $var . '}', strval($value), $url); } return $url; }
[ "public", "function", "replaceFields", "(", "$", "models", ")", "{", "// Loop through my fields", "$", "url", "=", "$", "this", "->", "_pattern", ";", "foreach", "(", "$", "this", "->", "_patternVariables", "as", "$", "var", ")", "{", "// Look up", "$", "v...
Replace fields in the Route with values from the Model instances @param \ChickenWire\Model $models Array of Model instances to use for values. The last in the array is assumed to be the primary Model to use for values. @return string The uri with the fields replaced
[ "Replace", "fields", "in", "the", "Route", "with", "values", "from", "the", "Model", "instances" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Route.php#L614-L673
train
laradic/service-provider
src/Plugins/Routing.php
Routing.startRoutingPlugin
protected function startRoutingPlugin($app) { $this->requiresPlugins(Paths::class, Resources::class); $this->onRegister('routing', function (Application $app) { if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) { $router = $app->make('router'); $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); foreach ($this->prependMiddleware as $class) { $kernel->prependMiddleware($class); } foreach ($this->middleware as $class) { $kernel->pushMiddleware($class); } foreach ($this->routeMiddleware as $name => $class) { if (method_exists($router, 'middleware')) { $router->middleware($name, $class); } else { $router->aliasMiddleware($name, $class); } } foreach ($this->middlewareGroups as $groupName => $classes) { $router->middlewareGroup($groupName, $classes); } foreach ($this->prependGroupMiddleware as $group => $class) { $router->prependMiddlewareToGroup($group, $class); } foreach ($this->groupMiddleware as $group => $class) { $router->pushMiddlewareToGroup($group, $class); } } }); $this->onBoot('routing', function (Application $app) { foreach ($this->routeFiles as $routeFile) { $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php'))); } }); static::refreshRoutes($app); }
php
protected function startRoutingPlugin($app) { $this->requiresPlugins(Paths::class, Resources::class); $this->onRegister('routing', function (Application $app) { if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) { $router = $app->make('router'); $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); foreach ($this->prependMiddleware as $class) { $kernel->prependMiddleware($class); } foreach ($this->middleware as $class) { $kernel->pushMiddleware($class); } foreach ($this->routeMiddleware as $name => $class) { if (method_exists($router, 'middleware')) { $router->middleware($name, $class); } else { $router->aliasMiddleware($name, $class); } } foreach ($this->middlewareGroups as $groupName => $classes) { $router->middlewareGroup($groupName, $classes); } foreach ($this->prependGroupMiddleware as $group => $class) { $router->prependMiddlewareToGroup($group, $class); } foreach ($this->groupMiddleware as $group => $class) { $router->pushMiddlewareToGroup($group, $class); } } }); $this->onBoot('routing', function (Application $app) { foreach ($this->routeFiles as $routeFile) { $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php'))); } }); static::refreshRoutes($app); }
[ "protected", "function", "startRoutingPlugin", "(", "$", "app", ")", "{", "$", "this", "->", "requiresPlugins", "(", "Paths", "::", "class", ",", "Resources", "::", "class", ")", ";", "$", "this", "->", "onRegister", "(", "'routing'", ",", "function", "(",...
startMiddlewarePlugin method. @param Application $app
[ "startMiddlewarePlugin", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Routing.php#L81-L126
train
dlabas/DlcDiagramm
src/DlcDiagramm/Proxy/Yuml.php
Yuml.getUriForDiagrammType
public function getUriForDiagrammType($type) { switch ($type) { case Diagramm::TYPE_ACTIVITY: $uri = $this->getOptions()->getYumlActivityDiagrammUrl(); break; case Diagramm::TYPE_CLASS: $uri = $this->getOptions()->getYumlClassDiagrammUrl(); break; case Diagramm::TYPE_DIAGRAMM: throw new \InvalidArgumentException('Unsupported diagramm type "' . $type . '"'); break; case Diagramm::TYPE_USE_CASE: $uri = $this->getOptions()->getYumlUseCaseDiagrammUrl(); break; default: throw new \InvalidArgumentException('Unkown diagramm type "' . $type . '"'); break; } return $uri; }
php
public function getUriForDiagrammType($type) { switch ($type) { case Diagramm::TYPE_ACTIVITY: $uri = $this->getOptions()->getYumlActivityDiagrammUrl(); break; case Diagramm::TYPE_CLASS: $uri = $this->getOptions()->getYumlClassDiagrammUrl(); break; case Diagramm::TYPE_DIAGRAMM: throw new \InvalidArgumentException('Unsupported diagramm type "' . $type . '"'); break; case Diagramm::TYPE_USE_CASE: $uri = $this->getOptions()->getYumlUseCaseDiagrammUrl(); break; default: throw new \InvalidArgumentException('Unkown diagramm type "' . $type . '"'); break; } return $uri; }
[ "public", "function", "getUriForDiagrammType", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "Diagramm", "::", "TYPE_ACTIVITY", ":", "$", "uri", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getYumlActivityDiagrammUrl", ...
Returns the URI for the yuml service for a diagramm type @param string $type @throws \InvalidArgumentException @return string
[ "Returns", "the", "URI", "for", "the", "yuml", "service", "for", "a", "diagramm", "type" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Proxy/Yuml.php#L46-L66
train
dlabas/DlcDiagramm
src/DlcDiagramm/Proxy/Yuml.php
Yuml.requestDiagramm
public function requestDiagramm($type, $dslText) { if ($this->getOptions()->getReturnDummyImage()) { return $this->getOptions()->getDummyImage(); } $httpClient = $this->getHttpClient(); $httpClient->setUri($this->getUriForDiagrammType($type)); $httpClient->setParameterPost(array('dsl_text' => $dslText)); $response = $httpClient->send(); if (!$response->isSuccess()) { throw new \UnexpectedValueException('HTTP Request failed'); } return $this->getOptions()->getYumlUrl() . $response->getBody(); }
php
public function requestDiagramm($type, $dslText) { if ($this->getOptions()->getReturnDummyImage()) { return $this->getOptions()->getDummyImage(); } $httpClient = $this->getHttpClient(); $httpClient->setUri($this->getUriForDiagrammType($type)); $httpClient->setParameterPost(array('dsl_text' => $dslText)); $response = $httpClient->send(); if (!$response->isSuccess()) { throw new \UnexpectedValueException('HTTP Request failed'); } return $this->getOptions()->getYumlUrl() . $response->getBody(); }
[ "public", "function", "requestDiagramm", "(", "$", "type", ",", "$", "dslText", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getReturnDummyImage", "(", ")", ")", "{", "return", "$", "this", "->", "getOptions", "(", ")", "->", ...
Requests a diagramm from yuml web service @param string $type @param string $dslText @throws \UnexpectedValueException @return string
[ "Requests", "a", "diagramm", "from", "yuml", "web", "service" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Proxy/Yuml.php#L76-L93
train
loopsframework/base
src/Loops/Service.php
Service.getConfig
public static function getConfig(Loops $loops = NULL, ArrayObject $config = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } if(!$config) { $parts = explode("\\", get_called_class()); if(count($parts) > 2 && array_slice($parts, 0, 2) == [ "Loops", "Service" ]) { $parts = array_slice($parts, 2); } $sectionname = Misc::underscore(implode("\\", $parts)); $config = $loops->getService('config'); $config = $config->offsetExists($sectionname) ? $config->offsetGet($sectionname) : new ArrayObject; } $result = static::getDefaultConfig($loops); $result->merge($config); $result->offsetSet('loops', $loops); return $result; }
php
public static function getConfig(Loops $loops = NULL, ArrayObject $config = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } if(!$config) { $parts = explode("\\", get_called_class()); if(count($parts) > 2 && array_slice($parts, 0, 2) == [ "Loops", "Service" ]) { $parts = array_slice($parts, 2); } $sectionname = Misc::underscore(implode("\\", $parts)); $config = $loops->getService('config'); $config = $config->offsetExists($sectionname) ? $config->offsetGet($sectionname) : new ArrayObject; } $result = static::getDefaultConfig($loops); $result->merge($config); $result->offsetSet('loops', $loops); return $result; }
[ "public", "static", "function", "getConfig", "(", "Loops", "$", "loops", "=", "NULL", ",", "ArrayObject", "$", "config", "=", "NULL", ")", "{", "if", "(", "!", "$", "loops", ")", "{", "$", "loops", "=", "Loops", "::", "getCurrentLoops", "(", ")", ";"...
Returns the complete config of a service A Loops context will be included in the configuration. The config value will be generated by getting the default configuration of this class to which additional config values can be merged. If no additional values have been set, the config service of the Loops context will be looked for extra values. Here, the value at the key that is determined as follows will be used: 1. Get the classname of this class without the "Loops\Service\" part. e.g. "SmartyRenderer" for class "Loops\Service\SmartyRenderer" 2. Underscore the classname (see Misc::undercore). e.g. "smarty_renderer" for classname "SmartyRenderer" So in order to define extra configuration values for the service "Loops\Service\SmartyRenderer" these values must be accessable by key "smarty_renderer" in the config service. Example in case a config.ini file is used (which is true for most cases): <code> ... [smarty_renderer] disable_security = TRUE ... </code> @param Loops $loops The Loops context. It will be included in the configuration. Defaults to the current Loops context if not set. @param Loops\ArrayObject $config Additional config values that should be merged to the default config. @return Loops\ArrayObject The configuration which combines default values with additional values and the loops context
[ "Returns", "the", "complete", "config", "of", "a", "service" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L224-L245
train
loopsframework/base
src/Loops/Service.php
Service.getService
public static function getService(ArrayObject $config, Loops $loops) { return Misc::reflectionInstance(static::getClassname($loops), static::getConfig($loops, $config)); }
php
public static function getService(ArrayObject $config, Loops $loops) { return Misc::reflectionInstance(static::getClassname($loops), static::getConfig($loops, $config)); }
[ "public", "static", "function", "getService", "(", "ArrayObject", "$", "config", ",", "Loops", "$", "loops", ")", "{", "return", "Misc", "::", "reflectionInstance", "(", "static", "::", "getClassname", "(", "$", "loops", ")", ",", "static", "::", "getConfig"...
The factory method that creates the service instance The service is instantiated by Misc::reflectionInstance. The classname that is returned by function getClassname will be instanciated and arguments for the constructor are retrieved by function getConfig. Without further changes in the child class, an instance of the service class will be instantiated and returned. @param Loops\ArrayObject $config The additiona config that will be merged into the default config. @param Loops $loops The loops context @return object The service object
[ "The", "factory", "method", "that", "creates", "the", "service", "instance" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L260-L262
train
loopsframework/base
src/Loops/Service.php
Service.hasService
public static function hasService(Loops $loops) { foreach(static::getDependencies($loops) as $classname) { if(!class_exists($classname)) { return FALSE; } } return TRUE; }
php
public static function hasService(Loops $loops) { foreach(static::getDependencies($loops) as $classname) { if(!class_exists($classname)) { return FALSE; } } return TRUE; }
[ "public", "static", "function", "hasService", "(", "Loops", "$", "loops", ")", "{", "foreach", "(", "static", "::", "getDependencies", "(", "$", "loops", ")", "as", "$", "classname", ")", "{", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ...
Checks if all dependent classnames are defined @param Loops\ArrayObject $config The additiona config that will be merged into the default config. @param Loops $loops The loops context @return bool TRUE if all dependencies are defined
[ "Checks", "if", "all", "dependent", "classnames", "are", "defined" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L271-L279
train
phergie/phergie-irc-event
src/EventConverter.php
EventConverter.convert
public function convert(EventInterface $event) { $connection = $event->getConnection(); $array = array( 'message' => $event->getMessage(), 'params' => $event->getParams(), 'command' => $event->getCommand(), 'connection' => array( 'serverHostname' => $connection->getServerHostname(), 'serverPort' => $connection->getServerPort(), 'nickname' => $connection->getNickname(), 'username' => $connection->getUsername(), 'hostname' => $connection->getHostname(), 'servername' => $connection->getServername(), 'realname' => $connection->getRealname(), ), ); if ($event instanceof UserEventInterface) { $array['user'] = array( 'prefix' => $event->getPrefix(), 'nick' => $event->getNick(), 'username' => $event->getUsername(), 'host' => $event->getHost(), 'targets' => $event->getTargets(), ); } if ($event instanceof CtcpEventInterface) { $array['ctcp'] = array( 'command' => $event->getCtcpCommand(), 'params' => $event->getCtcpParams(), ); } return $array; }
php
public function convert(EventInterface $event) { $connection = $event->getConnection(); $array = array( 'message' => $event->getMessage(), 'params' => $event->getParams(), 'command' => $event->getCommand(), 'connection' => array( 'serverHostname' => $connection->getServerHostname(), 'serverPort' => $connection->getServerPort(), 'nickname' => $connection->getNickname(), 'username' => $connection->getUsername(), 'hostname' => $connection->getHostname(), 'servername' => $connection->getServername(), 'realname' => $connection->getRealname(), ), ); if ($event instanceof UserEventInterface) { $array['user'] = array( 'prefix' => $event->getPrefix(), 'nick' => $event->getNick(), 'username' => $event->getUsername(), 'host' => $event->getHost(), 'targets' => $event->getTargets(), ); } if ($event instanceof CtcpEventInterface) { $array['ctcp'] = array( 'command' => $event->getCtcpCommand(), 'params' => $event->getCtcpParams(), ); } return $array; }
[ "public", "function", "convert", "(", "EventInterface", "$", "event", ")", "{", "$", "connection", "=", "$", "event", "->", "getConnection", "(", ")", ";", "$", "array", "=", "array", "(", "'message'", "=>", "$", "event", "->", "getMessage", "(", ")", ...
Converts an event object into an array. @param \Phergie\Irc\Event\EventInterface $event @return array
[ "Converts", "an", "event", "object", "into", "an", "array", "." ]
8650778727fc03af7fbfa2e4db9762e8521bc09e
https://github.com/phergie/phergie-irc-event/blob/8650778727fc03af7fbfa2e4db9762e8521bc09e/src/EventConverter.php#L28-L65
train
sheychen290/colis
src/Stream.php
Stream.attach
protected function attach($stream) { if (is_resource($stream) === false) { throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource'); } if (is_resource($this->stream) === true) { $this->detach(); } $this->stream = $stream; }
php
protected function attach($stream) { if (is_resource($stream) === false) { throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource'); } if (is_resource($this->stream) === true) { $this->detach(); } $this->stream = $stream; }
[ "protected", "function", "attach", "(", "$", "stream", ")", "{", "if", "(", "is_resource", "(", "$", "stream", ")", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__METHOD__", ".", "' argument must be a valid PHP resource'", ")", ";"...
Attach new resource to this object
[ "Attach", "new", "resource", "to", "this", "object" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L40-L51
train
sheychen290/colis
src/Stream.php
Stream.close
public function close() { if (is_resource($this->stream) === true) { fclose($this->stream); } $this->detach(); }
php
public function close() { if (is_resource($this->stream) === true) { fclose($this->stream); } $this->detach(); }
[ "public", "function", "close", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "fclose", "(", "$", "this", "->", "stream", ")", ";", "}", "$", "this", "->", "detach", "(", ")", ";", "}" ]
Closes the stream and any underlying resources
[ "Closes", "the", "stream", "and", "any", "underlying", "resources" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L54-L61
train
sheychen290/colis
src/Stream.php
Stream.getSize
public function getSize() { if (is_resource($this->stream) === true) { $stats = fstat($this->stream); if (isset($stats['size'])) { return $stats['size']; } } return null; }
php
public function getSize() { if (is_resource($this->stream) === true) { $stats = fstat($this->stream); if (isset($stats['size'])) { return $stats['size']; } } return null; }
[ "public", "function", "getSize", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "$", "stats", "=", "fstat", "(", "$", "this", "->", "stream", ")", ";", "if", "(", "isset", "(", "$", "stats...
Get the size of the stream if known
[ "Get", "the", "size", "of", "the", "stream", "if", "known" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L72-L81
train
sheychen290/colis
src/Stream.php
Stream.isWritable
public function isWritable() { if (is_resource($this->stream) === true) { $metadata = $this->getMetadata(); return Validator::isWritable($metadata); } return false; }
php
public function isWritable() { if (is_resource($this->stream) === true) { $metadata = $this->getMetadata(); return Validator::isWritable($metadata); } return false; }
[ "public", "function", "isWritable", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "$", "metadata", "=", "$", "this", "->", "getMetadata", "(", ")", ";", "return", "Validator", "::", "isWritable...
Returns whether or not the stream is writable
[ "Returns", "whether", "or", "not", "the", "stream", "is", "writable" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L127-L134
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & AddFields ($fields) { /** @var $this \MvcCore\Ext\Forms\IForm */ $fields = func_get_args(); if (count($fields) === 1 && is_array($fields[0])) $fields = $fields[0]; foreach ($fields as & $field) $this->AddField($field); return $this; }
php
public function & AddFields ($fields) { /** @var $this \MvcCore\Ext\Forms\IForm */ $fields = func_get_args(); if (count($fields) === 1 && is_array($fields[0])) $fields = $fields[0]; foreach ($fields as & $field) $this->AddField($field); return $this; }
[ "public", "function", "&", "AddFields", "(", "$", "fields", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "fields", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "fields", ")", "===", "1", "&&", "is_array", "(", "$", ...
Add multiple fully configured form field instances, function have infinite params with new field instances. @param \MvcCore\Ext\Forms\Field[]|\MvcCore\Ext\Forms\IField[] $fields,... Any `\MvcCore\Ext\Forms\IField` fully configured instance to add into form. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "multiple", "fully", "configured", "form", "field", "instances", "function", "have", "infinite", "params", "with", "new", "field", "instances", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L58-L65
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & AddField (\MvcCore\Ext\Forms\IField $field) { /** @var $this \MvcCore\Ext\Forms\IForm */ /** @var $field \MvcCore\Ext\Forms\Field */ if ($this->dispatchState < 1) $this->Init(); $fieldName = $field->GetName(); $field->SetForm($this); $this->fields[$fieldName] = & $field; if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) { $this->submitFields[$fieldName] = & $field; $fieldCustomResultState = $field->GetCustomResultState(); if ($fieldCustomResultState !== NULL) $this->customResultStates[$fieldName] = $fieldCustomResultState; } return $this; }
php
public function & AddField (\MvcCore\Ext\Forms\IField $field) { /** @var $this \MvcCore\Ext\Forms\IForm */ /** @var $field \MvcCore\Ext\Forms\Field */ if ($this->dispatchState < 1) $this->Init(); $fieldName = $field->GetName(); $field->SetForm($this); $this->fields[$fieldName] = & $field; if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) { $this->submitFields[$fieldName] = & $field; $fieldCustomResultState = $field->GetCustomResultState(); if ($fieldCustomResultState !== NULL) $this->customResultStates[$fieldName] = $fieldCustomResultState; } return $this; }
[ "public", "function", "&", "AddField", "(", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IField", "$", "field", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "/** @var $field \\MvcCore\\Ext\\Forms\\Field */", "if", "(", "$", "this", "->", "dispatc...
Add fully configured form field instance. @param \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField $field @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "fully", "configured", "form", "field", "instance", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L72-L86
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.HasField
public function HasField ($fieldOrFieldName = NULL) { $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } return isset($this->fields[$fieldName]); }
php
public function HasField ($fieldOrFieldName = NULL) { $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } return isset($this->fields[$fieldName]); }
[ "public", "function", "HasField", "(", "$", "fieldOrFieldName", "=", "NULL", ")", "{", "$", "fieldName", "=", "NULL", ";", "if", "(", "$", "fieldOrFieldName", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IField", ")", "{", "$", "fiel...
If `TRUE` if given field instance or given field name exists in form, `FALSE` otherwise. @param \MvcCore\Ext\Forms\IField|string $fieldOrFieldName @return bool
[ "If", "TRUE", "if", "given", "field", "instance", "or", "given", "field", "name", "exists", "in", "form", "FALSE", "otherwise", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L94-L102
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & RemoveField ($fieldOrFieldName = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ if ($this->dispatchState < 1) $this->Init(); $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } if (isset($this->fields[$fieldName])) unset($this->fields[$fieldName]); return $this; }
php
public function & RemoveField ($fieldOrFieldName = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ if ($this->dispatchState < 1) $this->Init(); $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } if (isset($this->fields[$fieldName])) unset($this->fields[$fieldName]); return $this; }
[ "public", "function", "&", "RemoveField", "(", "$", "fieldOrFieldName", "=", "NULL", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "if", "(", "$", "this", "->", "dispatchState", "<", "1", ")", "$", "this", "->", "Init", "(", ")", ";", "$", "fie...
Remove configured form field instance by given instance or given field name. If field is not found by it's name, no error happened. @param \MvcCore\Ext\Forms\IField|string $fieldOrFieldName @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Remove", "configured", "form", "field", "instance", "by", "given", "instance", "or", "given", "field", "name", ".", "If", "field", "is", "not", "found", "by", "it", "s", "name", "no", "error", "happened", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L110-L122
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & GetField ($fieldName = '') { $result = NULL; if (isset($this->fields[$fieldName])) $result = & $this->fields[$fieldName]; return $result; }
php
public function & GetField ($fieldName = '') { $result = NULL; if (isset($this->fields[$fieldName])) $result = & $this->fields[$fieldName]; return $result; }
[ "public", "function", "&", "GetField", "(", "$", "fieldName", "=", "''", ")", "{", "$", "result", "=", "NULL", ";", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ")", "$", "result", "=", "&", "$", "this", ...
Return form field instance by form field name if it exists, else return null; @param string $fieldName @return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField|NULL
[ "Return", "form", "field", "instance", "by", "form", "field", "name", "if", "it", "exists", "else", "return", "null", ";" ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L129-L134
train
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & GetFirstFieldByType ($fieldType = '') { $result = NULL; foreach ($this->fields as & $field) { if ($field->GetType() == $fieldType) { $result = & $field; } } return $result; }
php
public function & GetFirstFieldByType ($fieldType = '') { $result = NULL; foreach ($this->fields as & $field) { if ($field->GetType() == $fieldType) { $result = & $field; } } return $result; }
[ "public", "function", "&", "GetFirstFieldByType", "(", "$", "fieldType", "=", "''", ")", "{", "$", "result", "=", "NULL", ";", "foreach", "(", "$", "this", "->", "fields", "as", "&", "$", "field", ")", "{", "if", "(", "$", "field", "->", "GetType", ...
Return first caught form field instance by given field type string. If no field found, `NULL` is returned. @param string $fieldType @return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField|NULL
[ "Return", "first", "caught", "form", "field", "instance", "by", "given", "field", "type", "string", ".", "If", "no", "field", "found", "NULL", "is", "returned", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L158-L166
train
lamjack/php-tools
lib/Util/Date.php
Date.friendly
public static function friendly($time) { $now = time(); $delta = abs($time - $now); if ($delta < self::MINUTE) { return $delta === self::SECOND ? 'one second age' : ['%num% second ago', $delta]; } if ($delta < 2 * self::MINUTE) { return 'a minute ago'; } if ($delta < 45 * self::MINUTE) { return ['%num% minutes ago', (int)($delta / self::MINUTE)]; } if ($delta < 90 * self::MINUTE) { return 'an hour ago'; } if ($delta < 24 * self::HOUR) { return ['%num% hours ago', (int)($delta / self::HOUR)]; } if ($delta < 48 * self::HOUR) { return 'yesterday'; } if ($delta < self::MONTH) { return ['%num% days ago', (int)($delta / self::DAY)]; } if ($delta < self::YEAR) { $months = (int)($delta / self::MONTH); return $months <= 1 ? 'one month ago' : ['%num% months ago', $months]; } $years = (int)($delta / self::YEAR); return $years <= 1 ? 'one year ago' : ['%num% years ago', $years]; }
php
public static function friendly($time) { $now = time(); $delta = abs($time - $now); if ($delta < self::MINUTE) { return $delta === self::SECOND ? 'one second age' : ['%num% second ago', $delta]; } if ($delta < 2 * self::MINUTE) { return 'a minute ago'; } if ($delta < 45 * self::MINUTE) { return ['%num% minutes ago', (int)($delta / self::MINUTE)]; } if ($delta < 90 * self::MINUTE) { return 'an hour ago'; } if ($delta < 24 * self::HOUR) { return ['%num% hours ago', (int)($delta / self::HOUR)]; } if ($delta < 48 * self::HOUR) { return 'yesterday'; } if ($delta < self::MONTH) { return ['%num% days ago', (int)($delta / self::DAY)]; } if ($delta < self::YEAR) { $months = (int)($delta / self::MONTH); return $months <= 1 ? 'one month ago' : ['%num% months ago', $months]; } $years = (int)($delta / self::YEAR); return $years <= 1 ? 'one year ago' : ['%num% years ago', $years]; }
[ "public", "static", "function", "friendly", "(", "$", "time", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "delta", "=", "abs", "(", "$", "time", "-", "$", "now", ")", ";", "if", "(", "$", "delta", "<", "self", "::", "MINUTE", ")", ...
get friendly time string @param int $time @return array|string
[ "get", "friendly", "time", "string" ]
f7d9ffa17312dc2378003e8f917543adc95dddbd
https://github.com/lamjack/php-tools/blob/f7d9ffa17312dc2378003e8f917543adc95dddbd/lib/Util/Date.php#L61-L101
train
drmvc/database
src/Database/Drivers/Mysql.php
Mysql.genDsn
public function genDsn($config): string { // Parse config $dsn = ''; foreach ($config as $key => $value) { if (\in_array($key, self::AVAILABLE_OPTIONS, false)) { $dsn .= "$key=$value;"; } } // Get driver of connection $driver = strtolower($config['driver']); return "$driver:$dsn"; }
php
public function genDsn($config): string { // Parse config $dsn = ''; foreach ($config as $key => $value) { if (\in_array($key, self::AVAILABLE_OPTIONS, false)) { $dsn .= "$key=$value;"; } } // Get driver of connection $driver = strtolower($config['driver']); return "$driver:$dsn"; }
[ "public", "function", "genDsn", "(", "$", "config", ")", ":", "string", "{", "// Parse config", "$", "dsn", "=", "''", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "in_array", "(", "$", "key",...
Generate DSN by parameters in config @param array $config @return string
[ "Generate", "DSN", "by", "parameters", "in", "config" ]
c6b4589d37743edef71b851c9176365956a73c80
https://github.com/drmvc/database/blob/c6b4589d37743edef71b851c9176365956a73c80/src/Database/Drivers/Mysql.php#L40-L54
train
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.buildStates
private function buildStates(): array { $states = []; foreach ($this->getOffsetFromArray($this->schema, 'states', []) as $state) { $states[] = new State( $this->getOffsetFromArray($state, 'name'), $this->buildEvents($state), $this->getAdditionalFromArray($state, ['events', 'name']) ); } return $states; }
php
private function buildStates(): array { $states = []; foreach ($this->getOffsetFromArray($this->schema, 'states', []) as $state) { $states[] = new State( $this->getOffsetFromArray($state, 'name'), $this->buildEvents($state), $this->getAdditionalFromArray($state, ['events', 'name']) ); } return $states; }
[ "private", "function", "buildStates", "(", ")", ":", "array", "{", "$", "states", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "this", "->", "schema", ",", "'states'", ",", "[", "]", ")", "as", "$", "state", ...
Build states for process @return array
[ "Build", "states", "for", "process" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L72-L84
train
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.buildEvents
private function buildEvents(array $state): array { $events = []; foreach ($this->getOffsetFromArray($state, 'events', []) as $event) { $events[] = new Event( $this->getOffsetFromArray($event, 'name'), $this->getOffsetFromArray($event, 'targetState'), $this->getOffsetFromArray($event, 'errorState'), $this->getOffsetFromArray($event, 'command'), $this->getAdditionalFromArray($event, ['name', 'command', 'targetState', 'errorState']) ); } return $events; }
php
private function buildEvents(array $state): array { $events = []; foreach ($this->getOffsetFromArray($state, 'events', []) as $event) { $events[] = new Event( $this->getOffsetFromArray($event, 'name'), $this->getOffsetFromArray($event, 'targetState'), $this->getOffsetFromArray($event, 'errorState'), $this->getOffsetFromArray($event, 'command'), $this->getAdditionalFromArray($event, ['name', 'command', 'targetState', 'errorState']) ); } return $events; }
[ "private", "function", "buildEvents", "(", "array", "$", "state", ")", ":", "array", "{", "$", "events", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "state", ",", "'events'", ",", "[", "]", ")", "as", "$", ...
Build state events @param array $state @return Event[]
[ "Build", "state", "events" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L93-L107
train
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.getProcess
public function getProcess(): Process { if ($this->process === null) { $this->process = new Process( $this->getSchemaName(), $this->getInitialState(), $this->buildStates() ); } return $this->process; }
php
public function getProcess(): Process { if ($this->process === null) { $this->process = new Process( $this->getSchemaName(), $this->getInitialState(), $this->buildStates() ); } return $this->process; }
[ "public", "function", "getProcess", "(", ")", ":", "Process", "{", "if", "(", "$", "this", "->", "process", "===", "null", ")", "{", "$", "this", "->", "process", "=", "new", "Process", "(", "$", "this", "->", "getSchemaName", "(", ")", ",", "$", "...
Return schema process @return Process
[ "Return", "schema", "process" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L114-L125
train
ironedgesoftware/file-utils
src/File/Base.php
Base.load
public function load($refresh = false, array $options = array()) { if ($refresh || $this->_contents === null) { $this->_contents = @file_get_contents($this->_path); if ($this->_contents === false) { throw LoadException::create($this->_path); } $this->setContents($this->decode($options)); } return $this; }
php
public function load($refresh = false, array $options = array()) { if ($refresh || $this->_contents === null) { $this->_contents = @file_get_contents($this->_path); if ($this->_contents === false) { throw LoadException::create($this->_path); } $this->setContents($this->decode($options)); } return $this; }
[ "public", "function", "load", "(", "$", "refresh", "=", "false", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "refresh", "||", "$", "this", "->", "_contents", "===", "null", ")", "{", "$", "this", "->", "_contents...
Opens a file. @param bool $refresh - If this is true then the file will be open even if it was open before. @param array $options - Options. @throws LoadException @return $this
[ "Opens", "a", "file", "." ]
d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb
https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Base.php#L159-L172
train
yftzeng/phpWowLog
patch/monolog/Logger.php
Logger.pushHandler
public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); if ($this->_startTime === null) { $this->_startTime = microtime(true); $this->_previousRecordTime = $this->_startTime; } }
php
public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); if ($this->_startTime === null) { $this->_startTime = microtime(true); $this->_previousRecordTime = $this->_startTime; } }
[ "public", "function", "pushHandler", "(", "HandlerInterface", "$", "handler", ")", "{", "array_unshift", "(", "$", "this", "->", "handlers", ",", "$", "handler", ")", ";", "if", "(", "$", "this", "->", "_startTime", "===", "null", ")", "{", "$", "this", ...
Pushes a handler on to the stack. @param HandlerInterface $handler
[ "Pushes", "a", "handler", "on", "to", "the", "stack", "." ]
0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082
https://github.com/yftzeng/phpWowLog/blob/0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082/patch/monolog/Logger.php#L111-L118
train
yftzeng/phpWowLog
patch/monolog/Logger.php
Logger.isHandling
public function isHandling($level) { $record = array( 'message' => '', 'context' => array(), 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => new \DateTime(), 'extra' => array(), ); foreach ($this->handlers as $key => $handler) { if ($handler->isHandling($record)) { return true; } } return false; }
php
public function isHandling($level) { $record = array( 'message' => '', 'context' => array(), 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => new \DateTime(), 'extra' => array(), ); foreach ($this->handlers as $key => $handler) { if ($handler->isHandling($record)) { return true; } } return false; }
[ "public", "function", "isHandling", "(", "$", "level", ")", "{", "$", "record", "=", "array", "(", "'message'", "=>", "''", ",", "'context'", "=>", "array", "(", ")", ",", "'level'", "=>", "$", "level", ",", "'level_name'", "=>", "self", "::", "getLeve...
Checks whether the Logger has a handler that listens on the given level @param integer $level @return Boolean
[ "Checks", "whether", "the", "Logger", "has", "a", "handler", "that", "listens", "on", "the", "given", "level" ]
0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082
https://github.com/yftzeng/phpWowLog/blob/0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082/patch/monolog/Logger.php#L297-L316
train
lciolecki/zf-extensions-library
library/Extlib/Session/SaveHandler/Cache.php
Cache.normalizeId
protected function normalizeId($id) { if (null !== $this->getSessionPrefix()) { return $this->getSessionPrefix() . self::ID_SEPARATOR . $id; } return $id; }
php
protected function normalizeId($id) { if (null !== $this->getSessionPrefix()) { return $this->getSessionPrefix() . self::ID_SEPARATOR . $id; } return $id; }
[ "protected", "function", "normalizeId", "(", "$", "id", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "getSessionPrefix", "(", ")", ")", "{", "return", "$", "this", "->", "getSessionPrefix", "(", ")", ".", "self", "::", "ID_SEPARATOR", ".", "$...
Method prepare id @param string $id @return string
[ "Method", "prepare", "id" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Session/SaveHandler/Cache.php#L220-L227
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.computeSingleDocumentChangeSet
private function computeSingleDocumentChangeSet($document) { $state = $this->getDocumentState($document); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Document has to be managed or scheduled for removal for single computation " . self::objToStr($document)); } $class = $this->dm->getClassMetadata(get_class($document)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($document); } // Compute changes for INSERTed and UPSERTed documents first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); $this->computeScheduleUpsertsChangeSets(); // Ignore uninitialized proxy objects if ($document instanceof Proxy && ! $document->__isInitialized__) { return; } // Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here. $oid = spl_object_hash($document); if ( ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid]) && ! isset($this->documentDeletions[$oid]) && isset($this->documentStates[$oid]) ) { $this->computeChangeSet($class, $document); } }
php
private function computeSingleDocumentChangeSet($document) { $state = $this->getDocumentState($document); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Document has to be managed or scheduled for removal for single computation " . self::objToStr($document)); } $class = $this->dm->getClassMetadata(get_class($document)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($document); } // Compute changes for INSERTed and UPSERTed documents first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); $this->computeScheduleUpsertsChangeSets(); // Ignore uninitialized proxy objects if ($document instanceof Proxy && ! $document->__isInitialized__) { return; } // Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here. $oid = spl_object_hash($document); if ( ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid]) && ! isset($this->documentDeletions[$oid]) && isset($this->documentStates[$oid]) ) { $this->computeChangeSet($class, $document); } }
[ "private", "function", "computeSingleDocumentChangeSet", "(", "$", "document", ")", "{", "$", "state", "=", "$", "this", "->", "getDocumentState", "(", "$", "document", ")", ";", "if", "(", "$", "state", "!==", "self", "::", "STATE_MANAGED", "&&", "$", "st...
Only flush the given document according to a ruleset that keeps the UoW consistent. 1. All documents scheduled for insertion, (orphan) removals and changes in collections are processed as well! 2. Proxies are skipped. 3. Only if document is properly managed. @param object $document @throws \InvalidArgumentException If the document is not STATE_MANAGED @return void
[ "Only", "flush", "the", "given", "document", "according", "to", "a", "ruleset", "that", "keeps", "the", "UoW", "consistent", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L542-L575
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.executeExtraUpdates
private function executeExtraUpdates(array $options) { foreach ($this->extraUpdates as $oid => $update) { list ($document, $changeset) = $update; $this->documentChangeSets[$oid] = $changeset; $this->getDocumentPersister(get_class($document))->update($document, $options); } }
php
private function executeExtraUpdates(array $options) { foreach ($this->extraUpdates as $oid => $update) { list ($document, $changeset) = $update; $this->documentChangeSets[$oid] = $changeset; $this->getDocumentPersister(get_class($document))->update($document, $options); } }
[ "private", "function", "executeExtraUpdates", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "this", "->", "extraUpdates", "as", "$", "oid", "=>", "$", "update", ")", "{", "list", "(", "$", "document", ",", "$", "changeset", ")", "=", "$"...
Executes reference updates
[ "Executes", "reference", "updates" ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L580-L587
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getDocumentChangeSet
public function getDocumentChangeSet($document) { $oid = spl_object_hash($document); if (isset($this->documentChangeSets[$oid])) { return $this->documentChangeSets[$oid]; } return array(); }
php
public function getDocumentChangeSet($document) { $oid = spl_object_hash($document); if (isset($this->documentChangeSets[$oid])) { return $this->documentChangeSets[$oid]; } return array(); }
[ "public", "function", "getDocumentChangeSet", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "documentChangeSets", "[", "$", "oid", "]", ")", ")", "{", "re...
Gets the changeset for a document. @param object $document @return array
[ "Gets", "the", "changeset", "for", "a", "document", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L595-L602
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleForUpdate
public function scheduleForUpdate($document) { $oid = spl_object_hash($document); if ( ! isset($this->documentIdentifiers[$oid])) { throw new \InvalidArgumentException("Document has no identity."); } if (isset($this->documentDeletions[$oid])) { throw new \InvalidArgumentException("Document is removed."); } if ( ! isset($this->documentUpdates[$oid]) && ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid])) { $this->documentUpdates[$oid] = $document; } }
php
public function scheduleForUpdate($document) { $oid = spl_object_hash($document); if ( ! isset($this->documentIdentifiers[$oid])) { throw new \InvalidArgumentException("Document has no identity."); } if (isset($this->documentDeletions[$oid])) { throw new \InvalidArgumentException("Document is removed."); } if ( ! isset($this->documentUpdates[$oid]) && ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid])) { $this->documentUpdates[$oid] = $document; } }
[ "public", "function", "scheduleForUpdate", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "documentIdentifiers", "[", "$", "oid", "]", ")", ")", "{", ...
Schedules a document for being updated. @param object $document The document to schedule for being updated. @throws \InvalidArgumentException
[ "Schedules", "a", "document", "for", "being", "updated", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1514-L1527
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.cascadePreRemove
private function cascadePreRemove(ClassMetadata $class, $document) { $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preRemove])) { $entryClass->invokeLifecycleCallbacks(Events::preRemove, $entry); } if ($hasPreRemoveListeners) { $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entry, $this->dm)); } $this->cascadePreRemove($entryClass, $entry); } } } }
php
private function cascadePreRemove(ClassMetadata $class, $document) { $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preRemove])) { $entryClass->invokeLifecycleCallbacks(Events::preRemove, $entry); } if ($hasPreRemoveListeners) { $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entry, $this->dm)); } $this->cascadePreRemove($entryClass, $entry); } } } }
[ "private", "function", "cascadePreRemove", "(", "ClassMetadata", "$", "class", ",", "$", "document", ")", "{", "$", "hasPreRemoveListeners", "=", "$", "this", "->", "evm", "->", "hasListeners", "(", "Events", "::", "preRemove", ")", ";", "foreach", "(", "$",...
Cascades the preRemove event to embedded documents. @param ClassMetadata $class @param object $document
[ "Cascades", "the", "preRemove", "event", "to", "embedded", "documents", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2012-L2037
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.cascadePreLoad
private function cascadePreLoad(ClassMetadata $class, $document, $data) { $hasPreLoadListeners = $this->evm->hasListeners(Events::preLoad); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $entryClass->invokeLifecycleCallbacks(Events::preLoad, $entry, $args); } if ($hasPreLoadListeners) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($entry, $this->dm, $data[$mapping['name']])); } $this->cascadePreLoad($entryClass, $entry, $data[$mapping['name']]); } } } }
php
private function cascadePreLoad(ClassMetadata $class, $document, $data) { $hasPreLoadListeners = $this->evm->hasListeners(Events::preLoad); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $entryClass->invokeLifecycleCallbacks(Events::preLoad, $entry, $args); } if ($hasPreLoadListeners) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($entry, $this->dm, $data[$mapping['name']])); } $this->cascadePreLoad($entryClass, $entry, $data[$mapping['name']]); } } } }
[ "private", "function", "cascadePreLoad", "(", "ClassMetadata", "$", "class", ",", "$", "document", ",", "$", "data", ")", "{", "$", "hasPreLoadListeners", "=", "$", "this", "->", "evm", "->", "hasListeners", "(", "Events", "::", "preLoad", ")", ";", "forea...
Cascades the preLoad event to embedded documents. @param ClassMetadata $class @param object $document @param array $data
[ "Cascades", "the", "preLoad", "event", "to", "embedded", "documents", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2813-L2839
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getOriginalDocumentData
public function getOriginalDocumentData($document) { $oid = spl_object_hash($document); if (isset($this->originalDocumentData[$oid])) { return $this->originalDocumentData[$oid]; } return array(); }
php
public function getOriginalDocumentData($document) { $oid = spl_object_hash($document); if (isset($this->originalDocumentData[$oid])) { return $this->originalDocumentData[$oid]; } return array(); }
[ "public", "function", "getOriginalDocumentData", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "originalDocumentData", "[", "$", "oid", "]", ")", ")", "{", ...
Gets the original data of a document. The original data is the data that was present at the time the document was reconstituted from the database. @param object $document @return array
[ "Gets", "the", "original", "data", "of", "a", "document", ".", "The", "original", "data", "is", "the", "data", "that", "was", "present", "at", "the", "time", "the", "document", "was", "reconstituted", "from", "the", "database", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2868-L2875
train
squire-assistant/console
Event/ConsoleErrorEvent.php
ConsoleErrorEvent.setExitCode
public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); }
php
public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); }
[ "public", "function", "setExitCode", "(", "$", "exitCode", ")", "{", "$", "this", "->", "exitCode", "=", "(", "int", ")", "$", "exitCode", ";", "$", "r", "=", "new", "\\", "ReflectionProperty", "(", "$", "this", "->", "error", ",", "'code'", ")", ";"...
Sets the exit code. @param int $exitCode The command exit code
[ "Sets", "the", "exit", "code", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Event/ConsoleErrorEvent.php#L65-L72
train
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.index
public function index(PortfolioRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Portfolio\Repositories\Presenter\PortfolioPresenter::class) ->$function(); } $portfolios = $this->repository->paginate(); return $this->response->title(trans('portfolio::portfolio.names')) ->view('portfolio::portfolio.index', true) ->data(compact('portfolios')) ->output(); }
php
public function index(PortfolioRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Portfolio\Repositories\Presenter\PortfolioPresenter::class) ->$function(); } $portfolios = $this->repository->paginate(); return $this->response->title(trans('portfolio::portfolio.names')) ->view('portfolio::portfolio.index', true) ->data(compact('portfolios')) ->output(); }
[ "public", "function", "index", "(", "PortfolioRequest", "$", "request", ")", "{", "$", "view", "=", "$", "this", "->", "response", "->", "theme", "->", "listView", "(", ")", ";", "if", "(", "$", "this", "->", "response", "->", "typeIs", "(", "'json'", ...
Display a list of portfolio. @return Response
[ "Display", "a", "list", "of", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L38-L55
train
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.show
public function show(PortfolioRequest $request, Portfolio $portfolio) { if ($portfolio->exists) { $view = 'portfolio::portfolio.show'; } else { $view = 'portfolio::portfolio.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio::portfolio.name')) ->data(compact('portfolio')) ->view($view, true) ->output(); }
php
public function show(PortfolioRequest $request, Portfolio $portfolio) { if ($portfolio->exists) { $view = 'portfolio::portfolio.show'; } else { $view = 'portfolio::portfolio.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio::portfolio.name')) ->data(compact('portfolio')) ->view($view, true) ->output(); }
[ "public", "function", "show", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "if", "(", "$", "portfolio", "->", "exists", ")", "{", "$", "view", "=", "'portfolio::portfolio.show'", ";", "}", "else", "{", "$", "view",...
Display portfolio. @param Request $request @param Model $portfolio @return Response
[ "Display", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L65-L78
train
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.edit
public function edit(PortfolioRequest $request, Portfolio $portfolio) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio::portfolio.name')) ->view('portfolio::portfolio.edit', true) ->data(compact('portfolio')) ->output(); }
php
public function edit(PortfolioRequest $request, Portfolio $portfolio) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio::portfolio.name')) ->view('portfolio::portfolio.edit', true) ->data(compact('portfolio')) ->output(); }
[ "public", "function", "edit", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'portfolio::p...
Show portfolio for editing. @param Request $request @param Model $portfolio @return Response
[ "Show", "portfolio", "for", "editing", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L135-L141
train
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.update
public function update(PortfolioRequest $request, Portfolio $portfolio) { try { $attributes = $request->all(); $portfolio->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
php
public function update(PortfolioRequest $request, Portfolio $portfolio) { try { $attributes = $request->all(); $portfolio->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
[ "public", "function", "update", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "try", "{", "$", "attributes", "=", "$", "request", "->", "all", "(", ")", ";", "$", "portfolio", "->", "update", "(", "$", "attributes...
Update the portfolio. @param Request $request @param Model $portfolio @return Response
[ "Update", "the", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L151-L170
train
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.destroy
public function destroy(PortfolioRequest $request, Portfolio $portfolio) { try { $portfolio->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio::portfolio.name')])) ->code(202) ->status('success') ->url(guard_url('portfolio/portfolio/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
php
public function destroy(PortfolioRequest $request, Portfolio $portfolio) { try { $portfolio->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio::portfolio.name')])) ->code(202) ->status('success') ->url(guard_url('portfolio/portfolio/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
[ "public", "function", "destroy", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "try", "{", "$", "portfolio", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "...
Remove the portfolio. @param Model $portfolio @return Response
[ "Remove", "the", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L179-L199
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.connect
public function connect() { $dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};"; $dsnString .= "charset={$this->dbCharset}"; /* * Try to connect to database */ try { $this->dbConnection = new \PDO( $dsnString, "{$this->dbUsername}", "{$this->dbPassword}", $this->driverOptions ); } catch (\PDOException $ex) { // Error during database connection, check params. throw new \InvalidArgumentException( __METHOD__.': '.$ex->getMessage() ); } return $this->dbConnection; }
php
public function connect() { $dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};"; $dsnString .= "charset={$this->dbCharset}"; /* * Try to connect to database */ try { $this->dbConnection = new \PDO( $dsnString, "{$this->dbUsername}", "{$this->dbPassword}", $this->driverOptions ); } catch (\PDOException $ex) { // Error during database connection, check params. throw new \InvalidArgumentException( __METHOD__.': '.$ex->getMessage() ); } return $this->dbConnection; }
[ "public", "function", "connect", "(", ")", "{", "$", "dsnString", "=", "\"{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};\"", ";", "$", "dsnString", ".=", "\"charset={$this->dbCharset}\"", ";", "/*\n * Try to connect to database\n */", "try", "{...
Connect to a database by using constructor params @return PDO @throws \Exception
[ "Connect", "to", "a", "database", "by", "using", "constructor", "params" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L78-L100
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.query
public function query($queryString, array $queryValues = []) { if (!is_string($queryString) || empty($queryString)) { throw new \InvalidArgumentException( __METHOD__.': The specified query is not valid.' ); } $this->connect(); $this->resourceHandle = $this->dbConnection->prepare($queryString); try { // start transaction $this->dbConnection->beginTransaction(); // execute the query and return a status $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null); // get last inserted id if present $this->lastInsertedId = $this->dbConnection->lastInsertId(); // finally execute the query $this->dbConnection->commit(); } catch (\PDOException $ex) { // If an error occurs, execute rollback $this->dbConnection->rollBack(); // Return execution status to false $this->executionStatus = false; $this->resourceHandle->closeCursor(); throw new \RuntimeException( __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}" ); } return $this->resourceHandle; }
php
public function query($queryString, array $queryValues = []) { if (!is_string($queryString) || empty($queryString)) { throw new \InvalidArgumentException( __METHOD__.': The specified query is not valid.' ); } $this->connect(); $this->resourceHandle = $this->dbConnection->prepare($queryString); try { // start transaction $this->dbConnection->beginTransaction(); // execute the query and return a status $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null); // get last inserted id if present $this->lastInsertedId = $this->dbConnection->lastInsertId(); // finally execute the query $this->dbConnection->commit(); } catch (\PDOException $ex) { // If an error occurs, execute rollback $this->dbConnection->rollBack(); // Return execution status to false $this->executionStatus = false; $this->resourceHandle->closeCursor(); throw new \RuntimeException( __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}" ); } return $this->resourceHandle; }
[ "public", "function", "query", "(", "$", "queryString", ",", "array", "$", "queryValues", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "queryString", ")", "||", "empty", "(", "$", "queryString", ")", ")", "{", "throw", "new", "\\",...
Execute a query or a prepared statement with a params array values. @param string $queryString @param array $queryValues in format [:placeholder => 'value'] @return mixed
[ "Execute", "a", "query", "or", "a", "prepared", "statement", "with", "a", "params", "array", "values", "." ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L135-L172
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.select
public function select( $table, $conditions = null, $fields = null, $order = null, $limit = null, $offset = null ) { if (is_null($fields)) { $fields = "*"; } $queryString = "SELECT {$fields} FROM {$table} "; if (!is_null($conditions)) { $queryString .= "WHERE {$conditions} "; } if (!is_null($order)) { $queryString .= "ORDER BY {$order} "; } if (!is_null($limit)) { $queryString .= "LIMIT {$limit} "; } if (!is_null($offset) && !is_null($limit)) { $queryString .= "OFFSET {$offset} "; } $queryString .= ";"; $this->query($queryString); return $this->countRows(); }
php
public function select( $table, $conditions = null, $fields = null, $order = null, $limit = null, $offset = null ) { if (is_null($fields)) { $fields = "*"; } $queryString = "SELECT {$fields} FROM {$table} "; if (!is_null($conditions)) { $queryString .= "WHERE {$conditions} "; } if (!is_null($order)) { $queryString .= "ORDER BY {$order} "; } if (!is_null($limit)) { $queryString .= "LIMIT {$limit} "; } if (!is_null($offset) && !is_null($limit)) { $queryString .= "OFFSET {$offset} "; } $queryString .= ";"; $this->query($queryString); return $this->countRows(); }
[ "public", "function", "select", "(", "$", "table", ",", "$", "conditions", "=", "null", ",", "$", "fields", "=", "null", ",", "$", "order", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "is_nul...
Perform a SELECT statement @param string $table @param string $conditions @param string $fields @param string $order @param string $limit @param string $offset @return int number of affected rows
[ "Perform", "a", "SELECT", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L204-L241
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.insert
public function insert($table, array $data) { $nameFields = join(',', array_keys($data)); $preparedValues = $this->prepareValues($data); $keyValues = join(",", array_keys($preparedValues)); $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});"; $this->query($queryString, $preparedValues); return $this->getInsertId(); }
php
public function insert($table, array $data) { $nameFields = join(',', array_keys($data)); $preparedValues = $this->prepareValues($data); $keyValues = join(",", array_keys($preparedValues)); $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});"; $this->query($queryString, $preparedValues); return $this->getInsertId(); }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "data", ")", "{", "$", "nameFields", "=", "join", "(", "','", ",", "array_keys", "(", "$", "data", ")", ")", ";", "$", "preparedValues", "=", "$", "this", "->", "prepareValues", "(...
Perform a INSERT statement @param string $table @param array $data @return int last inserted id
[ "Perform", "a", "INSERT", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L251-L261
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.prepareValues
private function prepareValues($arrayData) { $arrayData = array_values($arrayData); $preparedValues = []; $vNumber = 1; foreach ($arrayData as $value) { $preparedValues[":value{$vNumber}"] = "$value"; $vNumber++; } unset($arrayData); unset($vNumber); return $preparedValues; }
php
private function prepareValues($arrayData) { $arrayData = array_values($arrayData); $preparedValues = []; $vNumber = 1; foreach ($arrayData as $value) { $preparedValues[":value{$vNumber}"] = "$value"; $vNumber++; } unset($arrayData); unset($vNumber); return $preparedValues; }
[ "private", "function", "prepareValues", "(", "$", "arrayData", ")", "{", "$", "arrayData", "=", "array_values", "(", "$", "arrayData", ")", ";", "$", "preparedValues", "=", "[", "]", ";", "$", "vNumber", "=", "1", ";", "foreach", "(", "$", "arrayData", ...
Preparate values for execute @param array $arrayData @return string
[ "Preparate", "values", "for", "execute" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L269-L284
train
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.update
public function update($table, array $data, $conditions) { $nameFields = array_keys($data); $preparedValues = $this->prepareValues($data); $queryString = "UPDATE {$table} SET "; $fNumber = 0; foreach ($preparedValues as $key => $value) { unset($value); $queryString .= "{$nameFields[$fNumber]} = {$key}, "; $fNumber++; } $queryString = preg_replace('/,\ $/', ' ', $queryString); $queryString .= "WHERE {$conditions};"; $this->query($queryString, $preparedValues); return $this->getAffectedRows(); }
php
public function update($table, array $data, $conditions) { $nameFields = array_keys($data); $preparedValues = $this->prepareValues($data); $queryString = "UPDATE {$table} SET "; $fNumber = 0; foreach ($preparedValues as $key => $value) { unset($value); $queryString .= "{$nameFields[$fNumber]} = {$key}, "; $fNumber++; } $queryString = preg_replace('/,\ $/', ' ', $queryString); $queryString .= "WHERE {$conditions};"; $this->query($queryString, $preparedValues); return $this->getAffectedRows(); }
[ "public", "function", "update", "(", "$", "table", ",", "array", "$", "data", ",", "$", "conditions", ")", "{", "$", "nameFields", "=", "array_keys", "(", "$", "data", ")", ";", "$", "preparedValues", "=", "$", "this", "->", "prepareValues", "(", "$", ...
Perform a UPDATE statement @param string $table @param array $data @param string $conditions @return int number of affected rows
[ "Perform", "a", "UPDATE", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L295-L314
train
elstamey/phergie-irc-plugin-react-tableflip
src/Plugin.php
Plugin.specialChar
private function specialChar($char) { switch($char) { case "!": return $this->hexToChar('00A1'); case "_": return $this->hexToChar('203E'); case "&": return $this->hexToChar('214B'); case "?": return $this->hexToChar('00BF'); case ".": return $this->hexToChar('U2D9'); case "\"": return $this->hexToChar('201E'); case "'": return $this->hexToChar('002C'); case "(": return $this->hexToChar('0029'); case ")": return $this->hexToChar('0028'); default: return $char; } }
php
private function specialChar($char) { switch($char) { case "!": return $this->hexToChar('00A1'); case "_": return $this->hexToChar('203E'); case "&": return $this->hexToChar('214B'); case "?": return $this->hexToChar('00BF'); case ".": return $this->hexToChar('U2D9'); case "\"": return $this->hexToChar('201E'); case "'": return $this->hexToChar('002C'); case "(": return $this->hexToChar('0029'); case ")": return $this->hexToChar('0028'); default: return $char; } }
[ "private", "function", "specialChar", "(", "$", "char", ")", "{", "switch", "(", "$", "char", ")", "{", "case", "\"!\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'00A1'", ")", ";", "case", "\"_\"", ":", "return", "$", "this", "->", "hexTo...
Switch statement to flip the special and punctuation characters @param string $char @return string
[ "Switch", "statement", "to", "flip", "the", "special", "and", "punctuation", "characters" ]
59cb591243597cbf6ff40d28696935099965cbeb
https://github.com/elstamey/phergie-irc-plugin-react-tableflip/blob/59cb591243597cbf6ff40d28696935099965cbeb/src/Plugin.php#L247-L272
train
Dhii/invocable-base
src/CreateInvocationExceptionCapableTrait.php
CreateInvocationExceptionCapableTrait._createInvocationException
protected function _createInvocationException( $message = null, $code = null, RootException $previous = null, callable $callable = null, $args = null ) { return new InvocationException($message, $code, $previous, $callable, $args); }
php
protected function _createInvocationException( $message = null, $code = null, RootException $previous = null, callable $callable = null, $args = null ) { return new InvocationException($message, $code, $previous, $callable, $args); }
[ "protected", "function", "_createInvocationException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "RootException", "$", "previous", "=", "null", ",", "callable", "$", "callable", "=", "null", ",", "$", "args", "=", "null", ")", ...
Creates a new Invocation exception. @since [*next-version*] @param string|Stringable|null $message The error message, if any. @param int|null $code The error code, if any. @param RootException|null $previous The inner exception for chaining, if any. @param callable $callable The callable that caused the problem, if any. @param Traversable|array $args The associated list of arguments, if any. @return InvocationExceptionInterface The new exception.
[ "Creates", "a", "new", "Invocation", "exception", "." ]
f8edf350653f1041388addb918a1478e46c3a83f
https://github.com/Dhii/invocable-base/blob/f8edf350653f1041388addb918a1478e46c3a83f/src/CreateInvocationExceptionCapableTrait.php#L31-L39
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.create
public static function create(string $locale = 'en'): ValidatorFactory { $translator = new Translator; $factory = new ValidatorFactory($translator); $factory = $factory->withBuiltInFactories(); $factory = $factory->withBuiltInTemplates($locale); return $factory; }
php
public static function create(string $locale = 'en'): ValidatorFactory { $translator = new Translator; $factory = new ValidatorFactory($translator); $factory = $factory->withBuiltInFactories(); $factory = $factory->withBuiltInTemplates($locale); return $factory; }
[ "public", "static", "function", "create", "(", "string", "$", "locale", "=", "'en'", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "new", "Translator", ";", "$", "factory", "=", "new", "ValidatorFactory", "(", "$", "translator", ")", ";", "$",...
Return a validator factory using all the default rule factories and the templates of the given locale. @param string $locale @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "validator", "factory", "using", "all", "the", "default", "rule", "factories", "and", "the", "templates", "of", "the", "given", "locale", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L72-L81
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withBuiltInFactories
private function withBuiltInFactories(): ValidatorFactory { $keys = array_keys(self::$defaults); return array_reduce($keys, function ($factory, $key) { $rule = self::$defaults[$key]; return $factory->withRuleFactory($key, function (array $parameters = []) use ($rule) { return new $rule(...$parameters); }); }, $this); }
php
private function withBuiltInFactories(): ValidatorFactory { $keys = array_keys(self::$defaults); return array_reduce($keys, function ($factory, $key) { $rule = self::$defaults[$key]; return $factory->withRuleFactory($key, function (array $parameters = []) use ($rule) { return new $rule(...$parameters); }); }, $this); }
[ "private", "function", "withBuiltInFactories", "(", ")", ":", "ValidatorFactory", "{", "$", "keys", "=", "array_keys", "(", "self", "::", "$", "defaults", ")", ";", "return", "array_reduce", "(", "$", "keys", ",", "function", "(", "$", "factory", ",", "$",...
Return a new validator factory with a rule factory for each default rules. @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "a", "rule", "factory", "for", "each", "default", "rules", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L102-L117
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withBuiltInTemplates
private function withBuiltInTemplates(string $locale): ValidatorFactory { $templates = include(__DIR__ . '/../lang/' . $locale . '.php'); return $this->withDefaultTemplates($templates); }
php
private function withBuiltInTemplates(string $locale): ValidatorFactory { $templates = include(__DIR__ . '/../lang/' . $locale . '.php'); return $this->withDefaultTemplates($templates); }
[ "private", "function", "withBuiltInTemplates", "(", "string", "$", "locale", ")", ":", "ValidatorFactory", "{", "$", "templates", "=", "include", "(", "__DIR__", ".", "'/../lang/'", ".", "$", "locale", ".", "'.php'", ")", ";", "return", "$", "this", "->", ...
Return a new validator factory using the built in templates for the given locale. @param string $locale @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "using", "the", "built", "in", "templates", "for", "the", "given", "locale", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L126-L131
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.getValidator
public function getValidator(array $rules = []): Validator { $parser = new RulesParser($this->factories); return new Validator($rules, $parser, $this->translator); }
php
public function getValidator(array $rules = []): Validator { $parser = new RulesParser($this->factories); return new Validator($rules, $parser, $this->translator); }
[ "public", "function", "getValidator", "(", "array", "$", "rules", "=", "[", "]", ")", ":", "Validator", "{", "$", "parser", "=", "new", "RulesParser", "(", "$", "this", "->", "factories", ")", ";", "return", "new", "Validator", "(", "$", "rules", ",", ...
Return a validator using the given rules. @param array $rules @return \Ellipse\Validation\Validator
[ "Return", "a", "validator", "using", "the", "given", "rules", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L139-L144
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withRuleFactory
public function withRuleFactory(string $name, callable $factory): ValidatorFactory { $factories = array_merge($this->factories, [$name => $factory]); return new ValidatorFactory($this->translator, $factories); }
php
public function withRuleFactory(string $name, callable $factory): ValidatorFactory { $factories = array_merge($this->factories, [$name => $factory]); return new ValidatorFactory($this->translator, $factories); }
[ "public", "function", "withRuleFactory", "(", "string", "$", "name", ",", "callable", "$", "factory", ")", ":", "ValidatorFactory", "{", "$", "factories", "=", "array_merge", "(", "$", "this", "->", "factories", ",", "[", "$", "name", "=>", "$", "factory",...
Return a new validator factory with an additional rule factory. @param string $name @param callable $factory @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "rule", "factory", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L153-L158
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withDefaultLabels
public function withDefaultLabels(array $labels): ValidatorFactory { $translator = $this->translator->withLabels($labels); return new ValidatorFactory($translator, $this->factories); }
php
public function withDefaultLabels(array $labels): ValidatorFactory { $translator = $this->translator->withLabels($labels); return new ValidatorFactory($translator, $this->factories); }
[ "public", "function", "withDefaultLabels", "(", "array", "$", "labels", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withLabels", "(", "$", "labels", ")", ";", "return", "new", "ValidatorFactory", "(", "$...
Return a new validator factory with an additional list of labels added to the translator. @param array $labels @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "list", "of", "labels", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L167-L172
train
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withDefaultTemplates
public function withDefaultTemplates(array $templates): ValidatorFactory { $translator = $this->translator->withTemplates($templates); return new ValidatorFactory($translator, $this->factories); }
php
public function withDefaultTemplates(array $templates): ValidatorFactory { $translator = $this->translator->withTemplates($templates); return new ValidatorFactory($translator, $this->factories); }
[ "public", "function", "withDefaultTemplates", "(", "array", "$", "templates", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withTemplates", "(", "$", "templates", ")", ";", "return", "new", "ValidatorFactory",...
Return a new validator factory with an additional list of templates added to the translator. @param array $templates @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "list", "of", "templates", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L181-L186
train
CodeMommy/CookiePHP
source/Cookie.php
Cookie.clear
public static function clear() { $isClearAll = true; if ($_COOKIE) { foreach ($_COOKIE as $key => $value) { $result = self::delete($key); if (!$result) { $isClearAll = false; } } } return $isClearAll; }
php
public static function clear() { $isClearAll = true; if ($_COOKIE) { foreach ($_COOKIE as $key => $value) { $result = self::delete($key); if (!$result) { $isClearAll = false; } } } return $isClearAll; }
[ "public", "static", "function", "clear", "(", ")", "{", "$", "isClearAll", "=", "true", ";", "if", "(", "$", "_COOKIE", ")", "{", "foreach", "(", "$", "_COOKIE", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "=", "self", "::", "d...
Clear all cookies @param void @return bool
[ "Clear", "all", "cookies" ]
fc1a018db015299807c218be43383b8753bbe814
https://github.com/CodeMommy/CookiePHP/blob/fc1a018db015299807c218be43383b8753bbe814/source/Cookie.php#L83-L95
train
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.disableAction
public function disableAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('CoreExtraBundle:Actor')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Actor entity.'); } $user = $this->get('security.token_storage')->getToken()->getUser(); if (!$user->isGranted('ROLE_ADMIN')) { return $this->redirect($this->generateUrl('coreextra_newsletter_index')); } $entity->setNewsletter(false); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.subscripts.disable'); return $this->redirect($this->generateUrl('coreextra_newsletter_subscription')); }
php
public function disableAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('CoreExtraBundle:Actor')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Actor entity.'); } $user = $this->get('security.token_storage')->getToken()->getUser(); if (!$user->isGranted('ROLE_ADMIN')) { return $this->redirect($this->generateUrl('coreextra_newsletter_index')); } $entity->setNewsletter(false); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.subscripts.disable'); return $this->redirect($this->generateUrl('coreextra_newsletter_subscription')); }
[ "public", "function", "disableAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Actor $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'Core...
Edits an existing Subscriptors entity. @param Request $request The request @param int $id The entity id @throws NotFoundHttpException @return array|RedirectResponse @Route("/subscription/{id}/disable")
[ "Edits", "an", "existing", "Subscriptors", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L75-L98
train
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.showAction
public function showAction(Newsletter $newsletter) { $deleteForm = $this->createDeleteForm($newsletter); return array( 'entity' => $newsletter, 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction(Newsletter $newsletter) { $deleteForm = $this->createDeleteForm($newsletter); return array( 'entity' => $newsletter, 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "Newsletter", "$", "newsletter", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "newsletter", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "newsletter", ",", "'delete_fo...
Finds and displays a Newsletter entity. @Route("/newsletter/{id}") @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "Newsletter", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L184-L192
train
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.newShippingAction
public function newShippingAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new NewsletterShipping(); $data = $request->request->get('corebundle_newslettershippingtype'); $formConfig = array(); if(isset($data['type']) && $data['type'] == 'token'){ $formConfig['token'] = true; } $form = $this->createForm('CoreExtraBundle\Form\NewsletterShippingType', $entity, $formConfig); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $emailArray = $this->get('core_manager')->getSubscriptorFromType($entity); $entity->setTotalSent(count($emailArray)); ///////////////////////////////////////////////////////// //Send every email with diferent token and store on DB // ///////////////////////////////////////////////////////// if($entity->getType() == NewsletterShipping::TYPE_TOKEN){ //truncate table email token $em = $this->getDoctrine()->getEntityManager(); $connection = $em->getConnection(); $statement = $connection->prepare("TRUNCATE TABLE email_token"); $statement->execute(); foreach ($emailArray as $email) { $emailToken = new EmailToken(); $emailToken->setEmail($email); $token = sha1(uniqid()); $emailToken->setToken($token); $em->persist($emailToken); $body = preg_replace('/(#TOKEN#)/', $token, $entity->getNewsletter()->getBody()); $this->get('core.mailer')->sendShipping(array($email), NewsletterShipping::TYPE_TOKEN, $body); } }else{ $body = $entity->getNewsletter()->getBody(); $this->get('core.mailer')->sendShipping($emailArray, $entity->getType(), $body); } $em->persist($entity); $em->flush(); //if come from popup if ($request->isXMLHttpRequest()) { return new JsonResponse(array( 'id' => $entity->getId() )); } $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.created'); return $this->redirect($this->generateUrl('coreextra_newsletter_showshipping', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newShippingAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new NewsletterShipping(); $data = $request->request->get('corebundle_newslettershippingtype'); $formConfig = array(); if(isset($data['type']) && $data['type'] == 'token'){ $formConfig['token'] = true; } $form = $this->createForm('CoreExtraBundle\Form\NewsletterShippingType', $entity, $formConfig); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $emailArray = $this->get('core_manager')->getSubscriptorFromType($entity); $entity->setTotalSent(count($emailArray)); ///////////////////////////////////////////////////////// //Send every email with diferent token and store on DB // ///////////////////////////////////////////////////////// if($entity->getType() == NewsletterShipping::TYPE_TOKEN){ //truncate table email token $em = $this->getDoctrine()->getEntityManager(); $connection = $em->getConnection(); $statement = $connection->prepare("TRUNCATE TABLE email_token"); $statement->execute(); foreach ($emailArray as $email) { $emailToken = new EmailToken(); $emailToken->setEmail($email); $token = sha1(uniqid()); $emailToken->setToken($token); $em->persist($emailToken); $body = preg_replace('/(#TOKEN#)/', $token, $entity->getNewsletter()->getBody()); $this->get('core.mailer')->sendShipping(array($email), NewsletterShipping::TYPE_TOKEN, $body); } }else{ $body = $entity->getNewsletter()->getBody(); $this->get('core.mailer')->sendShipping($emailArray, $entity->getType(), $body); } $em->persist($entity); $em->flush(); //if come from popup if ($request->isXMLHttpRequest()) { return new JsonResponse(array( 'id' => $entity->getId() )); } $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.created'); return $this->redirect($this->generateUrl('coreextra_newsletter_showshipping', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newShippingAction", "(", "Request", "$", "request", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "entity", "=", "new", "NewsletterShipping", "(", ")", ";", "$", "da...
Creates a new Shipping entity. @param Request $request The request @return array|RedirectResponse @Route("/shipping/new") @Method({"GET", "POST"}) @Template("CoreExtraBundle:Newsletter/Shipping:new.html.twig")
[ "Creates", "a", "new", "Shipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L340-L399
train
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.showShippingAction
public function showShippingAction(NewsletterShipping $newsletterShipping) { $deleteForm = $this->createNShippingDeleteForm($newsletterShipping); return array( 'entity' => $newsletterShipping, 'delete_form' => $deleteForm->createView(), ); }
php
public function showShippingAction(NewsletterShipping $newsletterShipping) { $deleteForm = $this->createNShippingDeleteForm($newsletterShipping); return array( 'entity' => $newsletterShipping, 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showShippingAction", "(", "NewsletterShipping", "$", "newsletterShipping", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createNShippingDeleteForm", "(", "$", "newsletterShipping", ")", ";", "return", "array", "(", "'entity'", "=>", ...
Finds and displays a NewsletterShipping entity. @Route("/shipping/{id}") @Method("GET") @Template("CoreExtraBundle:Newsletter/Shipping:show.html.twig")
[ "Finds", "and", "displays", "a", "NewsletterShipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L408-L416
train
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.deleteShippingAction
public function deleteShippingAction(Request $request, NewsletterShipping $newsletterShipping) { $em = $this->getDoctrine()->getManager(); $em->remove($newsletterShipping); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.deleted'); if($request->query->get('redirect')!=''){ return $this->redirect($request->query->get('redirect')); } return $this->redirect($this->generateUrl('coreextra_newsletter_shipping')); }
php
public function deleteShippingAction(Request $request, NewsletterShipping $newsletterShipping) { $em = $this->getDoctrine()->getManager(); $em->remove($newsletterShipping); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.deleted'); if($request->query->get('redirect')!=''){ return $this->redirect($request->query->get('redirect')); } return $this->redirect($this->generateUrl('coreextra_newsletter_shipping')); }
[ "public", "function", "deleteShippingAction", "(", "Request", "$", "request", ",", "NewsletterShipping", "$", "newsletterShipping", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "r...
Deletes a NewsletterShipping entity. @param Request $request The request @param int $id The entity id @throws NotFoundHttpException @return RedirectResponse @Route("/shipping/{id}/delete")
[ "Deletes", "a", "NewsletterShipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L430-L443
train
phpffcms/ffcms-console
src/Command.php
Command.ask
public function ask($question, $default = null) { $que = new Question($question, $default); $helper = new SymfonyQuestionHelper(); return $helper->ask($this->input, $this->output, $que); }
php
public function ask($question, $default = null) { $que = new Question($question, $default); $helper = new SymfonyQuestionHelper(); return $helper->ask($this->input, $this->output, $que); }
[ "public", "function", "ask", "(", "$", "question", ",", "$", "default", "=", "null", ")", "{", "$", "que", "=", "new", "Question", "(", "$", "question", ",", "$", "default", ")", ";", "$", "helper", "=", "new", "SymfonyQuestionHelper", "(", ")", ";",...
Ask string param from stdin php input @param string $question @param string|null $default @return string
[ "Ask", "string", "param", "from", "stdin", "php", "input" ]
da5a37a34c29d256ea0f2835a44c01178c53922b
https://github.com/phpffcms/ffcms-console/blob/da5a37a34c29d256ea0f2835a44c01178c53922b/src/Command.php#L41-L46
train
phpffcms/ffcms-console
src/Command.php
Command.optionOrAsk
public function optionOrAsk($option, $question, $default = null) { $value = $this->input->getOption($option); if ($value === null || Str::likeEmpty($value)) { $value = $this->ask($question, $default); } return $value; }
php
public function optionOrAsk($option, $question, $default = null) { $value = $this->input->getOption($option); if ($value === null || Str::likeEmpty($value)) { $value = $this->ask($question, $default); } return $value; }
[ "public", "function", "optionOrAsk", "(", "$", "option", ",", "$", "question", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "input", "->", "getOption", "(", "$", "option", ")", ";", "if", "(", "$", "value", "===...
Get input option value or ask it if empty @param string $option @param string $question @param string|null $default @return string
[ "Get", "input", "option", "value", "or", "ask", "it", "if", "empty" ]
da5a37a34c29d256ea0f2835a44c01178c53922b
https://github.com/phpffcms/ffcms-console/blob/da5a37a34c29d256ea0f2835a44c01178c53922b/src/Command.php#L81-L89
train
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/Util.php
Util.post
public static function post($url, $payload, $contentType = 'Content-Type: application/json') { // TODO move constants to global configuration file $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ( $contentType, 'Content-Length: ' . strlen ( $payload ) ) ); $result = curl_exec ( $ch ); return $result; }
php
public static function post($url, $payload, $contentType = 'Content-Type: application/json') { // TODO move constants to global configuration file $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ( $contentType, 'Content-Length: ' . strlen ( $payload ) ) ); $result = curl_exec ( $ch ); return $result; }
[ "public", "static", "function", "post", "(", "$", "url", ",", "$", "payload", ",", "$", "contentType", "=", "'Content-Type: application/json'", ")", "{", "// TODO move constants to global configuration file", "$", "ch", "=", "curl_init", "(", "$", "url", ")", ";",...
Function to post a payload to a url using cURL. @param string $url @param string $payload @param string $contentType @return mixed the result of the curl execution.
[ "Function", "to", "post", "a", "payload", "to", "a", "url", "using", "cURL", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/Util.php#L22-L34
train
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/Util.php
Util.createField
public static function createField($title, $value, $short = true) { $field = new SlackResultAttachmentField (); $field->setTitle ( $title ); $field->setValue ( $value ); $field->setShort ( $short ); return $field; }
php
public static function createField($title, $value, $short = true) { $field = new SlackResultAttachmentField (); $field->setTitle ( $title ); $field->setValue ( $value ); $field->setShort ( $short ); return $field; }
[ "public", "static", "function", "createField", "(", "$", "title", ",", "$", "value", ",", "$", "short", "=", "true", ")", "{", "$", "field", "=", "new", "SlackResultAttachmentField", "(", ")", ";", "$", "field", "->", "setTitle", "(", "$", "title", ")"...
Returns a \SlackHookFramework\SlackResultAttachmentField instance with the given values. @param string $title @param string $value @param boolean $short If true, returns a "short" field. Slack can render two short fields in two columns, or a "long" field ($short = false) in a single column. @return \SlackHookFramework\SlackResultAttachmentField
[ "Returns", "a", "\\", "SlackHookFramework", "\\", "SlackResultAttachmentField", "instance", "with", "the", "given", "values", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/Util.php#L102-L108
train
samurai-fw/samurai
src/Samurai/Component/Core/Framework.php
Framework.initContainer
private function initContainer() { $dicons = (array)$this->app->config('container.dicon'); $container = ContainerFactory::create(); foreach ($dicons as $dicon) { $file = $this->app->getLoader()->find($dicon)->first(); $container->import($file); } $container->register('framework', $this); $container->register('application', $this->app); $container->register('loader', $this->app->getLoader()); $this->setContainer($container); $this->app->setContainer($container); // callback foreach ((array)$this->app->config('container.callback.initialized') as $callback) { $callback($container); } }
php
private function initContainer() { $dicons = (array)$this->app->config('container.dicon'); $container = ContainerFactory::create(); foreach ($dicons as $dicon) { $file = $this->app->getLoader()->find($dicon)->first(); $container->import($file); } $container->register('framework', $this); $container->register('application', $this->app); $container->register('loader', $this->app->getLoader()); $this->setContainer($container); $this->app->setContainer($container); // callback foreach ((array)$this->app->config('container.callback.initialized') as $callback) { $callback($container); } }
[ "private", "function", "initContainer", "(", ")", "{", "$", "dicons", "=", "(", "array", ")", "$", "this", "->", "app", "->", "config", "(", "'container.dicon'", ")", ";", "$", "container", "=", "ContainerFactory", "::", "create", "(", ")", ";", "foreach...
initialize container. @access private
[ "initialize", "container", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/Framework.php#L132-L152
train
gossi/trixionary
src/model/Base/Video.php
Video.setReference
public function setReference(ChildReference $v = null) { if ($v === null) { $this->setReferenceId(NULL); } else { $this->setReferenceId($v->getId()); } $this->aReference = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildReference object, it will not be re-added. if ($v !== null) { $v->addVideo($this); } return $this; }
php
public function setReference(ChildReference $v = null) { if ($v === null) { $this->setReferenceId(NULL); } else { $this->setReferenceId($v->getId()); } $this->aReference = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildReference object, it will not be re-added. if ($v !== null) { $v->addVideo($this); } return $this; }
[ "public", "function", "setReference", "(", "ChildReference", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setReferenceId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setReference...
Declares an association between this object and a ChildReference object. @param ChildReference $v @return $this|\gossi\trixionary\model\Video The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "ChildReference", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2066-L2084
train
gossi/trixionary
src/model/Base/Video.php
Video.getReference
public function getReference(ConnectionInterface $con = null) { if ($this->aReference === null && ($this->reference_id !== null)) { $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aReference->addVideos($this); */ } return $this->aReference; }
php
public function getReference(ConnectionInterface $con = null) { if ($this->aReference === null && ($this->reference_id !== null)) { $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aReference->addVideos($this); */ } return $this->aReference; }
[ "public", "function", "getReference", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aReference", "===", "null", "&&", "(", "$", "this", "->", "reference_id", "!==", "null", ")", ")", "{", "$", "this", "->...
Get the associated ChildReference object @param ConnectionInterface $con Optional Connection object. @return ChildReference The associated ChildReference object. @throws PropelException
[ "Get", "the", "associated", "ChildReference", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2094-L2108
train
gossi/trixionary
src/model/Base/Video.php
Video.initFeaturedTutorialSkills
public function initFeaturedTutorialSkills($overrideExisting = true) { if (null !== $this->collFeaturedTutorialSkills && !$overrideExisting) { return; } $this->collFeaturedTutorialSkills = new ObjectCollection(); $this->collFeaturedTutorialSkills->setModel('\gossi\trixionary\model\Skill'); }
php
public function initFeaturedTutorialSkills($overrideExisting = true) { if (null !== $this->collFeaturedTutorialSkills && !$overrideExisting) { return; } $this->collFeaturedTutorialSkills = new ObjectCollection(); $this->collFeaturedTutorialSkills->setModel('\gossi\trixionary\model\Skill'); }
[ "public", "function", "initFeaturedTutorialSkills", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collFeaturedTutorialSkills", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", ...
Initializes the collFeaturedTutorialSkills collection. By default this just sets the collFeaturedTutorialSkills collection to an empty array (like clearcollFeaturedTutorialSkills()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collFeaturedTutorialSkills", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2606-L2613
train
gossi/trixionary
src/model/Base/Video.php
Video.getFeaturedTutorialSkillsJoinSport
public function getFeaturedTutorialSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getFeaturedTutorialSkills($query, $con); }
php
public function getFeaturedTutorialSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getFeaturedTutorialSkills($query, $con); }
[ "public", "function", "getFeaturedTutorialSkillsJoinSport", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkill...
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Video is new, it will return an empty collection; or if this Video has previously been saved, it will retrieve related FeaturedTutorialSkills from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Video. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Video", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", ...
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2807-L2813
train
hermajan/lib
src/services/Gravatar.php
Gravatar.createURL
public function createURL() { $url = "https://secure.gravatar.com/avatar/".$this->createHash(); $url = $url."?s=".$this->size."&d=".$this->default."&r=".$this->rating; if($this->forceDefault == true) { $url = $url.'&f=y'; } return $url; }
php
public function createURL() { $url = "https://secure.gravatar.com/avatar/".$this->createHash(); $url = $url."?s=".$this->size."&d=".$this->default."&r=".$this->rating; if($this->forceDefault == true) { $url = $url.'&f=y'; } return $url; }
[ "public", "function", "createURL", "(", ")", "{", "$", "url", "=", "\"https://secure.gravatar.com/avatar/\"", ".", "$", "this", "->", "createHash", "(", ")", ";", "$", "url", "=", "$", "url", ".", "\"?s=\"", ".", "$", "this", "->", "size", ".", "\"&d=\""...
Creates URL of a gravatar image. @return string Image URL.
[ "Creates", "URL", "of", "a", "gravatar", "image", "." ]
7d666260f5bcee041f130a3c3100f520b5e4bbd2
https://github.com/hermajan/lib/blob/7d666260f5bcee041f130a3c3100f520b5e4bbd2/src/services/Gravatar.php#L79-L87
train
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.css
public function css( $cssClasses ) { if ( ! $cssClasses ) { return $this; } $cssClasses = explode( ' ', $cssClasses ); foreach ( $cssClasses as $cssClass ) { if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) ) { $this->cssClasses[] = $cssClass; } } return $this; }
php
public function css( $cssClasses ) { if ( ! $cssClasses ) { return $this; } $cssClasses = explode( ' ', $cssClasses ); foreach ( $cssClasses as $cssClass ) { if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) ) { $this->cssClasses[] = $cssClass; } } return $this; }
[ "public", "function", "css", "(", "$", "cssClasses", ")", "{", "if", "(", "!", "$", "cssClasses", ")", "{", "return", "$", "this", ";", "}", "$", "cssClasses", "=", "explode", "(", "' '", ",", "$", "cssClasses", ")", ";", "foreach", "(", "$", "cssC...
Add a CSS class to the element. Multiple classes can be passed as a space-separated string. @param $cssClasses @return $this
[ "Add", "a", "CSS", "class", "to", "the", "element", ".", "Multiple", "classes", "can", "be", "passed", "as", "a", "space", "-", "separated", "string", "." ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L129-L147
train
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.ghost
public function ghost( $ghostValue ) { if ( $this->isCheckbox() ) { $this->ghostCheckboxValue = $ghostValue; $this->avoidGhost = ( null === $ghostValue ); } return $this; }
php
public function ghost( $ghostValue ) { if ( $this->isCheckbox() ) { $this->ghostCheckboxValue = $ghostValue; $this->avoidGhost = ( null === $ghostValue ); } return $this; }
[ "public", "function", "ghost", "(", "$", "ghostValue", ")", "{", "if", "(", "$", "this", "->", "isCheckbox", "(", ")", ")", "{", "$", "this", "->", "ghostCheckboxValue", "=", "$", "ghostValue", ";", "$", "this", "->", "avoidGhost", "=", "(", "null", ...
Set the "ghost value" for the checkbox. @see $ghostCheckboxValue @param $ghostValue
[ "Set", "the", "ghost", "value", "for", "the", "checkbox", "." ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L256-L265
train
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.getGhost
protected function getGhost() { // A value is set for this checkbox, use it if ( null !== $this->ghostCheckboxValue ) { return $this->ghostCheckboxValue; } // No value is set, and it is not forced to null, so use default ghost (if any) if ( ! $this->avoidGhost ) { return config( 'blade-materialize.checkbox_ghost' ); } // No value is set, user didn't force ghost return null; }
php
protected function getGhost() { // A value is set for this checkbox, use it if ( null !== $this->ghostCheckboxValue ) { return $this->ghostCheckboxValue; } // No value is set, and it is not forced to null, so use default ghost (if any) if ( ! $this->avoidGhost ) { return config( 'blade-materialize.checkbox_ghost' ); } // No value is set, user didn't force ghost return null; }
[ "protected", "function", "getGhost", "(", ")", "{", "// A value is set for this checkbox, use it", "if", "(", "null", "!==", "$", "this", "->", "ghostCheckboxValue", ")", "{", "return", "$", "this", "->", "ghostCheckboxValue", ";", "}", "// No value is set, and it is ...
Return the checkbox ghost value, or null if there is no ghost value;
[ "Return", "the", "checkbox", "ghost", "value", "or", "null", "if", "there", "is", "no", "ghost", "value", ";" ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L270-L284
train
mauretto78/in-memory-list
src/InMemoryList/Infrastructure/Persistance/PdoRepository.php
PdoRepository.createSchema
public function createSchema() { $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query); $query2 = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) NOT NULL, `list` varchar(255) NOT NULL, `body` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`), CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'.self::LIST_COLLECTION_TABLE_NAME.'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query2); }
php
public function createSchema() { $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query); $query2 = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) NOT NULL, `list` varchar(255) NOT NULL, `body` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`), CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'.self::LIST_COLLECTION_TABLE_NAME.'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query2); }
[ "public", "function", "createSchema", "(", ")", "{", "$", "query", "=", "'CREATE TABLE IF NOT EXISTS `'", ".", "self", "::", "LIST_COLLECTION_TABLE_NAME", ".", "'` (\n `id` int NOT NULL AUTO_INCREMENT,\n `uuid` varchar(255) UNIQUE NOT NULL,\n `headers` text D...
creates database schema.
[ "creates", "database", "schema", "." ]
8c916641be09b2bc9adcf670bbc17906fea67727
https://github.com/mauretto78/in-memory-list/blob/8c916641be09b2bc9adcf670bbc17906fea67727/src/InMemoryList/Infrastructure/Persistance/PdoRepository.php#L411-L436
train
SagePHP/System
src/SagePHP/System/Hostname.php
Hostname.get
public function get() { $exec = $this->getExecutor(); $exec->setCommand('hostname'); $exec->run(); $output = $exec->getOutput(); return $output['stdout']; }
php
public function get() { $exec = $this->getExecutor(); $exec->setCommand('hostname'); $exec->run(); $output = $exec->getOutput(); return $output['stdout']; }
[ "public", "function", "get", "(", ")", "{", "$", "exec", "=", "$", "this", "->", "getExecutor", "(", ")", ";", "$", "exec", "->", "setCommand", "(", "'hostname'", ")", ";", "$", "exec", "->", "run", "(", ")", ";", "$", "output", "=", "$", "exec",...
returns the current hostname @return string
[ "returns", "the", "current", "hostname" ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Hostname.php#L42-L52
train
SagePHP/System
src/SagePHP/System/Hostname.php
Hostname.set
public function set($name) { $exec = $this->getExecutor(); $exec->setCommand('hostname ' . $name); $exec->run(); return $exec->hasErrors(); }
php
public function set($name) { $exec = $this->getExecutor(); $exec->setCommand('hostname ' . $name); $exec->run(); return $exec->hasErrors(); }
[ "public", "function", "set", "(", "$", "name", ")", "{", "$", "exec", "=", "$", "this", "->", "getExecutor", "(", ")", ";", "$", "exec", "->", "setCommand", "(", "'hostname '", ".", "$", "name", ")", ";", "$", "exec", "->", "run", "(", ")", ";", ...
sets the hostname @param string $name @return boolean true on success falsr otherwise
[ "sets", "the", "hostname" ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Hostname.php#L61-L68
train
orchestral/studio
src/Traits/PublishFiles.php
PublishFiles.publishFiles
protected function publishFiles(Filesystem $filesystem, array $paths, $force = false) { foreach ($paths as $from => $to) { if ($filesystem->isFile($from)) { $this->publishFile($filesystem, $from, $to, $force); } elseif ($filesystem->isDirectory($from)) { $this->publishDirectory($from, $to, $force); } else { $this->error("Can't locate path: <{$from}>"); } } }
php
protected function publishFiles(Filesystem $filesystem, array $paths, $force = false) { foreach ($paths as $from => $to) { if ($filesystem->isFile($from)) { $this->publishFile($filesystem, $from, $to, $force); } elseif ($filesystem->isDirectory($from)) { $this->publishDirectory($from, $to, $force); } else { $this->error("Can't locate path: <{$from}>"); } } }
[ "protected", "function", "publishFiles", "(", "Filesystem", "$", "filesystem", ",", "array", "$", "paths", ",", "$", "force", "=", "false", ")", "{", "foreach", "(", "$", "paths", "as", "$", "from", "=>", "$", "to", ")", "{", "if", "(", "$", "filesys...
Publish files. @param \Illuminate\Filesystem\Filesystem $filesystem @param array $paths @param bool $force @return void
[ "Publish", "files", "." ]
254d0d3296ff8b52cdb7f4eab2423fea2bcced3b
https://github.com/orchestral/studio/blob/254d0d3296ff8b52cdb7f4eab2423fea2bcced3b/src/Traits/PublishFiles.php#L21-L32
train
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.paths
public function paths(): void { $paths = $this->getConfigPaths(); WP_CLI::success(count($paths) . ' config files found.'); WP_CLI::success('The later ones override any previous configurations.'); foreach ($paths as $path) { WP_CLI::log($path); } }
php
public function paths(): void { $paths = $this->getConfigPaths(); WP_CLI::success(count($paths) . ' config files found.'); WP_CLI::success('The later ones override any previous configurations.'); foreach ($paths as $path) { WP_CLI::log($path); } }
[ "public", "function", "paths", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "WP_CLI", "::", "success", "(", "count", "(", "$", "paths", ")", ".", "' config files found.'", ")", ";", "WP_CLI", "::", ...
Gets the paths to all config files. ## EXAMPLES # Get preflight.toml file paths $ wp preflight config paths Success: 3 config files found. Success: The later ones override any previous configurations. /x/.wp-cli/packages/vendor/y/z/config/default.toml /app/public/preflight.toml /app/preflight.toml # When paths not found $ wp preflight config paths wp preflight config paths No config file found. Perhaps 'preflight_config_paths_register' not filtering properly? Error: Abort!
[ "Gets", "the", "paths", "to", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L37-L47
train
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.cat
public function cat(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Printing $path%n") ); // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown $contents = file_get_contents($path); $contentsWithoutLineBreaks = str_replace(["\r", "\n"], '', $contents); if (empty($contentsWithoutLineBreaks)) { WP_CLI::error_multi_line([ "File '$path' is empty.", ]); } WP_CLI::line($contents); // Print a empty line for better UX. WP_CLI::line(''); } }
php
public function cat(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Printing $path%n") ); // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown $contents = file_get_contents($path); $contentsWithoutLineBreaks = str_replace(["\r", "\n"], '', $contents); if (empty($contentsWithoutLineBreaks)) { WP_CLI::error_multi_line([ "File '$path' is empty.", ]); } WP_CLI::line($contents); // Print a empty line for better UX. WP_CLI::line(''); } }
[ "public", "function", "cat", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "WP_CLI", "::", "line", "(", "WP_CLI", "::", "colorize", "(",...
Prints the content of all config files. ## EXAMPLES # Print the content of all config files $ wp preflight config cat
[ "Prints", "the", "content", "of", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L80-L103
train
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.validate
public function validate(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Validating $path%n") ); try { Toml::parseFile($path); WP_CLI::success("File '$path' is valid."); } catch (ParseException $parseException) { WP_CLI::error_multi_line([ $parseException->getMessage(), ]); WP_CLI::warning("File '$path' will be ignored."); } // Print a empty line for better UX. WP_CLI::line(''); } }
php
public function validate(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Validating $path%n") ); try { Toml::parseFile($path); WP_CLI::success("File '$path' is valid."); } catch (ParseException $parseException) { WP_CLI::error_multi_line([ $parseException->getMessage(), ]); WP_CLI::warning("File '$path' will be ignored."); } // Print a empty line for better UX. WP_CLI::line(''); } }
[ "public", "function", "validate", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "WP_CLI", "::", "line", "(", "WP_CLI", "::", "colorize", ...
Validates the TOML syntax of all config files. ## EXAMPLES # Validate the TOML syntax of the config files $ wp preflight config validate
[ "Validates", "the", "TOML", "syntax", "of", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L113-L136
train
manacode/phalconlibs
Translate/NativeArray.php
NativeArray._
public function _($translateKey, $defaultTranslation = "", $placeholders = null) { $translation = $translateKey; if (is_array($defaultTranslation) && $placeholders === null) { $placeholders = $defaultTranslation; } else { if ($defaultTranslation!="") { $translation = $defaultTranslation; } } if ($this->exists($translateKey)) { $translation = $this->_translate[$translateKey]; } return $this->replacePlaceholders($translation, $placeholders); }
php
public function _($translateKey, $defaultTranslation = "", $placeholders = null) { $translation = $translateKey; if (is_array($defaultTranslation) && $placeholders === null) { $placeholders = $defaultTranslation; } else { if ($defaultTranslation!="") { $translation = $defaultTranslation; } } if ($this->exists($translateKey)) { $translation = $this->_translate[$translateKey]; } return $this->replacePlaceholders($translation, $placeholders); }
[ "public", "function", "_", "(", "$", "translateKey", ",", "$", "defaultTranslation", "=", "\"\"", ",", "$", "placeholders", "=", "null", ")", "{", "$", "translation", "=", "$", "translateKey", ";", "if", "(", "is_array", "(", "$", "defaultTranslation", ")"...
Returns the translation related to the given key
[ "Returns", "the", "translation", "related", "to", "the", "given", "key" ]
e60864ac8305dd95e6804e4894193e5255725a5e
https://github.com/manacode/phalconlibs/blob/e60864ac8305dd95e6804e4894193e5255725a5e/Translate/NativeArray.php#L26-L41
train
manacode/phalconlibs
Translate/NativeArray.php
NativeArray.setTranslation
public function setTranslation($translation) { if (is_array($translation)) { $this->_translate = array_merge($this->_translate, $translation); } }
php
public function setTranslation($translation) { if (is_array($translation)) { $this->_translate = array_merge($this->_translate, $translation); } }
[ "public", "function", "setTranslation", "(", "$", "translation", ")", "{", "if", "(", "is_array", "(", "$", "translation", ")", ")", "{", "$", "this", "->", "_translate", "=", "array_merge", "(", "$", "this", "->", "_translate", ",", "$", "translation", ...
Set translation data @param array $translation translation data
[ "Set", "translation", "data" ]
e60864ac8305dd95e6804e4894193e5255725a5e
https://github.com/manacode/phalconlibs/blob/e60864ac8305dd95e6804e4894193e5255725a5e/Translate/NativeArray.php#L66-L71
train
phossa2/libs
src/Phossa2/Cache/Extension/DistributedExpiration.php
DistributedExpiration.distributeExpire
public function distributeExpire(EventInterface $event)/*# : bool */ { $dist = $this->distribution; $item = $event->getParam('item'); if ($item instanceof CacheItemExtendedInterface) { // expire ttl $ttl = $item->getExpiration()->getTimestamp() - time(); // percentage $percent = (rand(0, $dist * 2) - $dist) * 0.001; // new expire ttl $new_ttl = (int) round($ttl + $ttl * $percent); $item->expiresAfter($new_ttl); } return true; }
php
public function distributeExpire(EventInterface $event)/*# : bool */ { $dist = $this->distribution; $item = $event->getParam('item'); if ($item instanceof CacheItemExtendedInterface) { // expire ttl $ttl = $item->getExpiration()->getTimestamp() - time(); // percentage $percent = (rand(0, $dist * 2) - $dist) * 0.001; // new expire ttl $new_ttl = (int) round($ttl + $ttl * $percent); $item->expiresAfter($new_ttl); } return true; }
[ "public", "function", "distributeExpire", "(", "EventInterface", "$", "event", ")", "/*# : bool */", "{", "$", "dist", "=", "$", "this", "->", "distribution", ";", "$", "item", "=", "$", "event", "->", "getParam", "(", "'item'", ")", ";", "if", "(", "$",...
Evenly distribute the expiration time @param EventInterface $event @return bool @access public
[ "Evenly", "distribute", "the", "expiration", "time" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/DistributedExpiration.php#L86-L104
train
mtoolkit/mtoolkit-core
src/MDir.php
MDir.count
public function count(): int { if ($this->count == null) { $this->count = 0; if ($handle = opendir($this->fileInfo->getAbsoluteFilePath())) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..'))) { $this->count++; } } closedir($handle); } } return $this->count; }
php
public function count(): int { if ($this->count == null) { $this->count = 0; if ($handle = opendir($this->fileInfo->getAbsoluteFilePath())) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..'))) { $this->count++; } } closedir($handle); } } return $this->count; }
[ "public", "function", "count", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "count", "==", "null", ")", "{", "$", "this", "->", "count", "=", "0", ";", "if", "(", "$", "handle", "=", "opendir", "(", "$", "this", "->", "fileInfo", "-...
Returns the total number of directories and files in the directory. @return int
[ "Returns", "the", "total", "number", "of", "directories", "and", "files", "in", "the", "directory", "." ]
66c53273288a8652ff38240e063bdcffdf7c30aa
https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MDir.php#L146-L163
train
puli/asset-plugin
src/Api/Installer/NoSuchInstallerException.php
NoSuchInstallerException.forInstallerNameAndPackageName
public static function forInstallerNameAndPackageName($installerName, $packageName, Exception $cause = null) { return new static(sprintf( 'The installer "%s" does not exist in package "%s".', $installerName, $packageName ), 0, $cause); }
php
public static function forInstallerNameAndPackageName($installerName, $packageName, Exception $cause = null) { return new static(sprintf( 'The installer "%s" does not exist in package "%s".', $installerName, $packageName ), 0, $cause); }
[ "public", "static", "function", "forInstallerNameAndPackageName", "(", "$", "installerName", ",", "$", "packageName", ",", "Exception", "$", "cause", "=", "null", ")", "{", "return", "new", "static", "(", "sprintf", "(", "'The installer \"%s\" does not exist in packag...
Creates an exception for an installer name that was not found in a given package. @param string $installerName The installer name. @param string $packageName The package name. @param Exception $cause The exception that caused this exception. @return static The created exception.
[ "Creates", "an", "exception", "for", "an", "installer", "name", "that", "was", "not", "found", "in", "a", "given", "package", "." ]
f36c4a403a2173aced54376690a399884cde2627
https://github.com/puli/asset-plugin/blob/f36c4a403a2173aced54376690a399884cde2627/src/Api/Installer/NoSuchInstallerException.php#L50-L57
train