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
WasabiLib/wasabilib
src/WasabiLib/Ajax/Response.php
Response.add
public function add($object){ if(is_array($object)) { $this->responses = array_merge($this->responses, $object); } else { $implementedInterfaces = class_implements($object); if(array_key_exists("WasabiLib\Ajax\ResponseConfiguratorInterface", $implementedInterfaces)) { $object->configure(); // $this->responses = array_merge($this->responses, $object->getResponseTypes()); foreach($object->getResponseTypes() as $responseType){ $implementedInterfacesInResponseType = class_implements($responseType); if(array_key_exists("WasabiLib\Ajax\ResponseConfiguratorInterface", $implementedInterfacesInResponseType)) { $this->add($responseType); } else{ $this->responses[]=$responseType; } } } else if(array_key_exists("WasabiLib\Ajax\ResponseTypeInterface", $implementedInterfaces)) { $this->responses[] = $object; } else { throw new InvalidArgumentException("Invalid parameter type! Given value must be an array or implements the interfaces ResponseConfiguratorInterface or ResponseTypeInterface"); } } }
php
public function add($object){ if(is_array($object)) { $this->responses = array_merge($this->responses, $object); } else { $implementedInterfaces = class_implements($object); if(array_key_exists("WasabiLib\Ajax\ResponseConfiguratorInterface", $implementedInterfaces)) { $object->configure(); // $this->responses = array_merge($this->responses, $object->getResponseTypes()); foreach($object->getResponseTypes() as $responseType){ $implementedInterfacesInResponseType = class_implements($responseType); if(array_key_exists("WasabiLib\Ajax\ResponseConfiguratorInterface", $implementedInterfacesInResponseType)) { $this->add($responseType); } else{ $this->responses[]=$responseType; } } } else if(array_key_exists("WasabiLib\Ajax\ResponseTypeInterface", $implementedInterfaces)) { $this->responses[] = $object; } else { throw new InvalidArgumentException("Invalid parameter type! Given value must be an array or implements the interfaces ResponseConfiguratorInterface or ResponseTypeInterface"); } } }
[ "public", "function", "add", "(", "$", "object", ")", "{", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "$", "this", "->", "responses", "=", "array_merge", "(", "$", "this", "->", "responses", ",", "$", "object", ")", ";", "}", "else",...
Adds an object which implements the interfaces ResponseTypeInterface or ResponseConfiguratorInterface or an array of objects which implement the ResponseTypeInterface. @param $object array | ResponseConfiguratorInterface | ResponseTypeInterface @throws \Zend\Code\Exception\InvalidArgumentException
[ "Adds", "an", "object", "which", "implements", "the", "interfaces", "ResponseTypeInterface", "or", "ResponseConfiguratorInterface", "or", "an", "array", "of", "objects", "which", "implement", "the", "ResponseTypeInterface", "." ]
5a55bfbea6b6ee10222c521112d469015db170b7
https://github.com/WasabiLib/wasabilib/blob/5a55bfbea6b6ee10222c521112d469015db170b7/src/WasabiLib/Ajax/Response.php#L37-L63
train
phPoirot/Http
HttpMessage/Request/StreamBodyMultiPart.php
StreamBodyMultiPart.addElements
function addElements($multiPart) { if (! is_array($multiPart) ) throw new \InvalidArgumentException(sprintf( 'Accept array of Files; given: "%s".' , \Poirot\Std\flatten($multiPart) )); foreach($multiPart as $name => $element) $this->addElement($name, $element); $this->addElementDone(); return $this; }
php
function addElements($multiPart) { if (! is_array($multiPart) ) throw new \InvalidArgumentException(sprintf( 'Accept array of Files; given: "%s".' , \Poirot\Std\flatten($multiPart) )); foreach($multiPart as $name => $element) $this->addElement($name, $element); $this->addElementDone(); return $this; }
[ "function", "addElements", "(", "$", "multiPart", ")", "{", "if", "(", "!", "is_array", "(", "$", "multiPart", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Accept array of Files; given: \"%s\".'", ",", "\\", "Poirot", "\\", ...
Append Boundary Elements @param array|string $multiPart @return $this
[ "Append", "Boundary", "Elements" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/StreamBodyMultiPart.php#L69-L84
train
phPoirot/Http
HttpMessage/Request/StreamBodyMultiPart.php
StreamBodyMultiPart.addElement
function addElement($fieldName, $element, $headers = null) { if ($this->_trailingBoundary) throw new \Exception('Trailing Boundary Is Added.'); if (! $headers instanceof iHeaders ) $headers = (! empty($headers) ) ? new CollectionHeader($headers) : new CollectionHeader; if ( $this->_addElement($fieldName, $element, $headers) ) $this->elementsAdded[$fieldName] = $element; return $this; }
php
function addElement($fieldName, $element, $headers = null) { if ($this->_trailingBoundary) throw new \Exception('Trailing Boundary Is Added.'); if (! $headers instanceof iHeaders ) $headers = (! empty($headers) ) ? new CollectionHeader($headers) : new CollectionHeader; if ( $this->_addElement($fieldName, $element, $headers) ) $this->elementsAdded[$fieldName] = $element; return $this; }
[ "function", "addElement", "(", "$", "fieldName", ",", "$", "element", ",", "$", "headers", "=", "null", ")", "{", "if", "(", "$", "this", "->", "_trailingBoundary", ")", "throw", "new", "\\", "Exception", "(", "'Trailing Boundary Is Added.'", ")", ";", "if...
Append Boundary Element @param string $fieldName Form Field Name @param UploadedFileInterface|string|StreamInterface $element @param null|array $headers Extra Headers To Be Added @return $this @throws \Exception
[ "Append", "Boundary", "Element" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/StreamBodyMultiPart.php#L96-L109
train
phPoirot/Http
HttpMessage/Request/StreamBodyMultiPart.php
StreamBodyMultiPart.addElementDone
function addElementDone() { ## add trailing boundary as stream if not $this->_trailingBoundary = new STemporary("\r\n"."--{$this->_boundary}--"); $this->_t__wrap_stream->addStream($this->_trailingBoundary->rewind()); }
php
function addElementDone() { ## add trailing boundary as stream if not $this->_trailingBoundary = new STemporary("\r\n"."--{$this->_boundary}--"); $this->_t__wrap_stream->addStream($this->_trailingBoundary->rewind()); }
[ "function", "addElementDone", "(", ")", "{", "## add trailing boundary as stream if not", "$", "this", "->", "_trailingBoundary", "=", "new", "STemporary", "(", "\"\\r\\n\"", ".", "\"--{$this->_boundary}--\"", ")", ";", "$", "this", "->", "_t__wrap_stream", "->", "add...
Add Trailing Boundary And Finish Data @return void
[ "Add", "Trailing", "Boundary", "And", "Finish", "Data" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/StreamBodyMultiPart.php#L178-L183
train
znframework/package-generator
Project.php
Project.generate
public static function generate(String $name) : Bool { Post::project($name); $validation = Singleton::class('ZN\Validation\Data'); $validation->rules('project', ['alpha'], 'Project Name'); if( ! $error = $validation->error('string') ) { $source = EXTERNAL_FILES_DIR . 'DefaultProject.zip'; $target = PROJECTS_DIR . Post::project(); Forge::zipExtract($source, $target); return true; } return false; }
php
public static function generate(String $name) : Bool { Post::project($name); $validation = Singleton::class('ZN\Validation\Data'); $validation->rules('project', ['alpha'], 'Project Name'); if( ! $error = $validation->error('string') ) { $source = EXTERNAL_FILES_DIR . 'DefaultProject.zip'; $target = PROJECTS_DIR . Post::project(); Forge::zipExtract($source, $target); return true; } return false; }
[ "public", "static", "function", "generate", "(", "String", "$", "name", ")", ":", "Bool", "{", "Post", "::", "project", "(", "$", "name", ")", ";", "$", "validation", "=", "Singleton", "::", "class", "(", "'ZN\\Validation\\Data'", ")", ";", "$", "validat...
Select project name @param string $name @return bool
[ "Select", "project", "name" ]
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/Project.php#L25-L44
train
atelierspierrot/library
src/Library/Helper/Number.php
Number.isPrime
public static function isPrime($val = null) { if (is_null($val)) { return null; } if ( ($val<=1) || ($val>2 && ($val%2)===0) ) { return false; } for ($i=2;$i<$val;$i++) { if (($val%$i)===0) { return false; } } return true; }
php
public static function isPrime($val = null) { if (is_null($val)) { return null; } if ( ($val<=1) || ($val>2 && ($val%2)===0) ) { return false; } for ($i=2;$i<$val;$i++) { if (($val%$i)===0) { return false; } } return true; }
[ "public", "static", "function", "isPrime", "(", "$", "val", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "val", ")", ")", "{", "return", "null", ";", "}", "if", "(", "(", "$", "val", "<=", "1", ")", "||", "(", "$", "val", ">", "2", ...
Test if an integer is a "prime number" @param int $val @return bool
[ "Test", "if", "an", "integer", "is", "a", "prime", "number" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Number.php#L74-L91
train
atelierspierrot/library
src/Library/Helper/Number.php
Number.isLuhn
public static function isLuhn($val = null) { if (is_null($val)) { return null; } $_num = substr($val, 0, strlen($val)-1); return (bool) (intval($val) == intval($_num.self::getLuhnKey($_num))); }
php
public static function isLuhn($val = null) { if (is_null($val)) { return null; } $_num = substr($val, 0, strlen($val)-1); return (bool) (intval($val) == intval($_num.self::getLuhnKey($_num))); }
[ "public", "static", "function", "isLuhn", "(", "$", "val", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "val", ")", ")", "{", "return", "null", ";", "}", "$", "_num", "=", "substr", "(", "$", "val", ",", "0", ",", "strlen", "(", "$", ...
Check that the last number in a suite is its Luhn key @param int $val The number to check INCLUDING Luhn's key at last @return bool
[ "Check", "that", "the", "last", "number", "in", "a", "suite", "is", "its", "Luhn", "key" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Number.php#L154-L161
train
matuck/TorFeed
TorFeed.php
TorFeed.getItems
public function getItems() { $namespaces = $this->xml->getDocNamespaces(); foreach($namespaces as $namespace => $url) { $this->xml->registerXPathNamespace($namespace, $url); } foreach ($this->xml->xpath($this->itemXpath) as $item) { $this->items[] = new Item ( $this->itemtitleXpath ? (string) $item->xpath($this->itemtitleXpath)[0] : NULL, $this->itemtorrenturlXpath ? (string) $item->xpath($this->itemtorrenturlXpath)[0] : NULL, $this->itemmagnetXpath ? (string) $item->xpath($this->itemmagnetXpath)[0] : NULL ); } return $this->items; }
php
public function getItems() { $namespaces = $this->xml->getDocNamespaces(); foreach($namespaces as $namespace => $url) { $this->xml->registerXPathNamespace($namespace, $url); } foreach ($this->xml->xpath($this->itemXpath) as $item) { $this->items[] = new Item ( $this->itemtitleXpath ? (string) $item->xpath($this->itemtitleXpath)[0] : NULL, $this->itemtorrenturlXpath ? (string) $item->xpath($this->itemtorrenturlXpath)[0] : NULL, $this->itemmagnetXpath ? (string) $item->xpath($this->itemmagnetXpath)[0] : NULL ); } return $this->items; }
[ "public", "function", "getItems", "(", ")", "{", "$", "namespaces", "=", "$", "this", "->", "xml", "->", "getDocNamespaces", "(", ")", ";", "foreach", "(", "$", "namespaces", "as", "$", "namespace", "=>", "$", "url", ")", "{", "$", "this", "->", "xml...
Get Items from a feed. @return array Returns an array of Items
[ "Get", "Items", "from", "a", "feed", "." ]
278eeb43c0bde8d7bb3a00ef1efed14341788441
https://github.com/matuck/TorFeed/blob/278eeb43c0bde8d7bb3a00ef1efed14341788441/TorFeed.php#L114-L133
train
MehrAlsNix/Assumptions
src/Assume.php
Assume.assumeThat
public static function assumeThat($actual, Matcher $matcher, $message = ''): void { if (!$matcher->matches($actual)) { throw new AssumptionViolatedException($actual, $matcher, $message); } }
php
public static function assumeThat($actual, Matcher $matcher, $message = ''): void { if (!$matcher->matches($actual)) { throw new AssumptionViolatedException($actual, $matcher, $message); } }
[ "public", "static", "function", "assumeThat", "(", "$", "actual", ",", "Matcher", "$", "matcher", ",", "$", "message", "=", "''", ")", ":", "void", "{", "if", "(", "!", "$", "matcher", "->", "matches", "(", "$", "actual", ")", ")", "{", "throw", "n...
Assumes that a specific value matches a specific hamcrest matcher. @param mixed $actual @param Matcher $matcher @param string $message optional @return void @throws AssumptionViolatedException
[ "Assumes", "that", "a", "specific", "value", "matches", "a", "specific", "hamcrest", "matcher", "." ]
5d28349354bc80409beeac52df79e57d1d52bcf2
https://github.com/MehrAlsNix/Assumptions/blob/5d28349354bc80409beeac52df79e57d1d52bcf2/src/Assume.php#L77-L82
train
etd-framework/user
src/UserHelper.php
UserHelper.getUserGroups
public function getUserGroups() { $db = $this->db; $query = $db->getQuery(true) ->select('a.*, COUNT(DISTINCT b.id) AS level') ->from($db->quoteName('#__usergroups') . ' AS a') ->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt') ->group('a.id, a.title, a.lft, a.rgt, a.parent_id') ->order('a.lft ASC'); return $db->setQuery($query) ->loadObjectList(); }
php
public function getUserGroups() { $db = $this->db; $query = $db->getQuery(true) ->select('a.*, COUNT(DISTINCT b.id) AS level') ->from($db->quoteName('#__usergroups') . ' AS a') ->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt') ->group('a.id, a.title, a.lft, a.rgt, a.parent_id') ->order('a.lft ASC'); return $db->setQuery($query) ->loadObjectList(); }
[ "public", "function", "getUserGroups", "(", ")", "{", "$", "db", "=", "$", "this", "->", "db", ";", "$", "query", "=", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'a.*, COUNT(DISTINCT b.id) AS level'", ")", "->", "from", "(", "...
Retourne les groupes utilisateurs. @return array Un tableau des groupes utilisateurs.
[ "Retourne", "les", "groupes", "utilisateurs", "." ]
2eb6e5b98ed724e590ec87d95e77ba4bd2b7a620
https://github.com/etd-framework/user/blob/2eb6e5b98ed724e590ec87d95e77ba4bd2b7a620/src/UserHelper.php#L41-L55
train
microffice/core
src/Microffice/Core/Traits/EloquentModelResourceTrait.php
EloquentModelResourceTrait.index
public function index() { $model = $this->modelFullName; $collection = $model::all(); if($collection->isEmpty()) throw new NotFoundException('There Are No Resources Named "' . $this->getResourceName() . '" Yet'); return $collection; }
php
public function index() { $model = $this->modelFullName; $collection = $model::all(); if($collection->isEmpty()) throw new NotFoundException('There Are No Resources Named "' . $this->getResourceName() . '" Yet'); return $collection; }
[ "public", "function", "index", "(", ")", "{", "$", "model", "=", "$", "this", "->", "modelFullName", ";", "$", "collection", "=", "$", "model", "::", "all", "(", ")", ";", "if", "(", "$", "collection", "->", "isEmpty", "(", ")", ")", "throw", "new"...
Return a listing of the resource. @return \Illuminate\Database\Eloquent\Collection
[ "Return", "a", "listing", "of", "the", "resource", "." ]
e98975bb6029c6a0c79d73bcabc5f067063ad9d9
https://github.com/microffice/core/blob/e98975bb6029c6a0c79d73bcabc5f067063ad9d9/src/Microffice/Core/Traits/EloquentModelResourceTrait.php#L28-L34
train
microffice/core
src/Microffice/Core/Traits/EloquentModelResourceTrait.php
EloquentModelResourceTrait.show
public function show($id) { $modelName = $this->modelFullName; $model = $modelName::find($id); if(!$model) throw new NotFoundException('There is no Resource with id = ' . $id . ' !'); return $model; }
php
public function show($id) { $modelName = $this->modelFullName; $model = $modelName::find($id); if(!$model) throw new NotFoundException('There is no Resource with id = ' . $id . ' !'); return $model; }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "modelName", "=", "$", "this", "->", "modelFullName", ";", "$", "model", "=", "$", "modelName", "::", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "model", ")", "throw", "new"...
Return the specified resource. @param int $id @return \Illuminate\Database\Eloquent\Model|null
[ "Return", "the", "specified", "resource", "." ]
e98975bb6029c6a0c79d73bcabc5f067063ad9d9
https://github.com/microffice/core/blob/e98975bb6029c6a0c79d73bcabc5f067063ad9d9/src/Microffice/Core/Traits/EloquentModelResourceTrait.php#L58-L64
train
microffice/core
src/Microffice/Core/Traits/EloquentModelResourceTrait.php
EloquentModelResourceTrait.validate
protected function validate($data, $rules=false) { if(!$rules) { $modelName = $this->modelFullName; $rules = $modelName::$rules; } $validator = \Validator::make($data, $rules); if($validator->fails()) throw new ValidationException($validator); return true; }
php
protected function validate($data, $rules=false) { if(!$rules) { $modelName = $this->modelFullName; $rules = $modelName::$rules; } $validator = \Validator::make($data, $rules); if($validator->fails()) throw new ValidationException($validator); return true; }
[ "protected", "function", "validate", "(", "$", "data", ",", "$", "rules", "=", "false", ")", "{", "if", "(", "!", "$", "rules", ")", "{", "$", "modelName", "=", "$", "this", "->", "modelFullName", ";", "$", "rules", "=", "$", "modelName", "::", "$"...
Validate data for resource. @param array $data @param array $rules @return boolean
[ "Validate", "data", "for", "resource", "." ]
e98975bb6029c6a0c79d73bcabc5f067063ad9d9
https://github.com/microffice/core/blob/e98975bb6029c6a0c79d73bcabc5f067063ad9d9/src/Microffice/Core/Traits/EloquentModelResourceTrait.php#L106-L116
train
bugotech/io
src/Filesystem.php
Filesystem.force
public function force($path, $mode = 0777, $recursive = true) { if ($this->exists($path)) { return true; } return $this->makeDirectory($path, $mode, $recursive); }
php
public function force($path, $mode = 0777, $recursive = true) { if ($this->exists($path)) { return true; } return $this->makeDirectory($path, $mode, $recursive); }
[ "public", "function", "force", "(", "$", "path", ",", "$", "mode", "=", "0777", ",", "$", "recursive", "=", "true", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "path", ")", ")", "{", "return", "true", ";", "}", "return", "$", "t...
Alias of makeDirectory. @return bool
[ "Alias", "of", "makeDirectory", "." ]
3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0
https://github.com/bugotech/io/blob/3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0/src/Filesystem.php#L37-L44
train
bugotech/io
src/Filesystem.php
Filesystem.fileName
public function fileName($filename, $withExt = true) { return $withExt ? pathinfo($filename, PATHINFO_BASENAME) : pathinfo($filename, PATHINFO_FILENAME); }
php
public function fileName($filename, $withExt = true) { return $withExt ? pathinfo($filename, PATHINFO_BASENAME) : pathinfo($filename, PATHINFO_FILENAME); }
[ "public", "function", "fileName", "(", "$", "filename", ",", "$", "withExt", "=", "true", ")", "{", "return", "$", "withExt", "?", "pathinfo", "(", "$", "filename", ",", "PATHINFO_BASENAME", ")", ":", "pathinfo", "(", "$", "filename", ",", "PATHINFO_FILENA...
Get filename with or not extension. @return string
[ "Get", "filename", "with", "or", "not", "extension", "." ]
3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0
https://github.com/bugotech/io/blob/3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0/src/Filesystem.php#L63-L66
train
bugotech/io
src/Filesystem.php
Filesystem.saveConfig
public function saveConfig($group, $environment = '') { // Path do arquivo $path = config_path(); // Itens $items = config($group, []); // Nome do arquivo $file = (! $environment || ($environment == 'production')) ? "{$path}/{$group}.php" : "{$path}/{$environment}/{$group}.php"; // Salvar arquivo $code = '<?php' . "\r\n\r\n"; $code .= 'return ' . var_export($items, true) . ';'; $this->put($file, $code); }
php
public function saveConfig($group, $environment = '') { // Path do arquivo $path = config_path(); // Itens $items = config($group, []); // Nome do arquivo $file = (! $environment || ($environment == 'production')) ? "{$path}/{$group}.php" : "{$path}/{$environment}/{$group}.php"; // Salvar arquivo $code = '<?php' . "\r\n\r\n"; $code .= 'return ' . var_export($items, true) . ';'; $this->put($file, $code); }
[ "public", "function", "saveConfig", "(", "$", "group", ",", "$", "environment", "=", "''", ")", "{", "// Path do arquivo", "$", "path", "=", "config_path", "(", ")", ";", "// Itens", "$", "items", "=", "config", "(", "$", "group", ",", "[", "]", ")", ...
Salvar arquivo Config. @param $group @param string $environment
[ "Salvar", "arquivo", "Config", "." ]
3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0
https://github.com/bugotech/io/blob/3c7601af1839d1cdfa2ba5c43bf33d6d79117ae0/src/Filesystem.php#L176-L193
train
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/orm/classes/relation.php
Relation.select
public function select($table) { $props = call_user_func(array($this->model_to, 'properties')); $i = 0; $properties = array(); foreach ($props as $pk => $pv) { $properties[] = array($table.'.'.$pk, $table.'_c'.$i); $i++; } return $properties; }
php
public function select($table) { $props = call_user_func(array($this->model_to, 'properties')); $i = 0; $properties = array(); foreach ($props as $pk => $pv) { $properties[] = array($table.'.'.$pk, $table.'_c'.$i); $i++; } return $properties; }
[ "public", "function", "select", "(", "$", "table", ")", "{", "$", "props", "=", "call_user_func", "(", "array", "(", "$", "this", "->", "model_to", ",", "'properties'", ")", ")", ";", "$", "i", "=", "0", ";", "$", "properties", "=", "array", "(", "...
Should get the properties as associative array with alias => property, the table alias is given to be included with the property @param string @return array
[ "Should", "get", "the", "properties", "as", "associative", "array", "with", "alias", "=", ">", "property", "the", "table", "alias", "is", "given", "to", "be", "included", "with", "the", "property" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/orm/classes/relation.php#L88-L100
train
asbsoft/yii2-common_2_170212
helpers/BaseConfigsBuilder.php
BaseConfigsBuilder.includeConfigFile
public static function includeConfigFile($filename, $application = null) { if (empty($application)) { $application = Yii::$app; } $appKey = UniApplication::appKey($application); if (!isset(self::$_configFiles[$appKey][$filename])) { if (is_file($filename)) { self::$_configFiles[$appKey][$filename] = include($filename); // var $application can be used in $filename } else { throw new InvalidConfigException("Config file '$filename' required"); } } return self::$_configFiles[$appKey][$filename]; }
php
public static function includeConfigFile($filename, $application = null) { if (empty($application)) { $application = Yii::$app; } $appKey = UniApplication::appKey($application); if (!isset(self::$_configFiles[$appKey][$filename])) { if (is_file($filename)) { self::$_configFiles[$appKey][$filename] = include($filename); // var $application can be used in $filename } else { throw new InvalidConfigException("Config file '$filename' required"); } } return self::$_configFiles[$appKey][$filename]; }
[ "public", "static", "function", "includeConfigFile", "(", "$", "filename", ",", "$", "application", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "application", ")", ")", "{", "$", "application", "=", "Yii", "::", "$", "app", ";", "}", "$", "a...
Get, save in cache and return result of include file @param string $filename @param Application $application Note if config has some calculations caching may be not correct.
[ "Get", "save", "in", "cache", "and", "return", "result", "of", "include", "file" ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/helpers/BaseConfigsBuilder.php#L31-L45
train
asbsoft/yii2-common_2_170212
helpers/BaseConfigsBuilder.php
BaseConfigsBuilder.cleanConfigFileCache
public static function cleanConfigFileCache($application = null) { if (empty($application)) { $application = Yii::$app; } $appKey = UniApplication::appKey($application); static::$_configFiles[$appKey] = []; }
php
public static function cleanConfigFileCache($application = null) { if (empty($application)) { $application = Yii::$app; } $appKey = UniApplication::appKey($application); static::$_configFiles[$appKey] = []; }
[ "public", "static", "function", "cleanConfigFileCache", "(", "$", "application", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "application", ")", ")", "{", "$", "application", "=", "Yii", "::", "$", "app", ";", "}", "$", "appKey", "=", "UniAppl...
Clean included files cache
[ "Clean", "included", "files", "cache" ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/helpers/BaseConfigsBuilder.php#L47-L54
train
a15lam/workspace
src/Utility/Logger.php
Logger.write
protected function write($level, $msg) { $time = date('Y-m-d H:i:s', time()); $msg = "[" . $time . "][" . static::getLevelName($level) . "] " . $msg . PHP_EOL; if($this->debugOutput === true){ echo $msg; } if (static::$silent) { return false; } if (!$this->isAllowed($level)) { return false; } $fh = fopen($this->logFile, 'a'); if (!fwrite($fh, $msg)) { throw new \Exception('Failed to write to log file at ' . $this->logFile); } return true; }
php
protected function write($level, $msg) { $time = date('Y-m-d H:i:s', time()); $msg = "[" . $time . "][" . static::getLevelName($level) . "] " . $msg . PHP_EOL; if($this->debugOutput === true){ echo $msg; } if (static::$silent) { return false; } if (!$this->isAllowed($level)) { return false; } $fh = fopen($this->logFile, 'a'); if (!fwrite($fh, $msg)) { throw new \Exception('Failed to write to log file at ' . $this->logFile); } return true; }
[ "protected", "function", "write", "(", "$", "level", ",", "$", "msg", ")", "{", "$", "time", "=", "date", "(", "'Y-m-d H:i:s'", ",", "time", "(", ")", ")", ";", "$", "msg", "=", "\"[\"", ".", "$", "time", ".", "\"][\"", ".", "static", "::", "getL...
Writes to log file. @param int $level @param string $msg @return bool @throws \Exception
[ "Writes", "to", "log", "file", "." ]
a17508b47b2db11a6e203a3cbd43b886a85e25aa
https://github.com/a15lam/workspace/blob/a17508b47b2db11a6e203a3cbd43b886a85e25aa/src/Utility/Logger.php#L65-L85
train
a15lam/workspace
src/Utility/Logger.php
Logger.getLevelName
protected static function getLevelName($value) { $map = array_flip((new \ReflectionClass(self::class))->getConstants()); return (array_key_exists($value, $map) ? $map[$value] : null); }
php
protected static function getLevelName($value) { $map = array_flip((new \ReflectionClass(self::class))->getConstants()); return (array_key_exists($value, $map) ? $map[$value] : null); }
[ "protected", "static", "function", "getLevelName", "(", "$", "value", ")", "{", "$", "map", "=", "array_flip", "(", "(", "new", "\\", "ReflectionClass", "(", "self", "::", "class", ")", ")", "->", "getConstants", "(", ")", ")", ";", "return", "(", "arr...
Gets the log level name by value @param int $value @return null|string
[ "Gets", "the", "log", "level", "name", "by", "value" ]
a17508b47b2db11a6e203a3cbd43b886a85e25aa
https://github.com/a15lam/workspace/blob/a17508b47b2db11a6e203a3cbd43b886a85e25aa/src/Utility/Logger.php#L110-L115
train
a15lam/workspace
src/Utility/Logger.php
Logger.getLevelValue
public static function getLevelValue($name) { $name = strtoupper($name); $map = (new \ReflectionClass(self::class))->getConstants(); return (isset($map[$name]))? $map[$name] : null; }
php
public static function getLevelValue($name) { $name = strtoupper($name); $map = (new \ReflectionClass(self::class))->getConstants(); return (isset($map[$name]))? $map[$name] : null; }
[ "public", "static", "function", "getLevelValue", "(", "$", "name", ")", "{", "$", "name", "=", "strtoupper", "(", "$", "name", ")", ";", "$", "map", "=", "(", "new", "\\", "ReflectionClass", "(", "self", "::", "class", ")", ")", "->", "getConstants", ...
Gets the log level value by name @param $name @return null
[ "Gets", "the", "log", "level", "value", "by", "name" ]
a17508b47b2db11a6e203a3cbd43b886a85e25aa
https://github.com/a15lam/workspace/blob/a17508b47b2db11a6e203a3cbd43b886a85e25aa/src/Utility/Logger.php#L124-L130
train
Attibee/Bumble-Validation
src/BaseValidator.php
BaseValidator.error
protected function error( $messageKey, $value = null ) { //was a global message set? let's use the global key then if( key_exists( self::GLOBAL_MESSAGE_KEY, $this->templates ) ) $messageKey = self::GLOBAL_MESSAGE_KEY; //invalide message key if( !key_exists( $messageKey, $this->templates ) ) throw new Exception\MessageTemplateDoesNotExist( "A message template does not exist for key $messageKey" ); $this->messages[ $messageKey ] = $this->buildMessage( $this->templates[$messageKey], $value ); }
php
protected function error( $messageKey, $value = null ) { //was a global message set? let's use the global key then if( key_exists( self::GLOBAL_MESSAGE_KEY, $this->templates ) ) $messageKey = self::GLOBAL_MESSAGE_KEY; //invalide message key if( !key_exists( $messageKey, $this->templates ) ) throw new Exception\MessageTemplateDoesNotExist( "A message template does not exist for key $messageKey" ); $this->messages[ $messageKey ] = $this->buildMessage( $this->templates[$messageKey], $value ); }
[ "protected", "function", "error", "(", "$", "messageKey", ",", "$", "value", "=", "null", ")", "{", "//was a global message set? let's use the global key then\r", "if", "(", "key_exists", "(", "self", "::", "GLOBAL_MESSAGE_KEY", ",", "$", "this", "->", "templates", ...
Adds an error message to the list of errors. @param $messageKey The key of the message template. @param $value The value that is being validated. @throws Exception\MessageTemplateDoesNotExist The message template does not exist.
[ "Adds", "an", "error", "message", "to", "the", "list", "of", "errors", "." ]
4623b4a9b8592e3f36e615391fd7ec9ab2344a03
https://github.com/Attibee/Bumble-Validation/blob/4623b4a9b8592e3f36e615391fd7ec9ab2344a03/src/BaseValidator.php#L105-L115
train
Attibee/Bumble-Validation
src/BaseValidator.php
BaseValidator.updateMessageTemplate
private function updateMessageTemplate( $template, $key ) { //invalide message key if( !key_exists( $messageKey, $this->templates ) && $key != self::DEFAULT_KEY ) throw new Exception\MessageTemplateDoesNotExist( "A message template does not exist for key $messageKey" ); $this->templates[$key] = $template; }
php
private function updateMessageTemplate( $template, $key ) { //invalide message key if( !key_exists( $messageKey, $this->templates ) && $key != self::DEFAULT_KEY ) throw new Exception\MessageTemplateDoesNotExist( "A message template does not exist for key $messageKey" ); $this->templates[$key] = $template; }
[ "private", "function", "updateMessageTemplate", "(", "$", "template", ",", "$", "key", ")", "{", "//invalide message key\r", "if", "(", "!", "key_exists", "(", "$", "messageKey", ",", "$", "this", "->", "templates", ")", "&&", "$", "key", "!=", "self", "::...
Updates the message template. This overrides existing message templates. @param $template The message template. @param $key The message key.
[ "Updates", "the", "message", "template", ".", "This", "overrides", "existing", "message", "templates", "." ]
4623b4a9b8592e3f36e615391fd7ec9ab2344a03
https://github.com/Attibee/Bumble-Validation/blob/4623b4a9b8592e3f36e615391fd7ec9ab2344a03/src/BaseValidator.php#L122-L128
train
benkle-libs/feed-parser
src/Standards/Atom/Rules/SimpleAtomFieldRule.php
SimpleAtomFieldRule.getNodeContent
private function getNodeContent(\DOMNode $node) { $type = $node->attributes->getNamedItem('type'); if ($type && strtolower($type->nodeValue) == 'xhtml') { $result = ''; foreach ($node->childNodes as $childNode) { $result .= $node->ownerDocument->save($childNode); } return $result; } else { return $node->nodeValue; } }
php
private function getNodeContent(\DOMNode $node) { $type = $node->attributes->getNamedItem('type'); if ($type && strtolower($type->nodeValue) == 'xhtml') { $result = ''; foreach ($node->childNodes as $childNode) { $result .= $node->ownerDocument->save($childNode); } return $result; } else { return $node->nodeValue; } }
[ "private", "function", "getNodeContent", "(", "\\", "DOMNode", "$", "node", ")", "{", "$", "type", "=", "$", "node", "->", "attributes", "->", "getNamedItem", "(", "'type'", ")", ";", "if", "(", "$", "type", "&&", "strtolower", "(", "$", "type", "->", ...
Enable XHTML types. @param \DOMNode $node @return string @codeCoverageIgnore
[ "Enable", "XHTML", "types", "." ]
8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f
https://github.com/benkle-libs/feed-parser/blob/8b86daf9dfe57e6e7ccae83dbc65ac7ce462144f/src/Standards/Atom/Rules/SimpleAtomFieldRule.php#L85-L97
train
unforge/array-toolkit
src/Arr.php
Arr.getInt
public static function getInt(array $array, $key, int $default = 0) : int { $key = (string) $key; if ($array[$key] ?? 0) { return (int) $array[$key]; } return $default; }
php
public static function getInt(array $array, $key, int $default = 0) : int { $key = (string) $key; if ($array[$key] ?? 0) { return (int) $array[$key]; } return $default; }
[ "public", "static", "function", "getInt", "(", "array", "$", "array", ",", "$", "key", ",", "int", "$", "default", "=", "0", ")", ":", "int", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "$", "array", "[", "$", "key", ...
Return INT value from array @param array $array @param string|int $key @param int $default @return int
[ "Return", "INT", "value", "from", "array" ]
734992061dca91e593b33bee5f4b48112749dc60
https://github.com/unforge/array-toolkit/blob/734992061dca91e593b33bee5f4b48112749dc60/src/Arr.php#L55-L64
train
unforge/array-toolkit
src/Arr.php
Arr.getFloat
public static function getFloat(array $array, $key, float $default = 0.0) : float { $key = (string) $key; if ($array[$key] ?? 0) { return (float) $array[$key]; } return $default; }
php
public static function getFloat(array $array, $key, float $default = 0.0) : float { $key = (string) $key; if ($array[$key] ?? 0) { return (float) $array[$key]; } return $default; }
[ "public", "static", "function", "getFloat", "(", "array", "$", "array", ",", "$", "key", ",", "float", "$", "default", "=", "0.0", ")", ":", "float", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "$", "array", "[", "$", ...
Return FLOAT value from array @param array $array @param string|int $key @param float $default @return float
[ "Return", "FLOAT", "value", "from", "array" ]
734992061dca91e593b33bee5f4b48112749dc60
https://github.com/unforge/array-toolkit/blob/734992061dca91e593b33bee5f4b48112749dc60/src/Arr.php#L75-L84
train
unforge/array-toolkit
src/Arr.php
Arr.getString
public static function getString(array $array, $key, string $default = '') : string { $key = (string) $key; if ($array[$key] ?? 0) { return (string) $array[$key]; } return $default; }
php
public static function getString(array $array, $key, string $default = '') : string { $key = (string) $key; if ($array[$key] ?? 0) { return (string) $array[$key]; } return $default; }
[ "public", "static", "function", "getString", "(", "array", "$", "array", ",", "$", "key", ",", "string", "$", "default", "=", "''", ")", ":", "string", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "$", "array", "[", "$", ...
Return STRING value from array @param array $array @param string|int $key @param string $default @return string
[ "Return", "STRING", "value", "from", "array" ]
734992061dca91e593b33bee5f4b48112749dc60
https://github.com/unforge/array-toolkit/blob/734992061dca91e593b33bee5f4b48112749dc60/src/Arr.php#L95-L104
train
unforge/array-toolkit
src/Arr.php
Arr.getBool
public static function getBool(array $array, $key, bool $default = false) : bool { $key = (string) $key; if ($array[$key] ?? 0) { return (bool) $array[$key]; } return $default; }
php
public static function getBool(array $array, $key, bool $default = false) : bool { $key = (string) $key; if ($array[$key] ?? 0) { return (bool) $array[$key]; } return $default; }
[ "public", "static", "function", "getBool", "(", "array", "$", "array", ",", "$", "key", ",", "bool", "$", "default", "=", "false", ")", ":", "bool", "{", "$", "key", "=", "(", "string", ")", "$", "key", ";", "if", "(", "$", "array", "[", "$", "...
Return BOOL value from array @param array $array @param string|int $key @param bool $default @return bool
[ "Return", "BOOL", "value", "from", "array" ]
734992061dca91e593b33bee5f4b48112749dc60
https://github.com/unforge/array-toolkit/blob/734992061dca91e593b33bee5f4b48112749dc60/src/Arr.php#L115-L124
train
headzoo/core
src/Headzoo/Core/FunctionsTrait.php
FunctionsTrait.swapArgs
protected static function swapArgs(&$optional, &$swap, $default = null, $swap_required = true) { $is_swapped = false; if (empty($swap) && !empty($optional)) { $swap = $optional; $optional = $default; $is_swapped = true; } if ($swap_required && !$swap) { if (is_string($swap_required)) { $message = "Argument '{$swap_required}' is required."; } else { $message = "Missing argument."; } throw new Exceptions\InvalidArgumentException($message); } return $is_swapped; }
php
protected static function swapArgs(&$optional, &$swap, $default = null, $swap_required = true) { $is_swapped = false; if (empty($swap) && !empty($optional)) { $swap = $optional; $optional = $default; $is_swapped = true; } if ($swap_required && !$swap) { if (is_string($swap_required)) { $message = "Argument '{$swap_required}' is required."; } else { $message = "Missing argument."; } throw new Exceptions\InvalidArgumentException($message); } return $is_swapped; }
[ "protected", "static", "function", "swapArgs", "(", "&", "$", "optional", ",", "&", "$", "swap", ",", "$", "default", "=", "null", ",", "$", "swap_required", "=", "true", ")", "{", "$", "is_swapped", "=", "false", ";", "if", "(", "empty", "(", "$", ...
Swaps two values when the second is empty and the first is not Returns true when the arguments were swapped, and false if not. Example: ```php $env = "live"; $values = null; public function fetch($env, $values = null) { $is_swapped = $this->swapArgs($env, $values, "dev"); var_dump($is_swapped); var_dump($env); var_dump($values); // Outputs: // bool(true) // string(4) "dev" // string(4) "live" } ``` @param mixed $optional Swap when this value is not empty @param mixed $swap Swap when this value is empty @param null $default The new value for $optional when swapped @param bool $swap_required Is the $swap argument required? @throws Exceptions\InvalidArgumentException When the $swap value is required and is empty @return bool
[ "Swaps", "two", "values", "when", "the", "second", "is", "empty", "and", "the", "first", "is", "not" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/FunctionsTrait.php#L57-L75
train
headzoo/core
src/Headzoo/Core/FunctionsTrait.php
FunctionsTrait.swapCallable
protected static function swapCallable(&$optional, &$callable, $default = null, $callable_required = true) { $is_swapped = false; if (is_callable($optional)) { $callable = $optional; $optional = $default; $is_swapped = true; } if ($callable_required && !$callable) { throw new Exceptions\InvalidArgumentException( "A callable object is required." ); } return $is_swapped; }
php
protected static function swapCallable(&$optional, &$callable, $default = null, $callable_required = true) { $is_swapped = false; if (is_callable($optional)) { $callable = $optional; $optional = $default; $is_swapped = true; } if ($callable_required && !$callable) { throw new Exceptions\InvalidArgumentException( "A callable object is required." ); } return $is_swapped; }
[ "protected", "static", "function", "swapCallable", "(", "&", "$", "optional", ",", "&", "$", "callable", ",", "$", "default", "=", "null", ",", "$", "callable_required", "=", "true", ")", "{", "$", "is_swapped", "=", "false", ";", "if", "(", "is_callable...
Swaps two variables when the second is a callable object Used to create functions/methods which have callbacks as the final argument, and it's desirable to make middle argument optional, while the callback remains the final argument. Throws an exception when $callable_required is true, and the callable object is empty. Returns true if the arguments were swapped, false if not. Examples: ```php public function joinArray(array $values, $separator, callable $callback = null) { $this->swapCallable($separator, $callback, "-"); $values = array_map($callback, $values); return join($separator, $values); } // The function above may be called normally, like this: $values = ["headzoo", "joe"]; $this->joinArray($values, "-", 'Headzoo\Core\String::quote'); // Or the middle argument may be omitted, and called like this: $this->joinArray($values, 'Headzoo\Core\String::quote'); ``` @param mixed $optional The optional argument @param mixed $callable Possibly a callable object @param mixed $default The optional argument default value @param bool $callable_required Whether the callable object is required (cannot be empty) @throws Exceptions\InvalidArgumentException When the callable is required and empty @return bool
[ "Swaps", "two", "variables", "when", "the", "second", "is", "a", "callable", "object" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/FunctionsTrait.php#L114-L129
train
headzoo/core
src/Headzoo/Core/FunctionsTrait.php
FunctionsTrait.throwOnInvalidArgument
protected static function throwOnInvalidArgument($arg, $type) { $args = func_get_args(); $arg = array_shift($args); $arg_type = gettype($arg); $found = false; foreach($args as $type) { if ((in_array($type, self::$native_php_types) && $arg_type == $type) || $arg instanceof $type) { $found = true; break; } } if (!$found) { throw new Exceptions\InvalidArgumentException( sprintf( "Argument must be of type %s.", Arrays::conjunct($args, "or") ) ); } return true; }
php
protected static function throwOnInvalidArgument($arg, $type) { $args = func_get_args(); $arg = array_shift($args); $arg_type = gettype($arg); $found = false; foreach($args as $type) { if ((in_array($type, self::$native_php_types) && $arg_type == $type) || $arg instanceof $type) { $found = true; break; } } if (!$found) { throw new Exceptions\InvalidArgumentException( sprintf( "Argument must be of type %s.", Arrays::conjunct($args, "or") ) ); } return true; }
[ "protected", "static", "function", "throwOnInvalidArgument", "(", "$", "arg", ",", "$", "type", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "arg", "=", "array_shift", "(", "$", "args", ")", ";", "$", "arg_type", "=", "gettype", "("...
Throws an InvalidArgumentException when the argument is not one of the given types The $type argument should be one of the native PHP types returned by gettype() or the name of a class, in which case the argument must be an instance of that class. This method always returns true. Example: public function fetch($values) { $this->throwOnInvalidArgument($values, "array", ArrayableInterface::class); ... other stuff ... } ``` @param string $arg The argument @param string $type The first type to check @throws Exceptions\InvalidArgumentException @internal param $string ... Additional types to check @return bool
[ "Throws", "an", "InvalidArgumentException", "when", "the", "argument", "is", "not", "one", "of", "the", "given", "types" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/FunctionsTrait.php#L201-L225
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.parse
private function parse() { $this->parameters = []; $this->pathSegments = []; $parsedUrl = parse_url($this->returnValue); foreach ($parsedUrl as $key => $value) { if ($key == 'query') { parse_str($value, $this->parameters); } elseif ($key == 'path') { $this->pathSegments = ($value) ? explode('/', ltrim($value, '/')) : []; } else { $this->{$key} = $value; } } return $this; }
php
private function parse() { $this->parameters = []; $this->pathSegments = []; $parsedUrl = parse_url($this->returnValue); foreach ($parsedUrl as $key => $value) { if ($key == 'query') { parse_str($value, $this->parameters); } elseif ($key == 'path') { $this->pathSegments = ($value) ? explode('/', ltrim($value, '/')) : []; } else { $this->{$key} = $value; } } return $this; }
[ "private", "function", "parse", "(", ")", "{", "$", "this", "->", "parameters", "=", "[", "]", ";", "$", "this", "->", "pathSegments", "=", "[", "]", ";", "$", "parsedUrl", "=", "parse_url", "(", "$", "this", "->", "returnValue", ")", ";", "foreach",...
Parses the current returnValue and fills this objects properties @return $this
[ "Parses", "the", "current", "returnValue", "and", "fills", "this", "objects", "properties" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L27-L42
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.compareTo
public function compareTo($url, $caseSensitive = true, $includeQuery = false, $ignoreSpecialChars = false) { /* @var $urlObj Url */ $urlObj = $url instanceof Url ? $url : self::create($url)->decodePath(); /* @var $urlObj2 Url */ $urlObj2 = clone $this; $urlObj2->decodePath(); if ($ignoreSpecialChars) { $urlObj->tidy(); $urlObj2->tidy(); } if (!$includeQuery) { $urlObj->parameters = []; $urlObj2->parameters = []; } return $caseSensitive ? strcmp($urlObj, $urlObj2) : strcasecmp($urlObj, $urlObj2); }
php
public function compareTo($url, $caseSensitive = true, $includeQuery = false, $ignoreSpecialChars = false) { /* @var $urlObj Url */ $urlObj = $url instanceof Url ? $url : self::create($url)->decodePath(); /* @var $urlObj2 Url */ $urlObj2 = clone $this; $urlObj2->decodePath(); if ($ignoreSpecialChars) { $urlObj->tidy(); $urlObj2->tidy(); } if (!$includeQuery) { $urlObj->parameters = []; $urlObj2->parameters = []; } return $caseSensitive ? strcmp($urlObj, $urlObj2) : strcasecmp($urlObj, $urlObj2); }
[ "public", "function", "compareTo", "(", "$", "url", ",", "$", "caseSensitive", "=", "true", ",", "$", "includeQuery", "=", "false", ",", "$", "ignoreSpecialChars", "=", "false", ")", "{", "/* @var $urlObj Url */", "$", "urlObj", "=", "$", "url", "instanceof"...
Checks if this url object is equal to another. @param string $str2 <p> The string to compare against </p> @param bool $caseSensitive [optional] <p> If true the string comparision is case sensitive </p> </p> @param bool $includeQuery [optional] <p> If true the query string is ignored from the string comparision </p> @param bool $ignoreSpecialChars [optional] <p> If true the special characters are ignored from the string comparision </p> @return int &lt; 0 if <i>str1</i> is less than <i>str2</i>; &gt; 0 if <i>str1</i> is greater than <i>str2</i>, and 0 if they are equal.
[ "Checks", "if", "this", "url", "object", "is", "equal", "to", "another", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L123-L139
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.fromObject
function fromObject($value) { $this->clear(); $this->orignalValue = $this->returnValue = (string) (method_exists($value, '__toString') ? $value : null); return $this->parse(); }
php
function fromObject($value) { $this->clear(); $this->orignalValue = $this->returnValue = (string) (method_exists($value, '__toString') ? $value : null); return $this->parse(); }
[ "function", "fromObject", "(", "$", "value", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "$", "this", "->", "orignalValue", "=", "$", "this", "->", "returnValue", "=", "(", "string", ")", "(", "method_exists", "(", "$", "value", ",", "'__toS...
Create a Url instance from an object. @param object $value @return $this
[ "Create", "a", "Url", "instance", "from", "an", "object", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L175-L180
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.fromString
function fromString($value) { $this->clear(); $this->orignalValue = $this->returnValue = (string) $value; return $this->parse(); }
php
function fromString($value) { $this->clear(); $this->orignalValue = $this->returnValue = (string) $value; return $this->parse(); }
[ "function", "fromString", "(", "$", "value", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "$", "this", "->", "orignalValue", "=", "$", "this", "->", "returnValue", "=", "(", "string", ")", "$", "value", ";", "return", "$", "this", "->", "pa...
Create a Url instance from a string. @param string $value @return $this
[ "Create", "a", "Url", "instance", "from", "a", "string", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L188-L193
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.fromResource
function fromResource($value) { $this->clear(); $this->orignalValue = $this->returnValue = stream_get_contents($value); return $this->parse(); }
php
function fromResource($value) { $this->clear(); $this->orignalValue = $this->returnValue = stream_get_contents($value); return $this->parse(); }
[ "function", "fromResource", "(", "$", "value", ")", "{", "$", "this", "->", "clear", "(", ")", ";", "$", "this", "->", "orignalValue", "=", "$", "this", "->", "returnValue", "=", "stream_get_contents", "(", "$", "value", ")", ";", "return", "$", "this"...
Create a Url instance from a resource. @param resource $value @return $this
[ "Create", "a", "Url", "instance", "from", "a", "resource", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L201-L206
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.clear
protected function clear() { $this->scheme = null; $this->host = null; $this->port = null; $this->user = null; $this->pass = null; $this->pathSegments = []; $this->parameters = []; $this->fragment = null; $this->orignalValue = $this->returnValue = ''; return $this->parse(); }
php
protected function clear() { $this->scheme = null; $this->host = null; $this->port = null; $this->user = null; $this->pass = null; $this->pathSegments = []; $this->parameters = []; $this->fragment = null; $this->orignalValue = $this->returnValue = ''; return $this->parse(); }
[ "protected", "function", "clear", "(", ")", "{", "$", "this", "->", "scheme", "=", "null", ";", "$", "this", "->", "host", "=", "null", ";", "$", "this", "->", "port", "=", "null", ";", "$", "this", "->", "user", "=", "null", ";", "$", "this", ...
Empties the values of this Url @return $this
[ "Empties", "the", "values", "of", "this", "Url" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L213-L225
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.offsetGet
public function offsetGet($offset) { return isset($this->pathSegments[$offset]) ? $this->pathSegments[$offset] : null; }
php
public function offsetGet($offset) { return isset($this->pathSegments[$offset]) ? $this->pathSegments[$offset] : null; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "return", "isset", "(", "$", "this", "->", "pathSegments", "[", "$", "offset", "]", ")", "?", "$", "this", "->", "pathSegments", "[", "$", "offset", "]", ":", "null", ";", "}" ]
Retrieve path segment @link http://php.net/manual/en/arrayaccess.offsetget.php @param int $offset <p> The path segment offset to retrieve. </p> @return string|null The value of the path segement at the give offset or null if not set.
[ "Retrieve", "path", "segment" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L262-L265
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.current
public function current($includeQuery = true) { $url = ""; if (!$this->serverVars && php_sapi_name() == 'cli') { $url = "cli"; } else { $url .= $this->currentScheme().$this->currentHost(); $port = $this->currentPort(); if (!in_array($port, [ false, 80])) { $url .= ':'.$port; } $url .= $this->currentPath(); if ($includeQuery) { $query = $this->currentQuery(); if ($query) { $url .= '?'.$query; } } } return static::create($url); }
php
public function current($includeQuery = true) { $url = ""; if (!$this->serverVars && php_sapi_name() == 'cli') { $url = "cli"; } else { $url .= $this->currentScheme().$this->currentHost(); $port = $this->currentPort(); if (!in_array($port, [ false, 80])) { $url .= ':'.$port; } $url .= $this->currentPath(); if ($includeQuery) { $query = $this->currentQuery(); if ($query) { $url .= '?'.$query; } } } return static::create($url); }
[ "public", "function", "current", "(", "$", "includeQuery", "=", "true", ")", "{", "$", "url", "=", "\"\"", ";", "if", "(", "!", "$", "this", "->", "serverVars", "&&", "php_sapi_name", "(", ")", "==", "'cli'", ")", "{", "$", "url", "=", "\"cli\"", "...
Get the URL of current request. @param bool $includeQuery <p>Include the query string in the result</p> @return Url The URL of the current request or cli if called from the command line
[ "Get", "the", "URL", "of", "current", "request", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L332-L352
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.currentPath
public function currentPath() { $requestURI = $this->serverVar('REQUEST_URI'); $sciptName = $this->serverVar('SCRIPT_NAME'); return rtrim(parse_url($requestURI? : $sciptName, PHP_URL_PATH), '/'); }
php
public function currentPath() { $requestURI = $this->serverVar('REQUEST_URI'); $sciptName = $this->serverVar('SCRIPT_NAME'); return rtrim(parse_url($requestURI? : $sciptName, PHP_URL_PATH), '/'); }
[ "public", "function", "currentPath", "(", ")", "{", "$", "requestURI", "=", "$", "this", "->", "serverVar", "(", "'REQUEST_URI'", ")", ";", "$", "sciptName", "=", "$", "this", "->", "serverVar", "(", "'SCRIPT_NAME'", ")", ";", "return", "rtrim", "(", "pa...
Get the path of the current request. @return string
[ "Get", "the", "path", "of", "the", "current", "request", "." ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L399-L404
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.fetch
public function fetch($forwardCookie = true, $contextOptions = []) { $cookie = $this->serverVar('HTTP_COOKIE'); if ($forwardCookie && $cookie !== false) { $cookie = ['http' => ['header' => 'Cookie: '.$cookie."\r\n"]]; $contextOptions = array_merge($cookie, $contextOptions); } $context = stream_context_create($contextOptions); return file_get_contents((string) $this, false, $context); }
php
public function fetch($forwardCookie = true, $contextOptions = []) { $cookie = $this->serverVar('HTTP_COOKIE'); if ($forwardCookie && $cookie !== false) { $cookie = ['http' => ['header' => 'Cookie: '.$cookie."\r\n"]]; $contextOptions = array_merge($cookie, $contextOptions); } $context = stream_context_create($contextOptions); return file_get_contents((string) $this, false, $context); }
[ "public", "function", "fetch", "(", "$", "forwardCookie", "=", "true", ",", "$", "contextOptions", "=", "[", "]", ")", "{", "$", "cookie", "=", "$", "this", "->", "serverVar", "(", "'HTTP_COOKIE'", ")", ";", "if", "(", "$", "forwardCookie", "&&", "$", ...
Make a request to the URL and retieve the result as a string @param bool $forwardCookie <p>If true, the current request cookie will be forwarded in the request</p> @param type $contextOptions [optional] <p> Must be an associative array in the format $arr['parameter'] = $value. Refer to context parameters for a listing of standard stream parameters. </p> @link http://www.php.net/manual/en/context.php Options that can be passed with $contectOptions @link http://php.net/manual/en/function.file-get-contents.php The internal method used to fetch the url conetents @return type
[ "Make", "a", "request", "to", "the", "URL", "and", "retieve", "the", "result", "as", "a", "string" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L420-L429
train
guru-digital/framework-types
GDM/Framework/Types/Url.php
Url.toString
public function toString() { $result = ""; if ($this->scheme) { $result .= $this->scheme.'://'; } if ($this->user) { $result .= $this->user; if ($this->pass) { $result .= $this->user; } $result .= '@'; } if ($this->host) { $result .= $this->host; } if ($this->port) { $result .= ':'.$this->port; } if ($this->pathSegments) { $result .= '/'.implode('/', $this->pathSegments); } if ($this->parameters) { $result .= '?'.http_build_query($this->parameters); } if ($this->fragment) { $result .= '#'.$this->fragment; } return $result; }
php
public function toString() { $result = ""; if ($this->scheme) { $result .= $this->scheme.'://'; } if ($this->user) { $result .= $this->user; if ($this->pass) { $result .= $this->user; } $result .= '@'; } if ($this->host) { $result .= $this->host; } if ($this->port) { $result .= ':'.$this->port; } if ($this->pathSegments) { $result .= '/'.implode('/', $this->pathSegments); } if ($this->parameters) { $result .= '?'.http_build_query($this->parameters); } if ($this->fragment) { $result .= '#'.$this->fragment; } return $result; }
[ "public", "function", "toString", "(", ")", "{", "$", "result", "=", "\"\"", ";", "if", "(", "$", "this", "->", "scheme", ")", "{", "$", "result", ".=", "$", "this", "->", "scheme", ".", "'://'", ";", "}", "if", "(", "$", "this", "->", "user", ...
Gets the current URL as a string @return string The resulting URL as a string
[ "Gets", "the", "current", "URL", "as", "a", "string" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Url.php#L454-L483
train
yii2lab/yii2-test
src/traits/UnitAssertTrait.php
UnitAssertTrait.normalizeArrayForNewLines
private function normalizeArrayForNewLines(array $data) { foreach($data as $k => $item) { if(is_string($item)) { $data[$k] = str_replace(["\r\n", "\n\r", "\r"], "\n", $item); } elseif(is_array($item)) { $data[$k] = $this->normalizeArrayForNewLines($item); } } return $data; }
php
private function normalizeArrayForNewLines(array $data) { foreach($data as $k => $item) { if(is_string($item)) { $data[$k] = str_replace(["\r\n", "\n\r", "\r"], "\n", $item); } elseif(is_array($item)) { $data[$k] = $this->normalizeArrayForNewLines($item); } } return $data; }
[ "private", "function", "normalizeArrayForNewLines", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "item", ")", "{", "if", "(", "is_string", "(", "$", "item", ")", ")", "{", "$", "data", "[", "$", "k", ...
crutch for linux and windows
[ "crutch", "for", "linux", "and", "windows" ]
68cccc925c0365daeb4344bbd7839d9217992357
https://github.com/yii2lab/yii2-test/blob/68cccc925c0365daeb4344bbd7839d9217992357/src/traits/UnitAssertTrait.php#L79-L88
train
samurai-fw/samurai
src/Samurai/Component/Spec/PHPSpec/DIContainerMaintainer.php
DIContainerMaintainer.isUseableRaikiri
public function isUseableRaikiri($class) { $traits = []; do { $traits = array_merge($traits, class_uses($class)); } while ($class = get_parent_class($class)); foreach ($traits as $trait) { $traits = array_merge($traits, class_uses($trait)); } return in_array('Samurai\\Raikiri\\DependencyInjectable', $traits); }
php
public function isUseableRaikiri($class) { $traits = []; do { $traits = array_merge($traits, class_uses($class)); } while ($class = get_parent_class($class)); foreach ($traits as $trait) { $traits = array_merge($traits, class_uses($trait)); } return in_array('Samurai\\Raikiri\\DependencyInjectable', $traits); }
[ "public", "function", "isUseableRaikiri", "(", "$", "class", ")", "{", "$", "traits", "=", "[", "]", ";", "do", "{", "$", "traits", "=", "array_merge", "(", "$", "traits", ",", "class_uses", "(", "$", "class", ")", ")", ";", "}", "while", "(", "$",...
useable raikiri ? @param string $class @return boolean
[ "useable", "raikiri", "?" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Spec/PHPSpec/DIContainerMaintainer.php#L67-L78
train
maiklez/multimedia
src/Http/Controllers/EventosController.php
EventosController.show
public function show(Request $request, Evento $evento) { Debugbar::info($evento); return view('multimedia::eventos/show', [ 'evento' => $evento, ]); }
php
public function show(Request $request, Evento $evento) { Debugbar::info($evento); return view('multimedia::eventos/show', [ 'evento' => $evento, ]); }
[ "public", "function", "show", "(", "Request", "$", "request", ",", "Evento", "$", "evento", ")", "{", "Debugbar", "::", "info", "(", "$", "evento", ")", ";", "return", "view", "(", "'multimedia::eventos/show'", ",", "[", "'evento'", "=>", "$", "evento", ...
show the given task. @param Request $request @param Task $task @return Response
[ "show", "the", "given", "task", "." ]
581a559f6670eea09c21ba1784aff20c363c29f7
https://github.com/maiklez/multimedia/blob/581a559f6670eea09c21ba1784aff20c363c29f7/src/Http/Controllers/EventosController.php#L90-L96
train
aerialls/MadalynnPlumBundle
Command/DeployCommand.php
DeployCommand.deploy
protected function deploy($server, $deployer, OutputInterface $output) { $plum = $this->getContainer()->get('madalynn.plum'); $options = $plum->getOptions($server); $dryrun = ''; if (isset($options['dry_run']) && $options['dry_run']) { $dryrun = '<comment>(dry run mode)</comment>'; } $output->writeln(sprintf('Starting %s to <info>%s</info> %s', $deployer, $server, $dryrun)); // Let's go! $plum->deploy($server, $deployer, $options); $output->writeln(sprintf('Successfully %s to <info>%s</info>', $deployer, $server)); }
php
protected function deploy($server, $deployer, OutputInterface $output) { $plum = $this->getContainer()->get('madalynn.plum'); $options = $plum->getOptions($server); $dryrun = ''; if (isset($options['dry_run']) && $options['dry_run']) { $dryrun = '<comment>(dry run mode)</comment>'; } $output->writeln(sprintf('Starting %s to <info>%s</info> %s', $deployer, $server, $dryrun)); // Let's go! $plum->deploy($server, $deployer, $options); $output->writeln(sprintf('Successfully %s to <info>%s</info>', $deployer, $server)); }
[ "protected", "function", "deploy", "(", "$", "server", ",", "$", "deployer", ",", "OutputInterface", "$", "output", ")", "{", "$", "plum", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'madalynn.plum'", ")", ";", "$", "options", ...
Deploys the application to another server using a deployer. @param string $server The server name @param string $deployer The deployer name @param OutputInterface $output The output object
[ "Deploys", "the", "application", "to", "another", "server", "using", "a", "deployer", "." ]
6f7032db7c31d8fcbf378c266cd82f032a2ee963
https://github.com/aerialls/MadalynnPlumBundle/blob/6f7032db7c31d8fcbf378c266cd82f032a2ee963/Command/DeployCommand.php#L70-L86
train
mrcoco/phalms-core
user/controllers/ProfilesController.php
ProfilesController.searchAction
public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, 'Modules\User\Models\Profiles', $this->request->getPost()); $this->persistent->searchParams = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); } $parameters = []; if ($this->persistent->searchParams) { $parameters = $this->persistent->searchParams; } $profiles = Profiles::find($parameters); if (count($profiles) == 0) { $this->flash->notice("The search did not find any profiles"); return $this->dispatcher->forward([ "action" => "index" ]); } $paginator = new Paginator([ "data" => $profiles, "limit" => 10, "page" => $numberPage ]); $this->view->page = $paginator->getPaginate(); }
php
public function searchAction() { $numberPage = 1; if ($this->request->isPost()) { $query = Criteria::fromInput($this->di, 'Modules\User\Models\Profiles', $this->request->getPost()); $this->persistent->searchParams = $query->getParams(); } else { $numberPage = $this->request->getQuery("page", "int"); } $parameters = []; if ($this->persistent->searchParams) { $parameters = $this->persistent->searchParams; } $profiles = Profiles::find($parameters); if (count($profiles) == 0) { $this->flash->notice("The search did not find any profiles"); return $this->dispatcher->forward([ "action" => "index" ]); } $paginator = new Paginator([ "data" => $profiles, "limit" => 10, "page" => $numberPage ]); $this->view->page = $paginator->getPaginate(); }
[ "public", "function", "searchAction", "(", ")", "{", "$", "numberPage", "=", "1", ";", "if", "(", "$", "this", "->", "request", "->", "isPost", "(", ")", ")", "{", "$", "query", "=", "Criteria", "::", "fromInput", "(", "$", "this", "->", "di", ",",...
Searches for profiles
[ "Searches", "for", "profiles" ]
23486c3e75077896e708f0d2e257cde280a79ad4
https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/ProfilesController.php#L47-L79
train
mrcoco/phalms-core
user/controllers/ProfilesController.php
ProfilesController.createAction
public function createAction() { if ($this->request->isPost()) { $profile = new Profiles([ 'name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active') ]); if (!$profile->save()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was created successfully"); } Tag::resetInput(); } $this->view->form = new ProfilesForm(null); }
php
public function createAction() { if ($this->request->isPost()) { $profile = new Profiles([ 'name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active') ]); if (!$profile->save()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was created successfully"); } Tag::resetInput(); } $this->view->form = new ProfilesForm(null); }
[ "public", "function", "createAction", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "isPost", "(", ")", ")", "{", "$", "profile", "=", "new", "Profiles", "(", "[", "'name'", "=>", "$", "this", "->", "request", "->", "getPost", "(", ...
Creates a new Profile
[ "Creates", "a", "new", "Profile" ]
23486c3e75077896e708f0d2e257cde280a79ad4
https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/ProfilesController.php#L84-L103
train
mrcoco/phalms-core
user/controllers/ProfilesController.php
ProfilesController.editAction
public function editAction($id) { $profile = Profiles::findFirstById($id); if (!$profile) { $this->flash->error("Profile was not found"); return $this->dispatcher->forward([ 'action' => 'index' ]); } if ($this->request->isPost()) { $profile->assign([ 'name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active') ]); if (!$profile->save()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was updated successfully"); } Tag::resetInput(); } $this->view->form = new ProfilesForm($profile, [ 'edit' => true ]); $this->view->profile = $profile; }
php
public function editAction($id) { $profile = Profiles::findFirstById($id); if (!$profile) { $this->flash->error("Profile was not found"); return $this->dispatcher->forward([ 'action' => 'index' ]); } if ($this->request->isPost()) { $profile->assign([ 'name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active') ]); if (!$profile->save()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was updated successfully"); } Tag::resetInput(); } $this->view->form = new ProfilesForm($profile, [ 'edit' => true ]); $this->view->profile = $profile; }
[ "public", "function", "editAction", "(", "$", "id", ")", "{", "$", "profile", "=", "Profiles", "::", "findFirstById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "profile", ")", "{", "$", "this", "->", "flash", "->", "error", "(", "\"Profile was n...
Edits an existing Profile @param int $id
[ "Edits", "an", "existing", "Profile" ]
23486c3e75077896e708f0d2e257cde280a79ad4
https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/ProfilesController.php#L110-L141
train
mrcoco/phalms-core
user/controllers/ProfilesController.php
ProfilesController.deleteAction
public function deleteAction($id) { $profile = Profiles::findFirstById($id); if (!$profile) { $this->flash->error("Profile was not found"); return $this->dispatcher->forward([ 'action' => 'index' ]); } if (!$profile->delete()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was deleted"); } return $this->dispatcher->forward([ 'action' => 'index' ]); }
php
public function deleteAction($id) { $profile = Profiles::findFirstById($id); if (!$profile) { $this->flash->error("Profile was not found"); return $this->dispatcher->forward([ 'action' => 'index' ]); } if (!$profile->delete()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was deleted"); } return $this->dispatcher->forward([ 'action' => 'index' ]); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "$", "profile", "=", "Profiles", "::", "findFirstById", "(", "$", "id", ")", ";", "if", "(", "!", "$", "profile", ")", "{", "$", "this", "->", "flash", "->", "error", "(", "\"Profile was...
Deletes a Profile @param int $id
[ "Deletes", "a", "Profile" ]
23486c3e75077896e708f0d2e257cde280a79ad4
https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/controllers/ProfilesController.php#L148-L169
train
heyday/heystack-ecommerce-core
src/Currency/CurrencyService.php
CurrencyService.restoreState
public function restoreState() { if ($activeCurrency = $this->stateService->getByKey(self::ACTIVE_CURRENCY_KEY)) { $this->activeCurrency = $activeCurrency; } }
php
public function restoreState() { if ($activeCurrency = $this->stateService->getByKey(self::ACTIVE_CURRENCY_KEY)) { $this->activeCurrency = $activeCurrency; } }
[ "public", "function", "restoreState", "(", ")", "{", "if", "(", "$", "activeCurrency", "=", "$", "this", "->", "stateService", "->", "getByKey", "(", "self", "::", "ACTIVE_CURRENCY_KEY", ")", ")", "{", "$", "this", "->", "activeCurrency", "=", "$", "active...
Uses the State service to retrieve the active currency's identifier and sets the active currency. If the retrieved identifier is not an instance of the Identifier Interface, then it checks if it is a string, which it uses to create a new Identifier object to set the active currency. @return void
[ "Uses", "the", "State", "service", "to", "retrieve", "the", "active", "currency", "s", "identifier", "and", "sets", "the", "active", "currency", "." ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Currency/CurrencyService.php#L96-L101
train
heyday/heystack-ecommerce-core
src/Currency/CurrencyService.php
CurrencyService.convert
public function convert(Money $amount, IdentifierInterface $to) { if (!$toCurrency = $this->getCurrency($to)) { throw new \InvalidArgumentException("Currency not supported"); } /** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */ $fromCurrency = $amount->getCurrency(); return $amount->multiply($toCurrency->getValue() / $fromCurrency->getValue()); }
php
public function convert(Money $amount, IdentifierInterface $to) { if (!$toCurrency = $this->getCurrency($to)) { throw new \InvalidArgumentException("Currency not supported"); } /** @var \Heystack\Ecommerce\Currency\Interfaces\CurrencyInterface $fromCurrency */ $fromCurrency = $amount->getCurrency(); return $amount->multiply($toCurrency->getValue() / $fromCurrency->getValue()); }
[ "public", "function", "convert", "(", "Money", "$", "amount", ",", "IdentifierInterface", "$", "to", ")", "{", "if", "(", "!", "$", "toCurrency", "=", "$", "this", "->", "getCurrency", "(", "$", "to", ")", ")", "{", "throw", "new", "\\", "InvalidArgume...
Converts amount from one currency to another using the currency's identifier Warning this method can lose precision! @param \SebastianBergmann\Money\Money $amount @param \Heystack\Core\Identifier\IdentifierInterface $to @return \SebastianBergmann\Money\Money @throws \InvalidArgumentException
[ "Converts", "amount", "from", "one", "currency", "to", "another", "using", "the", "currency", "s", "identifier" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Currency/CurrencyService.php#L179-L189
train
xinc-develop/xinc-core
src/Build/Scheduler/DefaultScheduler.php
DefaultScheduler.getNextBuildTime
public function getNextBuildTime(BuildInterface $build) { if ($build->getLastBuild()->getBuildTime() == null && $build->getStatus() !== BuildInterface::STOPPED ) { if (!isset($this->_nextBuildTime)) { $this->_nextBuildTime = time(); } return $this->_nextBuildTime; } else { return; } }
php
public function getNextBuildTime(BuildInterface $build) { if ($build->getLastBuild()->getBuildTime() == null && $build->getStatus() !== BuildInterface::STOPPED ) { if (!isset($this->_nextBuildTime)) { $this->_nextBuildTime = time(); } return $this->_nextBuildTime; } else { return; } }
[ "public", "function", "getNextBuildTime", "(", "BuildInterface", "$", "build", ")", "{", "if", "(", "$", "build", "->", "getLastBuild", "(", ")", "->", "getBuildTime", "(", ")", "==", "null", "&&", "$", "build", "->", "getStatus", "(", ")", "!==", "Build...
Calculates the next build timestamp this is a build once scheduler. @return int
[ "Calculates", "the", "next", "build", "timestamp", "this", "is", "a", "build", "once", "scheduler", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Build/Scheduler/DefaultScheduler.php#L47-L60
train
open-orchestra/open-orchestra-bbcode-bundle
BBcodeBundle/ElementNode/BBcodeDocumentElement.php
BBcodeDocumentElement.getAsPreviewHTML
public function getAsPreviewHTML() { $html = ""; foreach ($this->getChildren() as $child) { $html .= $child->getAsPreviewHTML(); } return $html; }
php
public function getAsPreviewHTML() { $html = ""; foreach ($this->getChildren() as $child) { $html .= $child->getAsPreviewHTML(); } return $html; }
[ "public", "function", "getAsPreviewHTML", "(", ")", "{", "$", "html", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "html", ".=", "$", "child", "->", "getAsPreviewHTML", "(", ")", ";"...
Iterates through the document's children to return a html version, in a preview context @return string
[ "Iterates", "through", "the", "document", "s", "children", "to", "return", "a", "html", "version", "in", "a", "preview", "context" ]
4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54
https://github.com/open-orchestra/open-orchestra-bbcode-bundle/blob/4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54/BBcodeBundle/ElementNode/BBcodeDocumentElement.php#L18-L26
train
AnonymPHP/Anonym-Library
src/Anonym/Filesystem/Adapter.php
Adapter.chmod
public function chmod($path, $mod = 0777) { if ($this->adapter instanceof Local) { return chmod($path, $mod); } return false; }
php
public function chmod($path, $mod = 0777) { if ($this->adapter instanceof Local) { return chmod($path, $mod); } return false; }
[ "public", "function", "chmod", "(", "$", "path", ",", "$", "mod", "=", "0777", ")", "{", "if", "(", "$", "this", "->", "adapter", "instanceof", "Local", ")", "{", "return", "chmod", "(", "$", "path", ",", "$", "mod", ")", ";", "}", "return", "fal...
set the chmod to the file @param string $path @param int $mod @return bool
[ "set", "the", "chmod", "to", "the", "file" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Filesystem/Adapter.php#L43-L50
train
cityware/city-utility
src/Recursivity/Tree.php
Tree.getNodes
public function getNodes() { $nodes = array(); foreach ($this->nodes[$this->options['rootid']]->getDescendants() as $subnode) { $nodes[] = $subnode; } return $nodes; }
php
public function getNodes() { $nodes = array(); foreach ($this->nodes[$this->options['rootid']]->getDescendants() as $subnode) { $nodes[] = $subnode; } return $nodes; }
[ "public", "function", "getNodes", "(", ")", "{", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "nodes", "[", "$", "this", "->", "options", "[", "'rootid'", "]", "]", "->", "getDescendants", "(", ")", "as", "$", "subn...
Returns a flat, sorted array of all node objects in the tree. @return Node[] Nodes, sorted as if the tree was hierarchical, i.e.: the first level 1 item, then the children of the first level 1 item (and their children), then the second level 1 item and so on.
[ "Returns", "a", "flat", "sorted", "array", "of", "all", "node", "objects", "in", "the", "tree", "." ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree.php#L86-L93
train
cityware/city-utility
src/Recursivity/Tree.php
Tree.getNodeById
public function getNodeById($id) { if (empty($this->nodes[$id])) { throw new \InvalidArgumentException("Invalid node primary key $id"); } return $this->nodes[$id]; }
php
public function getNodeById($id) { if (empty($this->nodes[$id])) { throw new \InvalidArgumentException("Invalid node primary key $id"); } return $this->nodes[$id]; }
[ "public", "function", "getNodeById", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "nodes", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid node primary key $id\"", ")", ";", "...
Returns a single node from the tree, identified by its ID. @param int $id Node ID @throws \InvalidArgumentException @return Node
[ "Returns", "a", "single", "node", "from", "the", "tree", "identified", "by", "its", "ID", "." ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree.php#L104-L110
train
cityware/city-utility
src/Recursivity/Tree.php
Tree.getNodeByValuePath
public function getNodeByValuePath($name, array $search) { $findNested = function (array $nodes, array $tokens) use ($name, &$findNested) { $token = array_shift($tokens); foreach ($nodes as $node) { $nodeName = $node->get($name); if ($nodeName === $token) { // Match if (count($tokens)) { // Search next level return $findNested($node->getChildren(), $tokens); } else { // We found the node we were looking for return $node; } } } return null; }; return $findNested($this->getRootNodes(), $search); }
php
public function getNodeByValuePath($name, array $search) { $findNested = function (array $nodes, array $tokens) use ($name, &$findNested) { $token = array_shift($tokens); foreach ($nodes as $node) { $nodeName = $node->get($name); if ($nodeName === $token) { // Match if (count($tokens)) { // Search next level return $findNested($node->getChildren(), $tokens); } else { // We found the node we were looking for return $node; } } } return null; }; return $findNested($this->getRootNodes(), $search); }
[ "public", "function", "getNodeByValuePath", "(", "$", "name", ",", "array", "$", "search", ")", "{", "$", "findNested", "=", "function", "(", "array", "$", "nodes", ",", "array", "$", "tokens", ")", "use", "(", "$", "name", ",", "&", "$", "findNested",...
Returns the first node for which a specific property's values of all ancestors and the node are equal to the values in the given argument. Example: If nodes have property "name", and on the root level there is a node with name "A" which has a child with name "B" which has a child which has node "C", you would get the latter one by invoking getNodeByValuePath('name', ['A', 'B', 'C']). Comparison is case-sensitive and type-safe. @param string $name @param array $search @return Node|null
[ "Returns", "the", "first", "node", "for", "which", "a", "specific", "property", "s", "values", "of", "all", "ancestors", "and", "the", "node", "are", "equal", "to", "the", "values", "in", "the", "given", "argument", "." ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree.php#L136-L157
train
cityware/city-utility
src/Recursivity/Tree.php
Tree.build
private function build(array $data) { $children = array(); // Create the root node $this->nodes[$this->options['rootid']] = $this->createNode( array( 'id' => $this->options['rootid'], 'parent' => null, ) ); foreach ($data as $row) { $this->nodes[$row['id']] = $this->createNode($row); if (empty($children[$row['parent']])) { $children[$row['parent']] = array($row['id']); } else { $children[$row['parent']][] = $row['id']; } } foreach ($children as $pid => $childids) { foreach ($childids as $id) { if ($pid == $id) { throw new InvalidParentException( "Node with ID $id references its own ID as parent ID" ); } if (isset($this->nodes[$pid])) { $this->nodes[$pid]->addChild($this->nodes[$id]); } else { throw new InvalidParentException( "Node with ID $id points to non-existent parent with ID $pid" ); } } } }
php
private function build(array $data) { $children = array(); // Create the root node $this->nodes[$this->options['rootid']] = $this->createNode( array( 'id' => $this->options['rootid'], 'parent' => null, ) ); foreach ($data as $row) { $this->nodes[$row['id']] = $this->createNode($row); if (empty($children[$row['parent']])) { $children[$row['parent']] = array($row['id']); } else { $children[$row['parent']][] = $row['id']; } } foreach ($children as $pid => $childids) { foreach ($childids as $id) { if ($pid == $id) { throw new InvalidParentException( "Node with ID $id references its own ID as parent ID" ); } if (isset($this->nodes[$pid])) { $this->nodes[$pid]->addChild($this->nodes[$id]); } else { throw new InvalidParentException( "Node with ID $id points to non-existent parent with ID $pid" ); } } } }
[ "private", "function", "build", "(", "array", "$", "data", ")", "{", "$", "children", "=", "array", "(", ")", ";", "// Create the root node", "$", "this", "->", "nodes", "[", "$", "this", "->", "options", "[", "'rootid'", "]", "]", "=", "$", "this", ...
Core method for creating the tree @param array $data The data from which to generate the tree @throws InvalidParentException
[ "Core", "method", "for", "creating", "the", "tree" ]
fadd33233cdaf743d87c3c30e341f2b96e96e476
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree.php#L166-L203
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.setRunningEnvironment
public function setRunningEnvironment($running_env) { $running_env = (string)$running_env; if (empty($running_env)) { $this->toss( "InvalidArgument", "The environment name cannot be empty." ); } $previous = $this->running_env; $this->running_env = $running_env; if (!isset($this->callbacks[$this->running_env])) { $this->setCallback( $this->running_env, $this->getDefaultCallback() ); } return $previous; }
php
public function setRunningEnvironment($running_env) { $running_env = (string)$running_env; if (empty($running_env)) { $this->toss( "InvalidArgument", "The environment name cannot be empty." ); } $previous = $this->running_env; $this->running_env = $running_env; if (!isset($this->callbacks[$this->running_env])) { $this->setCallback( $this->running_env, $this->getDefaultCallback() ); } return $previous; }
[ "public", "function", "setRunningEnvironment", "(", "$", "running_env", ")", "{", "$", "running_env", "=", "(", "string", ")", "$", "running_env", ";", "if", "(", "empty", "(", "$", "running_env", ")", ")", "{", "$", "this", "->", "toss", "(", "\"Invalid...
Sets the current runtime environment Automatically sets the default error callback for this environment if none has been set already. Returns the previously set running environment. @param string $running_env Name of the environment @return string
[ "Sets", "the", "current", "runtime", "environment" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L258-L278
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.handle
public function handle($running_env = self::DEFAULT_ENVIRONMENT, callable $callback = null) { $is_handled = false; if (!$this->is_handling && !$this->last_error) { $this->swapCallable($running_env, $callback, $this->running_env, false); $this->setRunningEnvironment($running_env); if ($callback) { $this->setCallback($callback); } $this->prev_exception_handler = set_exception_handler($this->getUncaughtExceptionHandler()); $this->prev_error_handler = set_error_handler($this->getCoreErrorHandler()); register_shutdown_function(function() { if ($error = error_get_last()) { $this->handleCoreError( $error["type"], $error["message"], $error["file"], $error["line"] ); } }); $this->is_handling = true; $is_handled = true; } return $is_handled; }
php
public function handle($running_env = self::DEFAULT_ENVIRONMENT, callable $callback = null) { $is_handled = false; if (!$this->is_handling && !$this->last_error) { $this->swapCallable($running_env, $callback, $this->running_env, false); $this->setRunningEnvironment($running_env); if ($callback) { $this->setCallback($callback); } $this->prev_exception_handler = set_exception_handler($this->getUncaughtExceptionHandler()); $this->prev_error_handler = set_error_handler($this->getCoreErrorHandler()); register_shutdown_function(function() { if ($error = error_get_last()) { $this->handleCoreError( $error["type"], $error["message"], $error["file"], $error["line"] ); } }); $this->is_handling = true; $is_handled = true; } return $is_handled; }
[ "public", "function", "handle", "(", "$", "running_env", "=", "self", "::", "DEFAULT_ENVIRONMENT", ",", "callable", "$", "callback", "=", "null", ")", "{", "$", "is_handled", "=", "false", ";", "if", "(", "!", "$", "this", "->", "is_handling", "&&", "!",...
Starts handling errors Returns true when errors are now being handled, or false when errors were already being handled. Possibly because ::handle() had already been called, or an error has already been handled. Examples: ``` $handler = new ErrorHandler(); $handler->handle(); $handler = new ErrorHandler(); $handler->setCallback(function() { echo "Look out!"; }); $handler->handle(); $handler = new ErrorHandler(); $handler->setRunningEnvironment("live"); $handler->setCallback("live", function() { echo "Look out!"; }); $handler->handle(); $handler = new ErrorHandler(); $handler->handle("live", function() { echo "Look out!"; }); ``` @param string $running_env The running environment @param callable $callback The error callback @return bool
[ "Starts", "handling", "errors" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L309-L337
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.unhandle
public function unhandle() { $is_unhandled = false; if ($this->is_handling && !$this->last_error) { if ($this->prev_exception_handler) { set_exception_handler($this->prev_exception_handler); $this->prev_exception_handler = null; } if ($this->prev_error_handler) { set_error_handler($this->prev_error_handler); $this->prev_error_handler = null; } $this->is_handling = false; $is_unhandled = true; } return $is_unhandled; }
php
public function unhandle() { $is_unhandled = false; if ($this->is_handling && !$this->last_error) { if ($this->prev_exception_handler) { set_exception_handler($this->prev_exception_handler); $this->prev_exception_handler = null; } if ($this->prev_error_handler) { set_error_handler($this->prev_error_handler); $this->prev_error_handler = null; } $this->is_handling = false; $is_unhandled = true; } return $is_unhandled; }
[ "public", "function", "unhandle", "(", ")", "{", "$", "is_unhandled", "=", "false", ";", "if", "(", "$", "this", "->", "is_handling", "&&", "!", "$", "this", "->", "last_error", ")", "{", "if", "(", "$", "this", "->", "prev_exception_handler", ")", "{"...
Stop handling errors Restores the original uncaught exception handler, core error handler, and stops handling errors. Returns true when the original error handling state has been restored, or false when the class was not handling errors. Possibly because ::handle() was never called, or ::unhandle() was already called, or an error has already been handled. @return bool
[ "Stop", "handling", "errors" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L351-L368
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.setCallback
public function setCallback($env, callable $callable = null) { $this->swapCallable($env, $callable, $this->running_env); $this->callbacks[$env] = $callable; if (empty($this->errors[$env])) { $this->setCoreErrors($env, self::getDefaultCoreErrors()); } if (empty($this->exceptions[$env])) { $this->setUncaughtExceptions($env, self::$default_exceptions); } return $this; }
php
public function setCallback($env, callable $callable = null) { $this->swapCallable($env, $callable, $this->running_env); $this->callbacks[$env] = $callable; if (empty($this->errors[$env])) { $this->setCoreErrors($env, self::getDefaultCoreErrors()); } if (empty($this->exceptions[$env])) { $this->setUncaughtExceptions($env, self::$default_exceptions); } return $this; }
[ "public", "function", "setCallback", "(", "$", "env", ",", "callable", "$", "callable", "=", "null", ")", "{", "$", "this", "->", "swapCallable", "(", "$", "env", ",", "$", "callable", ",", "$", "this", "->", "running_env", ")", ";", "$", "this", "->...
Sets the callback that will be called when an error is handled Uses the currently running environment when none is given. Examples: ```php $handler->setCallback(function($handler) { // The $handler parameter is the ErrorHandler instance. // The $handler->getLastError() method returns an exception which // describes the error. include("templates/error.php"); }); $handler->setCallback("live", function($handler) { include("templates/error_live.php"); }); $handler->setCallback("dev", function($handler) { include("templates/error_dev.php"); }); ``` @param string|callable $env Name of the environment @param callable|null $callable The error callback @return $this
[ "Sets", "the", "callback", "that", "will", "be", "called", "when", "an", "error", "is", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L408-L421
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.getCallback
public function getCallback($env = null) { $env = $env ?: $this->running_env; return isset($this->callbacks[$env]) ? $this->callbacks[$env] : null; }
php
public function getCallback($env = null) { $env = $env ?: $this->running_env; return isset($this->callbacks[$env]) ? $this->callbacks[$env] : null; }
[ "public", "function", "getCallback", "(", "$", "env", "=", "null", ")", "{", "$", "env", "=", "$", "env", "?", ":", "$", "this", "->", "running_env", ";", "return", "isset", "(", "$", "this", "->", "callbacks", "[", "$", "env", "]", ")", "?", "$"...
Returns the callback that will be called when an error is handled Uses the currently running environment when none is given. @param string|null $env Name of the environment @return callable
[ "Returns", "the", "callback", "that", "will", "be", "called", "when", "an", "error", "is", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L432-L436
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.defaultCallback
public function defaultCallback($handler) { $exception = $handler->getLastError(); if (php_sapi_name() != "cli") { $message = htmlspecialchars($exception->getMessage()); $trace = nl2br(htmlspecialchars($exception->getTraceAsString())); echo "<!DOCTYPE html><html><head><title>Error</title></head><body>", "<h1>{$message}</h1><p>{$trace}</p></body><html>"; } else { echo $exception->getMessage() . PHP_EOL, "-----------" . PHP_EOL, $exception->getTraceAsString() . PHP_EOL; } }
php
public function defaultCallback($handler) { $exception = $handler->getLastError(); if (php_sapi_name() != "cli") { $message = htmlspecialchars($exception->getMessage()); $trace = nl2br(htmlspecialchars($exception->getTraceAsString())); echo "<!DOCTYPE html><html><head><title>Error</title></head><body>", "<h1>{$message}</h1><p>{$trace}</p></body><html>"; } else { echo $exception->getMessage() . PHP_EOL, "-----------" . PHP_EOL, $exception->getTraceAsString() . PHP_EOL; } }
[ "public", "function", "defaultCallback", "(", "$", "handler", ")", "{", "$", "exception", "=", "$", "handler", "->", "getLastError", "(", ")", ";", "if", "(", "php_sapi_name", "(", ")", "!=", "\"cli\"", ")", "{", "$", "message", "=", "htmlspecialchars", ...
The default error callback This is the default error callback. It displays a web page with error information. This should not be used in production. Ever. @param ErrorHandler $handler The object that handled the error @return mixed
[ "The", "default", "error", "callback" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L463-L476
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.setCoreErrors
public function setCoreErrors($env, $errors = 0) { $this->swapArgs($env, $errors, $this->running_env, false); $this->errors[$env] = $errors; if (!$this->getCallback($env)) { $this->setCallback($env, $this->getDefaultCallback()); } return $this; }
php
public function setCoreErrors($env, $errors = 0) { $this->swapArgs($env, $errors, $this->running_env, false); $this->errors[$env] = $errors; if (!$this->getCallback($env)) { $this->setCallback($env, $this->getDefaultCallback()); } return $this; }
[ "public", "function", "setCoreErrors", "(", "$", "env", ",", "$", "errors", "=", "0", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "errors", ",", "$", "this", "->", "running_env", ",", "false", ")", ";", "$", "this", "->", ...
Sets the core errors which will be handled By default only a few fatal errors are handled, but you can specify exactly which errors to handle with this method. Uses the currently running environment when none is given. Examples: ```php $handler->setCoreErrors(E_ERROR | E_WARNING | E_DEPRECIATED); $handler->setCoreErrors("live", E_ERROR | E_WARNING); $handler->setCoreError("dev", E_ERROR | E_WARNING | E_NOTICE); ``` @param string|int $env Name of the environment @param int $errors The errors to handle @return $this
[ "Sets", "the", "core", "errors", "which", "will", "be", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L500-L510
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.getCoreErrors
public function getCoreErrors($env = null) { $env = $env ?: $this->running_env; return isset($this->errors[$env]) ? $this->errors[$env] : 0; }
php
public function getCoreErrors($env = null) { $env = $env ?: $this->running_env; return isset($this->errors[$env]) ? $this->errors[$env] : 0; }
[ "public", "function", "getCoreErrors", "(", "$", "env", "=", "null", ")", "{", "$", "env", "=", "$", "env", "?", ":", "$", "this", "->", "running_env", ";", "return", "isset", "(", "$", "this", "->", "errors", "[", "$", "env", "]", ")", "?", "$",...
Returns the core errors which are being handled Uses the currently running environment when none is given. @param string|null $env Name of the environment @return int
[ "Returns", "the", "core", "errors", "which", "are", "being", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L521-L525
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.removeCoreError
public function removeCoreError($env, $error = 0) { $this->swapArgs($env, $error, $this->running_env); $is_removed = false; if (isset($this->errors[$env])) { $orig = $this->errors[$env]; $this->errors[$env] = ($this->errors[$env] & ~ $error); $is_removed = $this->errors[$env] !== $orig; } return $is_removed; }
php
public function removeCoreError($env, $error = 0) { $this->swapArgs($env, $error, $this->running_env); $is_removed = false; if (isset($this->errors[$env])) { $orig = $this->errors[$env]; $this->errors[$env] = ($this->errors[$env] & ~ $error); $is_removed = $this->errors[$env] !== $orig; } return $is_removed; }
[ "public", "function", "removeCoreError", "(", "$", "env", ",", "$", "error", "=", "0", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "error", ",", "$", "this", "->", "running_env", ")", ";", "$", "is_removed", "=", "false", ";...
Stops handling a core error Uses the currently running environment when none is given. Passing E_ALL removes all error handling for the given environment. Examples: ```php $handler->removeCoreError(E_NOTICE); $handler->removeCoreError("live", E_NOTICE); $handler->removeCoreError("dev", E_NOTICE | E_DEPRECIATED); ``` @param string|int $env Name of the environment @param string|int $error The error to remove @return bool
[ "Stops", "handling", "a", "core", "error" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L547-L559
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.setUncaughtExceptions
public function setUncaughtExceptions($env, array $exceptions = []) { $this->swapArgs($env, $exceptions, $this->running_env, false); $this->exceptions[$env] = []; if (!empty($exceptions)) { foreach($exceptions as $exception) { $this->exceptions[$env][] = Objects::getFullName($exception); } if (!$this->getCallback($env)) { $this->setCallback($env, $this->getDefaultCallback()); } } return $this; }
php
public function setUncaughtExceptions($env, array $exceptions = []) { $this->swapArgs($env, $exceptions, $this->running_env, false); $this->exceptions[$env] = []; if (!empty($exceptions)) { foreach($exceptions as $exception) { $this->exceptions[$env][] = Objects::getFullName($exception); } if (!$this->getCallback($env)) { $this->setCallback($env, $this->getDefaultCallback()); } } return $this; }
[ "public", "function", "setUncaughtExceptions", "(", "$", "env", ",", "array", "$", "exceptions", "=", "[", "]", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "exceptions", ",", "$", "this", "->", "running_env", ",", "false", ")", ...
Sets the uncaught exceptions which will be handled By default every uncaught exception is handled, but specific types may be specified using this method. The $exceptions argument may be an array of class names, or array of objects. Uncaught exceptions will not be handled when this method is given an empty array. Uses the currently running environment when none is given. Examples: ```php $handler->setUncaughtExceptions([RuntimeException::class, LogicException::class]); $handler->setUncaughtException("live", [RuntimeException::class, LogicException::class]); $handler->setUncaughtException("dev", [InvalidArgumentException::class, LogicException::class]); ``` @param string|string[]|Exception[] $env Name of the environment @param string[]|Exception[] $exceptions The exceptions to handle @return $this
[ "Sets", "the", "uncaught", "exceptions", "which", "will", "be", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L587-L602
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.getUncaughtExceptions
public function getUncaughtExceptions($env = null) { $env = $env ?: $this->running_env; return isset($this->exceptions[$env]) ? $this->exceptions[$env] : []; }
php
public function getUncaughtExceptions($env = null) { $env = $env ?: $this->running_env; return isset($this->exceptions[$env]) ? $this->exceptions[$env] : []; }
[ "public", "function", "getUncaughtExceptions", "(", "$", "env", "=", "null", ")", "{", "$", "env", "=", "$", "env", "?", ":", "$", "this", "->", "running_env", ";", "return", "isset", "(", "$", "this", "->", "exceptions", "[", "$", "env", "]", ")", ...
Returns the types of uncaught exceptions which are being handled Returns an array of class names representing the types of uncaught exceptions the class is handling. Uses the currently running environment when none is given. @param string|null $env Name of the environment @return string[]
[ "Returns", "the", "types", "of", "uncaught", "exceptions", "which", "are", "being", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L616-L620
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.removeUncaughtException
public function removeUncaughtException($env, $exception = null) { $this->swapArgs($env, $exception, $this->running_env); $is_removed = false; if (isset($this->exceptions[$env])) { $exception = Objects::getFullName($exception); $is_removed = (bool)Arrays::remove($this->exceptions[$env], $exception); } return $is_removed; }
php
public function removeUncaughtException($env, $exception = null) { $this->swapArgs($env, $exception, $this->running_env); $is_removed = false; if (isset($this->exceptions[$env])) { $exception = Objects::getFullName($exception); $is_removed = (bool)Arrays::remove($this->exceptions[$env], $exception); } return $is_removed; }
[ "public", "function", "removeUncaughtException", "(", "$", "env", ",", "$", "exception", "=", "null", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "exception", ",", "$", "this", "->", "running_env", ")", ";", "$", "is_removed", "...
Stops handling an uncaught exception Tells the class to stop handling the given type of exception, which may be either a class name, or object. Returns true if the exception type has been successfully unhandled. A false return value means the class wasn't handling the given exception. Uses the currently running environment when none is given. Examples: ```php $handler->removeUncaughtException(LogicError::class); $handler->removeUncaughtException("live", LogicError::class); $handler->removeUncaughtException("dev", InvalidArgumentException::class); ``` @param string|Exception|string $env Name of the environment @param Exception|string|null $exception The exception to check @return bool
[ "Stops", "handling", "an", "uncaught", "exception" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L646-L657
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.isHandlingCoreError
public function isHandlingCoreError($env, $error = 0) { $this->swapArgs($env, $error, $this->running_env); return isset($this->errors[$env]) && (($this->errors[$env] & $error) === $error); }
php
public function isHandlingCoreError($env, $error = 0) { $this->swapArgs($env, $error, $this->running_env); return isset($this->errors[$env]) && (($this->errors[$env] & $error) === $error); }
[ "public", "function", "isHandlingCoreError", "(", "$", "env", ",", "$", "error", "=", "0", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "error", ",", "$", "this", "->", "running_env", ")", ";", "return", "isset", "(", "$", "t...
Returns whether errors of the given type are being handled Returns true when the given error -- one of the E_ERROR constants -- is one of the errors being handled. Otherwise false is returned. Uses the currently running environment when none is given. Examples: ```php $is_handled = $handler->isHandlingCoreError(E_WARNING); $is_handled = $handler->isHandlingCoreError("live", E_WARNING); ``` @param string|int $env The environment to check @param string|int $error The core error to check @return bool
[ "Returns", "whether", "errors", "of", "the", "given", "type", "are", "being", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L679-L683
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.isHandlingUncaughtException
public function isHandlingUncaughtException($env, $exception = null) { $this->swapArgs($env, $exception, $this->running_env); $is_handling = false; if (isset($this->exceptions[$env])) { if (is_object($exception)) { $exception = Objects::getFullName($exception); } foreach($this->exceptions[$env] as $e) { if (is_subclass_of($exception, $e) || $exception == $e) { $is_handling = true; break; } } } return $is_handling; }
php
public function isHandlingUncaughtException($env, $exception = null) { $this->swapArgs($env, $exception, $this->running_env); $is_handling = false; if (isset($this->exceptions[$env])) { if (is_object($exception)) { $exception = Objects::getFullName($exception); } foreach($this->exceptions[$env] as $e) { if (is_subclass_of($exception, $e) || $exception == $e) { $is_handling = true; break; } } } return $is_handling; }
[ "public", "function", "isHandlingUncaughtException", "(", "$", "env", ",", "$", "exception", "=", "null", ")", "{", "$", "this", "->", "swapArgs", "(", "$", "env", ",", "$", "exception", ",", "$", "this", "->", "running_env", ")", ";", "$", "is_handling"...
Returns whether the given exception is being handled Returns true when the given exception is one of the exceptions being handled for the given running environment. Otherwise false is returned. The $exception argument can be a class name or object. Uses the currently running environment when none is given. Examples: ```php $is_handled = $handler->isHandlingUncaughtException(LogicException::class); $is_handled = $handler->isHandlingUncaughtException("live", LogicException::class); ``` @param string|int $env The environment to check @param string|Exception|null $exception The exception to check @return bool
[ "Returns", "whether", "the", "given", "exception", "is", "being", "handled" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L706-L724
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.handleCoreError
public function handleCoreError($type, $message, $file, $line) { $is_handled = false; if ($this->is_handling && $this->isHandlingCoreError($type)) { $exception = new Exceptions\PHPErrorException( $message, $type, $file, $line ); $is_handled = $this->triggerError($exception, "Core Error"); } return $is_handled; }
php
public function handleCoreError($type, $message, $file, $line) { $is_handled = false; if ($this->is_handling && $this->isHandlingCoreError($type)) { $exception = new Exceptions\PHPErrorException( $message, $type, $file, $line ); $is_handled = $this->triggerError($exception, "Core Error"); } return $is_handled; }
[ "public", "function", "handleCoreError", "(", "$", "type", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "$", "is_handled", "=", "false", ";", "if", "(", "$", "this", "->", "is_handling", "&&", "$", "this", "->", "isHandlingCoreErr...
Handles core errors Called by PHP when an error occures. This method determines whether the error is one of the errors being handled. If it is, the the error will be captured, and the error callback is called. @param int $type The level of the error raised @param string $message The error message @param string $file The filename that the error was raised in @param int $line The line number the error was raised at @return bool
[ "Handles", "core", "errors" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L740-L754
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.getCoreErrorHandler
public function getCoreErrorHandler() { return function($type, $message, $file, $line) { return $this->handleCoreError($type, $message, $file, $line); }; }
php
public function getCoreErrorHandler() { return function($type, $message, $file, $line) { return $this->handleCoreError($type, $message, $file, $line); }; }
[ "public", "function", "getCoreErrorHandler", "(", ")", "{", "return", "function", "(", "$", "type", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "return", "$", "this", "->", "handleCoreError", "(", "$", "type", ",", "$", "message"...
Returns the callback being used to handle core errors This method is primarily used internally when setting up error callbacks, but is left public for testing purposes. It essentially returns a reference to the ::handleCoreError() method. The returned closure has the following signature: ```php function(int $type, string $message, string $file, int $line) {} ``` @return Closure
[ "Returns", "the", "callback", "being", "used", "to", "handle", "core", "errors" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L791-L796
train
headzoo/core
src/Headzoo/Core/ErrorHandler.php
ErrorHandler.triggerError
protected function triggerError(Exception $exception, $label) { $this->unhandle(); $this->last_error = $exception; if ($exception instanceof Exceptions\PHPErrorException) { $type = Errors::toString($exception->getCode()); } else { $code = $exception->getCode(); $type = get_class($exception); $type = "{$type}[{$code}]"; } $this->logger->error( '{label} {type}: "{message}" in file {file}[{line}].', [ "label" => $label, "type" => $type, "message" => $exception->getMessage(), "file" => $exception->getFile(), "line" => $exception->getLine() ] ); try { call_user_func($this->getCallback(), $this); } catch (Exception $e) {} return true; }
php
protected function triggerError(Exception $exception, $label) { $this->unhandle(); $this->last_error = $exception; if ($exception instanceof Exceptions\PHPErrorException) { $type = Errors::toString($exception->getCode()); } else { $code = $exception->getCode(); $type = get_class($exception); $type = "{$type}[{$code}]"; } $this->logger->error( '{label} {type}: "{message}" in file {file}[{line}].', [ "label" => $label, "type" => $type, "message" => $exception->getMessage(), "file" => $exception->getFile(), "line" => $exception->getLine() ] ); try { call_user_func($this->getCallback(), $this); } catch (Exception $e) {} return true; }
[ "protected", "function", "triggerError", "(", "Exception", "$", "exception", ",", "$", "label", ")", "{", "$", "this", "->", "unhandle", "(", ")", ";", "$", "this", "->", "last_error", "=", "$", "exception", ";", "if", "(", "$", "exception", "instanceof"...
Calls the error callback Called by ::handleCoreError() and ::handleUncaughtException() when the type of error captured matches an error being handled. This method calls the error callback, and effectively shuts down the handler. @param Exception $exception The error @param string $label Label for the reason the error is being triggered @return bool
[ "Calls", "the", "error", "callback" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ErrorHandler.php#L831-L859
train
dlabas/DlcDoctrine
src/DlcDoctrine/Module.php
Module.onBootstrap
public function onBootstrap($e) { $eventManager = $e->getApplication()->getEventManager(); $serviceManager = $e->getApplication()->getServiceManager(); $options = $serviceManager->get('dlcdoctrine_module_options'); if ($options->getEnableAutoFlushFinishListener()) { $serviceManager->get('dlcdoctrine_event_finishlistener') ->attach($eventManager); } }
php
public function onBootstrap($e) { $eventManager = $e->getApplication()->getEventManager(); $serviceManager = $e->getApplication()->getServiceManager(); $options = $serviceManager->get('dlcdoctrine_module_options'); if ($options->getEnableAutoFlushFinishListener()) { $serviceManager->get('dlcdoctrine_event_finishlistener') ->attach($eventManager); } }
[ "public", "function", "onBootstrap", "(", "$", "e", ")", "{", "$", "eventManager", "=", "$", "e", "->", "getApplication", "(", ")", "->", "getEventManager", "(", ")", ";", "$", "serviceManager", "=", "$", "e", "->", "getApplication", "(", ")", "->", "g...
Registering module-specific listeners @param \Zend\Mvc\MvcEvent $e The MvcEvent instance @return void
[ "Registering", "module", "-", "specific", "listeners" ]
1e754c208197e9aa7a9d58efcc726e109aaa6edf
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Module.php#L18-L28
train
poliander/rio
src/Rio/Common/SchemaGenerator.php
SchemaGenerator.generate
private function generate() { $schema = []; foreach ($this->getTables() as $table) { $schema[$table] = $this->getTableDefinition($table); }; foreach (array_keys($schema) as $table) { $constraints = $this->driver->getConstraints($table); foreach ($constraints as $constraint) { if (false === empty($constraint['REF_TABLE'])) { $schema[$table]['properties'][$constraint['REF_TABLE']] = $this->mapConstraint($constraint); } } } return $schema; }
php
private function generate() { $schema = []; foreach ($this->getTables() as $table) { $schema[$table] = $this->getTableDefinition($table); }; foreach (array_keys($schema) as $table) { $constraints = $this->driver->getConstraints($table); foreach ($constraints as $constraint) { if (false === empty($constraint['REF_TABLE'])) { $schema[$table]['properties'][$constraint['REF_TABLE']] = $this->mapConstraint($constraint); } } } return $schema; }
[ "private", "function", "generate", "(", ")", "{", "$", "schema", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getTables", "(", ")", "as", "$", "table", ")", "{", "$", "schema", "[", "$", "table", "]", "=", "$", "this", "->", "getTableD...
Generate database schema definition @return array
[ "Generate", "database", "schema", "definition" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/Common/SchemaGenerator.php#L46-L65
train
poliander/rio
src/Rio/Common/SchemaGenerator.php
SchemaGenerator.get
public function get($table = null) { $schema = $this->generate(); if ($table !== null) { if (isset($schema[$table]) === false) { throw new Exception('Unknown table "' . $table . '"'); } $schema = $schema[$table]; } return $schema; }
php
public function get($table = null) { $schema = $this->generate(); if ($table !== null) { if (isset($schema[$table]) === false) { throw new Exception('Unknown table "' . $table . '"'); } $schema = $schema[$table]; } return $schema; }
[ "public", "function", "get", "(", "$", "table", "=", "null", ")", "{", "$", "schema", "=", "$", "this", "->", "generate", "(", ")", ";", "if", "(", "$", "table", "!==", "null", ")", "{", "if", "(", "isset", "(", "$", "schema", "[", "$", "table"...
Get schema definition for database or given table @param string|null $table @return array @throws \Rio\Exception
[ "Get", "schema", "definition", "for", "database", "or", "given", "table" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/Common/SchemaGenerator.php#L156-L169
train
ionutmilica/ionix-framework
src/Routing/ControllerDispatcher.php
ControllerDispatcher.dispatch
public function dispatch(Route $route) { $callback = $route->getCallback(); $params = array_values($route->getData()); if ($callback instanceof Closure) { return $this->container->resolveClosure($callback, $params); } $class = $this->container->make($callback[0]); return $this->container->resolveMethod($class, $callback[1], $params); }
php
public function dispatch(Route $route) { $callback = $route->getCallback(); $params = array_values($route->getData()); if ($callback instanceof Closure) { return $this->container->resolveClosure($callback, $params); } $class = $this->container->make($callback[0]); return $this->container->resolveMethod($class, $callback[1], $params); }
[ "public", "function", "dispatch", "(", "Route", "$", "route", ")", "{", "$", "callback", "=", "$", "route", "->", "getCallback", "(", ")", ";", "$", "params", "=", "array_values", "(", "$", "route", "->", "getData", "(", ")", ")", ";", "if", "(", "...
Get and serve the controller @param Route $route @return mixed @throws \Exception
[ "Get", "and", "serve", "the", "controller" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/ControllerDispatcher.php#L27-L38
train
academic/VipaImportBundle
Importer/PKP/ArticleImporter.php
ArticleImporter.importJournalArticles
public function importJournalArticles($oldJournalId, $newJournalId, $issueIds, $sectionIds) { $articleSql = "SELECT article_id FROM articles WHERE journal_id = :journal_id"; $articleStatement = $this->dbalConnection->prepare($articleSql); $articleStatement->bindValue('journal_id', $oldJournalId); $articleStatement->execute(); $articles = $articleStatement->fetchAll(); $this->importArticles($articles, $newJournalId, $sectionIds, $issueIds); }
php
public function importJournalArticles($oldJournalId, $newJournalId, $issueIds, $sectionIds) { $articleSql = "SELECT article_id FROM articles WHERE journal_id = :journal_id"; $articleStatement = $this->dbalConnection->prepare($articleSql); $articleStatement->bindValue('journal_id', $oldJournalId); $articleStatement->execute(); $articles = $articleStatement->fetchAll(); $this->importArticles($articles, $newJournalId, $sectionIds, $issueIds); }
[ "public", "function", "importJournalArticles", "(", "$", "oldJournalId", ",", "$", "newJournalId", ",", "$", "issueIds", ",", "$", "sectionIds", ")", "{", "$", "articleSql", "=", "\"SELECT article_id FROM articles WHERE journal_id = :journal_id\"", ";", "$", "articleSta...
Imports the articles of given Journal. @param int $oldJournalId Old journal's ID @param int $newJournalId New journal's ID @param array $issueIds Issue IDs of journal @param array $sectionIds Section IDs of journal @throws Exception @throws \Doctrine\DBAL\ConnectionException @throws \Doctrine\DBAL\DBALException
[ "Imports", "the", "articles", "of", "given", "Journal", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleImporter.php#L62-L71
train
academic/VipaImportBundle
Importer/PKP/ArticleImporter.php
ArticleImporter.importCitations
public function importCitations($oldArticleId, $article) { $this->consoleOutput->writeln("Reading citations..."); $citationSql = "SELECT * FROM citations WHERE assoc_id = :id"; $citationStatement = $this->dbalConnection->prepare($citationSql); $citationStatement->bindValue('id', $oldArticleId); $citationStatement->execute(); $orderCounter = 0; $citations = $citationStatement->fetchAll(); foreach ($citations as $pkpCitation) { $citation = new Citation(); $citation->setRaw(!empty($pkpCitation['raw_citation']) ? $pkpCitation['raw_citation'] : '-'); $citation->setOrderNum(!empty($pkpCitation['seq']) ? $pkpCitation['seq'] : $orderCounter); $article->addCitation($citation); $orderCounter++; } }
php
public function importCitations($oldArticleId, $article) { $this->consoleOutput->writeln("Reading citations..."); $citationSql = "SELECT * FROM citations WHERE assoc_id = :id"; $citationStatement = $this->dbalConnection->prepare($citationSql); $citationStatement->bindValue('id', $oldArticleId); $citationStatement->execute(); $orderCounter = 0; $citations = $citationStatement->fetchAll(); foreach ($citations as $pkpCitation) { $citation = new Citation(); $citation->setRaw(!empty($pkpCitation['raw_citation']) ? $pkpCitation['raw_citation'] : '-'); $citation->setOrderNum(!empty($pkpCitation['seq']) ? $pkpCitation['seq'] : $orderCounter); $article->addCitation($citation); $orderCounter++; } }
[ "public", "function", "importCitations", "(", "$", "oldArticleId", ",", "$", "article", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Reading citations...\"", ")", ";", "$", "citationSql", "=", "\"SELECT * FROM citations WHERE assoc_id = :id\"...
Imports citations of the given article. @param int $oldArticleId Old article's ID @param Article $article Newly imported Article's entity
[ "Imports", "citations", "of", "the", "given", "article", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleImporter.php#L278-L297
train
academic/VipaImportBundle
Importer/PKP/ArticleImporter.php
ArticleImporter.importAuthors
public function importAuthors($oldArticleId, $article) { $this->consoleOutput->writeln("Reading authors..."); $authorSql = "SELECT first_name, last_name, email, seq FROM authors " . "WHERE submission_id = :id ORDER BY first_name, last_name, email"; $authorStatement = $this->dbalConnection->prepare($authorSql); $authorStatement->bindValue('id', $oldArticleId); $authorStatement->execute(); $authors = $authorStatement->fetchAll(); foreach ($authors as $pkpAuthor) { $author = new Author(); $author->setCurrentLocale('en'); $author->setFirstName(!empty($pkpAuthor['first_name']) ? $pkpAuthor['first_name'] : '-'); $author->setLastName(!empty($pkpAuthor['last_name']) ? $pkpAuthor['last_name'] : '-'); $author->setEmail( !empty($pkpAuthor['email']) && $pkpAuthor['email'] !== '-' ? $pkpAuthor['email'] : 'author@example.com' ); $articleAuthor = new ArticleAuthor(); $articleAuthor->setAuthor($author); $articleAuthor->setArticle($article); $articleAuthor->setAuthorOrder(!empty($pkpAuthor['seq']) ? $pkpAuthor['seq'] : 0); } }
php
public function importAuthors($oldArticleId, $article) { $this->consoleOutput->writeln("Reading authors..."); $authorSql = "SELECT first_name, last_name, email, seq FROM authors " . "WHERE submission_id = :id ORDER BY first_name, last_name, email"; $authorStatement = $this->dbalConnection->prepare($authorSql); $authorStatement->bindValue('id', $oldArticleId); $authorStatement->execute(); $authors = $authorStatement->fetchAll(); foreach ($authors as $pkpAuthor) { $author = new Author(); $author->setCurrentLocale('en'); $author->setFirstName(!empty($pkpAuthor['first_name']) ? $pkpAuthor['first_name'] : '-'); $author->setLastName(!empty($pkpAuthor['last_name']) ? $pkpAuthor['last_name'] : '-'); $author->setEmail( !empty($pkpAuthor['email']) && $pkpAuthor['email'] !== '-' ? $pkpAuthor['email'] : 'author@example.com' ); $articleAuthor = new ArticleAuthor(); $articleAuthor->setAuthor($author); $articleAuthor->setArticle($article); $articleAuthor->setAuthorOrder(!empty($pkpAuthor['seq']) ? $pkpAuthor['seq'] : 0); } }
[ "public", "function", "importAuthors", "(", "$", "oldArticleId", ",", "$", "article", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Reading authors...\"", ")", ";", "$", "authorSql", "=", "\"SELECT first_name, last_name, email, seq FROM author...
Imports authors of the given article. @param int $oldArticleId Old article's ID @param Article $article Newly imported Article entity
[ "Imports", "authors", "of", "the", "given", "article", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleImporter.php#L304-L331
train
tenside/core-bundle
src/Command/RunTaskCommand.php
RunTaskCommand.fork
private function fork() { /** @var LoggerInterface $logger */ $logger = $this->getContainer()->get('logger'); if (!$this->getContainer()->get('tenside.config')->isForkingAvailable()) { $logger->warning('Forking disabled by configuration, execution will block until the command has finished.'); return false; } elseif (!FunctionAvailabilityCheck::isFunctionEnabled('pcntl_fork', 'pcntl')) { $logger->warning('pcntl_fork() is not available, execution will block until the command has finished.'); return false; } else { $pid = pcntl_fork(); if (-1 === $pid) { throw new \RuntimeException('pcntl_fork() returned -1.'); } elseif (0 !== $pid) { // Tell the calling method to exit now. $logger->info('Forked process ' . posix_getpid() . ' to pid ' . $pid); return true; } $logger->info('Processing task in forked process with pid ' . posix_getpid()); return false; } }
php
private function fork() { /** @var LoggerInterface $logger */ $logger = $this->getContainer()->get('logger'); if (!$this->getContainer()->get('tenside.config')->isForkingAvailable()) { $logger->warning('Forking disabled by configuration, execution will block until the command has finished.'); return false; } elseif (!FunctionAvailabilityCheck::isFunctionEnabled('pcntl_fork', 'pcntl')) { $logger->warning('pcntl_fork() is not available, execution will block until the command has finished.'); return false; } else { $pid = pcntl_fork(); if (-1 === $pid) { throw new \RuntimeException('pcntl_fork() returned -1.'); } elseif (0 !== $pid) { // Tell the calling method to exit now. $logger->info('Forked process ' . posix_getpid() . ' to pid ' . $pid); return true; } $logger->info('Processing task in forked process with pid ' . posix_getpid()); return false; } }
[ "private", "function", "fork", "(", ")", "{", "/** @var LoggerInterface $logger */", "$", "logger", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'logger'", ")", ";", "if", "(", "!", "$", "this", "->", "getContainer", "(", ")", "->...
Try to fork. The return value determines if the caller shall exit (when forking was successful and it is the forking process) or rather proceed execution (is the fork or unable to fork). True means exit, false means go on in this process. @return bool @throws \RuntimeException When the forking caused an error.
[ "Try", "to", "fork", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Command/RunTaskCommand.php#L98-L123
train
scholtz/AsyncWeb
src/AsyncWeb/Connectors/Page.php
Page.resolve_url
function resolve_url($base, $url) { if (!strlen($base)) return $url; // Step 2 if (!strlen($url)) return $base; // Step 3 if (preg_match('!^[a-z]+:!i', $url)) return $url; $base = parse_url($base); if ($url{0} == "#") { // Step 2 (fragment) $base['fragment'] = substr($url, 1); return Page::unparse_url($base); } unset($base['fragment']); unset($base['query']); if (substr($url, 0, 2) == "//") { // Step 4 return Page::unparse_url(array('scheme' => $base['scheme'], 'path' => $url,)); } else if ($url{0} == "/") { // Step 5 $base['path'] = $url; } else { // Step 6 $path = explode('/', $base['path']); $url_path = explode('/', $url); // Step 6a: drop file from base array_pop($path); // Step 6b, 6c, 6e: append url while removing "." and ".." from // the directory portion $end = array_pop($url_path); foreach ($url_path as $segment) { if ($segment == '.') { // skip } else if ($segment == '..' && $path && $path[sizeof($path) - 1] != '..') { array_pop($path); } else { $path[] = $segment; } } // Step 6d, 6f: remove "." and ".." from file portion if ($end == '.') { $path[] = ''; } else if ($end == '..' && $path && $path[sizeof($path) - 1] != '..') { $path[sizeof($path) - 1] = ''; } else { $path[] = $end; } // Step 6h $base['path'] = join('/', $path); } // Step 7 return Page::unparse_url($base); }
php
function resolve_url($base, $url) { if (!strlen($base)) return $url; // Step 2 if (!strlen($url)) return $base; // Step 3 if (preg_match('!^[a-z]+:!i', $url)) return $url; $base = parse_url($base); if ($url{0} == "#") { // Step 2 (fragment) $base['fragment'] = substr($url, 1); return Page::unparse_url($base); } unset($base['fragment']); unset($base['query']); if (substr($url, 0, 2) == "//") { // Step 4 return Page::unparse_url(array('scheme' => $base['scheme'], 'path' => $url,)); } else if ($url{0} == "/") { // Step 5 $base['path'] = $url; } else { // Step 6 $path = explode('/', $base['path']); $url_path = explode('/', $url); // Step 6a: drop file from base array_pop($path); // Step 6b, 6c, 6e: append url while removing "." and ".." from // the directory portion $end = array_pop($url_path); foreach ($url_path as $segment) { if ($segment == '.') { // skip } else if ($segment == '..' && $path && $path[sizeof($path) - 1] != '..') { array_pop($path); } else { $path[] = $segment; } } // Step 6d, 6f: remove "." and ".." from file portion if ($end == '.') { $path[] = ''; } else if ($end == '..' && $path && $path[sizeof($path) - 1] != '..') { $path[sizeof($path) - 1] = ''; } else { $path[] = $end; } // Step 6h $base['path'] = join('/', $path); } // Step 7 return Page::unparse_url($base); }
[ "function", "resolve_url", "(", "$", "base", ",", "$", "url", ")", "{", "if", "(", "!", "strlen", "(", "$", "base", ")", ")", "return", "$", "url", ";", "// Step 2", "if", "(", "!", "strlen", "(", "$", "url", ")", ")", "return", "$", "base", ";...
Resolve a URL relative to a base path. This happens to work with POSIX filenames as well. This is based on RFC 2396 section 5.2.
[ "Resolve", "a", "URL", "relative", "to", "a", "base", "path", ".", "This", "happens", "to", "work", "with", "POSIX", "filenames", "as", "well", ".", "This", "is", "based", "on", "RFC", "2396", "section", "5", ".", "2", "." ]
66a906298080c2c66d8f0fb85211b6100b3776bf
https://github.com/scholtz/AsyncWeb/blob/66a906298080c2c66d8f0fb85211b6100b3776bf/src/AsyncWeb/Connectors/Page.php#L144-L196
train
idandtrust/goodid-phpasn1
lib/ASN1/Object.php
Object.getIdentifier
public function getIdentifier() { $firstOctet = $this->getType(); if (Identifier::isLongForm($firstOctet)) { throw new LogicException(sprintf('Identifier of %s uses the long form and must therefor override "Object::getIdentifier()".', get_class($this))); } return chr($firstOctet); }
php
public function getIdentifier() { $firstOctet = $this->getType(); if (Identifier::isLongForm($firstOctet)) { throw new LogicException(sprintf('Identifier of %s uses the long form and must therefor override "Object::getIdentifier()".', get_class($this))); } return chr($firstOctet); }
[ "public", "function", "getIdentifier", "(", ")", "{", "$", "firstOctet", "=", "$", "this", "->", "getType", "(", ")", ";", "if", "(", "Identifier", "::", "isLongForm", "(", "$", "firstOctet", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf...
Returns all identifier octets. If an inheriting class models a tag with the long form identifier format, it MUST reimplement this method to return all octets of the identifier. @throws LogicException If the identifier format is long form @return string Identifier as a set of octets
[ "Returns", "all", "identifier", "octets", ".", "If", "an", "inheriting", "class", "models", "a", "tag", "with", "the", "long", "form", "identifier", "format", "it", "MUST", "reimplement", "this", "method", "to", "return", "all", "octets", "of", "the", "ident...
b95183bb85e51fbaf725d5e318dee1dbc3416b80
https://github.com/idandtrust/goodid-phpasn1/blob/b95183bb85e51fbaf725d5e318dee1dbc3416b80/lib/ASN1/Object.php#L91-L100
train
adammbalogh/key-value-store-memcached
src/Adapter/MemcachedAdapter/ValueTrait.php
ValueTrait.get
public function get($key) { $getResult = $this->getValue($key); $unserialized = @unserialize($getResult); if (Util::hasInternalExpireTime($unserialized)) { $getResult = $unserialized['v']; } return $getResult; }
php
public function get($key) { $getResult = $this->getValue($key); $unserialized = @unserialize($getResult); if (Util::hasInternalExpireTime($unserialized)) { $getResult = $unserialized['v']; } return $getResult; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "getResult", "=", "$", "this", "->", "getValue", "(", "$", "key", ")", ";", "$", "unserialized", "=", "@", "unserialize", "(", "$", "getResult", ")", ";", "if", "(", "Util", "::", "hasInt...
Gets the value of a key. @param string $key @return mixed The value of the key. @throws KeyNotFoundException @throws \Exception
[ "Gets", "the", "value", "of", "a", "key", "." ]
e9919d6ef75badf0b2caf4ad45629666af21cd67
https://github.com/adammbalogh/key-value-store-memcached/blob/e9919d6ef75badf0b2caf4ad45629666af21cd67/src/Adapter/MemcachedAdapter/ValueTrait.php#L24-L34
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferItemController.php
StockTransferItemController.newAction
public function newAction(StockTransfer $stockTransfer) { $stocktransferitem = new StockTransferItem(); $stocktransferitem->setStockTransfer($stockTransfer); $form = $this->createForm(new StockTransferItemType(), $stocktransferitem); return array( 'stocktransferitem' => $stocktransferitem, 'form' => $form->createView(), ); }
php
public function newAction(StockTransfer $stockTransfer) { $stocktransferitem = new StockTransferItem(); $stocktransferitem->setStockTransfer($stockTransfer); $form = $this->createForm(new StockTransferItemType(), $stocktransferitem); return array( 'stocktransferitem' => $stocktransferitem, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", "StockTransfer", "$", "stockTransfer", ")", "{", "$", "stocktransferitem", "=", "new", "StockTransferItem", "(", ")", ";", "$", "stocktransferitem", "->", "setStockTransfer", "(", "$", "stockTransfer", ")", ";", "$", "form...
Displays a form to create a new StockTransferItem entity. @Route("/{id}/new", name="stock_transfersitem_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "StockTransferItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferItemController.php#L30-L40
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferItemController.php
StockTransferItemController.createAction
public function createAction(Request $request) { $stocktransferitem = new StockTransferItem(); $form = $this->createForm(new StockTransferItemType(), $stocktransferitem); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($stocktransferitem); $em->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array( 'id' => $stocktransferitem->getStockTransfer()->getId(), ))); } return array( 'stocktransferitem' => $stocktransferitem, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $stocktransferitem = new StockTransferItem(); $form = $this->createForm(new StockTransferItemType(), $stocktransferitem); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($stocktransferitem); $em->flush(); return $this->redirect($this->generateUrl('stock_transfers_show', array( 'id' => $stocktransferitem->getStockTransfer()->getId(), ))); } return array( 'stocktransferitem' => $stocktransferitem, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "stocktransferitem", "=", "new", "StockTransferItem", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferItemType", "(", ")", ",", ...
Creates a new StockTransferItem entity. @Route("/create", name="stock_transfersitem_create") @Method("POST") @Template("FlowerStockBundle:StockTransferItem:new.html.twig")
[ "Creates", "a", "new", "StockTransferItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferItemController.php#L49-L67
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferItemController.php
StockTransferItemController.editAction
public function editAction(StockTransferItem $stocktransferitem) { $editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array( 'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($stocktransferitem->getId(), 'stock_transfersitem_delete'); return array( 'stocktransferitem' => $stocktransferitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editAction(StockTransferItem $stocktransferitem) { $editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array( 'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($stocktransferitem->getId(), 'stock_transfersitem_delete'); return array( 'stocktransferitem' => $stocktransferitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editAction", "(", "StockTransferItem", "$", "stocktransferitem", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferItemType", "(", ")", ",", "$", "stocktransferitem", ",", "array", "(", "'action'", ...
Displays a form to edit an existing StockTransferItem entity. @Route("/{id}/edit", name="stock_transfersitem_edit", requirements={"id"="\d+"}) @Method("GET") @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "StockTransferItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferItemController.php#L76-L89
train
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Controller/StockTransferItemController.php
StockTransferItemController.updateAction
public function updateAction(StockTransferItem $stocktransferitem, Request $request) { $editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array( 'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_transfersitem_show', array('id' => $stocktransferitem->getId()))); } $deleteForm = $this->createDeleteForm($stocktransferitem->getId(), 'stock_transfersitem_delete'); return array( 'stocktransferitem' => $stocktransferitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(StockTransferItem $stocktransferitem, Request $request) { $editForm = $this->createForm(new StockTransferItemType(), $stocktransferitem, array( 'action' => $this->generateUrl('stock_transfersitem_update', array('id' => $stocktransferitem->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)->isValid()) { $this->getDoctrine()->getManager()->flush(); return $this->redirect($this->generateUrl('stock_transfersitem_show', array('id' => $stocktransferitem->getId()))); } $deleteForm = $this->createDeleteForm($stocktransferitem->getId(), 'stock_transfersitem_delete'); return array( 'stocktransferitem' => $stocktransferitem, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "StockTransferItem", "$", "stocktransferitem", ",", "Request", "$", "request", ")", "{", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "StockTransferItemType", "(", ")", ",", "$", "stocktransferitem...
Edits an existing StockTransferItem entity. @Route("/{id}/update", name="stock_transfersitem_update", requirements={"id"="\d+"}) @Method("PUT") @Template("FlowerStockBundle:StockTransferItem:edit.html.twig")
[ "Edits", "an", "existing", "StockTransferItem", "entity", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/StockTransferItemController.php#L98-L116
train
mszewcz/php-light-framework
src/Config/Reader/Ini.php
Ini.processNode
private function processNode(array $node): array { $config = []; foreach ($node as $name => $value) { if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) { $name = $matches[1]; } if (\count($nameEx = \explode('.', $name)) > 1) { $name = \array_shift($nameEx); $mergeBase = isset($config[$name]) ? $config[$name] : []; $mergeWith = $this->processNode([\implode('.', $nameEx) => $value]); $config[$name] = \array_merge_recursive($mergeBase, $mergeWith); } elseif (\is_array($value)) { $config[$name] = $this->processNode($value); } else { $config[$name] = $this->castValue((string)$value); } } return $config; }
php
private function processNode(array $node): array { $config = []; foreach ($node as $name => $value) { if (\preg_match('/^num__([0-9]+)$/', $name, $matches)) { $name = $matches[1]; } if (\count($nameEx = \explode('.', $name)) > 1) { $name = \array_shift($nameEx); $mergeBase = isset($config[$name]) ? $config[$name] : []; $mergeWith = $this->processNode([\implode('.', $nameEx) => $value]); $config[$name] = \array_merge_recursive($mergeBase, $mergeWith); } elseif (\is_array($value)) { $config[$name] = $this->processNode($value); } else { $config[$name] = $this->castValue((string)$value); } } return $config; }
[ "private", "function", "processNode", "(", "array", "$", "node", ")", ":", "array", "{", "$", "config", "=", "[", "]", ";", "foreach", "(", "$", "node", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "\\", "preg_match", "(", "'/^num__(...
Processes INI config node @param array $node @return array
[ "Processes", "INI", "config", "node" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/Reader/Ini.php#L50-L69
train
mszewcz/php-light-framework
src/Config/Reader/Ini.php
Ini.castValue
private function castValue(string $value) { $value = $this->normalize($value); if (\preg_match('/^[0-9]+$/', $value)) { $value = (int)$value; } elseif (\preg_match('/^[0-9\.]+$/', $value)) { $value = (float)$value; } elseif (\preg_match('/^true|false$/', $value)) { $value = $value === 'true' ? true : false; } return $value; }
php
private function castValue(string $value) { $value = $this->normalize($value); if (\preg_match('/^[0-9]+$/', $value)) { $value = (int)$value; } elseif (\preg_match('/^[0-9\.]+$/', $value)) { $value = (float)$value; } elseif (\preg_match('/^true|false$/', $value)) { $value = $value === 'true' ? true : false; } return $value; }
[ "private", "function", "castValue", "(", "string", "$", "value", ")", "{", "$", "value", "=", "$", "this", "->", "normalize", "(", "$", "value", ")", ";", "if", "(", "\\", "preg_match", "(", "'/^[0-9]+$/'", ",", "$", "value", ")", ")", "{", "$", "v...
Casts value to a specified type @param string $value @return mixed
[ "Casts", "value", "to", "a", "specified", "type" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/Reader/Ini.php#L77-L88
train
mszewcz/php-light-framework
src/Config/Reader/Ini.php
Ini.normalize
private function normalize(string $string): string { return \str_replace($this->normalizeFrom, $this->normalizeTo, $string); }
php
private function normalize(string $string): string { return \str_replace($this->normalizeFrom, $this->normalizeTo, $string); }
[ "private", "function", "normalize", "(", "string", "$", "string", ")", ":", "string", "{", "return", "\\", "str_replace", "(", "$", "this", "->", "normalizeFrom", ",", "$", "this", "->", "normalizeTo", ",", "$", "string", ")", ";", "}" ]
Changes some characters from their utf-8 to normal representation @param string $string @return string
[ "Changes", "some", "characters", "from", "their", "utf", "-", "8", "to", "normal", "representation" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/Reader/Ini.php#L96-L99
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
HydratorFactory.hydrate
public function hydrate($document, $data, array $hints = array()) { $metadata = $this->dm->getClassMetadata(get_class($document)); // Invoke preLoad lifecycle events and listeners if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args); } if ($this->evm->hasListeners(Events::preLoad)) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($document, $this->dm, $data)); } // alsoLoadMethods may transform the document before hydration if ( ! empty($metadata->alsoLoadMethods)) { foreach ($metadata->alsoLoadMethods as $method => $fieldNames) { foreach ($fieldNames as $fieldName) { // Invoke the method only once for the first field we find if (array_key_exists($fieldName, $data)) { $document->$method($data[$fieldName]); continue 2; } } } } $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $hints); if ($document instanceof Proxy) { $document->__isInitialized__ = true; } // Invoke the postLoad lifecycle callbacks and listeners if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) { $metadata->invokeLifecycleCallbacks(Events::postLoad, $document); } if ($this->evm->hasListeners(Events::postLoad)) { $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm)); } return $data; }
php
public function hydrate($document, $data, array $hints = array()) { $metadata = $this->dm->getClassMetadata(get_class($document)); // Invoke preLoad lifecycle events and listeners if ( ! empty($metadata->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $metadata->invokeLifecycleCallbacks(Events::preLoad, $document, $args); } if ($this->evm->hasListeners(Events::preLoad)) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($document, $this->dm, $data)); } // alsoLoadMethods may transform the document before hydration if ( ! empty($metadata->alsoLoadMethods)) { foreach ($metadata->alsoLoadMethods as $method => $fieldNames) { foreach ($fieldNames as $fieldName) { // Invoke the method only once for the first field we find if (array_key_exists($fieldName, $data)) { $document->$method($data[$fieldName]); continue 2; } } } } $data = $this->getHydratorFor($metadata->name)->hydrate($document, $data, $hints); if ($document instanceof Proxy) { $document->__isInitialized__ = true; } // Invoke the postLoad lifecycle callbacks and listeners if ( ! empty($metadata->lifecycleCallbacks[Events::postLoad])) { $metadata->invokeLifecycleCallbacks(Events::postLoad, $document); } if ($this->evm->hasListeners(Events::postLoad)) { $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($document, $this->dm)); } return $data; }
[ "public", "function", "hydrate", "(", "$", "document", ",", "$", "data", ",", "array", "$", "hints", "=", "array", "(", ")", ")", "{", "$", "metadata", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")...
Hydrate array of MongoDB document data into the given document object. @param object $document The document object to hydrate the data into. @param array $data The array of document data. @param array $hints Any hints to account for during reconstitution/lookup of the document. @return array $values The array of hydrated values.
[ "Hydrate", "array", "of", "MongoDB", "document", "data", "into", "the", "given", "document", "object", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php#L403-L442
train
lasallecrm/lasallecrm-l5-listmanagement-pkg
src/Helpers/Helpers.php
Helpers.isEmailAddressPrimaryType
public function isEmailAddressPrimaryType($emailID) { // Must we accept "primary" email type only? if (!Config::get('lasallecrmlistmanagement.listmgmt_emails_in_list_primary_type_only')) { return false; } // "primary" type is #1 if ($this->getEmailType($emailID) != 1) { return false; } return true; }
php
public function isEmailAddressPrimaryType($emailID) { // Must we accept "primary" email type only? if (!Config::get('lasallecrmlistmanagement.listmgmt_emails_in_list_primary_type_only')) { return false; } // "primary" type is #1 if ($this->getEmailType($emailID) != 1) { return false; } return true; }
[ "public", "function", "isEmailAddressPrimaryType", "(", "$", "emailID", ")", "{", "// Must we accept \"primary\" email type only?", "if", "(", "!", "Config", "::", "get", "(", "'lasallecrmlistmanagement.listmgmt_emails_in_list_primary_type_only'", ")", ")", "{", "return", "...
Is the email type "primary" AND must we accept "primary" type only? Both conditions must be true to return true @param int $emailID Emails db table's ID @return bool
[ "Is", "the", "email", "type", "primary", "AND", "must", "we", "accept", "primary", "type", "only?" ]
4b5da1af5d25d5fb4be5199f3cf22da313d475f3
https://github.com/lasallecrm/lasallecrm-l5-listmanagement-pkg/blob/4b5da1af5d25d5fb4be5199f3cf22da313d475f3/src/Helpers/Helpers.php#L103-L116
train
faustbrian/binary
src/UnsignedInteger/Reader.php
Reader.bit16
public static function bit16(string $data, int $offset = 0, $endianness = false): int { // big-endian if (true === $endianness) { return unpack('n', $data, $offset)[1]; } // little-endian if (false === $endianness) { return unpack('v', $data, $offset)[1]; } // machine byte order if (null === $endianness) { return unpack('S', $data, $offset)[1]; } }
php
public static function bit16(string $data, int $offset = 0, $endianness = false): int { // big-endian if (true === $endianness) { return unpack('n', $data, $offset)[1]; } // little-endian if (false === $endianness) { return unpack('v', $data, $offset)[1]; } // machine byte order if (null === $endianness) { return unpack('S', $data, $offset)[1]; } }
[ "public", "static", "function", "bit16", "(", "string", "$", "data", ",", "int", "$", "offset", "=", "0", ",", "$", "endianness", "=", "false", ")", ":", "int", "{", "// big-endian", "if", "(", "true", "===", "$", "endianness", ")", "{", "return", "u...
Read an unsigned 16 bit integer. @param string $data @param int $offset @param mixed $endianness @return int
[ "Read", "an", "unsigned", "16", "bit", "integer", "." ]
7d845497460c2dabf7e369ec8e55baf989ef74cb
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/UnsignedInteger/Reader.php#L45-L61
train
faustbrian/binary
src/UnsignedInteger/Reader.php
Reader.bit64
public static function bit64(string $data, int $offset = 0, bool $endianness = false): int { // big-endian if (true === $endianness) { return unpack('J', $data, $offset)[1]; } // little-endian if (false === $endianness) { return unpack('P', $data, $offset)[1]; } // machine byte order if (null === $endianness) { return unpack('Q', $data, $offset)[1]; } }
php
public static function bit64(string $data, int $offset = 0, bool $endianness = false): int { // big-endian if (true === $endianness) { return unpack('J', $data, $offset)[1]; } // little-endian if (false === $endianness) { return unpack('P', $data, $offset)[1]; } // machine byte order if (null === $endianness) { return unpack('Q', $data, $offset)[1]; } }
[ "public", "static", "function", "bit64", "(", "string", "$", "data", ",", "int", "$", "offset", "=", "0", ",", "bool", "$", "endianness", "=", "false", ")", ":", "int", "{", "// big-endian", "if", "(", "true", "===", "$", "endianness", ")", "{", "ret...
Read an unsigned 64 bit integer. @param string $data @param int $offset @param mixed $endianness @return int
[ "Read", "an", "unsigned", "64", "bit", "integer", "." ]
7d845497460c2dabf7e369ec8e55baf989ef74cb
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/UnsignedInteger/Reader.php#L99-L115
train
samsonos/cms_app_materialtable
src/MaterialTableTable.php
MaterialTableTable.row
public function row(& $material, Pager & $pager = null, $module = NULL) { /** @var string $tdHTML Table cell HTML code */ $tdHTML = ''; $input = null; /** @var \samson\cms\CMSField $field Field of current table structure (Table column) */ foreach ($this->fields as $field) { /** @var \samson\activerecord\materialfield $materialField Materialfield object (Table cell) */ foreach ($material->onetomany['_materialfield'] as $materialField) { // If materialfield relates to field (column) $isRightField = $materialField->FieldID == $field->FieldID; // If field has same locale as passed $isRightLocale = $materialField->locale == $this->locale; // If field not localized then output it $isNotLocalizedField = $materialField->locale == ''; if ($isRightField && (($isRightLocale) || ($isNotLocalizedField))) { $this->headerFields[$field->id] = $field; if ($field->Type < 9 || $field->Type > 10) { $input = m('samsoncms_input_application') ->createFieldByType($this->dbQuery, $field->Type, $materialField); } // If current field has select type then go to build his value if ($field->Type == 4) { /** @var \samsoncms\input\select\Select $input Select input type */ $input->build($field->Value); } // When render the input of table then call all subscribers \samsonphp\event\Event::fire('samson.cms.input.table.render', array($input)); // Set HTML row code $tdHTML .= $this->renderModule->view('table/tdView')->set($input, 'input')->output(); break; } } } // Render field row return $this->renderModule ->view($this->row_tmpl) ->set(m('samsoncms_input_text_application')->createField($this->dbQuery, $material, 'Url'), 'materialName') ->set($material->id, 'materialID') ->set($material->priority, 'priority') ->set($material->parent_id, 'parentID') ->set($this->structure->StructureID, 'structureId') ->set($tdHTML, 'td_view') ->set($pager, 'pager') ->output(); }
php
public function row(& $material, Pager & $pager = null, $module = NULL) { /** @var string $tdHTML Table cell HTML code */ $tdHTML = ''; $input = null; /** @var \samson\cms\CMSField $field Field of current table structure (Table column) */ foreach ($this->fields as $field) { /** @var \samson\activerecord\materialfield $materialField Materialfield object (Table cell) */ foreach ($material->onetomany['_materialfield'] as $materialField) { // If materialfield relates to field (column) $isRightField = $materialField->FieldID == $field->FieldID; // If field has same locale as passed $isRightLocale = $materialField->locale == $this->locale; // If field not localized then output it $isNotLocalizedField = $materialField->locale == ''; if ($isRightField && (($isRightLocale) || ($isNotLocalizedField))) { $this->headerFields[$field->id] = $field; if ($field->Type < 9 || $field->Type > 10) { $input = m('samsoncms_input_application') ->createFieldByType($this->dbQuery, $field->Type, $materialField); } // If current field has select type then go to build his value if ($field->Type == 4) { /** @var \samsoncms\input\select\Select $input Select input type */ $input->build($field->Value); } // When render the input of table then call all subscribers \samsonphp\event\Event::fire('samson.cms.input.table.render', array($input)); // Set HTML row code $tdHTML .= $this->renderModule->view('table/tdView')->set($input, 'input')->output(); break; } } } // Render field row return $this->renderModule ->view($this->row_tmpl) ->set(m('samsoncms_input_text_application')->createField($this->dbQuery, $material, 'Url'), 'materialName') ->set($material->id, 'materialID') ->set($material->priority, 'priority') ->set($material->parent_id, 'parentID') ->set($this->structure->StructureID, 'structureId') ->set($tdHTML, 'td_view') ->set($pager, 'pager') ->output(); }
[ "public", "function", "row", "(", "&", "$", "material", ",", "Pager", "&", "$", "pager", "=", "null", ",", "$", "module", "=", "NULL", ")", "{", "/** @var string $tdHTML Table cell HTML code */", "$", "tdHTML", "=", "''", ";", "$", "input", "=", "null", ...
Function to view table row @param \samson\activerecord\material $material Tale material represented as row @param Pager $pager Pager for multi page table @return string
[ "Function", "to", "view", "table", "row" ]
550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e
https://github.com/samsonos/cms_app_materialtable/blob/550fb1916070b6cf8cbd4fa7d61a19ca9a2d090e/src/MaterialTableTable.php#L143-L197
train