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
magdev/php-assimp
src/Command/Result.php
Result.setParsed
public function setParsed(bool $parsed = true): Result { $this->parsed = (boolean) $parsed; return $this; }
php
public function setParsed(bool $parsed = true): Result { $this->parsed = (boolean) $parsed; return $this; }
[ "public", "function", "setParsed", "(", "bool", "$", "parsed", "=", "true", ")", ":", "Result", "{", "$", "this", "->", "parsed", "=", "(", "boolean", ")", "$", "parsed", ";", "return", "$", "this", ";", "}" ]
Mark the output as parsed @param boolean $parsed @return \Assimp\Command\Result
[ "Mark", "the", "output", "as", "parsed" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Result.php#L271-L275
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request.php
Request.forge
public static function forge($uri = null, $options = true, $method = null) { is_bool($options) and $options = array('route' => $options); is_string($options) and $options = array('driver' => $options); if ( ! empty($options['driver'])) { $class = \Inflector::words_to_upper('Request_'.$options['driver']); return $class::forge($uri, $options, $method); } $request = new static($uri, isset($options['route']) ? $options['route'] : true, $method); if (static::$active) { $request->parent = static::$active; static::$active->children[] = $request; } // fire any request created events \Event::instance()->has_events('request_created') and \Event::instance()->trigger('request_created', '', 'none'); return $request; }
php
public static function forge($uri = null, $options = true, $method = null) { is_bool($options) and $options = array('route' => $options); is_string($options) and $options = array('driver' => $options); if ( ! empty($options['driver'])) { $class = \Inflector::words_to_upper('Request_'.$options['driver']); return $class::forge($uri, $options, $method); } $request = new static($uri, isset($options['route']) ? $options['route'] : true, $method); if (static::$active) { $request->parent = static::$active; static::$active->children[] = $request; } // fire any request created events \Event::instance()->has_events('request_created') and \Event::instance()->trigger('request_created', '', 'none'); return $request; }
[ "public", "static", "function", "forge", "(", "$", "uri", "=", "null", ",", "$", "options", "=", "true", ",", "$", "method", "=", "null", ")", "{", "is_bool", "(", "$", "options", ")", "and", "$", "options", "=", "array", "(", "'route'", "=>", "$",...
Generates a new request. The request is then set to be the active request. If this is the first request, then save that as the main request for the app. Usage: Request::forge('hello/world'); @param string The URI of the request @param mixed Internal: whether to use the routes; external: driver type or array with settings (driver key must be set) @param string request method @return Request The new request object
[ "Generates", "a", "new", "request", ".", "The", "request", "is", "then", "set", "to", "be", "the", "active", "request", ".", "If", "this", "is", "the", "first", "request", "then", "save", "that", "as", "the", "main", "request", "for", "the", "app", "."...
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L59-L81
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request.php
Request.reset_request
public static function reset_request($full = false) { // Let's make the previous Request active since we are done executing this one. static::$active and static::$active = static::$active->parent(); if ($full) { static::$main = null; } }
php
public static function reset_request($full = false) { // Let's make the previous Request active since we are done executing this one. static::$active and static::$active = static::$active->parent(); if ($full) { static::$main = null; } }
[ "public", "static", "function", "reset_request", "(", "$", "full", "=", "false", ")", "{", "// Let's make the previous Request active since we are done executing this one.", "static", "::", "$", "active", "and", "static", "::", "$", "active", "=", "static", "::", "$",...
Reset's the active request with the previous one. This is needed after the active request is finished. Usage: Request::reset_request(); @return void
[ "Reset", "s", "the", "active", "request", "with", "the", "previous", "one", ".", "This", "is", "needed", "after", "the", "active", "request", "is", "finished", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L146-L155
train
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/request.php
Request.param
public function param($param, $default = null) { if ( ! isset($this->named_params[$param])) { return \Fuel::value($default); } return $this->named_params[$param]; }
php
public function param($param, $default = null) { if ( ! isset($this->named_params[$param])) { return \Fuel::value($default); } return $this->named_params[$param]; }
[ "public", "function", "param", "(", "$", "param", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "named_params", "[", "$", "param", "]", ")", ")", "{", "return", "\\", "Fuel", "::", "value", "(", "$",...
Gets a specific named parameter @param string $param Name of the parameter @param mixed $default Default value @return mixed
[ "Gets", "a", "specific", "named", "parameter" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L587-L595
train
canis-io/yii2-canis-lib
lib/web/grid/Cell.php
Cell.getClasses
public function getClasses() { $classes = []; $sizes = $this->sizes; if (isset($sizes['phone'])) { $classes[] = 'col-xs-' . $sizes['phone']; } if (isset($sizes['tablet'])) { $classes[] = 'col-sm-' . $sizes['tablet']; } if (isset($sizes['mediumDesktop'])) { $classes[] = 'col-md-' . $sizes['mediumDesktop']; } if (isset($sizes['largeDesktop'])) { $classes[] = 'col-lg-' . $sizes['largeDesktop']; } return implode(' ', $classes); }
php
public function getClasses() { $classes = []; $sizes = $this->sizes; if (isset($sizes['phone'])) { $classes[] = 'col-xs-' . $sizes['phone']; } if (isset($sizes['tablet'])) { $classes[] = 'col-sm-' . $sizes['tablet']; } if (isset($sizes['mediumDesktop'])) { $classes[] = 'col-md-' . $sizes['mediumDesktop']; } if (isset($sizes['largeDesktop'])) { $classes[] = 'col-lg-' . $sizes['largeDesktop']; } return implode(' ', $classes); }
[ "public", "function", "getClasses", "(", ")", "{", "$", "classes", "=", "[", "]", ";", "$", "sizes", "=", "$", "this", "->", "sizes", ";", "if", "(", "isset", "(", "$", "sizes", "[", "'phone'", "]", ")", ")", "{", "$", "classes", "[", "]", "=",...
Get classes. @return [[@doctodo return_type:getClasses]] [[@doctodo return_description:getClasses]]
[ "Get", "classes", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L203-L221
train
canis-io/yii2-canis-lib
lib/web/grid/Cell.php
Cell.getSizes
public function getSizes() { $sizes = []; if ($this->phoneSize === 'auto') { $sizes['phone'] = $this->generatePhoneSize(); } elseif ($this->phoneSize === true && $this->hasPhoneColumns) { $sizes['phone'] = $this->phoneColumns; } if ($this->tabletSize === 'auto') { $sizes['tablet'] = $this->generateTabletSize(); } elseif ($this->tabletSize === true && $this->hasTabletColumns) { $sizes['tablet'] = $this->tabletColumns; } if ($this->mediumDesktopSize === 'auto') { $sizes['mediumDesktop'] = $this->generateMediumDesktopSize(); } elseif ($this->mediumDesktopSize === true && $this->hasMediumDesktopColumns) { $sizes['mediumDesktop'] = $this->mediumDesktopColumns; } if ($this->largeDesktopSize === 'auto') { $sizes['largeDesktop'] = $this->generateLargeDesktopSize(); } elseif ($this->largeDesktopSize === true && $this->hasLargeDesktopColumns) { $sizes['largeDesktop'] = $this->largeDesktopColumns; } return $sizes; }
php
public function getSizes() { $sizes = []; if ($this->phoneSize === 'auto') { $sizes['phone'] = $this->generatePhoneSize(); } elseif ($this->phoneSize === true && $this->hasPhoneColumns) { $sizes['phone'] = $this->phoneColumns; } if ($this->tabletSize === 'auto') { $sizes['tablet'] = $this->generateTabletSize(); } elseif ($this->tabletSize === true && $this->hasTabletColumns) { $sizes['tablet'] = $this->tabletColumns; } if ($this->mediumDesktopSize === 'auto') { $sizes['mediumDesktop'] = $this->generateMediumDesktopSize(); } elseif ($this->mediumDesktopSize === true && $this->hasMediumDesktopColumns) { $sizes['mediumDesktop'] = $this->mediumDesktopColumns; } if ($this->largeDesktopSize === 'auto') { $sizes['largeDesktop'] = $this->generateLargeDesktopSize(); } elseif ($this->largeDesktopSize === true && $this->hasLargeDesktopColumns) { $sizes['largeDesktop'] = $this->largeDesktopColumns; } return $sizes; }
[ "public", "function", "getSizes", "(", ")", "{", "$", "sizes", "=", "[", "]", ";", "if", "(", "$", "this", "->", "phoneSize", "===", "'auto'", ")", "{", "$", "sizes", "[", "'phone'", "]", "=", "$", "this", "->", "generatePhoneSize", "(", ")", ";", ...
Get sizes. @return [[@doctodo return_type:getSizes]] [[@doctodo return_description:getSizes]]
[ "Get", "sizes", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L228-L253
train
canis-io/yii2-canis-lib
lib/web/grid/Cell.php
Cell.getMaxColumns
public function getMaxColumns($size = null) { if (is_object($this->content) && property_exists($this->content, 'maxColumns') && !is_null($this->content->maxColumns)) { return $this->content->maxColumns; } if (is_null($size)) { $size = $this->baseSize; } $columnAttribute = 'max' . ucfirst($size) . 'Columns'; return $this->{$columnAttribute}; }
php
public function getMaxColumns($size = null) { if (is_object($this->content) && property_exists($this->content, 'maxColumns') && !is_null($this->content->maxColumns)) { return $this->content->maxColumns; } if (is_null($size)) { $size = $this->baseSize; } $columnAttribute = 'max' . ucfirst($size) . 'Columns'; return $this->{$columnAttribute}; }
[ "public", "function", "getMaxColumns", "(", "$", "size", "=", "null", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "content", ")", "&&", "property_exists", "(", "$", "this", "->", "content", ",", "'maxColumns'", ")", "&&", "!", "is_null", ...
Get max columns. @param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional] @return [[@doctodo return_type:getMaxColumns]] [[@doctodo return_description:getMaxColumns]]
[ "Get", "max", "columns", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L318-L329
train
canis-io/yii2-canis-lib
lib/web/grid/Cell.php
Cell.setMaxColumns
public function setMaxColumns($columns, $size = null) { if (is_null($size)) { $size = $this->baseSize; } $columnAttribute = 'max' . ucfirst($size) . 'Columns'; $this->{$columnAttribute} = $columns; }
php
public function setMaxColumns($columns, $size = null) { if (is_null($size)) { $size = $this->baseSize; } $columnAttribute = 'max' . ucfirst($size) . 'Columns'; $this->{$columnAttribute} = $columns; }
[ "public", "function", "setMaxColumns", "(", "$", "columns", ",", "$", "size", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "size", ")", ")", "{", "$", "size", "=", "$", "this", "->", "baseSize", ";", "}", "$", "columnAttribute", "=", "'ma...
Set max columns. @param [[@doctodo param_type:columns]] $columns [[@doctodo param_description:columns]] @param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional]
[ "Set", "max", "columns", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L337-L344
train
canis-io/yii2-canis-lib
lib/web/grid/Cell.php
Cell.getFlex
public function getFlex($size = null) { if (is_null($size)) { $size = $this->baseSize; } $getter = $size . 'Columns'; $flex = $this->getMaxColumns($size) - $this->{$getter}; if ($flex < 0) { return 0; } return $flex; }
php
public function getFlex($size = null) { if (is_null($size)) { $size = $this->baseSize; } $getter = $size . 'Columns'; $flex = $this->getMaxColumns($size) - $this->{$getter}; if ($flex < 0) { return 0; } return $flex; }
[ "public", "function", "getFlex", "(", "$", "size", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "size", ")", ")", "{", "$", "size", "=", "$", "this", "->", "baseSize", ";", "}", "$", "getter", "=", "$", "size", ".", "'Columns'", ";", ...
Get flex. @param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional] @return [[@doctodo return_type:getFlex]] [[@doctodo return_description:getFlex]]
[ "Get", "flex", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L625-L637
train
vinala/kernel
src/Html/Html.php
Html.open
public static function open($tag, array $options = [], $self = false) { $attributes = self::attributes($options); //add the opened tag to $opened array if (!$self || is_null($self)) { self::$opened[] = $tag; // return '<'.$tag.$attributes.'>'; } else { return '<'.$tag.$attributes.' />'; } }
php
public static function open($tag, array $options = [], $self = false) { $attributes = self::attributes($options); //add the opened tag to $opened array if (!$self || is_null($self)) { self::$opened[] = $tag; // return '<'.$tag.$attributes.'>'; } else { return '<'.$tag.$attributes.' />'; } }
[ "public", "static", "function", "open", "(", "$", "tag", ",", "array", "$", "options", "=", "[", "]", ",", "$", "self", "=", "false", ")", "{", "$", "attributes", "=", "self", "::", "attributes", "(", "$", "options", ")", ";", "//add the opened tag to ...
open html tag. @param string $tag @param array $options @return string
[ "open", "html", "tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L25-L37
train
vinala/kernel
src/Html/Html.php
Html.close
public static function close() { //get the last opened tag $tag = self::$opened[count(self::$opened) - 1]; //remove the last opened tag array_pop(self::$opened); return '</'.$tag.'>'; }
php
public static function close() { //get the last opened tag $tag = self::$opened[count(self::$opened) - 1]; //remove the last opened tag array_pop(self::$opened); return '</'.$tag.'>'; }
[ "public", "static", "function", "close", "(", ")", "{", "//get the last opened tag", "$", "tag", "=", "self", "::", "$", "opened", "[", "count", "(", "self", "::", "$", "opened", ")", "-", "1", "]", ";", "//remove the last opened tag", "array_pop", "(", "s...
close the last open html tag. @return string
[ "close", "the", "last", "open", "html", "tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L44-L53
train
vinala/kernel
src/Html/Html.php
Html.title
public static function title($title = null) { if (is_null($title)) { $title = config('app.title'); } $tag = static::open('title'); $tag .= $title; $tag .= static::close(); return $tag; }
php
public static function title($title = null) { if (is_null($title)) { $title = config('app.title'); } $tag = static::open('title'); $tag .= $title; $tag .= static::close(); return $tag; }
[ "public", "static", "function", "title", "(", "$", "title", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "title", ")", ")", "{", "$", "title", "=", "config", "(", "'app.title'", ")", ";", "}", "$", "tag", "=", "static", "::", "open", "(...
The HTML title tag. @param string $title @return string
[ "The", "HTML", "title", "tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L132-L143
train
AlcyZ/Alcys-ORM
src/Core/Db/QueryBuilder/MySql/InsertBuilder.php
InsertBuilder._prepareColumns
private function _prepareColumns(array $columnArray) { if(count($columnArray) === 0) { throw new \Exception('The column method of the statement must called before!'); } foreach($columnArray as $column) { $this->columns .= $column->getColumnName() . ', '; } $this->columns = rtrim($this->columns); $this->columns = rtrim($this->columns, ','); return $this; }
php
private function _prepareColumns(array $columnArray) { if(count($columnArray) === 0) { throw new \Exception('The column method of the statement must called before!'); } foreach($columnArray as $column) { $this->columns .= $column->getColumnName() . ', '; } $this->columns = rtrim($this->columns); $this->columns = rtrim($this->columns, ','); return $this; }
[ "private", "function", "_prepareColumns", "(", "array", "$", "columnArray", ")", "{", "if", "(", "count", "(", "$", "columnArray", ")", "===", "0", ")", "{", "throw", "new", "\\", "Exception", "(", "'The column method of the statement must called before!'", ")", ...
Validate and prepare the columns property to set it to the query. @param ColumnInterface[] $columnArray An array with ColumnInterface objects as elements. @return $this The same instance to concatenate methods. @throws \Exception When column method of statement was not invoked.
[ "Validate", "and", "prepare", "the", "columns", "property", "to", "set", "it", "to", "the", "query", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/QueryBuilder/MySql/InsertBuilder.php#L96-L110
train
AlcyZ/Alcys-ORM
src/Core/Db/QueryBuilder/MySql/InsertBuilder.php
InsertBuilder._prepareValues
private function _prepareValues(array $valueArrays) { if(count($valueArrays) === 0) { throw new \Exception('The value method of the statement must called before!'); } foreach($valueArrays as $valueArray) { $valueString = '('; foreach($valueArray as $value) { $valueString .= $value->getValue() . ', '; } $valueString = rtrim($valueString); $valueString = rtrim($valueString, ',') . ')'; $this->values .= $valueString . ', '; } $this->values = rtrim($this->values); $this->values = rtrim($this->values, ','); return $this; }
php
private function _prepareValues(array $valueArrays) { if(count($valueArrays) === 0) { throw new \Exception('The value method of the statement must called before!'); } foreach($valueArrays as $valueArray) { $valueString = '('; foreach($valueArray as $value) { $valueString .= $value->getValue() . ', '; } $valueString = rtrim($valueString); $valueString = rtrim($valueString, ',') . ')'; $this->values .= $valueString . ', '; } $this->values = rtrim($this->values); $this->values = rtrim($this->values, ','); return $this; }
[ "private", "function", "_prepareValues", "(", "array", "$", "valueArrays", ")", "{", "if", "(", "count", "(", "$", "valueArrays", ")", "===", "0", ")", "{", "throw", "new", "\\", "Exception", "(", "'The value method of the statement must called before!'", ")", "...
Validate and prepare the values property to set it to the query. @param ReferencesInterface[][] $valueArrays An array with arrays that contain ReferenceInterface objects. @return $this The same instance to concatenate methods. @throws \Exception When statements values method was not called.
[ "Validate", "and", "prepare", "the", "values", "property", "to", "set", "it", "to", "the", "query", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/QueryBuilder/MySql/InsertBuilder.php#L121-L142
train
wucdbm/menu-builder-bundle
Composer/ScriptHandler.php
ScriptHandler.importRoutes
public static function importRoutes(Event $event) { $options = self::getOptions($event); $appDir = $options['symfony-app-dir']; $webDir = $options['symfony-web-dir']; if (!is_dir($webDir)) { echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL; return; } static::executeCommand($event, $appDir, 'wucdbm_menu_builder:import_routes'); }
php
public static function importRoutes(Event $event) { $options = self::getOptions($event); $appDir = $options['symfony-app-dir']; $webDir = $options['symfony-web-dir']; if (!is_dir($webDir)) { echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL; return; } static::executeCommand($event, $appDir, 'wucdbm_menu_builder:import_routes'); }
[ "public", "static", "function", "importRoutes", "(", "Event", "$", "event", ")", "{", "$", "options", "=", "self", "::", "getOptions", "(", "$", "event", ")", ";", "$", "appDir", "=", "$", "options", "[", "'symfony-app-dir'", "]", ";", "$", "webDir", "...
Imports routes into the database. @param $event Event A instance
[ "Imports", "routes", "into", "the", "database", "." ]
85bbb0760701eda4eb7c624f743abcc63a320168
https://github.com/wucdbm/menu-builder-bundle/blob/85bbb0760701eda4eb7c624f743abcc63a320168/Composer/ScriptHandler.php#L30-L42
train
bishopb/vanilla
library/core/class.applicationmanager.php
Gdn_ApplicationManager.AvailableApplications
public function AvailableApplications() { if (!is_array($this->_AvailableApplications)) { $ApplicationInfo = array(); $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS); // Get an array of all application folders $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders); // Now look for about files within them. // Include them all right here and fill the application info array $ApplicationCount = count($ApplicationAboutFiles); for ($i = 0; $i < $ApplicationCount; ++$i) { include($ApplicationAboutFiles[$i]); // Define the folder name for the newly added item foreach ($ApplicationInfo as $ApplicationName => $Info) { if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === FALSE) { $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS)); if (substr($Folder, 0, 1) == DS) $Folder = substr($Folder, 1); $Folder = substr($Folder, 0, strpos($Folder, DS)); $ApplicationInfo[$ApplicationName]['Folder'] = $Folder; } } } // Add all of the indexes to the applications. foreach ($ApplicationInfo as $Index => &$Info) { $Info['Index'] = $Index; } $this->_AvailableApplications = $ApplicationInfo; } return $this->_AvailableApplications; }
php
public function AvailableApplications() { if (!is_array($this->_AvailableApplications)) { $ApplicationInfo = array(); $AppFolders = Gdn_FileSystem::Folders(PATH_APPLICATIONS); // Get an array of all application folders $ApplicationAboutFiles = Gdn_FileSystem::FindAll(PATH_APPLICATIONS, 'settings' . DS . 'about.php', $AppFolders); // Now look for about files within them. // Include them all right here and fill the application info array $ApplicationCount = count($ApplicationAboutFiles); for ($i = 0; $i < $ApplicationCount; ++$i) { include($ApplicationAboutFiles[$i]); // Define the folder name for the newly added item foreach ($ApplicationInfo as $ApplicationName => $Info) { if (array_key_exists('Folder', $ApplicationInfo[$ApplicationName]) === FALSE) { $Folder = substr($ApplicationAboutFiles[$i], strlen(PATH_APPLICATIONS)); if (substr($Folder, 0, 1) == DS) $Folder = substr($Folder, 1); $Folder = substr($Folder, 0, strpos($Folder, DS)); $ApplicationInfo[$ApplicationName]['Folder'] = $Folder; } } } // Add all of the indexes to the applications. foreach ($ApplicationInfo as $Index => &$Info) { $Info['Index'] = $Index; } $this->_AvailableApplications = $ApplicationInfo; } return $this->_AvailableApplications; }
[ "public", "function", "AvailableApplications", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "_AvailableApplications", ")", ")", "{", "$", "ApplicationInfo", "=", "array", "(", ")", ";", "$", "AppFolders", "=", "Gdn_FileSystem", "::", ...
Looks through the root Garden directory for valid applications and returns them as an associative array of "Application Name" => "Application Info Array". It also adds a "Folder" definition to the Application Info Array for each application.
[ "Looks", "through", "the", "root", "Garden", "directory", "for", "valid", "applications", "and", "returns", "them", "as", "an", "associative", "array", "of", "Application", "Name", "=", ">", "Application", "Info", "Array", ".", "It", "also", "adds", "a", "Fo...
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.applicationmanager.php#L47-L79
train
bishopb/vanilla
library/core/class.applicationmanager.php
Gdn_ApplicationManager.EnabledApplications
public function EnabledApplications() { if (!is_array($this->_EnabledApplications)) { $EnabledApplications = Gdn::Config('EnabledApplications', array('Dashboard' => 'dashboard')); // Add some information about the applications to the array. foreach($EnabledApplications as $Name => $Folder) { $EnabledApplications[$Name] = array('Folder' => $Folder); //$EnabledApplications[$Name]['Version'] = Gdn::Config($Name.'.Version', ''); $EnabledApplications[$Name]['Version'] = ''; $EnabledApplications[$Name]['Index'] = $Name; // Get the application version from it's about file. $AboutPath = PATH_APPLICATIONS.'/'.strtolower($Name).'/settings/about.php'; if (file_exists($AboutPath)) { $ApplicationInfo = array(); include $AboutPath; $EnabledApplications[$Name]['Version'] = GetValueR("$Name.Version", $ApplicationInfo, ''); } } $this->_EnabledApplications = $EnabledApplications; } return $this->_EnabledApplications; }
php
public function EnabledApplications() { if (!is_array($this->_EnabledApplications)) { $EnabledApplications = Gdn::Config('EnabledApplications', array('Dashboard' => 'dashboard')); // Add some information about the applications to the array. foreach($EnabledApplications as $Name => $Folder) { $EnabledApplications[$Name] = array('Folder' => $Folder); //$EnabledApplications[$Name]['Version'] = Gdn::Config($Name.'.Version', ''); $EnabledApplications[$Name]['Version'] = ''; $EnabledApplications[$Name]['Index'] = $Name; // Get the application version from it's about file. $AboutPath = PATH_APPLICATIONS.'/'.strtolower($Name).'/settings/about.php'; if (file_exists($AboutPath)) { $ApplicationInfo = array(); include $AboutPath; $EnabledApplications[$Name]['Version'] = GetValueR("$Name.Version", $ApplicationInfo, ''); } } $this->_EnabledApplications = $EnabledApplications; } return $this->_EnabledApplications; }
[ "public", "function", "EnabledApplications", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "_EnabledApplications", ")", ")", "{", "$", "EnabledApplications", "=", "Gdn", "::", "Config", "(", "'EnabledApplications'", ",", "array", "(", "'...
Gets an array of all of the enabled applications. @return array
[ "Gets", "an", "array", "of", "all", "of", "the", "enabled", "applications", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.applicationmanager.php#L85-L106
train
laravel-commode/common
src/LaravelCommode/Common/GhostService/GhostService.php
GhostService.prepareService
private function prepareService() { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!($bound = $this->app->bound(ServiceShortCuts::CORE_INITIALIZED))) { $this->services(['LaravelCommode\Common\CommodeCommonServiceProvider']); } $withGhostServiceDo = function (GhostServices $appServices) use ($bound) { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!$bound) { $appServices->register('LaravelCommode\Common\CommodeCommonServiceProvider'); } /** * Get and register service providers in ServiceManager */ $services = $appServices->differUnique($this->uses(), true); /** * Register service proviers in laravel app * differing from already used ones */ $this->services(array_diff($services, array_keys($this->app->getLoadedProviders()))); /** * Mark current service as registered */ $appServices->register(get_class($this)); }; $this->with(ServiceShortCuts::GHOST_SERVICE, $withGhostServiceDo); return $this; }
php
private function prepareService() { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!($bound = $this->app->bound(ServiceShortCuts::CORE_INITIALIZED))) { $this->services(['LaravelCommode\Common\CommodeCommonServiceProvider']); } $withGhostServiceDo = function (GhostServices $appServices) use ($bound) { /** * If CommodeCommonServiceProvider is not loaded yet, load it * and mark as registered in GhostServices */ if (!$bound) { $appServices->register('LaravelCommode\Common\CommodeCommonServiceProvider'); } /** * Get and register service providers in ServiceManager */ $services = $appServices->differUnique($this->uses(), true); /** * Register service proviers in laravel app * differing from already used ones */ $this->services(array_diff($services, array_keys($this->app->getLoadedProviders()))); /** * Mark current service as registered */ $appServices->register(get_class($this)); }; $this->with(ServiceShortCuts::GHOST_SERVICE, $withGhostServiceDo); return $this; }
[ "private", "function", "prepareService", "(", ")", "{", "/**\n * If CommodeCommonServiceProvider is not loaded yet, load it\n * and mark as registered in GhostServices\n */", "if", "(", "!", "(", "$", "bound", "=", "$", "this", "->", "app", "->", "bound"...
Prepares service for launching. If LaravelCommode\Common\CommodeCommonServiceProvider is not registered in your app config, it will be forced to launch. Loads all services used by current GhostService instance. @return $this
[ "Prepares", "service", "for", "launching", ".", "If", "LaravelCommode", "\\", "Common", "\\", "CommodeCommonServiceProvider", "is", "not", "registered", "in", "your", "app", "config", "it", "will", "be", "forced", "to", "launch", ".", "Loads", "all", "services",...
5c9289c3ce5bbd934281c4ac7537657d32c5a9ec
https://github.com/laravel-commode/common/blob/5c9289c3ce5bbd934281c4ac7537657d32c5a9ec/src/LaravelCommode/Common/GhostService/GhostService.php#L58-L97
train
amercier/rectangular-mozaic
src/Generator.php
Generator.generateGrid
protected function generateGrid($tiles, $columns) { [$distribution, $grid] = Distributor::distribute( $tiles, $columns, $this->settings['tallRate'], $this->settings['wideRate'] ); RandomFiller::fill($grid, $distribution, $this->settings['maxFillRetries']); return $grid; }
php
protected function generateGrid($tiles, $columns) { [$distribution, $grid] = Distributor::distribute( $tiles, $columns, $this->settings['tallRate'], $this->settings['wideRate'] ); RandomFiller::fill($grid, $distribution, $this->settings['maxFillRetries']); return $grid; }
[ "protected", "function", "generateGrid", "(", "$", "tiles", ",", "$", "columns", ")", "{", "[", "$", "distribution", ",", "$", "grid", "]", "=", "Distributor", "::", "distribute", "(", "$", "tiles", ",", "$", "columns", ",", "$", "this", "->", "setting...
Generate a Grid that contains a given number of columns. @param int $tiles Total number of tiles. @param int $columns Number of columns of the grid. @return Grid A new grid filled with Cell values.
[ "Generate", "a", "Grid", "that", "contains", "a", "given", "number", "of", "columns", "." ]
d026a82c1bc73979308235a7a440665e92ee8525
https://github.com/amercier/rectangular-mozaic/blob/d026a82c1bc73979308235a7a440665e92ee8525/src/Generator.php#L49-L59
train
EcomDev/phpspec-file-matcher
src/Extension.php
Extension.load
public function load(ServiceContainer $container, array $params) { $container->define( 'ecomdev.matcher.file', function () { return $this->createFileMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.file_content', function () { return $this->createFileContentMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.directory', function () { return $this->createDirectoryMatcher(); }, ['matchers'] ); }
php
public function load(ServiceContainer $container, array $params) { $container->define( 'ecomdev.matcher.file', function () { return $this->createFileMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.file_content', function () { return $this->createFileContentMatcher(); }, ['matchers'] ); $container->define( 'ecomdev.matcher.directory', function () { return $this->createDirectoryMatcher(); }, ['matchers'] ); }
[ "public", "function", "load", "(", "ServiceContainer", "$", "container", ",", "array", "$", "params", ")", "{", "$", "container", "->", "define", "(", "'ecomdev.matcher.file'", ",", "function", "(", ")", "{", "return", "$", "this", "->", "createFileMatcher", ...
Loads matchers into PHPSpec service container @param ServiceContainer $container @param array $params
[ "Loads", "matchers", "into", "PHPSpec", "service", "container" ]
5323bf833774c3d9d763bc01cdc7354a2985b47c
https://github.com/EcomDev/phpspec-file-matcher/blob/5323bf833774c3d9d763bc01cdc7354a2985b47c/src/Extension.php#L18-L43
train
EcomDev/phpspec-file-matcher
src/Extension.php
Extension.createCheckMatcher
private function createCheckMatcher($verbs, $nouns, ...$matcherArguments) { return new CheckMatcher( $this->createLexer($verbs, $nouns), ...$matcherArguments ); }
php
private function createCheckMatcher($verbs, $nouns, ...$matcherArguments) { return new CheckMatcher( $this->createLexer($verbs, $nouns), ...$matcherArguments ); }
[ "private", "function", "createCheckMatcher", "(", "$", "verbs", ",", "$", "nouns", ",", "...", "$", "matcherArguments", ")", "{", "return", "new", "CheckMatcher", "(", "$", "this", "->", "createLexer", "(", "$", "verbs", ",", "$", "nouns", ")", ",", "......
Create check matcher instance @param string[] $verbs @param string[] $nouns @param array $matcherArguments @return CheckMatcher
[ "Create", "check", "matcher", "instance" ]
5323bf833774c3d9d763bc01cdc7354a2985b47c
https://github.com/EcomDev/phpspec-file-matcher/blob/5323bf833774c3d9d763bc01cdc7354a2985b47c/src/Extension.php#L121-L127
train
mpoiriert/draw-test-helper-bundle
Helper/BaseRequestHelper.php
BaseRequestHelper.instantiate
static public function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if(static::isSingleInstance()) { if(isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; } } $instance = new static(); $instance->requestHelper = $requestHelper; $instance->initialize(); $requestHelper->getEventDispatcher() ->dispatch( RequestHelper::EVENT_NEW_HELPER, new RequestHelperEvent($requestHelper, array('helper' => $instance)) ); if(static::isSingleInstance()) { static::$instances[$objectHash][static::getName()] = $instance; } return $instance; }
php
static public function instantiate(RequestHelper $requestHelper) { $objectHash = spl_object_hash($requestHelper); if(static::isSingleInstance()) { if(isset(static::$instances[$objectHash][static::getName()])) { return static::$instances[$objectHash][static::getName()]; } } $instance = new static(); $instance->requestHelper = $requestHelper; $instance->initialize(); $requestHelper->getEventDispatcher() ->dispatch( RequestHelper::EVENT_NEW_HELPER, new RequestHelperEvent($requestHelper, array('helper' => $instance)) ); if(static::isSingleInstance()) { static::$instances[$objectHash][static::getName()] = $instance; } return $instance; }
[ "static", "public", "function", "instantiate", "(", "RequestHelper", "$", "requestHelper", ")", "{", "$", "objectHash", "=", "spl_object_hash", "(", "$", "requestHelper", ")", ";", "if", "(", "static", "::", "isSingleInstance", "(", ")", ")", "{", "if", "(",...
Return a instance of himself. Sometime only one helper of a specific type must be set for a request so the same instance can be return if the same request helper is used. This method should always be used instead of the constructor. @param RequestHelper $requestHelper @return static
[ "Return", "a", "instance", "of", "himself", "." ]
cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889
https://github.com/mpoiriert/draw-test-helper-bundle/blob/cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889/Helper/BaseRequestHelper.php#L58-L82
train
CodeLoversAt/AclBundle
Handler/AbstractAclHandler.php
AbstractAclHandler.deleteAcl
public function deleteAcl($object) { try { if ($objectIdentity = $this->getObjectIdentity($object)) { $this->aclProvider->deleteAcl($objectIdentity); } } catch (\Exception $e) { // nothing to do } }
php
public function deleteAcl($object) { try { if ($objectIdentity = $this->getObjectIdentity($object)) { $this->aclProvider->deleteAcl($objectIdentity); } } catch (\Exception $e) { // nothing to do } }
[ "public", "function", "deleteAcl", "(", "$", "object", ")", "{", "try", "{", "if", "(", "$", "objectIdentity", "=", "$", "this", "->", "getObjectIdentity", "(", "$", "object", ")", ")", "{", "$", "this", "->", "aclProvider", "->", "deleteAcl", "(", "$"...
delete the ACL for the given object @param object $object
[ "delete", "the", "ACL", "for", "the", "given", "object" ]
024fe2831e81d7ddff071c695b8daec97f25b990
https://github.com/CodeLoversAt/AclBundle/blob/024fe2831e81d7ddff071c695b8daec97f25b990/Handler/AbstractAclHandler.php#L151-L160
train
flavorzyb/simple
src/Filesystem/Filesystem.php
Filesystem.files
public function files($directory, $recursive = false) { $result = []; $recursive = boolval($recursive); if ( ! $this->isDirectory($directory)) return []; $items = new FilesystemIterator($directory); foreach ($items as $item) { if ($item->isFile()) { $result[] = $item->getPathname(); } elseif ($recursive && $item->isDir() && ! $item->isLink()) { $subFiles = $this->files($item->getPathname(), $recursive); foreach ($subFiles as $file) { $result[] = $file; } } } return $result; }
php
public function files($directory, $recursive = false) { $result = []; $recursive = boolval($recursive); if ( ! $this->isDirectory($directory)) return []; $items = new FilesystemIterator($directory); foreach ($items as $item) { if ($item->isFile()) { $result[] = $item->getPathname(); } elseif ($recursive && $item->isDir() && ! $item->isLink()) { $subFiles = $this->files($item->getPathname(), $recursive); foreach ($subFiles as $file) { $result[] = $file; } } } return $result; }
[ "public", "function", "files", "(", "$", "directory", ",", "$", "recursive", "=", "false", ")", "{", "$", "result", "=", "[", "]", ";", "$", "recursive", "=", "boolval", "(", "$", "recursive", ")", ";", "if", "(", "!", "$", "this", "->", "isDirecto...
get all files in directory @param string $directory @param bool $recursive @return array
[ "get", "all", "files", "in", "directory" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Filesystem/Filesystem.php#L340-L361
train
petrofcz/groupie
src/Pcz/Groupie/Groupie.php
Groupie.buildGroups
public function buildGroups($entities, $level = 0) { if(!count($this->groupDefinitions)) { throw new \RuntimeException('There are no groups defined.'); } // Building groups /** @var Group[] $groups */ $groups = []; if(!isset($this->groupDefinitions[$level])) { return []; } $groupDefinition = $this->groupDefinitions[$level]; $entitiesByGroupUid = []; foreach($entities as $entity) { $groupUid = $level . '-' . call_user_func($groupDefinition->getUidRetriever(), $entity); if(!isset($groups[$groupUid])) { $groups[$groupUid] = new Group( $groupUid, call_user_func($groupDefinition->getGroupDataFactory(), $entity), $level, $entity ); $entitiesByGroupUid[$groupUid] = []; } $entitiesByGroupUid[$groupUid][] = $entity; } foreach($entitiesByGroupUid as $groupUid => $iEntities) { $subGroups = $this->buildGroups($iEntities, $level + 1); foreach($subGroups as $subGroup) { $groups[$groupUid]->addChild($subGroup); } } /** @var IColumnData[][] $columnDatasByGroupUid */ $columnDatasByGroupUid = []; foreach($entitiesByGroupUid as $groupUid => $iEntities) { if (!isset($columnDatasByGroupUid[$groupUid])) { $columnDatasByGroupUid[$groupUid] = []; } } $groupDefinition = $this->getGroup($level); foreach($this->getColumnDefinitions() as $columnId => $columnDefinition) { $columnFoundInGroup = false; foreach ($groupDefinition->getColumnDefinitionsWithDataFactories() as $columnDefinitionsWithDataFactory) { list($groupColumnDefinition, $columnDataFactory) = $columnDefinitionsWithDataFactory; if ($columnDefinition->equals($groupColumnDefinition)) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = $columnDataFactory($iEntities); } $columnFoundInGroup = true; break; } } if(!$columnFoundInGroup) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = null; } } } foreach($columnDatasByGroupUid as $groupUid => $columnDatas) { $groups[$groupUid]->setColumnDatas($columnDatas); } $finalGroups = array_values($groups); if(($sortingComparator = $groupDefinition->getSortingComparator()) !== null) { usort($finalGroups, $sortingComparator); } return $finalGroups; }
php
public function buildGroups($entities, $level = 0) { if(!count($this->groupDefinitions)) { throw new \RuntimeException('There are no groups defined.'); } // Building groups /** @var Group[] $groups */ $groups = []; if(!isset($this->groupDefinitions[$level])) { return []; } $groupDefinition = $this->groupDefinitions[$level]; $entitiesByGroupUid = []; foreach($entities as $entity) { $groupUid = $level . '-' . call_user_func($groupDefinition->getUidRetriever(), $entity); if(!isset($groups[$groupUid])) { $groups[$groupUid] = new Group( $groupUid, call_user_func($groupDefinition->getGroupDataFactory(), $entity), $level, $entity ); $entitiesByGroupUid[$groupUid] = []; } $entitiesByGroupUid[$groupUid][] = $entity; } foreach($entitiesByGroupUid as $groupUid => $iEntities) { $subGroups = $this->buildGroups($iEntities, $level + 1); foreach($subGroups as $subGroup) { $groups[$groupUid]->addChild($subGroup); } } /** @var IColumnData[][] $columnDatasByGroupUid */ $columnDatasByGroupUid = []; foreach($entitiesByGroupUid as $groupUid => $iEntities) { if (!isset($columnDatasByGroupUid[$groupUid])) { $columnDatasByGroupUid[$groupUid] = []; } } $groupDefinition = $this->getGroup($level); foreach($this->getColumnDefinitions() as $columnId => $columnDefinition) { $columnFoundInGroup = false; foreach ($groupDefinition->getColumnDefinitionsWithDataFactories() as $columnDefinitionsWithDataFactory) { list($groupColumnDefinition, $columnDataFactory) = $columnDefinitionsWithDataFactory; if ($columnDefinition->equals($groupColumnDefinition)) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = $columnDataFactory($iEntities); } $columnFoundInGroup = true; break; } } if(!$columnFoundInGroup) { foreach($entitiesByGroupUid as $groupUid => $iEntities) { $columnDatasByGroupUid[$groupUid][] = null; } } } foreach($columnDatasByGroupUid as $groupUid => $columnDatas) { $groups[$groupUid]->setColumnDatas($columnDatas); } $finalGroups = array_values($groups); if(($sortingComparator = $groupDefinition->getSortingComparator()) !== null) { usort($finalGroups, $sortingComparator); } return $finalGroups; }
[ "public", "function", "buildGroups", "(", "$", "entities", ",", "$", "level", "=", "0", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "groupDefinitions", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'There are no groups defin...
This method builds the whole structure. @param $entities array Flat array of entities to be grouped. @param int $level Group level index. Levels can be skipped by setting value > 0. @return Group[]
[ "This", "method", "builds", "the", "whole", "structure", "." ]
727773562d4559de5b6c65eb557b867f0b533ba5
https://github.com/petrofcz/groupie/blob/727773562d4559de5b6c65eb557b867f0b533ba5/src/Pcz/Groupie/Groupie.php#L25-L95
train
petrofcz/groupie
src/Pcz/Groupie/Groupie.php
Groupie.addGlobalColumn
public function addGlobalColumn(ColumnDefinition $columnDefinition, callable $columnDataFactory) { $this->addColumn($columnDefinition); foreach($this->groupDefinitions as $groupDefinition) { $groupDefinition->addColumn($columnDefinition, $columnDataFactory); } return $this; }
php
public function addGlobalColumn(ColumnDefinition $columnDefinition, callable $columnDataFactory) { $this->addColumn($columnDefinition); foreach($this->groupDefinitions as $groupDefinition) { $groupDefinition->addColumn($columnDefinition, $columnDataFactory); } return $this; }
[ "public", "function", "addGlobalColumn", "(", "ColumnDefinition", "$", "columnDefinition", ",", "callable", "$", "columnDataFactory", ")", "{", "$", "this", "->", "addColumn", "(", "$", "columnDefinition", ")", ";", "foreach", "(", "$", "this", "->", "groupDefin...
This method adds column to groupie and to all available groups. IT SHOULD BE CALLED AFTER ALL GROUPS ARE ADDED! @param ColumnDefinition $columnDefinition @param $columnDataFactory callable This method should return callback that will construct the IColumnData object (it contains aggregated value to be displayed). Args: [array $entities] @return $this
[ "This", "method", "adds", "column", "to", "groupie", "and", "to", "all", "available", "groups", ".", "IT", "SHOULD", "BE", "CALLED", "AFTER", "ALL", "GROUPS", "ARE", "ADDED!" ]
727773562d4559de5b6c65eb557b867f0b533ba5
https://github.com/petrofcz/groupie/blob/727773562d4559de5b6c65eb557b867f0b533ba5/src/Pcz/Groupie/Groupie.php#L134-L140
train
pdenis/travis-client
src/Snide/Travis/Model/Repository.php
Repository.addBuild
public function addBuild(Build $build) { $this->getBuilds(); $build->setRepositoryId($this->getId()); $this->builds[$build->getId()] = $build; }
php
public function addBuild(Build $build) { $this->getBuilds(); $build->setRepositoryId($this->getId()); $this->builds[$build->getId()] = $build; }
[ "public", "function", "addBuild", "(", "Build", "$", "build", ")", "{", "$", "this", "->", "getBuilds", "(", ")", ";", "$", "build", "->", "setRepositoryId", "(", "$", "this", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "builds", "[", "$"...
Add build to the list @param Build $build
[ "Add", "build", "to", "the", "list" ]
6925427ac2650a52a03bd23e4809cc9186bb63cd
https://github.com/pdenis/travis-client/blob/6925427ac2650a52a03bd23e4809cc9186bb63cd/src/Snide/Travis/Model/Repository.php#L110-L115
train
pdenis/travis-client
src/Snide/Travis/Model/Repository.php
Repository.removeBuild
public function removeBuild(Build $build) { if (isset($this->builds[$build->getId()])) { unset($this->builds[$build->getId()]); } }
php
public function removeBuild(Build $build) { if (isset($this->builds[$build->getId()])) { unset($this->builds[$build->getId()]); } }
[ "public", "function", "removeBuild", "(", "Build", "$", "build", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "builds", "[", "$", "build", "->", "getId", "(", ")", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "builds", "[", "$", ...
Remove build from the list @param Build $build
[ "Remove", "build", "from", "the", "list" ]
6925427ac2650a52a03bd23e4809cc9186bb63cd
https://github.com/pdenis/travis-client/blob/6925427ac2650a52a03bd23e4809cc9186bb63cd/src/Snide/Travis/Model/Repository.php#L122-L127
train
Thuata/FrameworkBundle
Entity/DocumentSerialization.php
DocumentSerialization.jsonDeserialize
public static function jsonDeserialize(array $json): DocumentSerializationInterface { $managerClass = $json['document_serialization']['manager_class']; $data = (array) $json['document_serialization']['data']; return new self($managerClass, $data); }
php
public static function jsonDeserialize(array $json): DocumentSerializationInterface { $managerClass = $json['document_serialization']['manager_class']; $data = (array) $json['document_serialization']['data']; return new self($managerClass, $data); }
[ "public", "static", "function", "jsonDeserialize", "(", "array", "$", "json", ")", ":", "DocumentSerializationInterface", "{", "$", "managerClass", "=", "$", "json", "[", "'document_serialization'", "]", "[", "'manager_class'", "]", ";", "$", "data", "=", "(", ...
Deserialize the data @param array $json @return DocumentSerializationInterface
[ "Deserialize", "the", "data" ]
78c38a5103256d829d7f7574b4e15c9087d0cfd9
https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Entity/DocumentSerialization.php#L87-L93
train
dcarbone/helpers
src/JsonToList.php
JsonToList.invoke
public static function invoke($jsonString, $returnNode = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $jsonString = mb_convert_encoding($jsonString, 'UTF-8', mb_detect_encoding($jsonString)); $jsonDecode = json_decode($jsonString, false); $lastError = json_last_error(); if (JSON_ERROR_NONE === $lastError) { $ul = $dom->createElement('ul'); $ul->setAttribute('class', 'json-list'); $dom->appendChild($ul); if ($jsonDecode instanceof \stdClass) self::objectOutput($jsonDecode, $dom, $ul); else if (is_array($jsonDecode)) self::arrayOutput($jsonDecode, $dom, $ul); if ($returnNode) return $dom; return static::saveHTMLExact($dom, $ul); } throw new \DomainException(sprintf( 'Could not convert input to HTML: "%s"', JsonErrorHelper::invoke(true, $lastError) )); }
php
public static function invoke($jsonString, $returnNode = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $jsonString = mb_convert_encoding($jsonString, 'UTF-8', mb_detect_encoding($jsonString)); $jsonDecode = json_decode($jsonString, false); $lastError = json_last_error(); if (JSON_ERROR_NONE === $lastError) { $ul = $dom->createElement('ul'); $ul->setAttribute('class', 'json-list'); $dom->appendChild($ul); if ($jsonDecode instanceof \stdClass) self::objectOutput($jsonDecode, $dom, $ul); else if (is_array($jsonDecode)) self::arrayOutput($jsonDecode, $dom, $ul); if ($returnNode) return $dom; return static::saveHTMLExact($dom, $ul); } throw new \DomainException(sprintf( 'Could not convert input to HTML: "%s"', JsonErrorHelper::invoke(true, $lastError) )); }
[ "public", "static", "function", "invoke", "(", "$", "jsonString", ",", "$", "returnNode", "=", "false", ")", "{", "$", "dom", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "jsonString", "=", "mb_convert_encoding", "(", "$"...
Invoke the helper @param $jsonString @param bool $returnNode @return \DOMNode|string
[ "Invoke", "the", "helper" ]
43dc122491e38f47f22d1c7634f9c35f987ac545
https://github.com/dcarbone/helpers/blob/43dc122491e38f47f22d1c7634f9c35f987ac545/src/JsonToList.php#L26-L56
train
dcarbone/helpers
src/JsonToList.php
JsonToList.objectOutput
protected static function objectOutput(\stdClass $object, \DOMDocument $dom, \DOMElement $parentUL) { foreach($object as $k=>$v) { $li = $dom->createElement('li'); $parentUL->appendChild($li); $strong = $dom->createElement('strong', $k); $li->appendChild($strong); if ($v instanceof \stdClass) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::objectOutput($v, $dom, $ul); } else if (is_array($v)) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::arrayOutput($v, $dom, $ul); } else if (is_bool($v)) { switch($v) { case true: $li->appendChild($dom->createTextNode(' TRUE')); break; case false: $li->appendChild($dom->createTextNode(' FALSE')); break; } } else if (is_scalar($v)) { $span = $dom->createElement('span'); $span->appendChild($dom->createTextNode(' '.strval($v))); $li->appendChild($span); } } return $dom; }
php
protected static function objectOutput(\stdClass $object, \DOMDocument $dom, \DOMElement $parentUL) { foreach($object as $k=>$v) { $li = $dom->createElement('li'); $parentUL->appendChild($li); $strong = $dom->createElement('strong', $k); $li->appendChild($strong); if ($v instanceof \stdClass) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::objectOutput($v, $dom, $ul); } else if (is_array($v)) { $ul = $dom->createElement('ul'); $li->appendChild($ul); self::arrayOutput($v, $dom, $ul); } else if (is_bool($v)) { switch($v) { case true: $li->appendChild($dom->createTextNode(' TRUE')); break; case false: $li->appendChild($dom->createTextNode(' FALSE')); break; } } else if (is_scalar($v)) { $span = $dom->createElement('span'); $span->appendChild($dom->createTextNode(' '.strval($v))); $li->appendChild($span); } } return $dom; }
[ "protected", "static", "function", "objectOutput", "(", "\\", "stdClass", "$", "object", ",", "\\", "DOMDocument", "$", "dom", ",", "\\", "DOMElement", "$", "parentUL", ")", "{", "foreach", "(", "$", "object", "as", "$", "k", "=>", "$", "v", ")", "{", ...
Parse through json object @param \stdClass $object @param \DOMDocument $dom @param \DOMElement $parentUL @return \DOMDocument
[ "Parse", "through", "json", "object" ]
43dc122491e38f47f22d1c7634f9c35f987ac545
https://github.com/dcarbone/helpers/blob/43dc122491e38f47f22d1c7634f9c35f987ac545/src/JsonToList.php#L79-L115
train
AlphaLabs/FilterEngine
src/Bridge/Doctrine/FilteringRepositoryTrait.php
FilteringRepositoryTrait.applyFilters
public function applyFilters(QueryBuilder $queryBuilder, $alias, FilterBagInterface $filterBag = null) { if (is_null($filterBag)) { return $queryBuilder; } foreach ($filterBag->all() as $filter) { if ($filter instanceof FilterNode) { $this->applyFilter($queryBuilder, $alias, $filter); } } return $queryBuilder; }
php
public function applyFilters(QueryBuilder $queryBuilder, $alias, FilterBagInterface $filterBag = null) { if (is_null($filterBag)) { return $queryBuilder; } foreach ($filterBag->all() as $filter) { if ($filter instanceof FilterNode) { $this->applyFilter($queryBuilder, $alias, $filter); } } return $queryBuilder; }
[ "public", "function", "applyFilters", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "alias", ",", "FilterBagInterface", "$", "filterBag", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "filterBag", ")", ")", "{", "return", "$", "queryBuilder", ...
Apply filters from a filter bag on the provided query builder @param QueryBuilder $queryBuilder QueryBuilder @param string $alias QueryBuilder root alias @param FilterBagInterface $filterBag Filters to apply @return QueryBuilder
[ "Apply", "filters", "from", "a", "filter", "bag", "on", "the", "provided", "query", "builder" ]
806a7c31e50839033dbf0d41aed34b8d14c347f6
https://github.com/AlphaLabs/FilterEngine/blob/806a7c31e50839033dbf0d41aed34b8d14c347f6/src/Bridge/Doctrine/FilteringRepositoryTrait.php#L31-L44
train
AlphaLabs/FilterEngine
src/Bridge/Doctrine/FilteringRepositoryTrait.php
FilteringRepositoryTrait.applyFilter
protected function applyFilter(QueryBuilder $queryBuilder, $alias, FilterNode $filter) { $queryBuilderPatcher = new QueryBuilderPatcher(new QueryExpressionBuilder()); return $queryBuilderPatcher->patch($queryBuilder, $filter, new QueryContext($alias)); }
php
protected function applyFilter(QueryBuilder $queryBuilder, $alias, FilterNode $filter) { $queryBuilderPatcher = new QueryBuilderPatcher(new QueryExpressionBuilder()); return $queryBuilderPatcher->patch($queryBuilder, $filter, new QueryContext($alias)); }
[ "protected", "function", "applyFilter", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "alias", ",", "FilterNode", "$", "filter", ")", "{", "$", "queryBuilderPatcher", "=", "new", "QueryBuilderPatcher", "(", "new", "QueryExpressionBuilder", "(", ")", ")", "...
Apply one filter to the query builder @param QueryBuilder $queryBuilder QueryBuilder @param string $alias QueryBuilder root alias @param FilterNode $filter Filter to apply @return QueryBuilder
[ "Apply", "one", "filter", "to", "the", "query", "builder" ]
806a7c31e50839033dbf0d41aed34b8d14c347f6
https://github.com/AlphaLabs/FilterEngine/blob/806a7c31e50839033dbf0d41aed34b8d14c347f6/src/Bridge/Doctrine/FilteringRepositoryTrait.php#L55-L60
train
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addErrorMessage
public function addErrorMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'error', 'bootstrapType' => 'danger', 'message' => $message ); static::$success = false; }
php
public function addErrorMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'error', 'bootstrapType' => 'danger', 'message' => $message ); static::$success = false; }
[ "public", "function", "addErrorMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", ...
add a error message to the api call @param $message
[ "add", "a", "error", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L260-L269
train
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addSuccessMessage
public function addSuccessMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[$message] = array( 'type' => 'success', 'bootstrapType' => 'success', 'message' => $message ); }
php
public function addSuccessMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[$message] = array( 'type' => 'success', 'bootstrapType' => 'success', 'message' => $message ); }
[ "public", "function", "addSuccessMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages",...
add a success message to the api call @param $message
[ "add", "a", "success", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L275-L283
train
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addInfoMessage
public function addInfoMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'info', 'bootstrapType' => 'info', 'message' => $message ); }
php
public function addInfoMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'info', 'bootstrapType' => 'info', 'message' => $message ); }
[ "public", "function", "addInfoMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages", ...
add a info message to the api call @param $message
[ "add", "a", "info", "message", "to", "the", "api", "call" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L289-L297
train
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/AbstractApi.php
AbstractApi.addWarningMessage
public function addWarningMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'warning', 'bootstrapType' => 'warning', 'message' => $message ); }
php
public function addWarningMessage($message, $params = array()) { $message = $this->trans($message, $params); static::$messages[] = array( 'type' => 'warning', 'bootstrapType' => 'warning', 'message' => $message ); }
[ "public", "function", "addWarningMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "trans", "(", "$", "message", ",", "$", "params", ")", ";", "static", "::", "$", "messages",...
add a warning message to the api @param $message
[ "add", "a", "warning", "message", "to", "the", "api" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/AbstractApi.php#L303-L311
train
zepi/turbo-base
Zepi/Web/AccessControl/src/EventHandler/DisplayNoAccessMessage.php
DisplayNoAccessMessage.execute
public function execute(Framework $framework, WebRequest $request, Response $response) { $renderedOutput = $this->render('\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage'); $response->setOutput($renderedOutput); }
php
public function execute(Framework $framework, WebRequest $request, Response $response) { $renderedOutput = $this->render('\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage'); $response->setOutput($renderedOutput); }
[ "public", "function", "execute", "(", "Framework", "$", "framework", ",", "WebRequest", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "renderedOutput", "=", "$", "this", "->", "render", "(", "'\\\\Zepi\\\\Web\\\\AccessControl\\\\Templates\\\\NoAcc...
Displays a message if the session has no access to the requested command. @param \Zepi\Turbo\Framework $framework @param \Zepi\Turbo\Request\WebRequest $request @param \Zepi\Turbo\Response\Response $response
[ "Displays", "a", "message", "if", "the", "session", "has", "no", "access", "to", "the", "requested", "command", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/DisplayNoAccessMessage.php#L58-L63
train
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getPropertyAnnotation
public function getPropertyAnnotation(\ReflectionProperty $property) { $annot = $this->reader->getPropertyAnnotation($property, '\Represent\Annotations\Property'); if (!$annot) { return false; } return $annot; }
php
public function getPropertyAnnotation(\ReflectionProperty $property) { $annot = $this->reader->getPropertyAnnotation($property, '\Represent\Annotations\Property'); if (!$annot) { return false; } return $annot; }
[ "public", "function", "getPropertyAnnotation", "(", "\\", "ReflectionProperty", "$", "property", ")", "{", "$", "annot", "=", "$", "this", "->", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "'\\Represent\\Annotations\\Property'", ")", ";", "...
Returns the property annotation or false if one is not present; @param \ReflectionProperty $property @return bool|Property
[ "Returns", "the", "property", "annotation", "or", "false", "if", "one", "is", "not", "present", ";" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L35-L44
train
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getSerializedName
public function getSerializedName(\ReflectionProperty $property, Property $annot = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getName(); } return $property->getName(); }
php
public function getSerializedName(\ReflectionProperty $property, Property $annot = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getName(); } return $property->getName(); }
[ "public", "function", "getSerializedName", "(", "\\", "ReflectionProperty", "$", "property", ",", "Property", "$", "annot", "=", "null", ")", "{", "if", "(", "$", "annot", "||", "$", "annot", "=", "$", "this", "->", "getPropertyAnnotation", "(", "$", "prop...
Returns the serialized name for this property @param \ReflectionProperty $property @param Property $annot @return string
[ "Returns", "the", "serialized", "name", "for", "this", "property" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L53-L61
train
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.propertyTypeOverride
public function propertyTypeOverride(Property $annot = null, \ReflectionProperty $property = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getType(); } return null; }
php
public function propertyTypeOverride(Property $annot = null, \ReflectionProperty $property = null) { if ($annot || $annot = $this->getPropertyAnnotation($property)) { return $annot->getType(); } return null; }
[ "public", "function", "propertyTypeOverride", "(", "Property", "$", "annot", "=", "null", ",", "\\", "ReflectionProperty", "$", "property", "=", "null", ")", "{", "if", "(", "$", "annot", "||", "$", "annot", "=", "$", "this", "->", "getPropertyAnnotation", ...
Returns the type this property is changed to during serialization or false if no conversion occurs @param \ReflectionProperty $property @param Property $annot @return null|string
[ "Returns", "the", "type", "this", "property", "is", "changed", "to", "during", "serialization", "or", "false", "if", "no", "conversion", "occurs" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L70-L78
train
MarcusFulbright/represent
src/Represent/Handler/PropertyHandler.php
PropertyHandler.getConvertedValue
public function getConvertedValue(\ReflectionProperty $property, $original, Property $annot = null) { return $this->handleTypeConversion($this->propertyTypeOverride($annot, $property), $property->getValue($original)); }
php
public function getConvertedValue(\ReflectionProperty $property, $original, Property $annot = null) { return $this->handleTypeConversion($this->propertyTypeOverride($annot, $property), $property->getValue($original)); }
[ "public", "function", "getConvertedValue", "(", "\\", "ReflectionProperty", "$", "property", ",", "$", "original", ",", "Property", "$", "annot", "=", "null", ")", "{", "return", "$", "this", "->", "handleTypeConversion", "(", "$", "this", "->", "propertyTypeO...
Returns the value used for serialization from a reflection property @param \ReflectionProperty $property @param $original @param Property $annot @return bool|DateTime|int|string
[ "Returns", "the", "value", "used", "for", "serialization", "from", "a", "reflection", "property" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Handler/PropertyHandler.php#L88-L91
train
WellCommerce/Form
Formatter/JavascriptFormatter.php
JavascriptFormatter.formatAttributeValue
protected function formatAttributeValue(Attribute $attribute) { $value = $attribute->getValue(); if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) { return new Expr($value); } return $value; }
php
protected function formatAttributeValue(Attribute $attribute) { $value = $attribute->getValue(); if ($attribute->getType() === Attribute::TYPE_FUNCTION && strlen($value)) { return new Expr($value); } return $value; }
[ "protected", "function", "formatAttributeValue", "(", "Attribute", "$", "attribute", ")", "{", "$", "value", "=", "$", "attribute", "->", "getValue", "(", ")", ";", "if", "(", "$", "attribute", "->", "getType", "(", ")", "===", "Attribute", "::", "TYPE_FUN...
Formats attributes value @param Attribute $attribute @return mixed|Expr
[ "Formats", "attributes", "value" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Formatter/JavascriptFormatter.php#L121-L130
train
iwillhappy1314/wenprise-eloquent
src/WP/User.php
User.getAvatarAttribute
public function getAvatarAttribute() { $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : ''; return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash); }
php
public function getAvatarAttribute() { $hash = ! empty($this->email) ? md5(strtolower(trim($this->email))) : ''; return sprintf('//secure.gravatar.com/avatar/%s?d=mm', $hash); }
[ "public", "function", "getAvatarAttribute", "(", ")", "{", "$", "hash", "=", "!", "empty", "(", "$", "this", "->", "email", ")", "?", "md5", "(", "strtolower", "(", "trim", "(", "$", "this", "->", "email", ")", ")", ")", ":", "''", ";", "return", ...
Get the avatar url from Gravatar @return string
[ "Get", "the", "avatar", "url", "from", "Gravatar" ]
7eb045c7d19aaf5e7438625558a390ce39f1a34e
https://github.com/iwillhappy1314/wenprise-eloquent/blob/7eb045c7d19aaf5e7438625558a390ce39f1a34e/src/WP/User.php#L188-L193
train
Schibsted-Tech-Polska/travis-ci-client
src/Stp/TravisClient/Client.php
Client.prepareParametersUrl
private function prepareParametersUrl(array $params, array $allowedParams) { $allowedParams = array_flip($allowedParams); $params = array_intersect_key($params, $allowedParams); $paramsUrlItems = []; foreach ($params as $key => $param) { $paramsUrlItems[] = $key . '=' . urlencode($param); } $paramsUrl = join('&', $paramsUrlItems); if (strlen($paramsUrl) > 0) { $paramsUrl = '?' . $paramsUrl; } return $paramsUrl; }
php
private function prepareParametersUrl(array $params, array $allowedParams) { $allowedParams = array_flip($allowedParams); $params = array_intersect_key($params, $allowedParams); $paramsUrlItems = []; foreach ($params as $key => $param) { $paramsUrlItems[] = $key . '=' . urlencode($param); } $paramsUrl = join('&', $paramsUrlItems); if (strlen($paramsUrl) > 0) { $paramsUrl = '?' . $paramsUrl; } return $paramsUrl; }
[ "private", "function", "prepareParametersUrl", "(", "array", "$", "params", ",", "array", "$", "allowedParams", ")", "{", "$", "allowedParams", "=", "array_flip", "(", "$", "allowedParams", ")", ";", "$", "params", "=", "array_intersect_key", "(", "$", "params...
Prepares params url that can be appended to request. @param array $params @param array $allowedParams @return string
[ "Prepares", "params", "url", "that", "can", "be", "appended", "to", "request", "." ]
6c0a67a72e970efe4a8a924eae7119d5c8ab0fac
https://github.com/Schibsted-Tech-Polska/travis-ci-client/blob/6c0a67a72e970efe4a8a924eae7119d5c8ab0fac/src/Stp/TravisClient/Client.php#L203-L219
train
browserfs/base
src/EventEmitter.php
EventEmitter.on
public final function on( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => false, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
php
public final function on( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => false, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
[ "public", "final", "function", "on", "(", "$", "eventName", ",", "$", "eventCallback", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: stri...
Adds a event listener. @param eventName: string @param eventCallback: callable( $e: \browserfs\Event ) => void @throws \browserfs\Exception
[ "Adds", "a", "event", "listener", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L16-L50
train
browserfs/base
src/EventEmitter.php
EventEmitter.once
public final function once( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => true, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
php
public final function once( $eventName, $eventCallback ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected'); } else { if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: expected non-empty string'); } else { if ( !is_callable( $eventCallback ) ) { throw new \browserfs\Exception('Invalid argument $eventCallback: callable expected' ); } else { $this->events[ $eventName ] = isset( $this->events[ $eventName ] ) ? $this->events[ $eventName ] : []; $this->events[ $eventName ][] = [ 'once' => true, 'callback' => $eventCallback, 'fireId' => 0 ]; } } } }
[ "public", "final", "function", "once", "(", "$", "eventName", ",", "$", "eventCallback", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: st...
Adds a event listener that will be fired only once. @param eventName: string @param eventCallback: callable( $e: \browserfs\Event ) => void @throws \browserfs\Exception
[ "Adds", "a", "event", "listener", "that", "will", "be", "fired", "only", "once", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L58-L88
train
browserfs/base
src/EventEmitter.php
EventEmitter.callbackEquals
private static function callbackEquals( $callback1, $callback2 ) { if ( is_array( $callback1 ) && is_array( $callback2 ) ) { if ( count( $callback1 ) == count( $callback2 ) ) { for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) { if ( $callback1[$i] != $callback2[$i] ) { return false; } } return true; } else { return false; } } else { return $callback1 == $callback2; } }
php
private static function callbackEquals( $callback1, $callback2 ) { if ( is_array( $callback1 ) && is_array( $callback2 ) ) { if ( count( $callback1 ) == count( $callback2 ) ) { for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) { if ( $callback1[$i] != $callback2[$i] ) { return false; } } return true; } else { return false; } } else { return $callback1 == $callback2; } }
[ "private", "static", "function", "callbackEquals", "(", "$", "callback1", ",", "$", "callback2", ")", "{", "if", "(", "is_array", "(", "$", "callback1", ")", "&&", "is_array", "(", "$", "callback2", ")", ")", "{", "if", "(", "count", "(", "$", "callbac...
Helper to compare if two callbacks are equal. @param callback1 - callable @param callback2 - callable
[ "Helper", "to", "compare", "if", "two", "callbacks", "are", "equal", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L95-L121
train
browserfs/base
src/EventEmitter.php
EventEmitter.off
public final function off( $eventName, $eventCallback = null ) { if ( is_string( $eventName ) ) { if ( strlen( $eventName ) > 0 ) { if ( isset( $this->events[ $eventName ] ) ) { if ( $eventCallback === null ) { unset( $this->events[ $eventName ] ); } else { for ( $i = count( $this->events[ $eventName ] ) - 1; $i>=0; $i-- ) { if ( self::callbackEquals( $eventCallback, $this->events[ $eventName ][ $i ]['callback'] ) ) { // remove event array_splice( $this->events[ $eventName ], $i, 1 ); if ( count( $this->events[ $eventName ] ) == 0 ) { unset( $this->events[ $eventName ] ); } break; } } } } } else { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected!'); } } else { throw new \browserfs\Exception('Invalid argument $eventName: string expected!' ); } }
php
public final function off( $eventName, $eventCallback = null ) { if ( is_string( $eventName ) ) { if ( strlen( $eventName ) > 0 ) { if ( isset( $this->events[ $eventName ] ) ) { if ( $eventCallback === null ) { unset( $this->events[ $eventName ] ); } else { for ( $i = count( $this->events[ $eventName ] ) - 1; $i>=0; $i-- ) { if ( self::callbackEquals( $eventCallback, $this->events[ $eventName ][ $i ]['callback'] ) ) { // remove event array_splice( $this->events[ $eventName ], $i, 1 ); if ( count( $this->events[ $eventName ] ) == 0 ) { unset( $this->events[ $eventName ] ); } break; } } } } } else { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected!'); } } else { throw new \browserfs\Exception('Invalid argument $eventName: string expected!' ); } }
[ "public", "final", "function", "off", "(", "$", "eventName", ",", "$", "eventCallback", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "eventName", ")", ")", "{", "if", "(", "strlen", "(", "$", "eventName", ")", ">", "0", ")", "{", "if", ...
Removes a event listener callback binded to eventName @param eventName - string - > the name of the event @param eventCallback -> [ callable( $e: \browserfs\Event ): void ] -> a callable function that was previously added with the "on" or "once" methods. If unspecified, all listeners that were added to eventName will be cleared.
[ "Removes", "a", "event", "listener", "callback", "binded", "to", "eventName" ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L130-L177
train
browserfs/base
src/EventEmitter.php
EventEmitter.fire
public final function fire( $eventName /* ... $eventArgs: any[] */ ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected' ); } else if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected'); } if ( !isset( $this->events[ $eventName ] ) ) { return; } $eventArgs = array_slice( func_get_args(), 1 ); $event = Event::create( $eventName, $eventArgs ); try { $this->fireId++; // run the loop on a copy, in order to allow the $this->off method // to work properly $copy = []; foreach ( $this->events[ $eventName ] as &$subscriber ) { $copy[] = &$subscriber; } foreach ( $copy as &$subscriber ) { $subscriber['fireId'] = $this->fireId; call_user_func( $subscriber['callback'], $event ); if ( $event->isPropagationStopped() ) { break; } } if ( isset( $this->events[ $eventName ] ) ) { // remove the fired "once" listeners for ( $i = count( $this->events[ $eventName ] ) - 1; $i >= 0; $i-- ) { if ( $this->events[ $eventName ][$i]['fireId'] === $this->fireId ) { if ( $this->events[ $eventName ][$i]['once'] === true ) { // remove event array_splice( $this->events[$eventName], $i, 1 ); } } } } } catch ( \Exception $e ) { throw new \browserfs\Exception( "Error firing event " . $eventName, 0, $e ); } return $event; }
php
public final function fire( $eventName /* ... $eventArgs: any[] */ ) { if ( !is_string( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: string expected' ); } else if ( !strlen( $eventName ) ) { throw new \browserfs\Exception('Invalid argument $eventName: non-empty string expected'); } if ( !isset( $this->events[ $eventName ] ) ) { return; } $eventArgs = array_slice( func_get_args(), 1 ); $event = Event::create( $eventName, $eventArgs ); try { $this->fireId++; // run the loop on a copy, in order to allow the $this->off method // to work properly $copy = []; foreach ( $this->events[ $eventName ] as &$subscriber ) { $copy[] = &$subscriber; } foreach ( $copy as &$subscriber ) { $subscriber['fireId'] = $this->fireId; call_user_func( $subscriber['callback'], $event ); if ( $event->isPropagationStopped() ) { break; } } if ( isset( $this->events[ $eventName ] ) ) { // remove the fired "once" listeners for ( $i = count( $this->events[ $eventName ] ) - 1; $i >= 0; $i-- ) { if ( $this->events[ $eventName ][$i]['fireId'] === $this->fireId ) { if ( $this->events[ $eventName ][$i]['once'] === true ) { // remove event array_splice( $this->events[$eventName], $i, 1 ); } } } } } catch ( \Exception $e ) { throw new \browserfs\Exception( "Error firing event " . $eventName, 0, $e ); } return $event; }
[ "public", "final", "function", "fire", "(", "$", "eventName", "/* ... $eventArgs: any[] */", ")", "{", "if", "(", "!", "is_string", "(", "$", "eventName", ")", ")", "{", "throw", "new", "\\", "browserfs", "\\", "Exception", "(", "'Invalid argument $eventName: st...
Fires a event, and returns it's generated event object. @param $eventName: string -> the name of the event to be fired @param ...$eventArgs: any[] -> event arguments @return \browserfs\Event -> event object @throws \Exception
[ "Fires", "a", "event", "and", "returns", "it", "s", "generated", "event", "object", "." ]
d98550b5cf6f6e9083f99f39d17fd1b79d61db55
https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/EventEmitter.php#L186-L252
train
sebardo/ecommerce
EcommerceBundle/Entity/Repository/CategoryRepository.php
CategoryRepository.findNextSubcategory
public function findNextSubcategory($subcategory) { $qb = $this->getQueryBuilder() ->select('c') ->where('c.id > :id') ->andWhere('c.parentCategory = :parentCategory') ->orderBy('c.id', 'asc') ->setMaxResults(1) ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); // get the first subcategory when there is no next if (0 == count($qb->getQuery()->getResult())) { $qb->where('c.id < :id') ->andWhere('c.parentCategory = :parentCategory') ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); if (0 == count($qb->getQuery()->getResult())) { return null; } } return $qb->getQuery() ->getSingleResult(); }
php
public function findNextSubcategory($subcategory) { $qb = $this->getQueryBuilder() ->select('c') ->where('c.id > :id') ->andWhere('c.parentCategory = :parentCategory') ->orderBy('c.id', 'asc') ->setMaxResults(1) ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); // get the first subcategory when there is no next if (0 == count($qb->getQuery()->getResult())) { $qb->where('c.id < :id') ->andWhere('c.parentCategory = :parentCategory') ->setParameter('id', $subcategory->getId()) ->setParameter('parentCategory', $subcategory->getParentCategory()); if (0 == count($qb->getQuery()->getResult())) { return null; } } return $qb->getQuery() ->getSingleResult(); }
[ "public", "function", "findNextSubcategory", "(", "$", "subcategory", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "select", "(", "'c'", ")", "->", "where", "(", "'c.id > :id'", ")", "->", "andWhere", "(", "'c.parentCateg...
Find the next subcategory, or the first one if none is found @param Category $subcategory @return Category|null
[ "Find", "the", "next", "subcategory", "or", "the", "first", "one", "if", "none", "is", "found" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/CategoryRepository.php#L234-L259
train
sebardo/ecommerce
EcommerceBundle/Entity/Repository/CategoryRepository.php
CategoryRepository.getBrands
public function getBrands($category, $limit = null) { $qb = $this->getQueryBuilder() ->select('DISTINCT b.id, b.name') ->innerJoin('c.products', 'p') ->innerJoin('p.brand', 'b') ->where('p.active = TRUE') ->andWhere('b.available = TRUE'); if ($category->getFamily()) { // this is a category $qb->andWhere('c.parentCategory = :category') ->setParameter('category', $category); } else { // this is a subcategory $qb->andWhere('c = :category') ->setParameter('category', $category); } if (!is_null($limit)) { $qb->setMaxResults($limit); } return $qb->getQuery() ->getResult(); }
php
public function getBrands($category, $limit = null) { $qb = $this->getQueryBuilder() ->select('DISTINCT b.id, b.name') ->innerJoin('c.products', 'p') ->innerJoin('p.brand', 'b') ->where('p.active = TRUE') ->andWhere('b.available = TRUE'); if ($category->getFamily()) { // this is a category $qb->andWhere('c.parentCategory = :category') ->setParameter('category', $category); } else { // this is a subcategory $qb->andWhere('c = :category') ->setParameter('category', $category); } if (!is_null($limit)) { $qb->setMaxResults($limit); } return $qb->getQuery() ->getResult(); }
[ "public", "function", "getBrands", "(", "$", "category", ",", "$", "limit", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "select", "(", "'DISTINCT b.id, b.name'", ")", "->", "innerJoin", "(", "'c.products'", ...
Get brands from their products relationship @param Category $category @param integer|null $limit @return ArrayCollection
[ "Get", "brands", "from", "their", "products", "relationship" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/CategoryRepository.php#L269-L294
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.find
public function find($paths = null) { if ($paths === null) $paths = $this->paths; // iterator $iterator = $this->getIterator(); // search in target paths foreach ((array)$paths as $path) { $this->searchInPath($iterator, $path); } // clear $this->clear(); return $iterator; }
php
public function find($paths = null) { if ($paths === null) $paths = $this->paths; // iterator $iterator = $this->getIterator(); // search in target paths foreach ((array)$paths as $path) { $this->searchInPath($iterator, $path); } // clear $this->clear(); return $iterator; }
[ "public", "function", "find", "(", "$", "paths", "=", "null", ")", "{", "if", "(", "$", "paths", "===", "null", ")", "$", "paths", "=", "$", "this", "->", "paths", ";", "// iterator", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")"...
find trigger. @param string|array $paths
[ "find", "trigger", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L115-L131
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.searchInPath
private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0) { // when exists. if (file_exists($path)) { if(is_dir($path)) { $dir = new FileSystem\Directory($path); if ($parent) $dir->setParent($parent); if ($this->validate($dir)) $iterator->add($dir); if ($this->recursive || $depth < 1) { $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1); } } else { $file = new FileSystem\File($path); if ($parent) $file->setParent($parent); if ($this->validate($file)) $iterator->add($file); } } // when not exists, then glob. else { foreach (glob($path) as $file) { $this->searchInPath($iterator, $file, $parent, $depth); } } }
php
private function searchInPath(FileSystem\Iterator\IteratorAggregate $iterator, $path, FileSystem\Directory $parent = null, $depth = 0) { // when exists. if (file_exists($path)) { if(is_dir($path)) { $dir = new FileSystem\Directory($path); if ($parent) $dir->setParent($parent); if ($this->validate($dir)) $iterator->add($dir); if ($this->recursive || $depth < 1) { $this->searchInPath($iterator, "{$dir}/*", $dir, $depth + 1); } } else { $file = new FileSystem\File($path); if ($parent) $file->setParent($parent); if ($this->validate($file)) $iterator->add($file); } } // when not exists, then glob. else { foreach (glob($path) as $file) { $this->searchInPath($iterator, $file, $parent, $depth); } } }
[ "private", "function", "searchInPath", "(", "FileSystem", "\\", "Iterator", "\\", "IteratorAggregate", "$", "iterator", ",", "$", "path", ",", "FileSystem", "\\", "Directory", "$", "parent", "=", "null", ",", "$", "depth", "=", "0", ")", "{", "// when exists...
search files in target path. @param Samurai\Samurai\Component\FileSystem\Iterator\IteratorAggregate $iterator @param string $path @param Samurai\Samurai\Component\FileSystem\Directory $parent @param int $depth @return array
[ "search", "files", "in", "target", "path", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L143-L166
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.validate
private function validate(FileSystem\File $file) { $filters = $this->buildFilters(); foreach ($filters as $filter) { if (! $filter->validate($file)) return false; } return true; }
php
private function validate(FileSystem\File $file) { $filters = $this->buildFilters(); foreach ($filters as $filter) { if (! $filter->validate($file)) return false; } return true; }
[ "private", "function", "validate", "(", "FileSystem", "\\", "File", "$", "file", ")", "{", "$", "filters", "=", "$", "this", "->", "buildFilters", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "$", "f...
validate file. @param Samurai\Samurai\Component\FileSystem\File $file @return boolean
[ "validate", "file", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L175-L183
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.buildFilters
private function buildFilters() { $filters = array(); // file only ? or direcotry only ? if ($this->file_only) $filters[] = new Filter\FileOnlyFilter(); if ($this->directory_only) $filters[] = new Filter\DirectoryOnlyFilter(); // name match ? foreach ($this->names as $name) { $filters[] = new Filter\NameFilter($name); } return $filters; }
php
private function buildFilters() { $filters = array(); // file only ? or direcotry only ? if ($this->file_only) $filters[] = new Filter\FileOnlyFilter(); if ($this->directory_only) $filters[] = new Filter\DirectoryOnlyFilter(); // name match ? foreach ($this->names as $name) { $filters[] = new Filter\NameFilter($name); } return $filters; }
[ "private", "function", "buildFilters", "(", ")", "{", "$", "filters", "=", "array", "(", ")", ";", "// file only ? or direcotry only ?", "if", "(", "$", "this", "->", "file_only", ")", "$", "filters", "[", "]", "=", "new", "Filter", "\\", "FileOnlyFilter", ...
build filters for validate. @return array
[ "build", "filters", "for", "validate", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L191-L205
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.fileOnly
public function fileOnly($flag = true) { $this->file_only = $flag; if ($this->file_only) $this->directory_only = false; return $this; }
php
public function fileOnly($flag = true) { $this->file_only = $flag; if ($this->file_only) $this->directory_only = false; return $this; }
[ "public", "function", "fileOnly", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "file_only", "=", "$", "flag", ";", "if", "(", "$", "this", "->", "file_only", ")", "$", "this", "->", "directory_only", "=", "false", ";", "return", "$", ...
set file only flag is true @return Samurai\Samurai\Component\FileSystem\Finder\Finder
[ "set", "file", "only", "flag", "is", "true" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L250-L255
train
samurai-fw/samurai
src/Samurai/Component/FileSystem/Finder/Finder.php
Finder.directoryOnly
public function directoryOnly($flag = true) { $this->directory_only = $flag; if ($this->directory_only) $this->file_only = false; return $this; }
php
public function directoryOnly($flag = true) { $this->directory_only = $flag; if ($this->directory_only) $this->file_only = false; return $this; }
[ "public", "function", "directoryOnly", "(", "$", "flag", "=", "true", ")", "{", "$", "this", "->", "directory_only", "=", "$", "flag", ";", "if", "(", "$", "this", "->", "directory_only", ")", "$", "this", "->", "file_only", "=", "false", ";", "return"...
set directory only is true. @param boolean $flag @return Samurai\Samurai\Component\FileSystem\Finder\Finder
[ "set", "directory", "only", "is", "true", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/FileSystem/Finder/Finder.php#L263-L268
train
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.removeListener
public function removeListener(Listener $listener) { foreach ($this->listeners as $id => $listening) { if ($listener == $listening) { unset($this->listeners[$id]); break; } } }
php
public function removeListener(Listener $listener) { foreach ($this->listeners as $id => $listening) { if ($listener == $listening) { unset($this->listeners[$id]); break; } } }
[ "public", "function", "removeListener", "(", "Listener", "$", "listener", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "as", "$", "id", "=>", "$", "listening", ")", "{", "if", "(", "$", "listener", "==", "$", "listening", ")", "{", "unset"...
Remove a Listener Object @param Listener listener @note must be executed synchronously (in the context that created the Robot)
[ "Remove", "a", "Listener", "Object" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L34-L41
train
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.login
public function login($nick, $password = null) { if ($password) { if (!$this->connection->send("PASS {$password}")) { throw new \RuntimeException( "failed to send password to {$this->server}"); } } else { if (!$this->connection->send("PASS NOPASS")) { throw new \RuntimeException( "failed to send nopass to {$this->server}"); } } if (!$this->connection->send("NICK {$nick}")) { throw new \RuntimeException( "failed to set nick {$nick} on {$this->server}"); } $this->loop(false); if (!$this->connection->send("USER {$nick} AS IRC BOT")) { throw new \RuntimeException( "failed to set user {$nick} on {$this->server}"); } $this->loop(false); return $this; }
php
public function login($nick, $password = null) { if ($password) { if (!$this->connection->send("PASS {$password}")) { throw new \RuntimeException( "failed to send password to {$this->server}"); } } else { if (!$this->connection->send("PASS NOPASS")) { throw new \RuntimeException( "failed to send nopass to {$this->server}"); } } if (!$this->connection->send("NICK {$nick}")) { throw new \RuntimeException( "failed to set nick {$nick} on {$this->server}"); } $this->loop(false); if (!$this->connection->send("USER {$nick} AS IRC BOT")) { throw new \RuntimeException( "failed to set user {$nick} on {$this->server}"); } $this->loop(false); return $this; }
[ "public", "function", "login", "(", "$", "nick", ",", "$", "password", "=", "null", ")", "{", "if", "(", "$", "password", ")", "{", "if", "(", "!", "$", "this", "->", "connection", "->", "send", "(", "\"PASS {$password}\"", ")", ")", "{", "throw", ...
Login into server as nick with optional password @param string nick @param string password @return Connection @throws \RuntimeException
[ "Login", "into", "server", "as", "nick", "with", "optional", "password" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L68-L96
train
DatingVIP/IRC
src/DatingVIP/IRC/Robot.php
Robot.loop
public function loop($main = true) { if ($main && $this->manager) { $this->manager->onStartup($this); } while (($line = $this->connection->recv())) { if (preg_match("~^ping :(.*)?~i", $line, $pong)) { if (!$this->connection->send("PONG {$pong[1]}")) { throw new \RuntimeException( "failed to send PONG to {$this->server}"); } } else { $message = new Message($line); /* management interface invokation */ if ($main && $this->manager) { switch ($message->getType()) { case Message::join: $this->manager->onJoin($this, $message); break; case Message::part: $this->manager->onPart($this, $message); break; case Message::nick: $this->manager->onNick($this, $message); break; case Message::priv: $this->manager->onPriv($this, $message); break; /* and so on ... */ } } /* listener interface invokation */ foreach ($this->listeners as $listener) { $response = $listener ->onReceive($this->connection, $message); if ($response) { if (($response instanceof Task)) { $this->pool ->submit($response); continue; } throw new \RuntimeException(sprintf( "%s returned an invalid response, ". "expected Task object or nothing", get_class($listener))); } } } if (!$main) break; $this->pool->collect(function($responder) { if ($responder instanceof Task) { return $responder->isGarbage(); } else return true; }); } if ($main && $this->manager) { $this->manager->onShutdown($this); } return $main ? $this->loop($main) : $this; }
php
public function loop($main = true) { if ($main && $this->manager) { $this->manager->onStartup($this); } while (($line = $this->connection->recv())) { if (preg_match("~^ping :(.*)?~i", $line, $pong)) { if (!$this->connection->send("PONG {$pong[1]}")) { throw new \RuntimeException( "failed to send PONG to {$this->server}"); } } else { $message = new Message($line); /* management interface invokation */ if ($main && $this->manager) { switch ($message->getType()) { case Message::join: $this->manager->onJoin($this, $message); break; case Message::part: $this->manager->onPart($this, $message); break; case Message::nick: $this->manager->onNick($this, $message); break; case Message::priv: $this->manager->onPriv($this, $message); break; /* and so on ... */ } } /* listener interface invokation */ foreach ($this->listeners as $listener) { $response = $listener ->onReceive($this->connection, $message); if ($response) { if (($response instanceof Task)) { $this->pool ->submit($response); continue; } throw new \RuntimeException(sprintf( "%s returned an invalid response, ". "expected Task object or nothing", get_class($listener))); } } } if (!$main) break; $this->pool->collect(function($responder) { if ($responder instanceof Task) { return $responder->isGarbage(); } else return true; }); } if ($main && $this->manager) { $this->manager->onShutdown($this); } return $main ? $this->loop($main) : $this; }
[ "public", "function", "loop", "(", "$", "main", "=", "true", ")", "{", "if", "(", "$", "main", "&&", "$", "this", "->", "manager", ")", "{", "$", "this", "->", "manager", "->", "onStartup", "(", "$", "this", ")", ";", "}", "while", "(", "(", "$...
Enter into IO loop @param boolean main @return Connection @throws \RuntimeException
[ "Enter", "into", "IO", "loop" ]
c09add1317210cd772529146fc617130db957c16
https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Robot.php#L118-L178
train
xloit/xloit-bridge-zend-servicemanager
src/ServiceFactory.php
ServiceFactory.createServiceFactory
protected function createServiceFactory( $requestedName, ReflectionClass $reflection, ContainerInterface $container ) { /** @var array $mappings */ $mappings = $this->getServiceMapping($container, $requestedName); if ($reflection->implementsInterface(Factory\FactoryInterface::class)) { $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace); } else { $factory = $reflection->newInstance(); } $this->lookupCache[$requestedName]['factoryInstance'] = $factory; if ($factory instanceof Factory\FactoryInterface) { /** @var Factory\FactoryInterface $factory */ $factory->setContainer($container); } return $factory($container, $requestedName); }
php
protected function createServiceFactory( $requestedName, ReflectionClass $reflection, ContainerInterface $container ) { /** @var array $mappings */ $mappings = $this->getServiceMapping($container, $requestedName); if ($reflection->implementsInterface(Factory\FactoryInterface::class)) { $factory = $reflection->newInstance($mappings['namespace'], $mappings['service'], $this->namespace); } else { $factory = $reflection->newInstance(); } $this->lookupCache[$requestedName]['factoryInstance'] = $factory; if ($factory instanceof Factory\FactoryInterface) { /** @var Factory\FactoryInterface $factory */ $factory->setContainer($container); } return $factory($container, $requestedName); }
[ "protected", "function", "createServiceFactory", "(", "$", "requestedName", ",", "ReflectionClass", "$", "reflection", ",", "ContainerInterface", "$", "container", ")", "{", "/** @var array $mappings */", "$", "mappings", "=", "$", "this", "->", "getServiceMapping", "...
Initiate service factory from the ReflectionClass. @param string $requestedName @param ReflectionClass $reflection @param ContainerInterface $container @return mixed @throws \ReflectionException @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface @throws \Xloit\Std\Exception\RuntimeException
[ "Initiate", "service", "factory", "from", "the", "ReflectionClass", "." ]
f3285842a6fdcb3de0416b98f9bc20dd7a122cc4
https://github.com/xloit/xloit-bridge-zend-servicemanager/blob/f3285842a6fdcb3de0416b98f9bc20dd7a122cc4/src/ServiceFactory.php#L201-L221
train
leedave/filehandler
src/File.php
File.iterateFileName
protected static function iterateFileName(string $fileName) { //First remove Extension $arrFileParts = explode(".", $fileName); $extension = array_pop($arrFileParts); $tempFileName = implode(".", $arrFileParts); $arrFileName = explode("_", $tempFileName); if (is_numeric($arrFileName[(count($arrFileName) - 1)])) { $iterator = (int) array_pop($arrFileName); $iterator++; $arrFileName[] = $iterator; $newFileName = implode("_", $arrFileName); return $newFileName . "." . $extension; } return $tempFileName."_1." . $extension; }
php
protected static function iterateFileName(string $fileName) { //First remove Extension $arrFileParts = explode(".", $fileName); $extension = array_pop($arrFileParts); $tempFileName = implode(".", $arrFileParts); $arrFileName = explode("_", $tempFileName); if (is_numeric($arrFileName[(count($arrFileName) - 1)])) { $iterator = (int) array_pop($arrFileName); $iterator++; $arrFileName[] = $iterator; $newFileName = implode("_", $arrFileName); return $newFileName . "." . $extension; } return $tempFileName."_1." . $extension; }
[ "protected", "static", "function", "iterateFileName", "(", "string", "$", "fileName", ")", "{", "//First remove Extension", "$", "arrFileParts", "=", "explode", "(", "\".\"", ",", "$", "fileName", ")", ";", "$", "extension", "=", "array_pop", "(", "$", "arrFil...
Puts a number on the end of a file name, prevents overwriting @param string $fileName @return string
[ "Puts", "a", "number", "on", "the", "end", "of", "a", "file", "name", "prevents", "overwriting" ]
924e3fed15861b7d74e8e62aad6dd41b274e777a
https://github.com/leedave/filehandler/blob/924e3fed15861b7d74e8e62aad6dd41b274e777a/src/File.php#L42-L57
train
phramework/basic-authentication
src/BasicAuthentication.php
BasicAuthentication.authenticate
public function authenticate($params, $method, $headers) { $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']); $password = $params['password']; $user = call_user_func(Manager::getUserGetByEmailMethod(), $email); if (!$user) { return false; } if (!password_verify($password, $user['password'])) { return false; } /* * Create the token as an array */ $data = [ 'id' => $user['id'] ]; //copy user attributes to jwt's data foreach (Manager::getAttributes() as $attribute) { if (!isset($user[$attribute])) { throw new \Phramework\Exceptions\ServerException(sprintf( 'Attribute "%s" is not set in user object', $attribute )); } $data[$attribute] = $user[$attribute]; } //Convert to object $data = (object)$data; //Call onAuthenticate callback if set if (($callback = Manager::getOnAuthenticateCallback()) !== null) { call_user_func( $callback, $data ); } return [$data]; }
php
public function authenticate($params, $method, $headers) { $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']); $password = $params['password']; $user = call_user_func(Manager::getUserGetByEmailMethod(), $email); if (!$user) { return false; } if (!password_verify($password, $user['password'])) { return false; } /* * Create the token as an array */ $data = [ 'id' => $user['id'] ]; //copy user attributes to jwt's data foreach (Manager::getAttributes() as $attribute) { if (!isset($user[$attribute])) { throw new \Phramework\Exceptions\ServerException(sprintf( 'Attribute "%s" is not set in user object', $attribute )); } $data[$attribute] = $user[$attribute]; } //Convert to object $data = (object)$data; //Call onAuthenticate callback if set if (($callback = Manager::getOnAuthenticateCallback()) !== null) { call_user_func( $callback, $data ); } return [$data]; }
[ "public", "function", "authenticate", "(", "$", "params", ",", "$", "method", ",", "$", "headers", ")", "{", "$", "email", "=", "\\", "Phramework", "\\", "Validate", "\\", "EmailValidator", "::", "parseStatic", "(", "$", "params", "[", "'email'", "]", ")...
Authenticate a user using JWT authentication method @param array $params Request parameters @param string $method Request method @param array $headers Request headers @return false|array Returns false on failure
[ "Authenticate", "a", "user", "using", "JWT", "authentication", "method" ]
9c2a5b89a589f58a8f2fb0df6c708803e5e7ada3
https://github.com/phramework/basic-authentication/blob/9c2a5b89a589f58a8f2fb0df6c708803e5e7ada3/src/BasicAuthentication.php#L110-L155
train
ncrypthic/lla-dci
src/LLA/Dci/ContextTrait.php
ContextTrait.set
public function set($prop, $value) { $class = get_class($this); if(property_exists($class, $prop)) { // Use reflection to set private property $reflection = new \ReflectionProperty($class, $prop); $reflection->setAccessible(true); $reflection->setValue($this, $value); } else { $msg = sprintf("Unexpected data set `%s` on `%s`", $prop, $class); throw new ContextException($msg); } return $this; }
php
public function set($prop, $value) { $class = get_class($this); if(property_exists($class, $prop)) { // Use reflection to set private property $reflection = new \ReflectionProperty($class, $prop); $reflection->setAccessible(true); $reflection->setValue($this, $value); } else { $msg = sprintf("Unexpected data set `%s` on `%s`", $prop, $class); throw new ContextException($msg); } return $this; }
[ "public", "function", "set", "(", "$", "prop", ",", "$", "value", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "if", "(", "property_exists", "(", "$", "class", ",", "$", "prop", ")", ")", "{", "// Use reflection to set private ...
Set context data @param string $prop @param mixed $value @return this @throws \Ris\Dci\ContextDataException
[ "Set", "context", "data" ]
c27f46884747d56213f28a64f5537766dc8020c5
https://github.com/ncrypthic/lla-dci/blob/c27f46884747d56213f28a64f5537766dc8020c5/src/LLA/Dci/ContextTrait.php#L16-L29
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addCondition
public function addCondition($field, $value = false, $operator = '=') { if (is_array($field) && !$value) { foreach ($field as $key => $value) { // handles #6 if (is_array($value)) { call_user_func_array([$this, 'addCondition'], $value); // handles #7 } elseif (!is_numeric($key)) { $this->addCondition($key, $value); // handles #8 } else { $this->addCondition($value); } } return $this; } // handles #4 and #5 $condition = [$field]; // handles #1, #2, and #3 if (func_num_args() >= 2) { $condition[] = $operator; $condition[] = $value; } $this->conditions[] = $condition; return $this; }
php
public function addCondition($field, $value = false, $operator = '=') { if (is_array($field) && !$value) { foreach ($field as $key => $value) { // handles #6 if (is_array($value)) { call_user_func_array([$this, 'addCondition'], $value); // handles #7 } elseif (!is_numeric($key)) { $this->addCondition($key, $value); // handles #8 } else { $this->addCondition($value); } } return $this; } // handles #4 and #5 $condition = [$field]; // handles #1, #2, and #3 if (func_num_args() >= 2) { $condition[] = $operator; $condition[] = $value; } $this->conditions[] = $condition; return $this; }
[ "public", "function", "addCondition", "(", "$", "field", ",", "$", "value", "=", "false", ",", "$", "operator", "=", "'='", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", "&&", "!", "$", "value", ")", "{", "foreach", "(", "$", "field", ...
Adds a condition to the statement. Accepts the following forms: 1. Equality comparison: addCondition('username', 'john') 2. Comparison with custom operator: addCondition('balance', 100, '>') 3. IN statement: addCondition('group', ['admin', 'owner']) 4. SQL fragment: addCondition('name LIKE "%john%"') 5. Subquery: addCondition(function(SelectQuery $query) {}) 6. List of conditions to add: addCondition([['balance', 100, '>'], ['user_id', 5]]) 7. Map of equality comparisons: addCondition(['username' => 'john', 'user_id' => 5]) 8. List of SQL fragments: addCondition(['first_name LIKE "%john%"', 'last_name LIKE "%doe%"']) @param array|string $field @param string|bool $value condition value (optional) @param string $operator operator (optional) @return self
[ "Adds", "a", "condition", "to", "the", "statement", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L75-L106
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addBetweenCondition
public function addBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, true]; return $this; }
php
public function addBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, true]; return $this; }
[ "public", "function", "addBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "[", "'BETWEEN'", ",", "$", "field", ",", "$", "a", ",", "$", "b", ",", "true", "]", ";", "r...
Adds a between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L130-L135
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.addNotBetweenCondition
public function addNotBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, false]; return $this; }
php
public function addNotBetweenCondition($field, $a, $b) { $this->conditions[] = ['BETWEEN', $field, $a, $b, false]; return $this; }
[ "public", "function", "addNotBetweenCondition", "(", "$", "field", ",", "$", "a", ",", "$", "b", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "[", "'BETWEEN'", ",", "$", "field", ",", "$", "a", ",", "$", "b", ",", "false", "]", ";", ...
Adds a not between condition to the query. @param string $field @param mixed $a first between value @param mixed $b second between value @return self
[ "Adds", "a", "not", "between", "condition", "to", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L146-L151
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildClause
protected function buildClause(array $cond) { // handle SQL fragments if (count($cond) == 1 && (is_string($cond[0]) || !is_callable($cond[0]))) { return $cond[0]; } // handle EXISTS conditions if ($cond[0] === 'EXISTS') { return $this->buildExists($cond[1], $cond[2]); } // handle BETWEEN conditions if ($cond[0] === 'BETWEEN') { return $this->buildBetween($cond[1], $cond[2], $cond[3], $cond[4]); } // escape an identifier if (is_string($cond[0]) || !is_callable($cond[0])) { $cond[0] = $this->escapeIdentifier($cond[0]); // handle a subquery // NOTE string callables are not supported // as subquery functions } elseif (is_callable($cond[0])) { $cond[0] = $this->buildSubquery($cond[0]); } if (count($cond) === 1 || empty($cond[0])) { return $cond[0]; } // handle NULL values if ($cond[2] === null && in_array($cond[1], ['=', '<>'])) { return $this->buildNull($cond[0], $cond[1] == '='); } // handle IN values if (is_array($cond[2]) && in_array($cond[1], ['=', '<>'])) { return $this->buildIn($cond[0], $cond[2], $cond[1] == '='); } // otherwise parameterize the value $cond[2] = $this->parameterize($cond[2]); return implode(' ', $cond); }
php
protected function buildClause(array $cond) { // handle SQL fragments if (count($cond) == 1 && (is_string($cond[0]) || !is_callable($cond[0]))) { return $cond[0]; } // handle EXISTS conditions if ($cond[0] === 'EXISTS') { return $this->buildExists($cond[1], $cond[2]); } // handle BETWEEN conditions if ($cond[0] === 'BETWEEN') { return $this->buildBetween($cond[1], $cond[2], $cond[3], $cond[4]); } // escape an identifier if (is_string($cond[0]) || !is_callable($cond[0])) { $cond[0] = $this->escapeIdentifier($cond[0]); // handle a subquery // NOTE string callables are not supported // as subquery functions } elseif (is_callable($cond[0])) { $cond[0] = $this->buildSubquery($cond[0]); } if (count($cond) === 1 || empty($cond[0])) { return $cond[0]; } // handle NULL values if ($cond[2] === null && in_array($cond[1], ['=', '<>'])) { return $this->buildNull($cond[0], $cond[1] == '='); } // handle IN values if (is_array($cond[2]) && in_array($cond[1], ['=', '<>'])) { return $this->buildIn($cond[0], $cond[2], $cond[1] == '='); } // otherwise parameterize the value $cond[2] = $this->parameterize($cond[2]); return implode(' ', $cond); }
[ "protected", "function", "buildClause", "(", "array", "$", "cond", ")", "{", "// handle SQL fragments", "if", "(", "count", "(", "$", "cond", ")", "==", "1", "&&", "(", "is_string", "(", "$", "cond", "[", "0", "]", ")", "||", "!", "is_callable", "(", ...
Builds a parameterized and escaped SQL fragment for a condition that uses our own internal representation. A condition is represented by an array, and can be have one of the following forms: 1. ['SQL fragment'] 2. ['identifier', '=', 'value'] 3. ['BETWEEN', 'identifier', 'value', 'value', true] 4. ['EXISTS', function(SelectQuery $query) {}, true] 5. [function(SelectQuery $query) {}] 6. [function(SelectQuery $query) {}, '=', 'value'] @param array $cond @return string generated SQL fragment
[ "Builds", "a", "parameterized", "and", "escaped", "SQL", "fragment", "for", "a", "condition", "that", "uses", "our", "own", "internal", "representation", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L230-L276
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildSubquery
protected function buildSubquery(callable $f) { $query = new SelectQuery(); $query->getSelect()->clearFields(); $f($query); $sql = $query->build(); $this->values = array_merge($this->values, $query->getValues()); return '('.$sql.')'; }
php
protected function buildSubquery(callable $f) { $query = new SelectQuery(); $query->getSelect()->clearFields(); $f($query); $sql = $query->build(); $this->values = array_merge($this->values, $query->getValues()); return '('.$sql.')'; }
[ "protected", "function", "buildSubquery", "(", "callable", "$", "f", ")", "{", "$", "query", "=", "new", "SelectQuery", "(", ")", ";", "$", "query", "->", "getSelect", "(", ")", "->", "clearFields", "(", ")", ";", "$", "f", "(", "$", "query", ")", ...
Builds a subquery. @param callable $f @return string
[ "Builds", "a", "subquery", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L285-L294
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildBetween
protected function buildBetween($field, $value1, $value2, $isBetween) { $operator = $isBetween ? 'BETWEEN' : 'NOT BETWEEN'; return $this->escapeIdentifier($field).' '.$operator.' '.$this->parameterize($value1).' AND '.$this->parameterize($value2); }
php
protected function buildBetween($field, $value1, $value2, $isBetween) { $operator = $isBetween ? 'BETWEEN' : 'NOT BETWEEN'; return $this->escapeIdentifier($field).' '.$operator.' '.$this->parameterize($value1).' AND '.$this->parameterize($value2); }
[ "protected", "function", "buildBetween", "(", "$", "field", ",", "$", "value1", ",", "$", "value2", ",", "$", "isBetween", ")", "{", "$", "operator", "=", "$", "isBetween", "?", "'BETWEEN'", ":", "'NOT BETWEEN'", ";", "return", "$", "this", "->", "escape...
Builds a BETWEEN clause. @param string $field @param mixed $value1 @param mixed $value2 @param bool $isBetween @return string
[ "Builds", "a", "BETWEEN", "clause", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L321-L326
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.buildIn
protected function buildIn($field, array $values, $isIn) { $operator = $isIn ? ' IN ' : ' NOT IN '; return $field.$operator.$this->parameterizeValues($values); }
php
protected function buildIn($field, array $values, $isIn) { $operator = $isIn ? ' IN ' : ' NOT IN '; return $field.$operator.$this->parameterizeValues($values); }
[ "protected", "function", "buildIn", "(", "$", "field", ",", "array", "$", "values", ",", "$", "isIn", ")", "{", "$", "operator", "=", "$", "isIn", "?", "' IN '", ":", "' NOT IN '", ";", "return", "$", "field", ".", "$", "operator", ".", "$", "this", ...
Builds an IN clause. @param string $field @param array $values @param bool $isIn @return string
[ "Builds", "an", "IN", "clause", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L352-L357
train
jaredtking/jaqb
src/Statement/WhereStatement.php
WhereStatement.implodeClauses
protected function implodeClauses(array $clauses) { $str = ''; $op = false; foreach ($clauses as $clause) { // an 'OR' token will change the operator used // when concatenating the next clause if ($clause == 'OR') { $op = ' OR '; continue; } if ($op && $str) { $str .= $op; } $str .= $clause; $op = ' AND '; } return $str; }
php
protected function implodeClauses(array $clauses) { $str = ''; $op = false; foreach ($clauses as $clause) { // an 'OR' token will change the operator used // when concatenating the next clause if ($clause == 'OR') { $op = ' OR '; continue; } if ($op && $str) { $str .= $op; } $str .= $clause; $op = ' AND '; } return $str; }
[ "protected", "function", "implodeClauses", "(", "array", "$", "clauses", ")", "{", "$", "str", "=", "''", ";", "$", "op", "=", "false", ";", "foreach", "(", "$", "clauses", "as", "$", "clause", ")", "{", "// an 'OR' token will change the operator used", "// ...
Implodes a list of WHERE clauses. @param array $clauses @return string
[ "Implodes", "a", "list", "of", "WHERE", "clauses", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Statement/WhereStatement.php#L366-L387
train
nonetallt/jinitialize-core
src/JinitializeCommand.php
JinitializeCommand.export
protected function export(string $key, $value) { $container = JinitializeContainer::getInstance(); $container->getPlugin($this->getPluginName())->getContainer()->set($key, $value); }
php
protected function export(string $key, $value) { $container = JinitializeContainer::getInstance(); $container->getPlugin($this->getPluginName())->getContainer()->set($key, $value); }
[ "protected", "function", "export", "(", "string", "$", "key", ",", "$", "value", ")", "{", "$", "container", "=", "JinitializeContainer", "::", "getInstance", "(", ")", ";", "$", "container", "->", "getPlugin", "(", "$", "this", "->", "getPluginName", "(",...
Save a value to the application container
[ "Save", "a", "value", "to", "the", "application", "container" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeCommand.php#L64-L68
train
nonetallt/jinitialize-core
src/JinitializeCommand.php
JinitializeCommand.import
protected function import(string $key) { $container = JinitializeContainer::getInstance(); return $container->getPlugin($this->getPluginName())->getContainer()->get($key); }
php
protected function import(string $key) { $container = JinitializeContainer::getInstance(); return $container->getPlugin($this->getPluginName())->getContainer()->get($key); }
[ "protected", "function", "import", "(", "string", "$", "key", ")", "{", "$", "container", "=", "JinitializeContainer", "::", "getInstance", "(", ")", ";", "return", "$", "container", "->", "getPlugin", "(", "$", "this", "->", "getPluginName", "(", ")", ")"...
Get a value from the local plugin container
[ "Get", "a", "value", "from", "the", "local", "plugin", "container" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeCommand.php#L74-L78
train
jooorooo/embed
src/ImageInfo/Curl.php
Curl.getImageInfo
public static function getImageInfo($image, array $config = null) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $img = new static($image['value'], $finfo, $config); $curl = $img->getConnection(); curl_exec($curl); curl_close($curl); $info = $img->getInfo(); finfo_close($finfo); return $info; }
php
public static function getImageInfo($image, array $config = null) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $img = new static($image['value'], $finfo, $config); $curl = $img->getConnection(); curl_exec($curl); curl_close($curl); $info = $img->getInfo(); finfo_close($finfo); return $info; }
[ "public", "static", "function", "getImageInfo", "(", "$", "image", ",", "array", "$", "config", "=", "null", ")", "{", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "img", "=", "new", "static", "(", "$", "image", "[", "'val...
Get the info of only one image @param string $image @param null|array $config @return array|null
[ "Get", "the", "info", "of", "only", "one", "image" ]
078e70a093f246dc8e10b92f909f9166932c4106
https://github.com/jooorooo/embed/blob/078e70a093f246dc8e10b92f909f9166932c4106/src/ImageInfo/Curl.php#L97-L111
train
jooorooo/embed
src/ImageInfo/Curl.php
Curl.writeCallback
public function writeCallback($connection, $string) { $this->content .= $string; if (!$this->mime) { $this->mime = finfo_buffer($this->finfo, $this->content); if (!in_array($this->mime, static::$mimetypes, true)) { $this->mime = null; return -1; } } if (!($info = getimagesizefromstring($this->content))) { return strlen($string); } $this->info = [ 'width' => $info[0], 'height' => $info[1], 'size' => $info[0] * $info[1], 'mime' => $this->mime, ]; return -1; }
php
public function writeCallback($connection, $string) { $this->content .= $string; if (!$this->mime) { $this->mime = finfo_buffer($this->finfo, $this->content); if (!in_array($this->mime, static::$mimetypes, true)) { $this->mime = null; return -1; } } if (!($info = getimagesizefromstring($this->content))) { return strlen($string); } $this->info = [ 'width' => $info[0], 'height' => $info[1], 'size' => $info[0] * $info[1], 'mime' => $this->mime, ]; return -1; }
[ "public", "function", "writeCallback", "(", "$", "connection", ",", "$", "string", ")", "{", "$", "this", "->", "content", ".=", "$", "string", ";", "if", "(", "!", "$", "this", "->", "mime", ")", "{", "$", "this", "->", "mime", "=", "finfo_buffer", ...
Callback used to save the first bytes of the body content @param resource $connection @param string $string return integer
[ "Callback", "used", "to", "save", "the", "first", "bytes", "of", "the", "body", "content" ]
078e70a093f246dc8e10b92f909f9166932c4106
https://github.com/jooorooo/embed/blob/078e70a093f246dc8e10b92f909f9166932c4106/src/ImageInfo/Curl.php#L165-L191
train
gperler/common
src/Civis/Common/File.php
File.delete
public function delete() { if (!$this->exists()) { return false; } if ($this->isDir()) { return rmdir($this->absoluteFileName); } return unlink($this->absoluteFileName); }
php
public function delete() { if (!$this->exists()) { return false; } if ($this->isDir()) { return rmdir($this->absoluteFileName); } return unlink($this->absoluteFileName); }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "isDir", "(", ")", ")", "{", "return", "rmdir", "(", "$", "this", "->", ...
tries to delete a file @return bool
[ "tries", "to", "delete", "a", "file" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L94-L104
train
gperler/common
src/Civis/Common/File.php
File.createDir
public function createDir($mode = 0777) { return is_dir($this->absoluteFileName) || mkdir($this->absoluteFileName, $mode, true); }
php
public function createDir($mode = 0777) { return is_dir($this->absoluteFileName) || mkdir($this->absoluteFileName, $mode, true); }
[ "public", "function", "createDir", "(", "$", "mode", "=", "0777", ")", "{", "return", "is_dir", "(", "$", "this", "->", "absoluteFileName", ")", "||", "mkdir", "(", "$", "this", "->", "absoluteFileName", ",", "$", "mode", ",", "true", ")", ";", "}" ]
creates needed directories recursively @param int $mode @return bool
[ "creates", "needed", "directories", "recursively" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L141-L144
train
gperler/common
src/Civis/Common/File.php
File.scanDir
public function scanDir() { // only possible in directories if (!$this->isDir() || !$this->exists()) { return null; } $fileList = []; $fileNameList = scandir($this->absoluteFileName); foreach ($fileNameList as $fileName) { // do not add . and .. if ($fileName === "." or $fileName === "..") { continue; } $absoluteFileName = $this->absoluteFileName . "/" . $fileName; $fileList [] = new File ($absoluteFileName); } return $fileList; }
php
public function scanDir() { // only possible in directories if (!$this->isDir() || !$this->exists()) { return null; } $fileList = []; $fileNameList = scandir($this->absoluteFileName); foreach ($fileNameList as $fileName) { // do not add . and .. if ($fileName === "." or $fileName === "..") { continue; } $absoluteFileName = $this->absoluteFileName . "/" . $fileName; $fileList [] = new File ($absoluteFileName); } return $fileList; }
[ "public", "function", "scanDir", "(", ")", "{", "// only possible in directories", "if", "(", "!", "$", "this", "->", "isDir", "(", ")", "||", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "$", "fileList", "=", "["...
scans a directory and returns a list of Files @return File[]
[ "scans", "a", "directory", "and", "returns", "a", "list", "of", "Files" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L150-L169
train
gperler/common
src/Civis/Common/File.php
File.findFirstOccurenceOfFile
public function findFirstOccurenceOfFile(string $fileName) { if (!$this->isDir() || !$this->exists()) { return null; } foreach ($this->scanDir() as $file) { if ($file->getFileName() === $fileName) { return $file; } if ($file->isDir()) { $result = $file->findFirstOccurenceOfFile($fileName); if ($result !== null) { return $result; } } } return null; }
php
public function findFirstOccurenceOfFile(string $fileName) { if (!$this->isDir() || !$this->exists()) { return null; } foreach ($this->scanDir() as $file) { if ($file->getFileName() === $fileName) { return $file; } if ($file->isDir()) { $result = $file->findFirstOccurenceOfFile($fileName); if ($result !== null) { return $result; } } } return null; }
[ "public", "function", "findFirstOccurenceOfFile", "(", "string", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "isDir", "(", ")", "||", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "return", "null", ";", "}", "foreach", "(", ...
Finds the first occurence of the given filename @param string $fileName @return null|File
[ "Finds", "the", "first", "occurence", "of", "the", "given", "filename" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L178-L197
train
gperler/common
src/Civis/Common/File.php
File.loadAsXSLTProcessor
public function loadAsXSLTProcessor() { $this->checkFileExists(); $xsl = new \XSLTProcessor(); $xsl->importStylesheet($this->loadAsXML()); return $xsl; }
php
public function loadAsXSLTProcessor() { $this->checkFileExists(); $xsl = new \XSLTProcessor(); $xsl->importStylesheet($this->loadAsXML()); return $xsl; }
[ "public", "function", "loadAsXSLTProcessor", "(", ")", "{", "$", "this", "->", "checkFileExists", "(", ")", ";", "$", "xsl", "=", "new", "\\", "XSLTProcessor", "(", ")", ";", "$", "xsl", "->", "importStylesheet", "(", "$", "this", "->", "loadAsXML", "(",...
loads the file as XSLT Processor @return \XSLTProcessor
[ "loads", "the", "file", "as", "XSLT", "Processor" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L227-L233
train
gperler/common
src/Civis/Common/File.php
File.loadAsXML
public function loadAsXML() { $this->checkFileExists(); $xml = new \DomDocument (); libxml_use_internal_errors(true); $result = $xml->load($this->absoluteFileName); if ($result) { return $xml; } $messageObject = ArrayUtil::getFromArray(libxml_get_errors(), 0); $libXMLMessage = ObjectUtil::getFromObject($messageObject, "message"); $message = sprintf(self::EXCEPTION_INVALID_XML, $this->absoluteFileName, $libXMLMessage); $e = new \Exception(libxml_get_errors()[0]->message); libxml_clear_errors(); throw $e; }
php
public function loadAsXML() { $this->checkFileExists(); $xml = new \DomDocument (); libxml_use_internal_errors(true); $result = $xml->load($this->absoluteFileName); if ($result) { return $xml; } $messageObject = ArrayUtil::getFromArray(libxml_get_errors(), 0); $libXMLMessage = ObjectUtil::getFromObject($messageObject, "message"); $message = sprintf(self::EXCEPTION_INVALID_XML, $this->absoluteFileName, $libXMLMessage); $e = new \Exception(libxml_get_errors()[0]->message); libxml_clear_errors(); throw $e; }
[ "public", "function", "loadAsXML", "(", ")", "{", "$", "this", "->", "checkFileExists", "(", ")", ";", "$", "xml", "=", "new", "\\", "DomDocument", "(", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "result", "=", "$", "xml", "->"...
loads the file as XML DOMDocument @return \DomDocument @throws \Exception
[ "loads", "the", "file", "as", "XML", "DOMDocument" ]
d9e58e4f52715ef431475700a8ab85aa3c480749
https://github.com/gperler/common/blob/d9e58e4f52715ef431475700a8ab85aa3c480749/src/Civis/Common/File.php#L240-L255
train
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldBeVisible
public function elementShouldBeVisible($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->isVisible()); }
php
public function elementShouldBeVisible($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->isVisible()); }
[ "public", "function", "elementShouldBeVisible", "(", "$", "selector", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "...
Checks an element is visible @Then /^"([^"]*)" element should be visible$/ @return void
[ "Checks", "an", "element", "is", "visible" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L46-L57
train
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldBeHidden
public function elementShouldBeHidden($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->isVisible()); }
php
public function elementShouldBeHidden($selector) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->isVisible()); }
[ "public", "function", "elementShouldBeHidden", "(", "$", "selector", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", "=", "$", "page", "-...
Checks an element is hidden @Then /^"([^"]*)" element should be hidden$/ @return void
[ "Checks", "an", "element", "is", "hidden" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L68-L79
train
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldHaveClass
public function elementShouldHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->hasClass($class)); }
php
public function elementShouldHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertTrue($element->hasClass($class)); }
[ "public", "function", "elementShouldHaveClass", "(", "$", "selector", ",", "$", "class", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element", ...
Checks an element has a class @Then /^"([^"]*)" element should have class "([^"]*)"$/ @return void
[ "Checks", "an", "element", "has", "a", "class" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L90-L101
train
neemzy/patchwork-core
src/FeatureContext.php
FeatureContext.elementShouldNotHaveClass
public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->hasClass($class)); }
php
public function elementShouldNotHaveClass($selector, $class) { $session = $this->getSession(); $page = $session->getPage(); $element = $page->find('css', $selector); if (!$element) { throw new ElementNotFoundException($session, 'Element "'.$selector.'"'); } \PHPUnit_Framework_TestCase::assertFalse($element->hasClass($class)); }
[ "public", "function", "elementShouldNotHaveClass", "(", "$", "selector", ",", "$", "class", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "page", "=", "$", "session", "->", "getPage", "(", ")", ";", "$", "element",...
Checks an element doesn't have a class @Then /^"([^"]*)" element should not have class "([^"]*)"$/ @return void
[ "Checks", "an", "element", "doesn", "t", "have", "a", "class" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/FeatureContext.php#L112-L123
train
SocietyCMS/Core
Utilities/AssetManager/JavascriptPipeline/SocietyJavascriptPipeline.php
SocietyJavascriptPipeline.addJs
public function addJs($js) { if (is_array($js)) { foreach ($js as $script) { $this->addJs($script); } return $this; } $this->js->push($js); return $this; }
php
public function addJs($js) { if (is_array($js)) { foreach ($js as $script) { $this->addJs($script); } return $this; } $this->js->push($js); return $this; }
[ "public", "function", "addJs", "(", "$", "js", ")", "{", "if", "(", "is_array", "(", "$", "js", ")", ")", "{", "foreach", "(", "$", "js", "as", "$", "script", ")", "{", "$", "this", "->", "addJs", "(", "$", "script", ")", ";", "}", "return", ...
Add a javascript dependency on the view. @param string $js @throws AssetNotFoundException @return $this
[ "Add", "a", "javascript", "dependency", "on", "the", "view", "." ]
fb6be1b1dd46c89a976c02feb998e9af01ddca54
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Utilities/AssetManager/JavascriptPipeline/SocietyJavascriptPipeline.php#L35-L48
train
dflydev/dflydev-composer-autoload
src/Dflydev/Composer/Autoload/ClassLoaderLocator.php
ClassLoaderLocator.getClassLoaders
public function getClassLoaders() { if (null !== static::$classLoaders) { return static::$classLoaders; } static::$classLoaders = array(); foreach (spl_autoload_functions() as $function) { if (is_array($function) && count($function[0]) > 0 && is_object($function[0]) && 'Composer\Autoload\ClassLoader' === get_class($function[0])) { static::$classLoaders[] = $function[0]; } } return static::$classLoaders; }
php
public function getClassLoaders() { if (null !== static::$classLoaders) { return static::$classLoaders; } static::$classLoaders = array(); foreach (spl_autoload_functions() as $function) { if (is_array($function) && count($function[0]) > 0 && is_object($function[0]) && 'Composer\Autoload\ClassLoader' === get_class($function[0])) { static::$classLoaders[] = $function[0]; } } return static::$classLoaders; }
[ "public", "function", "getClassLoaders", "(", ")", "{", "if", "(", "null", "!==", "static", "::", "$", "classLoaders", ")", "{", "return", "static", "::", "$", "classLoaders", ";", "}", "static", "::", "$", "classLoaders", "=", "array", "(", ")", ";", ...
Locate all Composer Autoload ClassLoader instances @return \Composer\Autoload\ClassLoader[]
[ "Locate", "all", "Composer", "Autoload", "ClassLoader", "instances" ]
fcdc111b7f2f7301ef05c5938a5a07026481b504
https://github.com/dflydev/dflydev-composer-autoload/blob/fcdc111b7f2f7301ef05c5938a5a07026481b504/src/Dflydev/Composer/Autoload/ClassLoaderLocator.php#L68-L83
train
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.migrateTask
public function migrateTask(Option $option) { $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->migrate($this->application->getEnv(), $option->getArg(0)); } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); $this->task('db:schema:dump', $option->copy()); }
php
public function migrateTask(Option $option) { $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->migrate($this->application->getEnv(), $option->getArg(0)); } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); $this->task('db:schema:dump', $option->copy()); }
[ "public", "function", "migrateTask", "(", "Option", "$", "option", ")", "{", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "$", "start", "=", "microtime", "(", "true", ")", ";", "foreach", "(", "$", "databases"...
database migration task. using phinx. usage: $ ./app db:migrate [version] @option database,d=all target database (default is all databases).
[ "database", "migration", "task", ".", "using", "phinx", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L51-L66
train
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.seedTask
public function seedTask(Option $option) { $name = $option->getArg(0); $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { foreach ($this->migrationHelper->getSeeders($alias, $name) as $seeder) { try { $this->sendMessage('seeding... -> %s', $seeder->getName()); $seeder->seed(); } catch (\Exception $e) { $this->sendMessage($e->getMessage()); $this->sendMessage('has error. aborting.'); return; } } } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); }
php
public function seedTask(Option $option) { $name = $option->getArg(0); $databases = $this->getDatabases($option); $start = microtime(true); foreach ($databases as $alias => $database) { foreach ($this->migrationHelper->getSeeders($alias, $name) as $seeder) { try { $this->sendMessage('seeding... -> %s', $seeder->getName()); $seeder->seed(); } catch (\Exception $e) { $this->sendMessage($e->getMessage()); $this->sendMessage('has error. aborting.'); return; } } } $end = microtime(true); $this->sendMessage(''); $this->sendMessage('All Done. Took %.4fs', $end - $start); }
[ "public", "function", "seedTask", "(", "Option", "$", "option", ")", "{", "$", "name", "=", "$", "option", "->", "getArg", "(", "0", ")", ";", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "$", "start", "="...
database seeding task. usage: # all seeding files import. $ ./app db:seed # target seeding file import. $ ./app db:seed [name] --database=base seeder file: App/Database/Seed/[database alias]/[name]Seeder.php @option database,d=all target database (default is all databases).
[ "database", "seeding", "task", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L147-L169
train
samurai-fw/samurai
src/Console/Task/DbTaskList.php
DbTaskList.statusTask
public function statusTask(Option $option) { $databases = $this->getDatabases($option); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->printStatus($this->application->getEnv(), $option->get('format')); } }
php
public function statusTask(Option $option) { $databases = $this->getDatabases($option); foreach ($databases as $alias => $database) { $manager = $this->getManager($alias, $database); $manager->printStatus($this->application->getEnv(), $option->get('format')); } }
[ "public", "function", "statusTask", "(", "Option", "$", "option", ")", "{", "$", "databases", "=", "$", "this", "->", "getDatabases", "(", "$", "option", ")", ";", "foreach", "(", "$", "databases", "as", "$", "alias", "=>", "$", "database", ")", "{", ...
show database mgration status task. using phinx. usage: $ ./app db:status [version] @option format,f output format. (default is text) @option database,d=all target database (default is all databases).
[ "show", "database", "mgration", "status", "task", ".", "using", "phinx", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Task/DbTaskList.php#L181-L189
train
deasilworks/cef
src/StatementBuilder/InsertModel.php
InsertModel.setModel
public function setModel($model) { $model->setSerializeNull($this->isSerializeNull()); $this->setJson($model->toJson()); return $this; }
php
public function setModel($model) { $model->setSerializeNull($this->isSerializeNull()); $this->setJson($model->toJson()); return $this; }
[ "public", "function", "setModel", "(", "$", "model", ")", "{", "$", "model", "->", "setSerializeNull", "(", "$", "this", "->", "isSerializeNull", "(", ")", ")", ";", "$", "this", "->", "setJson", "(", "$", "model", "->", "toJson", "(", ")", ")", ";",...
Set Model. @param EntityDataModel $model @return InsertModel
[ "Set", "Model", "." ]
18c65f2b123512bba2208975dc655354f57670be
https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/StatementBuilder/InsertModel.php#L67-L73
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.onKernelException
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = null; switch (true) { case ($exception instanceof NotFoundHttpException): $response = $this->createNotFoundResponse($event->getRequest(), $exception); break; case ($exception instanceof AccessDeniedHttpException): case ($exception instanceof UnauthorizedHttpException): case ($exception instanceof BadRequestHttpException): case ($exception instanceof ServiceUnavailableHttpException): case ($exception instanceof NotAcceptableHttpException): case ($exception instanceof HttpException): /** @var HttpException $exception */ $response = $this->createHttpExceptionResponse($exception); break; case ($exception instanceof AuthenticationCredentialsNotFoundException): $response = $this->createUnauthenticatedResponse($exception); break; default: } if (null === $response) { $response = $this->createInternalServerError($exception); } $event->setResponse($response); }
php
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = null; switch (true) { case ($exception instanceof NotFoundHttpException): $response = $this->createNotFoundResponse($event->getRequest(), $exception); break; case ($exception instanceof AccessDeniedHttpException): case ($exception instanceof UnauthorizedHttpException): case ($exception instanceof BadRequestHttpException): case ($exception instanceof ServiceUnavailableHttpException): case ($exception instanceof NotAcceptableHttpException): case ($exception instanceof HttpException): /** @var HttpException $exception */ $response = $this->createHttpExceptionResponse($exception); break; case ($exception instanceof AuthenticationCredentialsNotFoundException): $response = $this->createUnauthenticatedResponse($exception); break; default: } if (null === $response) { $response = $this->createInternalServerError($exception); } $event->setResponse($response); }
[ "public", "function", "onKernelException", "(", "GetResponseForExceptionEvent", "$", "event", ")", "{", "$", "exception", "=", "$", "event", "->", "getException", "(", ")", ";", "$", "response", "=", "null", ";", "switch", "(", "true", ")", "{", "case", "(...
Maps known exceptions to HTTP exceptions. @param GetResponseForExceptionEvent $event The event object. @return void @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Maps", "known", "exceptions", "to", "HTTP", "exceptions", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L77-L106
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createNotFoundResponse
private function createNotFoundResponse($request, $exception) { $message = $exception->getMessage(); if (empty($message)) { $message = 'Uri ' . $request->getRequestUri() . ' could not be found'; } return new JsonResponse( [ 'status' => 'ERROR', 'message' => $message ], JsonResponse::HTTP_NOT_FOUND ); }
php
private function createNotFoundResponse($request, $exception) { $message = $exception->getMessage(); if (empty($message)) { $message = 'Uri ' . $request->getRequestUri() . ' could not be found'; } return new JsonResponse( [ 'status' => 'ERROR', 'message' => $message ], JsonResponse::HTTP_NOT_FOUND ); }
[ "private", "function", "createNotFoundResponse", "(", "$", "request", ",", "$", "exception", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "if", "(", "empty", "(", "$", "message", ")", ")", "{", "$", "message", "="...
Create a 404 response. @param Request $request The http request. @param \Exception $exception The exception. @return JsonResponse @SuppressWarnings(PHPMD.UnusedPrivateMethod)
[ "Create", "a", "404", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L119-L133
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createHttpExceptionResponse
private function createHttpExceptionResponse(HttpException $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'message' => $exception->getMessage() ], $exception->getStatusCode(), $exception->getHeaders() ); }
php
private function createHttpExceptionResponse(HttpException $exception) { return new JsonResponse( [ 'status' => 'ERROR', 'message' => $exception->getMessage() ], $exception->getStatusCode(), $exception->getHeaders() ); }
[ "private", "function", "createHttpExceptionResponse", "(", "HttpException", "$", "exception", ")", "{", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "'ERROR'", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ",", "$...
Create a http response. @param HttpException $exception The exception to create a response for. @return JsonResponse
[ "Create", "a", "http", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L142-L152
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.createInternalServerError
private function createInternalServerError(\Exception $exception) { $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() ); $this->logger->error($message, array('exception' => $exception)); $response = [ 'status' => 'ERROR', 'message' => JsonResponse::$statusTexts[JsonResponse::HTTP_INTERNAL_SERVER_ERROR] ]; if ($this->debug) { $response['exception'] = $this->formatException($exception); } return new JsonResponse($response, JsonResponse::HTTP_INTERNAL_SERVER_ERROR); }
php
private function createInternalServerError(\Exception $exception) { $message = sprintf( '%s: %s (uncaught exception) at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine() ); $this->logger->error($message, array('exception' => $exception)); $response = [ 'status' => 'ERROR', 'message' => JsonResponse::$statusTexts[JsonResponse::HTTP_INTERNAL_SERVER_ERROR] ]; if ($this->debug) { $response['exception'] = $this->formatException($exception); } return new JsonResponse($response, JsonResponse::HTTP_INTERNAL_SERVER_ERROR); }
[ "private", "function", "createInternalServerError", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "message", "=", "sprintf", "(", "'%s: %s (uncaught exception) at %s line %s'", ",", "get_class", "(", "$", "exception", ")", ",", "$", "exception", "->", "...
Create a 500 response. @param \Exception $exception The exception to log. @return JsonResponse
[ "Create", "a", "500", "response", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L179-L201
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.formatStackFrame
private function formatStackFrame($frame) { return [ 'file' => isset($frame['file']) ? $frame['file'] : 'unknown', 'line' => isset($frame['line']) ? $frame['line'] : 'unknown', 'function' => (isset($frame['class']) ? $frame['class'] . $frame['type'] : '') . $frame['function'], 'arguments' => $this->formatArguments($frame['args']) ]; }
php
private function formatStackFrame($frame) { return [ 'file' => isset($frame['file']) ? $frame['file'] : 'unknown', 'line' => isset($frame['line']) ? $frame['line'] : 'unknown', 'function' => (isset($frame['class']) ? $frame['class'] . $frame['type'] : '') . $frame['function'], 'arguments' => $this->formatArguments($frame['args']) ]; }
[ "private", "function", "formatStackFrame", "(", "$", "frame", ")", "{", "return", "[", "'file'", "=>", "isset", "(", "$", "frame", "[", "'file'", "]", ")", "?", "$", "frame", "[", "'file'", "]", ":", "'unknown'", ",", "'line'", "=>", "isset", "(", "$...
Convert a stack frame to array. @param array $frame The stack frame to convert. @return array
[ "Convert", "a", "stack", "frame", "to", "array", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L242-L250
train
tenside/core-bundle
src/EventListener/ExceptionListener.php
ExceptionListener.formatArguments
private function formatArguments($arguments) { $result = []; foreach ($arguments as $key => $argument) { if (is_object($argument)) { $result[$key] = get_class($argument); continue; } if (is_array($argument)) { $result[$key] = $this->formatArguments($argument); continue; } $result[$key] = $argument; } return $result; }
php
private function formatArguments($arguments) { $result = []; foreach ($arguments as $key => $argument) { if (is_object($argument)) { $result[$key] = get_class($argument); continue; } if (is_array($argument)) { $result[$key] = $this->formatArguments($argument); continue; } $result[$key] = $argument; } return $result; }
[ "private", "function", "formatArguments", "(", "$", "arguments", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "argument", ")", "{", "if", "(", "is_object", "(", "$", "argument", ")", ")",...
Reformat an argument list. @param array $arguments The arguments to reformat. @return mixed
[ "Reformat", "an", "argument", "list", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/EventListener/ExceptionListener.php#L259-L277
train
wigedev/simple-mvc
src/Core.php
Core._init
public static function _init(): Core { static::$framework = new Core(); static::$framework->createDIContainer(); try { static::$framework->fireEvent('initialized'); } catch (\Exception $e) { echo('Unable to fire initialization.'); exit(); } $router = new Router(); $mcl = new ModuleControllerLoader(); static::$framework->response = new Response($router, $mcl); return static::$framework; }
php
public static function _init(): Core { static::$framework = new Core(); static::$framework->createDIContainer(); try { static::$framework->fireEvent('initialized'); } catch (\Exception $e) { echo('Unable to fire initialization.'); exit(); } $router = new Router(); $mcl = new ModuleControllerLoader(); static::$framework->response = new Response($router, $mcl); return static::$framework; }
[ "public", "static", "function", "_init", "(", ")", ":", "Core", "{", "static", "::", "$", "framework", "=", "new", "Core", "(", ")", ";", "static", "::", "$", "framework", "->", "createDIContainer", "(", ")", ";", "try", "{", "static", "::", "$", "fr...
Function initializes the framework object. @return Core
[ "Function", "initializes", "the", "framework", "object", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Core.php#L153-L167
train