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
cubiclab/users-cube
models/User.php
User.findIdentities
public static function findIdentities($ids, $scope = null) { $query = static::find()->where(['id' => $ids]); if ($scope !== null) { if (is_array($scope)) { foreach ($scope as $value) { $query->$value(); } } else { $query->$scope(); } } return $query->all(); }
php
public static function findIdentities($ids, $scope = null) { $query = static::find()->where(['id' => $ids]); if ($scope !== null) { if (is_array($scope)) { foreach ($scope as $value) { $query->$value(); } } else { $query->$scope(); } } return $query->all(); }
[ "public", "static", "function", "findIdentities", "(", "$", "ids", ",", "$", "scope", "=", "null", ")", "{", "$", "query", "=", "static", "::", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "ids", "]", ")", ";", "if", "(", "$", ...
Find users by IDs. @param $ids Users IDs @param null $scope Scope @return array|\yii\db\ActiveRecord[] Users
[ "Find", "users", "by", "IDs", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/models/User.php#L128-L141
train
cubiclab/users-cube
models/User.php
User.delete
public function delete(){ if(!($this->id == 1 && $this->module->cantDeleteRoot == true)){ if ($this->status == self::STATUS_DELETED) { Yii::$app->authManager->revokeAll($this->getId()); parent::delete(); } else { $this->status = self::STATUS_DELETED; $this->save(false); // validation = false } } }
php
public function delete(){ if(!($this->id == 1 && $this->module->cantDeleteRoot == true)){ if ($this->status == self::STATUS_DELETED) { Yii::$app->authManager->revokeAll($this->getId()); parent::delete(); } else { $this->status = self::STATUS_DELETED; $this->save(false); // validation = false } } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "id", "==", "1", "&&", "$", "this", "->", "module", "->", "cantDeleteRoot", "==", "true", ")", ")", "{", "if", "(", "$", "this", "->", "status", "==", "self", ...
Deside delete user or just set a deleted status
[ "Deside", "delete", "user", "or", "just", "set", "a", "deleted", "status" ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/models/User.php#L243-L253
train
webtoucher/geometeo-libs
src/GeoDataProvider.php
GeoDataProvider.calculate
public function calculate(Calculator $calculator, $inputValuesGrid) { $outputValuesGrid = []; foreach ($inputValuesGrid as $date => $inputValues) { $outputValuesGrid[$date] = $calculator->calculate($this, new \DateTime($date, $this->dataTimeZone), $inputValues); } return $outputValuesGrid; }
php
public function calculate(Calculator $calculator, $inputValuesGrid) { $outputValuesGrid = []; foreach ($inputValuesGrid as $date => $inputValues) { $outputValuesGrid[$date] = $calculator->calculate($this, new \DateTime($date, $this->dataTimeZone), $inputValues); } return $outputValuesGrid; }
[ "public", "function", "calculate", "(", "Calculator", "$", "calculator", ",", "$", "inputValuesGrid", ")", "{", "$", "outputValuesGrid", "=", "[", "]", ";", "foreach", "(", "$", "inputValuesGrid", "as", "$", "date", "=>", "$", "inputValues", ")", "{", "$",...
Returns calculated params time grid. @param Calculator $calculator @param array $inputValuesGrid @return array
[ "Returns", "calculated", "params", "time", "grid", "." ]
196fa7261d98b95e058ee9ed6c5a80c4747797bd
https://github.com/webtoucher/geometeo-libs/blob/196fa7261d98b95e058ee9ed6c5a80c4747797bd/src/GeoDataProvider.php#L43-L50
train
edunola13/core-modules
src/DependencyEngine/Reflection.php
Reflection.getProperties
public function getProperties($properties){ $values= array(); foreach ($properties as $key) { $values[$key]= $this->getProperty($key); } return $values; }
php
public function getProperties($properties){ $values= array(); foreach ($properties as $key) { $values[$key]= $this->getProperty($key); } return $values; }
[ "public", "function", "getProperties", "(", "$", "properties", ")", "{", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "key", ")", "{", "$", "values", "[", "$", "key", "]", "=", "$", "this", "->", "getPro...
Retorna un array con todos los valores de las propiedades. Para leer cada propiedad llama al metodo getProperty. @param array $properties @return array - propertyName => value
[ "Retorna", "un", "array", "con", "todos", "los", "valores", "de", "las", "propiedades", ".", "Para", "leer", "cada", "propiedad", "llama", "al", "metodo", "getProperty", "." ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DependencyEngine/Reflection.php#L54-L60
train
edunola13/core-modules
src/DependencyEngine/Reflection.php
Reflection.setProperties
public function setProperties($properties, $create = FALSE){ foreach ($properties as $key => $value) { $this->setProperty($key, $value, $create); } }
php
public function setProperties($properties, $create = FALSE){ foreach ($properties as $key => $value) { $this->setProperty($key, $value, $create); } }
[ "public", "function", "setProperties", "(", "$", "properties", ",", "$", "create", "=", "FALSE", ")", "{", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "setProperty", "(", "$", "key", ",", "$",...
Setea las propiedades de un objeto. Para setear cada valor llama al metodo setProperty @param array $properties @param boolean $create
[ "Setea", "las", "propiedades", "de", "un", "objeto", ".", "Para", "setear", "cada", "valor", "llama", "al", "metodo", "setProperty" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DependencyEngine/Reflection.php#L95-L99
train
opsbears/piccolo-web-io-standard
src/StandardWebIOModule.php
StandardWebIOModule.configureDependencyInjection
public function configureDependencyInjection(DependencyInjectionContainer $dic, array $moduleConfig, array $globalConfig) { $dic->alias(InputProcessor::class, StandardInputProcessor::class); $dic->alias(OutputProcessor::class, StandardOutputProcessor::class); $dic->setClassParameters(InputProcessor::class, [ 'server' => $_SERVER, 'get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE ]); }
php
public function configureDependencyInjection(DependencyInjectionContainer $dic, array $moduleConfig, array $globalConfig) { $dic->alias(InputProcessor::class, StandardInputProcessor::class); $dic->alias(OutputProcessor::class, StandardOutputProcessor::class); $dic->setClassParameters(InputProcessor::class, [ 'server' => $_SERVER, 'get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE ]); }
[ "public", "function", "configureDependencyInjection", "(", "DependencyInjectionContainer", "$", "dic", ",", "array", "$", "moduleConfig", ",", "array", "$", "globalConfig", ")", "{", "$", "dic", "->", "alias", "(", "InputProcessor", "::", "class", ",", "StandardIn...
Configures StandardInputProcessor and StandardOutputProcessor as IO handlers and wires up the input processor to use standard PHP superglobals for input. @param DependencyInjectionContainer $dic @param array $moduleConfig @param array $globalConfig @SuppressWarnings(PHPMD.Superglobals)
[ "Configures", "StandardInputProcessor", "and", "StandardOutputProcessor", "as", "IO", "handlers", "and", "wires", "up", "the", "input", "processor", "to", "use", "standard", "PHP", "superglobals", "for", "input", "." ]
ee8638bfded26d68a93a7fc3e0fed3f6add8d196
https://github.com/opsbears/piccolo-web-io-standard/blob/ee8638bfded26d68a93a7fc3e0fed3f6add8d196/src/StandardWebIOModule.php#L38-L49
train
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dump
public function dump(array $input, string $outerIndent = ''): string { $this->indentLength = StringHelper::lengthUtf8($this->indent); return $this->dumpArray( $input, $outerIndent, StringHelper::lengthUtf8($outerIndent) ); }
php
public function dump(array $input, string $outerIndent = ''): string { $this->indentLength = StringHelper::lengthUtf8($this->indent); return $this->dumpArray( $input, $outerIndent, StringHelper::lengthUtf8($outerIndent) ); }
[ "public", "function", "dump", "(", "array", "$", "input", ",", "string", "$", "outerIndent", "=", "''", ")", ":", "string", "{", "$", "this", "->", "indentLength", "=", "StringHelper", "::", "lengthUtf8", "(", "$", "this", "->", "indent", ")", ";", "re...
Dumps an array to PHP code @param array $input Input array @param string $outerIndent Optional outer indent string for wrapped lines @return string PHP code of array. Doing `eval()` of this code will return an array identical `===` to input array. @throws \InvalidArgumentException
[ "Dumps", "an", "array", "to", "PHP", "code" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L32-L41
train
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dumpValue
protected function dumpValue($value): string { if (null === $value) { return 'null'; } if (false === $value) { return 'false'; } if (true === $value) { return 'true'; } if (\is_int($value) || \is_float($value)) { return (string)$value; } if (\is_string($value)) { return StringHelper::dumpString($value); } throw new \InvalidArgumentException('Unsupported data type:' . gettype($value)); }
php
protected function dumpValue($value): string { if (null === $value) { return 'null'; } if (false === $value) { return 'false'; } if (true === $value) { return 'true'; } if (\is_int($value) || \is_float($value)) { return (string)$value; } if (\is_string($value)) { return StringHelper::dumpString($value); } throw new \InvalidArgumentException('Unsupported data type:' . gettype($value)); }
[ "protected", "function", "dumpValue", "(", "$", "value", ")", ":", "string", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "'null'", ";", "}", "if", "(", "false", "===", "$", "value", ")", "{", "return", "'false'", ";", "}", "if"...
Dumps a value other then array @param mixed $value @return string @throws \InvalidArgumentException In case of unsupported data type
[ "Dumps", "a", "value", "other", "then", "array" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L49-L71
train
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dumpArray
protected function dumpArray(array $input, string $indent, int $outerLineLength): string { if (!$input) { return '[]'; } if ($outerLineLength < $this->lineLength) { $dump = $this->tryDumpList($input, $outerLineLength, 1); if (null !== $dump) { return $dump; } } $next_indent = $indent . $this->indent; $next_indent_length = $outerLineLength + $this->indentLength; $dump = '[' . $this->eol; $index = 0; $still_linear = true; foreach ($input as $key => $value) { $item = $next_indent; $item_outer_length = $next_indent_length; if ($still_linear && $key === $index) { ++$index; } else { $still_linear = false; $key_dump = $this->dumpValue($key); $item .= $key_dump . ' => '; $item_outer_length += 4 + StringHelper::lengthUtf8($key_dump); } if (\is_array($value)) { // there will be trailing comma ',' after value, so outer length gives +1 $value_dump = $this->dumpArray($value, $next_indent, $item_outer_length + 1); } else { $value_dump = $this->dumpValue($value); } $item .= $value_dump; $dump .= $item . ',' . $this->eol; } $dump .= $indent . ']'; return $dump; }
php
protected function dumpArray(array $input, string $indent, int $outerLineLength): string { if (!$input) { return '[]'; } if ($outerLineLength < $this->lineLength) { $dump = $this->tryDumpList($input, $outerLineLength, 1); if (null !== $dump) { return $dump; } } $next_indent = $indent . $this->indent; $next_indent_length = $outerLineLength + $this->indentLength; $dump = '[' . $this->eol; $index = 0; $still_linear = true; foreach ($input as $key => $value) { $item = $next_indent; $item_outer_length = $next_indent_length; if ($still_linear && $key === $index) { ++$index; } else { $still_linear = false; $key_dump = $this->dumpValue($key); $item .= $key_dump . ' => '; $item_outer_length += 4 + StringHelper::lengthUtf8($key_dump); } if (\is_array($value)) { // there will be trailing comma ',' after value, so outer length gives +1 $value_dump = $this->dumpArray($value, $next_indent, $item_outer_length + 1); } else { $value_dump = $this->dumpValue($value); } $item .= $value_dump; $dump .= $item . ',' . $this->eol; } $dump .= $indent . ']'; return $dump; }
[ "protected", "function", "dumpArray", "(", "array", "$", "input", ",", "string", "$", "indent", ",", "int", "$", "outerLineLength", ")", ":", "string", "{", "if", "(", "!", "$", "input", ")", "{", "return", "'[]'", ";", "}", "if", "(", "$", "outerLin...
Dumps an array with specific indention @param array $input Input array @param string $indent Full indention string @param int $outerLineLength Length of `$indent` in characters @return string PHP code @throws \InvalidArgumentException In case of unsupported data type
[ "Dumps", "an", "array", "with", "specific", "indention" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L81-L129
train
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.tryDumpList
protected function tryDumpList(array $input, int $outerLineLength, int $level): ?string { if ($level > $this->listDepthLimit) { return null; } $dump = '['; $total_length = $outerLineLength + 1; $index = 0; foreach ($input as $key => $value) { if ($key !== $index) { return null; } if ($index > 0) { $dump .= ', '; $total_length += 2; } if ($total_length >= $this->lineLength) { return null; } ++$index; if (\is_array($value)) { $value_dump = $this->tryDumpList($value, $total_length, $level + 1); if (null === $value_dump) { return null; } } else { $value_dump = $this->dumpValue($value); } $total_length += StringHelper::lengthUtf8($value_dump); if ($total_length >= $this->lineLength) { return null; } $dump .= $value_dump; } $total_length += 1; if ($total_length > $this->lineLength) { return null; } $dump .= ']'; return $dump; }
php
protected function tryDumpList(array $input, int $outerLineLength, int $level): ?string { if ($level > $this->listDepthLimit) { return null; } $dump = '['; $total_length = $outerLineLength + 1; $index = 0; foreach ($input as $key => $value) { if ($key !== $index) { return null; } if ($index > 0) { $dump .= ', '; $total_length += 2; } if ($total_length >= $this->lineLength) { return null; } ++$index; if (\is_array($value)) { $value_dump = $this->tryDumpList($value, $total_length, $level + 1); if (null === $value_dump) { return null; } } else { $value_dump = $this->dumpValue($value); } $total_length += StringHelper::lengthUtf8($value_dump); if ($total_length >= $this->lineLength) { return null; } $dump .= $value_dump; } $total_length += 1; if ($total_length > $this->lineLength) { return null; } $dump .= ']'; return $dump; }
[ "protected", "function", "tryDumpList", "(", "array", "$", "input", ",", "int", "$", "outerLineLength", ",", "int", "$", "level", ")", ":", "?", "string", "{", "if", "(", "$", "level", ">", "$", "this", "->", "listDepthLimit", ")", "{", "return", "null...
Dump list if possible @param array $input Input array @param int $outerLineLength Known line length outside of expected dump @param int $level Nesting lists level starting from 1. @return string|null PHP code in case of success. A `null` when one-line dump is not possible @throws \InvalidArgumentException In case of unsupported data type
[ "Dump", "list", "if", "possible" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L140-L190
train
jeromeklam/freefw
src/FreeFW/JsonApi/V1/Encoder.php
Encoder.encodeSingleResource
protected function encodeSingleResource( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\ResourceObject { $resource = new \FreeFW\JsonApi\V1\Model\ResourceObject( $p_api_response->getApiType(), $p_api_response->getApiId() ); $fields = $p_api_response->getApiAttributes(); if ($fields) { $attributes = new \FreeFW\JsonApi\V1\Model\AttributesObject($fields); $resource->setAttributes($attributes); } return $resource; }
php
protected function encodeSingleResource( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\ResourceObject { $resource = new \FreeFW\JsonApi\V1\Model\ResourceObject( $p_api_response->getApiType(), $p_api_response->getApiId() ); $fields = $p_api_response->getApiAttributes(); if ($fields) { $attributes = new \FreeFW\JsonApi\V1\Model\AttributesObject($fields); $resource->setAttributes($attributes); } return $resource; }
[ "protected", "function", "encodeSingleResource", "(", "\\", "FreeFW", "\\", "Interfaces", "\\", "ApiResponseInterface", "$", "p_api_response", ")", ":", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "ResourceObject", "{", "$", "resource", "="...
Encode single resource @param \FreeFW\Interfaces\ApiResponseInterface $p_api_response @return \FreeFW\JsonApi\V1\Model\ResourceObject
[ "Encode", "single", "resource" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Encoder.php#L19-L32
train
jeromeklam/freefw
src/FreeFW/JsonApi/V1/Encoder.php
Encoder.encode
public function encode( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\Document { $document = new \FreeFW\JsonApi\V1\Model\Document(); if ($p_api_response->hasErrors()) { /** * @var \FreeFW\Core\Error $oneError */ foreach ($p_api_response->getErrors() as $idx => $oneError) { $newError = new \FreeFW\JsonApi\V1\Model\ErrorObject( $oneError->getType(), $oneError->getMessage(), $oneError->getCode() ); $document->addError($newError); } } else { if ($p_api_response instanceof \Iterator) { // Composed of multiple objetcs } else { $resource = $this->encodeSingleResource($p_api_response); $document->setData($resource); } } return $document; }
php
public function encode( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\Document { $document = new \FreeFW\JsonApi\V1\Model\Document(); if ($p_api_response->hasErrors()) { /** * @var \FreeFW\Core\Error $oneError */ foreach ($p_api_response->getErrors() as $idx => $oneError) { $newError = new \FreeFW\JsonApi\V1\Model\ErrorObject( $oneError->getType(), $oneError->getMessage(), $oneError->getCode() ); $document->addError($newError); } } else { if ($p_api_response instanceof \Iterator) { // Composed of multiple objetcs } else { $resource = $this->encodeSingleResource($p_api_response); $document->setData($resource); } } return $document; }
[ "public", "function", "encode", "(", "\\", "FreeFW", "\\", "Interfaces", "\\", "ApiResponseInterface", "$", "p_api_response", ")", ":", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "Document", "{", "$", "document", "=", "new", "\\", "F...
Encode a ApiResponseInterface @param \FreeFW\Interfaces\ApiResponseInterface $p_api_response @return \FreeFW\JsonApi\V1\Model\Document
[ "Encode", "a", "ApiResponseInterface" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Encoder.php#L41-L66
train
consigliere/components
src/Migrations/Migrator.php
Migrator.table
public function table() { return $this->database ? $this->laravel['db']->connection($this->database)->table(config('database.migrations')) : $this->laravel['db']->table(config('database.migrations')); }
php
public function table() { return $this->database ? $this->laravel['db']->connection($this->database)->table(config('database.migrations')) : $this->laravel['db']->table(config('database.migrations')); }
[ "public", "function", "table", "(", ")", "{", "return", "$", "this", "->", "database", "?", "$", "this", "->", "laravel", "[", "'db'", "]", "->", "connection", "(", "$", "this", "->", "database", ")", "->", "table", "(", "config", "(", "'database.migra...
Get table instance. @return string
[ "Get", "table", "instance", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Migrations/Migrator.php#L223-L226
train
mszewcz/php-light-framework
src/Config/ReaderManager.php
ReaderManager.get
public static function get(string $type): AbstractReader { if (!\array_key_exists($type, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported config file type: '.$type); } return new static::$invokableClasses[$type]; }
php
public static function get(string $type): AbstractReader { if (!\array_key_exists($type, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported config file type: '.$type); } return new static::$invokableClasses[$type]; }
[ "public", "static", "function", "get", "(", "string", "$", "type", ")", ":", "AbstractReader", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "type", ",", "static", "::", "$", "invokableClasses", ")", ")", "{", "throw", "new", "InvalidArgumentExc...
Returns config reader class @param string $type @return AbstractReader
[ "Returns", "config", "reader", "class" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/ReaderManager.php#L35-L42
train
aruberutochan/repository
src/Traits/RepositoryAncestorCriteriaTrait.php
RepositoryAncestorCriteriaTrait.pushAncestor
public function pushAncestor($ancestor) { if (is_string($ancestor)) { $ancestor = new $ancestor; } if (!$ancestor instanceof AncestorCriteriaInterface) { throw new RepositoryException("Class " . get_class($ancestor) . " must be an instance of Aruberuto\\Repository\\Contracts\\AncestorCriteriaInterface"); } $this->ancestor->push($ancestor); return $this; }
php
public function pushAncestor($ancestor) { if (is_string($ancestor)) { $ancestor = new $ancestor; } if (!$ancestor instanceof AncestorCriteriaInterface) { throw new RepositoryException("Class " . get_class($ancestor) . " must be an instance of Aruberuto\\Repository\\Contracts\\AncestorCriteriaInterface"); } $this->ancestor->push($ancestor); return $this; }
[ "public", "function", "pushAncestor", "(", "$", "ancestor", ")", "{", "if", "(", "is_string", "(", "$", "ancestor", ")", ")", "{", "$", "ancestor", "=", "new", "$", "ancestor", ";", "}", "if", "(", "!", "$", "ancestor", "instanceof", "AncestorCriteriaInt...
Push Ancestor for filter the query @param $ancestor @return $this @throws \Aruberuto\Repository\Exceptions\RepositoryException
[ "Push", "Ancestor", "for", "filter", "the", "query" ]
4ecc5eb37377af8f000af76c886c217479dcf454
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Traits/RepositoryAncestorCriteriaTrait.php#L34-L45
train
aruberutochan/repository
src/Traits/RepositoryAncestorCriteriaTrait.php
RepositoryAncestorCriteriaTrait.getByAncestor
public function getByAncestor(AncestorCriteriaInterface $ancestor) { $this->model = $ancestor->apply($this->model, $this); $results = $this->model->get(); $this->resetModel(); return $this->parserResult($results); }
php
public function getByAncestor(AncestorCriteriaInterface $ancestor) { $this->model = $ancestor->apply($this->model, $this); $results = $this->model->get(); $this->resetModel(); return $this->parserResult($results); }
[ "public", "function", "getByAncestor", "(", "AncestorCriteriaInterface", "$", "ancestor", ")", "{", "$", "this", "->", "model", "=", "$", "ancestor", "->", "apply", "(", "$", "this", "->", "model", ",", "$", "this", ")", ";", "$", "results", "=", "$", ...
Find data by Ancestor @param AncestorCriteriaInterface $ancestor @return mixed
[ "Find", "data", "by", "Ancestor" ]
4ecc5eb37377af8f000af76c886c217479dcf454
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Traits/RepositoryAncestorCriteriaTrait.php#L88-L95
train
gossi/trixionary
src/model/Base/Object.php
Object.getSport
public function getSport(ConnectionInterface $con = null) { if ($this->aSport === null && ($this->sport_id !== null)) { $this->aSport = ChildSportQuery::create()->findPk($this->sport_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aSport->addObjects($this); */ } return $this->aSport; }
php
public function getSport(ConnectionInterface $con = null) { if ($this->aSport === null && ($this->sport_id !== null)) { $this->aSport = ChildSportQuery::create()->findPk($this->sport_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aSport->addObjects($this); */ } return $this->aSport; }
[ "public", "function", "getSport", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aSport", "===", "null", "&&", "(", "$", "this", "->", "sport_id", "!==", "null", ")", ")", "{", "$", "this", "->", "aSport...
Get the associated ChildSport object @param ConnectionInterface $con Optional Connection object. @return ChildSport The associated ChildSport object. @throws PropelException
[ "Get", "the", "associated", "ChildSport", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Object.php#L1442-L1456
train
gossi/trixionary
src/model/Base/Object.php
Object.initSkills
public function initSkills($overrideExisting = true) { if (null !== $this->collSkills && !$overrideExisting) { return; } $this->collSkills = new ObjectCollection(); $this->collSkills->setModel('\gossi\trixionary\model\Skill'); }
php
public function initSkills($overrideExisting = true) { if (null !== $this->collSkills && !$overrideExisting) { return; } $this->collSkills = new ObjectCollection(); $this->collSkills->setModel('\gossi\trixionary\model\Skill'); }
[ "public", "function", "initSkills", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collSkills", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collSkills", "=", ...
Initializes the collSkills collection. By default this just sets the collSkills collection to an empty array (like clearcollSkills()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collSkills", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Object.php#L1508-L1515
train
etcinit/tutum-php
src/Chromabits/TutumClient/Entities/ContainerLink.php
ContainerLink.getEndpointAsUrl
public function getEndpointAsUrl($port, $protocol = 'tcp') { if (!$this->hasEndpoint($port, $protocol)) { throw new Exception('Endpoint is not available'); } $key = $port . '/' . $protocol; return Url::fromString($this->endpoints[$key]); }
php
public function getEndpointAsUrl($port, $protocol = 'tcp') { if (!$this->hasEndpoint($port, $protocol)) { throw new Exception('Endpoint is not available'); } $key = $port . '/' . $protocol; return Url::fromString($this->endpoints[$key]); }
[ "public", "function", "getEndpointAsUrl", "(", "$", "port", ",", "$", "protocol", "=", "'tcp'", ")", "{", "if", "(", "!", "$", "this", "->", "hasEndpoint", "(", "$", "port", ",", "$", "protocol", ")", ")", "{", "throw", "new", "Exception", "(", "'End...
Try to get a single endpoint as a Url @param $port @param string $protocol @return Url @throws Exception
[ "Try", "to", "get", "a", "single", "endpoint", "as", "a", "Url" ]
39fb3375e0d47109a5da70a0e441efb8fd4f4008
https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/Entities/ContainerLink.php#L113-L122
train
etcinit/tutum-php
src/Chromabits/TutumClient/Entities/ContainerLink.php
ContainerLink.hasEndpoint
public function hasEndpoint($port, $protocol = 'tcp') { $key = $port . '/' . $protocol; return array_key_exists($key, $this->endpoints); }
php
public function hasEndpoint($port, $protocol = 'tcp') { $key = $port . '/' . $protocol; return array_key_exists($key, $this->endpoints); }
[ "public", "function", "hasEndpoint", "(", "$", "port", ",", "$", "protocol", "=", "'tcp'", ")", "{", "$", "key", "=", "$", "port", ".", "'/'", ".", "$", "protocol", ";", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "endpoint...
Return whether or not an endpoint exists @param $port @param string $protocol @return bool
[ "Return", "whether", "or", "not", "an", "endpoint", "exists" ]
39fb3375e0d47109a5da70a0e441efb8fd4f4008
https://github.com/etcinit/tutum-php/blob/39fb3375e0d47109a5da70a0e441efb8fd4f4008/src/Chromabits/TutumClient/Entities/ContainerLink.php#L132-L137
train
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.getPathAndParent
private function getPathAndParent(PersistentCollection $coll) { $mapping = $coll->getMapping(); $fields = array(); $parent = $coll->getOwner(); while (null !== ($association = $this->uow->getParentAssociation($parent))) { list($m, $owner, $field) = $association; if (isset($m['reference'])) { break; } $parent = $owner; $fields[] = $field; } $propertyPath = implode('.', array_reverse($fields)); $path = $mapping['name']; if ($propertyPath) { $path = $propertyPath . '.' . $path; } return array($path, $parent); }
php
private function getPathAndParent(PersistentCollection $coll) { $mapping = $coll->getMapping(); $fields = array(); $parent = $coll->getOwner(); while (null !== ($association = $this->uow->getParentAssociation($parent))) { list($m, $owner, $field) = $association; if (isset($m['reference'])) { break; } $parent = $owner; $fields[] = $field; } $propertyPath = implode('.', array_reverse($fields)); $path = $mapping['name']; if ($propertyPath) { $path = $propertyPath . '.' . $path; } return array($path, $parent); }
[ "private", "function", "getPathAndParent", "(", "PersistentCollection", "$", "coll", ")", "{", "$", "mapping", "=", "$", "coll", "->", "getMapping", "(", ")", ";", "$", "fields", "=", "array", "(", ")", ";", "$", "parent", "=", "$", "coll", "->", "getO...
Gets the parent information for a given PersistentCollection. It will retrieve the top-level persistent Document that the PersistentCollection lives in. We can use this to issue queries when updating a PersistentCollection that is multiple levels deep inside an embedded document. <code> list($path, $parent) = $this->getPathAndParent($coll) </code> @param PersistentCollection $coll @return array $pathAndParent
[ "Gets", "the", "parent", "information", "for", "a", "given", "PersistentCollection", ".", "It", "will", "retrieve", "the", "top", "-", "level", "persistent", "Document", "that", "the", "PersistentCollection", "lives", "in", ".", "We", "can", "use", "this", "to...
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L258-L277
train
tofex/util
Helper/Arrays.php
Arrays.arrayFilterRecursive
public function arrayFilterRecursive(array $array) { foreach ($array as &$value) { if (is_array($value)) { /** @var $value array */ $value = count($value) === 1 && array_key_exists(0, $value) && is_string($value[ 0 ]) && $this->variable->isEmpty(trim($value[ 0 ])) ? $value[ 0 ] : $this->arrayFilterRecursive($value); } } return array_filter($array, function ($value) { return ! $this->variable->isEmpty($value) && ! (is_string($value) && $this->variable->isEmpty(trim($value))); }); }
php
public function arrayFilterRecursive(array $array) { foreach ($array as &$value) { if (is_array($value)) { /** @var $value array */ $value = count($value) === 1 && array_key_exists(0, $value) && is_string($value[ 0 ]) && $this->variable->isEmpty(trim($value[ 0 ])) ? $value[ 0 ] : $this->arrayFilterRecursive($value); } } return array_filter($array, function ($value) { return ! $this->variable->isEmpty($value) && ! (is_string($value) && $this->variable->isEmpty(trim($value))); }); }
[ "public", "function", "arrayFilterRecursive", "(", "array", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "/** @var $value array */", "$", "value", "=", ...
Method to filter empty elements from XML @param array $array @return array
[ "Method", "to", "filter", "empty", "elements", "from", "XML" ]
7b167c1094976732dc634367c3c6da37d586ddf2
https://github.com/tofex/util/blob/7b167c1094976732dc634367c3c6da37d586ddf2/Helper/Arrays.php#L446-L460
train
railken/laravel-application
src/AppServiceProvider.php
AppServiceProvider.makePath
public function makePath() { $path = base_path('src'); if (!File::exists($path)) { File::makeDirectory($path, 0775, true); } }
php
public function makePath() { $path = base_path('src'); if (!File::exists($path)) { File::makeDirectory($path, 0775, true); } }
[ "public", "function", "makePath", "(", ")", "{", "$", "path", "=", "base_path", "(", "'src'", ")", ";", "if", "(", "!", "File", "::", "exists", "(", "$", "path", ")", ")", "{", "File", "::", "makeDirectory", "(", "$", "path", ",", "0775", ",", "t...
Create basic path if doesn't exists @return void
[ "Create", "basic", "path", "if", "doesn", "t", "exists" ]
51b6f5063551e7b2e2302ac096e78b69fbad68de
https://github.com/railken/laravel-application/blob/51b6f5063551e7b2e2302ac096e78b69fbad68de/src/AppServiceProvider.php#L88-L95
train
phlexible/phlexible
src/Phlexible/Component/Util/StringUtil.php
StringUtil.truncatePreservingTags
public function truncatePreservingTags($str, $textMaxLength, $postString = '...', $encoding = 'UTF-8') { // complete string length with tags $htmlLength = mb_strlen($str, $encoding); // cursor position $htmlPos = 0; // extracted text length without tags $textLength = 0; // tags that need to closed $closeTag = array(); if ($htmlLength <= $textMaxLength) { return $str; } $inEntity = false; // loop through str, start at cursor position for ($i = $htmlPos; $i < $htmlLength; ++$i) { // extract multibyte encoded char on cursor position $char = mb_substr($str, $i, 1, $encoding); if ($char === '&') { if (!$inEntity) { $inEntity = true; } } elseif ($char === ';') { if ($inEntity) { $inEntity = false; } } // check on an angle bracket assuming text following is a tag elseif ($char === '<') { // sub cursor position inside the tag (after the first angle bracket) $tagPos = $i + 1; // remember first position inside the tag $tagFirst = $tagPos; // size of tag (including angle brackets <1234>) $tagSize = 1; // tag name $tagName = ''; // tag is valid ( <tag> OR </tag> ) $isTag = true; // tag is a closing tag </tag> $isClosingTag = false; // loop through text inside the tag until it is closed for ($j = $tagPos; $j < $htmlLength; ++$j) { // extract multibyte encoded char on sub cursor position $charTag = mb_substr($str, $j, 1, $encoding); // another opening angle bracket = first angle bracket serves as "smaller as" // not a valid tag, set mark and break if ($charTag === '<') { $isTag = false; break; } // seems to be an '<>' entity // not a valid tag, set mark and break elseif ($tagFirst === $j && $charTag === '>' ) { $isTag = false; break; } // closing tag, set mark elseif ($tagFirst === $j && $charTag === '/' ) { $isClosingTag = true; } // tag has ended, break elseif ($charTag === '>') { break; } // remember char as tag name else { $tagName .= $charTag; } ++$tagSize; } // valid tag if (!empty($isTag)) { // closing tag </tag> if (!empty($isClosingTag)) { // remove it from closing array array_pop($closeTag); } // not a closing tag else { // remember to close it $closeTag[] = $tagName; } // set cursor position, continue with next char after the tag $i = $i + $tagSize; } // not a valid tag else { // set assumed tag size as additional textLength, because it is text $textLength = $textLength + $tagSize; // set cursor position and reset the last < or > char to start a new check $i = $i + $tagSize - 1; } } // normal char, increase textLength else { ++$textLength; } // if maximum length reached break if (!$inEntity && $textLength >= $textMaxLength) { break; } } // set cursor to new position $htmlPos = $i + 1; // extract preview text from 0 to current cursor position $ret = mb_substr($str, 0, $htmlPos, $encoding); // if necessary set placeholder string (before tags get closed) if ($textLength >= $textMaxLength) { $ret .= $postString; } // if we are between tags, close them correctly if (count($closeTag)) { foreach (array_reverse($closeTag) as $tag) { $tokens = explode(' ', $tag); $ret .= '</'.$tokens[0].'>'; } } return $ret; }
php
public function truncatePreservingTags($str, $textMaxLength, $postString = '...', $encoding = 'UTF-8') { // complete string length with tags $htmlLength = mb_strlen($str, $encoding); // cursor position $htmlPos = 0; // extracted text length without tags $textLength = 0; // tags that need to closed $closeTag = array(); if ($htmlLength <= $textMaxLength) { return $str; } $inEntity = false; // loop through str, start at cursor position for ($i = $htmlPos; $i < $htmlLength; ++$i) { // extract multibyte encoded char on cursor position $char = mb_substr($str, $i, 1, $encoding); if ($char === '&') { if (!$inEntity) { $inEntity = true; } } elseif ($char === ';') { if ($inEntity) { $inEntity = false; } } // check on an angle bracket assuming text following is a tag elseif ($char === '<') { // sub cursor position inside the tag (after the first angle bracket) $tagPos = $i + 1; // remember first position inside the tag $tagFirst = $tagPos; // size of tag (including angle brackets <1234>) $tagSize = 1; // tag name $tagName = ''; // tag is valid ( <tag> OR </tag> ) $isTag = true; // tag is a closing tag </tag> $isClosingTag = false; // loop through text inside the tag until it is closed for ($j = $tagPos; $j < $htmlLength; ++$j) { // extract multibyte encoded char on sub cursor position $charTag = mb_substr($str, $j, 1, $encoding); // another opening angle bracket = first angle bracket serves as "smaller as" // not a valid tag, set mark and break if ($charTag === '<') { $isTag = false; break; } // seems to be an '<>' entity // not a valid tag, set mark and break elseif ($tagFirst === $j && $charTag === '>' ) { $isTag = false; break; } // closing tag, set mark elseif ($tagFirst === $j && $charTag === '/' ) { $isClosingTag = true; } // tag has ended, break elseif ($charTag === '>') { break; } // remember char as tag name else { $tagName .= $charTag; } ++$tagSize; } // valid tag if (!empty($isTag)) { // closing tag </tag> if (!empty($isClosingTag)) { // remove it from closing array array_pop($closeTag); } // not a closing tag else { // remember to close it $closeTag[] = $tagName; } // set cursor position, continue with next char after the tag $i = $i + $tagSize; } // not a valid tag else { // set assumed tag size as additional textLength, because it is text $textLength = $textLength + $tagSize; // set cursor position and reset the last < or > char to start a new check $i = $i + $tagSize - 1; } } // normal char, increase textLength else { ++$textLength; } // if maximum length reached break if (!$inEntity && $textLength >= $textMaxLength) { break; } } // set cursor to new position $htmlPos = $i + 1; // extract preview text from 0 to current cursor position $ret = mb_substr($str, 0, $htmlPos, $encoding); // if necessary set placeholder string (before tags get closed) if ($textLength >= $textMaxLength) { $ret .= $postString; } // if we are between tags, close them correctly if (count($closeTag)) { foreach (array_reverse($closeTag) as $tag) { $tokens = explode(' ', $tag); $ret .= '</'.$tokens[0].'>'; } } return $ret; }
[ "public", "function", "truncatePreservingTags", "(", "$", "str", ",", "$", "textMaxLength", ",", "$", "postString", "=", "'...'", ",", "$", "encoding", "=", "'UTF-8'", ")", "{", "// complete string length with tags", "$", "htmlLength", "=", "mb_strlen", "(", "$"...
Function truncates a HTML string, preserving and closing all tags. @param string $str @param int $textMaxLength @param string $postString @param string $encoding @return string
[ "Function", "truncates", "a", "HTML", "string", "preserving", "and", "closing", "all", "tags", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Util/StringUtil.php#L32-L164
train
MarcusFulbright/represent
src/Represent/Factory/StreamingResponseFactory.php
StreamingResponseFactory.createStreamingResponse
public function createStreamingResponse($filePath, $fileName, $type = 'application/octet-stream') { $response = new StreamedResponse(); $this->setStreamCallBack($response, $filePath); $this->setStreamHeaders($response, $fileName, $type); return $response; }
php
public function createStreamingResponse($filePath, $fileName, $type = 'application/octet-stream') { $response = new StreamedResponse(); $this->setStreamCallBack($response, $filePath); $this->setStreamHeaders($response, $fileName, $type); return $response; }
[ "public", "function", "createStreamingResponse", "(", "$", "filePath", ",", "$", "fileName", ",", "$", "type", "=", "'application/octet-stream'", ")", "{", "$", "response", "=", "new", "StreamedResponse", "(", ")", ";", "$", "this", "->", "setStreamCallBack", ...
Handles creating a streaming response for the given file path and uses the given file name @param $filePath @param $fileName @param string $type @return StreamedResponse
[ "Handles", "creating", "a", "streaming", "response", "for", "the", "given", "file", "path", "and", "uses", "the", "given", "file", "name" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Factory/StreamingResponseFactory.php#L31-L38
train
beheh/sulphur
src/Parser.php
Parser.parse
public function parse($string) { $response = new Response(); // normalize line endings $filtered = preg_replace("/(\n|\r){2,}/", PHP_EOL, $string); $lines = explode(PHP_EOL, $filtered); foreach($lines as $line) { $matches = array(); if(preg_match('/^(\s*)\[(.*)\]$/', $line, $matches)) { // entering new section $depth = strlen($matches[1]); // merge all lower sections $this->completeSection($response, $depth); $this->stack[$depth] = new Section($matches[2]); } else if(preg_match('/^(\s*)(.*)=(.*)$/', $line, $matches)) { $depth = strlen($matches[1]); if(isset($this->stack[$depth])) { $section = $this->stack[$depth]; $section->__set($matches[2], self::cast($matches[3])); } } } // merge remaining children into parents $this->completeSection($response, 0); return $response; }
php
public function parse($string) { $response = new Response(); // normalize line endings $filtered = preg_replace("/(\n|\r){2,}/", PHP_EOL, $string); $lines = explode(PHP_EOL, $filtered); foreach($lines as $line) { $matches = array(); if(preg_match('/^(\s*)\[(.*)\]$/', $line, $matches)) { // entering new section $depth = strlen($matches[1]); // merge all lower sections $this->completeSection($response, $depth); $this->stack[$depth] = new Section($matches[2]); } else if(preg_match('/^(\s*)(.*)=(.*)$/', $line, $matches)) { $depth = strlen($matches[1]); if(isset($this->stack[$depth])) { $section = $this->stack[$depth]; $section->__set($matches[2], self::cast($matches[3])); } } } // merge remaining children into parents $this->completeSection($response, 0); return $response; }
[ "public", "function", "parse", "(", "$", "string", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "// normalize line endings", "$", "filtered", "=", "preg_replace", "(", "\"/(\\n|\\r){2,}/\"", ",", "PHP_EOL", ",", "$", "string", ")", ";", ...
Parses the passed response and passes the key-value pairs to references. @param string $string the string to parse @return Response the response
[ "Parses", "the", "passed", "response", "and", "passes", "the", "key", "-", "value", "pairs", "to", "references", "." ]
d608b40d6cf26f12476d992276ee9a0aa455bd55
https://github.com/beheh/sulphur/blob/d608b40d6cf26f12476d992276ee9a0aa455bd55/src/Parser.php#L20-L49
train
beheh/sulphur
src/Parser.php
Parser.cast
public static function cast($value) { $matches = array(); if(strtolower($value) === 'true') { $value = (bool) true; } else if(strtolower($value) === 'false') { $value = (bool) false; } else if(is_numeric($value)) { $value = (int) $value; } else if(preg_match('/^"(.*)"$/', $value, $matches)) { $value = $matches[1]; } return $value; }
php
public static function cast($value) { $matches = array(); if(strtolower($value) === 'true') { $value = (bool) true; } else if(strtolower($value) === 'false') { $value = (bool) false; } else if(is_numeric($value)) { $value = (int) $value; } else if(preg_match('/^"(.*)"$/', $value, $matches)) { $value = $matches[1]; } return $value; }
[ "public", "static", "function", "cast", "(", "$", "value", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "strtolower", "(", "$", "value", ")", "===", "'true'", ")", "{", "$", "value", "=", "(", "bool", ")", "true", ";", "}", ...
Casts the value to the correct datatype. @param string $value the value to cast @return any
[ "Casts", "the", "value", "to", "the", "correct", "datatype", "." ]
d608b40d6cf26f12476d992276ee9a0aa455bd55
https://github.com/beheh/sulphur/blob/d608b40d6cf26f12476d992276ee9a0aa455bd55/src/Parser.php#L79-L91
train
stubbles/stubbles-sequence
src/main/php/Collector.php
Collector.forSum
public static function forSum(callable $num): self { return new self( function() { return 0; }, function(&$result, $element) use($num) { $result+= $num($element); } ); }
php
public static function forSum(callable $num): self { return new self( function() { return 0; }, function(&$result, $element) use($num) { $result+= $num($element); } ); }
[ "public", "static", "function", "forSum", "(", "callable", "$", "num", ")", ":", "self", "{", "return", "new", "self", "(", "function", "(", ")", "{", "return", "0", ";", "}", ",", "function", "(", "&", "$", "result", ",", "$", "element", ")", "use...
returns a collector to sum up elements @api @param callable $num callable which retrieves a number from a given element @return \stubbles\sequence\Collector
[ "returns", "a", "collector", "to", "sum", "up", "elements" ]
258d2247f1cdd826818348fe15829d5a98a9de70
https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collector.php#L108-L113
train
stubbles/stubbles-sequence
src/main/php/Collector.php
Collector.forAverage
public static function forAverage(callable $num): self { return new self( function() { return [0, 0]; }, function(&$result, $arg) use($num) { $result[0] += $num($arg); $result[1]++; }, function($result) { return $result[0] / $result[1]; } ); }
php
public static function forAverage(callable $num): self { return new self( function() { return [0, 0]; }, function(&$result, $arg) use($num) { $result[0] += $num($arg); $result[1]++; }, function($result) { return $result[0] / $result[1]; } ); }
[ "public", "static", "function", "forAverage", "(", "callable", "$", "num", ")", ":", "self", "{", "return", "new", "self", "(", "function", "(", ")", "{", "return", "[", "0", ",", "0", "]", ";", "}", ",", "function", "(", "&", "$", "result", ",", ...
returns a collector to calculate an average for all the given elements @api @param callable $num callable which retrieves a number from a given element @return \stubbles\sequence\Collector
[ "returns", "a", "collector", "to", "calculate", "an", "average", "for", "all", "the", "given", "elements" ]
258d2247f1cdd826818348fe15829d5a98a9de70
https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collector.php#L122-L128
train
stubbles/stubbles-sequence
src/main/php/Collector.php
Collector.accumulate
public function accumulate($element, $key) { $accumulate = $this->accumulator; $accumulate($this->structure, $element, $key); }
php
public function accumulate($element, $key) { $accumulate = $this->accumulator; $accumulate($this->structure, $element, $key); }
[ "public", "function", "accumulate", "(", "$", "element", ",", "$", "key", ")", "{", "$", "accumulate", "=", "$", "this", "->", "accumulator", ";", "$", "accumulate", "(", "$", "this", "->", "structure", ",", "$", "element", ",", "$", "key", ")", ";",...
adds given element and key to result structure @param mixed $element @param mixed $key
[ "adds", "given", "element", "and", "key", "to", "result", "structure" ]
258d2247f1cdd826818348fe15829d5a98a9de70
https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collector.php#L146-L150
train
stubbles/stubbles-sequence
src/main/php/Collector.php
Collector.finish
public function finish() { if (null === $this->finisher) { return $this->structure; } $finish = $this->finisher; return $finish($this->structure); }
php
public function finish() { if (null === $this->finisher) { return $this->structure; } $finish = $this->finisher; return $finish($this->structure); }
[ "public", "function", "finish", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "finisher", ")", "{", "return", "$", "this", "->", "structure", ";", "}", "$", "finish", "=", "$", "this", "->", "finisher", ";", "return", "$", "finish", "...
finishes collection of result @param mixed $result @return mixed finished result
[ "finishes", "collection", "of", "result" ]
258d2247f1cdd826818348fe15829d5a98a9de70
https://github.com/stubbles/stubbles-sequence/blob/258d2247f1cdd826818348fe15829d5a98a9de70/src/main/php/Collector.php#L158-L166
train
jsiefer/class-mocker
src/Registry/FootprintRegistry.php
FootprintRegistry.import
public function import($file) { if (!file_exists($file)) { throw new \InvalidArgumentException("Footprint file '$file' does not exist"); } $content = file_get_contents($file); $this->importJson($content); }
php
public function import($file) { if (!file_exists($file)) { throw new \InvalidArgumentException("Footprint file '$file' does not exist"); } $content = file_get_contents($file); $this->importJson($content); }
[ "public", "function", "import", "(", "$", "file", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Footprint file '$file' does not exist\"", ")", ";", "}", "$", "content", "="...
Import footprints from json file @param string $file @return void
[ "Import", "footprints", "from", "json", "file" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Registry/FootprintRegistry.php#L47-L54
train
jsiefer/class-mocker
src/Registry/FootprintRegistry.php
FootprintRegistry.importJson
public function importJson($jsonData) { $json = json_decode($jsonData, true); if ($json === null) { throw new \InvalidArgumentException("Footprint json is not a valid"); } if (!is_array($json)) { throw new \InvalidArgumentException("Footprint json data is not a valid"); } $this->_data += $json; }
php
public function importJson($jsonData) { $json = json_decode($jsonData, true); if ($json === null) { throw new \InvalidArgumentException("Footprint json is not a valid"); } if (!is_array($json)) { throw new \InvalidArgumentException("Footprint json data is not a valid"); } $this->_data += $json; }
[ "public", "function", "importJson", "(", "$", "jsonData", ")", "{", "$", "json", "=", "json_decode", "(", "$", "jsonData", ",", "true", ")", ";", "if", "(", "$", "json", "===", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\...
Import footprints from json string @param string $jsonData @return void
[ "Import", "footprints", "from", "json", "string" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Registry/FootprintRegistry.php#L63-L76
train
jsiefer/class-mocker
src/Registry/FootprintRegistry.php
FootprintRegistry.get
public function get($className) { if (isset($this->_footprints[$className])) { return $this->_footprints[$className]; } if (isset($this->_data[$className])) { $data = $this->_data[$className]; $footprint = new ClassFootprint($data); } else { $footprint = new ClassFootprint(); if (preg_match($this->_interfaceRegex, $className)) { $footprint->setType(ClassFootprint::TYPE_INTERFACE); } } $this->addFootprint($className, $footprint); return $footprint; }
php
public function get($className) { if (isset($this->_footprints[$className])) { return $this->_footprints[$className]; } if (isset($this->_data[$className])) { $data = $this->_data[$className]; $footprint = new ClassFootprint($data); } else { $footprint = new ClassFootprint(); if (preg_match($this->_interfaceRegex, $className)) { $footprint->setType(ClassFootprint::TYPE_INTERFACE); } } $this->addFootprint($className, $footprint); return $footprint; }
[ "public", "function", "get", "(", "$", "className", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_footprints", "[", "$", "className", "]", ")", ")", "{", "return", "$", "this", "->", "_footprints", "[", "$", "className", "]", ";", "}", "i...
Retrieve class footprint @param string $className @return ClassFootprint
[ "Retrieve", "class", "footprint" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/Registry/FootprintRegistry.php#L98-L116
train
sbstjn/reng
src/lib/Component/Base.php
Base.validate
private function validate() { if (!stristr(self::CHARACTER_LIST, $this->value[0])) { throw new \Exception('Invalid first character: ' . $this->value[0]); } if (!in_array($this->value, self::listForCharacter($this->value[0]))) { throw new \Exception('Word not in known list of words: ' . $this->value); } }
php
private function validate() { if (!stristr(self::CHARACTER_LIST, $this->value[0])) { throw new \Exception('Invalid first character: ' . $this->value[0]); } if (!in_array($this->value, self::listForCharacter($this->value[0]))) { throw new \Exception('Word not in known list of words: ' . $this->value); } }
[ "private", "function", "validate", "(", ")", "{", "if", "(", "!", "stristr", "(", "self", "::", "CHARACTER_LIST", ",", "$", "this", "->", "value", "[", "0", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid first character: '", ".", ...
Validate word against list of allowed characters and words @throws \Exception
[ "Validate", "word", "against", "list", "of", "allowed", "characters", "and", "words" ]
d0da8ed3498a269e610226ceb4c690f4447bd6a4
https://github.com/sbstjn/reng/blob/d0da8ed3498a269e610226ceb4c690f4447bd6a4/src/lib/Component/Base.php#L36-L45
train
sbstjn/reng
src/lib/Component/Base.php
Base.randomFor
public static function randomFor($char) { $list = self::listForCharacter($char); $class = get_called_class(); return new $class($list[rand(0, count($list) - 1)]); }
php
public static function randomFor($char) { $list = self::listForCharacter($char); $class = get_called_class(); return new $class($list[rand(0, count($list) - 1)]); }
[ "public", "static", "function", "randomFor", "(", "$", "char", ")", "{", "$", "list", "=", "self", "::", "listForCharacter", "(", "$", "char", ")", ";", "$", "class", "=", "get_called_class", "(", ")", ";", "return", "new", "$", "class", "(", "$", "l...
Get random string startign with given character @param $char @return string
[ "Get", "random", "string", "startign", "with", "given", "character" ]
d0da8ed3498a269e610226ceb4c690f4447bd6a4
https://github.com/sbstjn/reng/blob/d0da8ed3498a269e610226ceb4c690f4447bd6a4/src/lib/Component/Base.php#L76-L83
train
sbstjn/reng
src/lib/Component/Base.php
Base.listForCharacter
public static function listForCharacter($char) { $file = self::getDataFolder() . '/' . $char; $data = strtolower(file_get_contents($file)); return explode("\n", $data); }
php
public static function listForCharacter($char) { $file = self::getDataFolder() . '/' . $char; $data = strtolower(file_get_contents($file)); return explode("\n", $data); }
[ "public", "static", "function", "listForCharacter", "(", "$", "char", ")", "{", "$", "file", "=", "self", "::", "getDataFolder", "(", ")", ".", "'/'", ".", "$", "char", ";", "$", "data", "=", "strtolower", "(", "file_get_contents", "(", "$", "file", ")...
Get list of available words for given character @param $char Needed character @return array
[ "Get", "list", "of", "available", "words", "for", "given", "character" ]
d0da8ed3498a269e610226ceb4c690f4447bd6a4
https://github.com/sbstjn/reng/blob/d0da8ed3498a269e610226ceb4c690f4447bd6a4/src/lib/Component/Base.php#L91-L96
train
railsphp/framework
src/Rails/ActiveRecord/Relation.php
Relation.firstOrCreate
public function firstOrCreate(array $attributes = []) { $model = $this->first(); if (!$model) { $model = $this->create($attributes); } return $model; }
php
public function firstOrCreate(array $attributes = []) { $model = $this->first(); if (!$model) { $model = $this->create($attributes); } return $model; }
[ "public", "function", "firstOrCreate", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "first", "(", ")", ";", "if", "(", "!", "$", "model", ")", "{", "$", "model", "=", "$", "this", "->", "create",...
Find first or create record. @param array $attributes additional attributes to create the record with. @return object
[ "Find", "first", "or", "create", "record", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Relation.php#L248-L255
train
mkjpryor/option
src/Result.php
Result.get
public function get() { if( $this->value !== null ) return $this->value; if( $this->error !== null ) throw $this->error; throw new \LogicException("Value and error cannot both be null"); }
php
public function get() { if( $this->value !== null ) return $this->value; if( $this->error !== null ) throw $this->error; throw new \LogicException("Value and error cannot both be null"); }
[ "public", "function", "get", "(", ")", "{", "if", "(", "$", "this", "->", "value", "!==", "null", ")", "return", "$", "this", "->", "value", ";", "if", "(", "$", "this", "->", "error", "!==", "null", ")", "throw", "$", "this", "->", "error", ";",...
Returns the value of the result if it is a success If it is an error, the exception it was created with is thrown
[ "Returns", "the", "value", "of", "the", "result", "if", "it", "is", "a", "success" ]
202af894c6fac89b4cb3769acfa4f81813167706
https://github.com/mkjpryor/option/blob/202af894c6fac89b4cb3769acfa4f81813167706/src/Result.php#L37-L41
train
mkjpryor/option
src/Result.php
Result._try
public static function _try(callable $f) { try { return Result::success($f()); } catch( \Exception $error ) { return Result::error($error); } }
php
public static function _try(callable $f) { try { return Result::success($f()); } catch( \Exception $error ) { return Result::error($error); } }
[ "public", "static", "function", "_try", "(", "callable", "$", "f", ")", "{", "try", "{", "return", "Result", "::", "success", "(", "$", "f", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "error", ")", "{", "return", "Result", "::",...
Tries to execute the given function and returns a result representing the outcome, i.e. if the function returns normally, a successful result is returned containing the return value and if the function throws an exception, an error result is returned containing the error $f should take no arguments and return a value that will be wrapped in a success if the computation completes successfully The _ is required if we want to use the word try since it is keyword
[ "Tries", "to", "execute", "the", "given", "function", "and", "returns", "a", "result", "representing", "the", "outcome", "i", ".", "e", ".", "if", "the", "function", "returns", "normally", "a", "successful", "result", "is", "returned", "containing", "the", "...
202af894c6fac89b4cb3769acfa4f81813167706
https://github.com/mkjpryor/option/blob/202af894c6fac89b4cb3769acfa4f81813167706/src/Result.php#L166-L173
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.addGuestActions
public function addGuestActions($guestActions) { if (!is_array($guestActions)) { $guestActions = [$guestActions]; } $this->_guestActions = Hash::merge($this->_guestActions, $guestActions); }
php
public function addGuestActions($guestActions) { if (!is_array($guestActions)) { $guestActions = [$guestActions]; } $this->_guestActions = Hash::merge($this->_guestActions, $guestActions); }
[ "public", "function", "addGuestActions", "(", "$", "guestActions", ")", "{", "if", "(", "!", "is_array", "(", "$", "guestActions", ")", ")", "{", "$", "guestActions", "=", "[", "$", "guestActions", "]", ";", "}", "$", "this", "->", "_guestActions", "=", ...
Add guest actions which don't require a logged in user. @param array|string $guestActions The guest action to add. @return void
[ "Add", "guest", "actions", "which", "don", "t", "require", "a", "logged", "in", "user", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L146-L153
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.hasAccess
public function hasAccess($url) { if ($this->isGuestAction($url)) { return true; } $path = $this->getPathFromUrl($url); $groupId = $this->Auth->user('group_id'); if ($groupId === null) { return false; } if (!is_array($groupId)) { $groupId = [$groupId]; } if (in_array(1, $groupId)) { return true; } $user = Wasabi::user(); if (empty($user->permissions)) { Wasabi::user()->permissions = $this->_getGroupPermissions()->findAllForGroup($groupId); } if (array_key_exists($path, Wasabi::user()->permissions)) { return true; } return false; }
php
public function hasAccess($url) { if ($this->isGuestAction($url)) { return true; } $path = $this->getPathFromUrl($url); $groupId = $this->Auth->user('group_id'); if ($groupId === null) { return false; } if (!is_array($groupId)) { $groupId = [$groupId]; } if (in_array(1, $groupId)) { return true; } $user = Wasabi::user(); if (empty($user->permissions)) { Wasabi::user()->permissions = $this->_getGroupPermissions()->findAllForGroup($groupId); } if (array_key_exists($path, Wasabi::user()->permissions)) { return true; } return false; }
[ "public", "function", "hasAccess", "(", "$", "url", ")", "{", "if", "(", "$", "this", "->", "isGuestAction", "(", "$", "url", ")", ")", "{", "return", "true", ";", "}", "$", "path", "=", "$", "this", "->", "getPathFromUrl", "(", "$", "url", ")", ...
Check if the currently logged in user is authorized to access the given url. @param array $url The url parameters. @return bool
[ "Check", "if", "the", "currently", "logged", "in", "user", "is", "authorized", "to", "access", "the", "given", "url", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L161-L193
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.isGuestAction
public function isGuestAction($url) { $path = $this->getPathFromUrl($url); if (in_array($path, $this->_guestActions)) { return true; } return false; }
php
public function isGuestAction($url) { $path = $this->getPathFromUrl($url); if (in_array($path, $this->_guestActions)) { return true; } return false; }
[ "public", "function", "isGuestAction", "(", "$", "url", ")", "{", "$", "path", "=", "$", "this", "->", "getPathFromUrl", "(", "$", "url", ")", ";", "if", "(", "in_array", "(", "$", "path", ",", "$", "this", "->", "_guestActions", ")", ")", "{", "re...
Check if the requested action does not require an authenticated user. -> guest action @param array $url The url parameters. @return bool
[ "Check", "if", "the", "requested", "action", "does", "not", "require", "an", "authenticated", "user", ".", "-", ">", "guest", "action" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L202-L211
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.getPathFromUrl
public function getPathFromUrl($url) { $cacheKey = md5(serialize($url)); return Cache::remember($cacheKey, function () use ($url) { $plugin = 'App'; $action = 'index'; $parsedUrl = !is_array($url) ? Router::parse($url) : $url; if (isset($parsedUrl['plugin']) && !empty($parsedUrl['plugin'])) { $plugin = $parsedUrl['plugin']; } $controller = $parsedUrl['controller']; if (isset($parsedUrl['action']) && $parsedUrl['action'] !== '') { $action = $parsedUrl['action']; } return $plugin . '.' . $controller . '.' . $action; }, 'wasabi/core/guardian_paths'); }
php
public function getPathFromUrl($url) { $cacheKey = md5(serialize($url)); return Cache::remember($cacheKey, function () use ($url) { $plugin = 'App'; $action = 'index'; $parsedUrl = !is_array($url) ? Router::parse($url) : $url; if (isset($parsedUrl['plugin']) && !empty($parsedUrl['plugin'])) { $plugin = $parsedUrl['plugin']; } $controller = $parsedUrl['controller']; if (isset($parsedUrl['action']) && $parsedUrl['action'] !== '') { $action = $parsedUrl['action']; } return $plugin . '.' . $controller . '.' . $action; }, 'wasabi/core/guardian_paths'); }
[ "public", "function", "getPathFromUrl", "(", "$", "url", ")", "{", "$", "cacheKey", "=", "md5", "(", "serialize", "(", "$", "url", ")", ")", ";", "return", "Cache", "::", "remember", "(", "$", "cacheKey", ",", "function", "(", ")", "use", "(", "$", ...
Determine the path for a given url array. @param array $url The url parameters. @return string
[ "Determine", "the", "path", "for", "a", "given", "url", "array", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L229-L249
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.getActionMap
public function getActionMap() { $plugins = $this->getLoadedPluginPaths(); $actionMap = []; foreach ($plugins as $plugin => $path) { $controllers = $this->getControllersForPlugin($plugin, $path); foreach ($controllers as $controller) { $actions = $this->introspectController($controller['path']); if (empty($actions)) { continue; } foreach ($actions as $action) { $path = "{$plugin}.{$controller['name']}.{$action}"; if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => $plugin, 'controller' => $controller['name'], 'action' => $action ]; } } } $appControllers = $this->getControllersForApp(); foreach ($appControllers as $controller) { $actions = $this->introspectController($controller['path']); if (empty($actions)) { continue; } foreach ($actions as $action) { if (strpos($controller['path'], ROOT . DS . 'src' . DS . 'Controller') === false) { $path = "App.{$controller['name']}.{$action}"; if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => 'App', 'controller' => $controller['name'], 'action' => $action ]; } else { $namespaceParts = explode(DS, substr($controller['path'], strlen(ROOT . DS . 'src' . DS . 'Controller') + 1)); array_pop($namespaceParts); $namespace = join('/', $namespaceParts); if (!empty($namespace)) { $path = "App.{$namespace}/{$controller['name']}.{$action}"; } else { $path = "App.{$controller['name']}.{$action}"; } if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => 'App', 'controller' => !empty($namespace) ? $namespace . '/' . $controller['name'] : $controller['name'], 'action' => $action ]; } } } return $actionMap; }
php
public function getActionMap() { $plugins = $this->getLoadedPluginPaths(); $actionMap = []; foreach ($plugins as $plugin => $path) { $controllers = $this->getControllersForPlugin($plugin, $path); foreach ($controllers as $controller) { $actions = $this->introspectController($controller['path']); if (empty($actions)) { continue; } foreach ($actions as $action) { $path = "{$plugin}.{$controller['name']}.{$action}"; if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => $plugin, 'controller' => $controller['name'], 'action' => $action ]; } } } $appControllers = $this->getControllersForApp(); foreach ($appControllers as $controller) { $actions = $this->introspectController($controller['path']); if (empty($actions)) { continue; } foreach ($actions as $action) { if (strpos($controller['path'], ROOT . DS . 'src' . DS . 'Controller') === false) { $path = "App.{$controller['name']}.{$action}"; if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => 'App', 'controller' => $controller['name'], 'action' => $action ]; } else { $namespaceParts = explode(DS, substr($controller['path'], strlen(ROOT . DS . 'src' . DS . 'Controller') + 1)); array_pop($namespaceParts); $namespace = join('/', $namespaceParts); if (!empty($namespace)) { $path = "App.{$namespace}/{$controller['name']}.{$action}"; } else { $path = "App.{$controller['name']}.{$action}"; } if (in_array($path, $this->_guestActions)) { continue; } $actionMap[$path] = [ 'plugin' => 'App', 'controller' => !empty($namespace) ? $namespace . '/' . $controller['name'] : $controller['name'], 'action' => $action ]; } } } return $actionMap; }
[ "public", "function", "getActionMap", "(", ")", "{", "$", "plugins", "=", "$", "this", "->", "getLoadedPluginPaths", "(", ")", ";", "$", "actionMap", "=", "[", "]", ";", "foreach", "(", "$", "plugins", "as", "$", "plugin", "=>", "$", "path", ")", "{"...
Get a mapped array of all guardable controller actions excluding the provided guest actions. @return array
[ "Get", "a", "mapped", "array", "of", "all", "guardable", "controller", "actions", "excluding", "the", "provided", "guest", "actions", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L257-L323
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.getLoadedPluginPaths
public function getLoadedPluginPaths() { $pluginPaths = []; $plugins = Plugin::loaded() ?? []; foreach ($plugins as $p) { // @TODO load active plugins from plugin manager if (in_array($p, ['DebugKit', 'Migrations'])) { continue; } $pluginPaths[$p] = Plugin::path($p); } return $pluginPaths; }
php
public function getLoadedPluginPaths() { $pluginPaths = []; $plugins = Plugin::loaded() ?? []; foreach ($plugins as $p) { // @TODO load active plugins from plugin manager if (in_array($p, ['DebugKit', 'Migrations'])) { continue; } $pluginPaths[$p] = Plugin::path($p); } return $pluginPaths; }
[ "public", "function", "getLoadedPluginPaths", "(", ")", "{", "$", "pluginPaths", "=", "[", "]", ";", "$", "plugins", "=", "Plugin", "::", "loaded", "(", ")", "??", "[", "]", ";", "foreach", "(", "$", "plugins", "as", "$", "p", ")", "{", "// @TODO loa...
Get the paths of all installed and active plugins. @return array
[ "Get", "the", "paths", "of", "all", "installed", "and", "active", "plugins", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L330-L344
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.getControllersForPlugin
public function getControllersForPlugin($plugin, $pluginPath) { $controllers = []; $Folder = new Folder(); $ctrlFolder = $Folder->cd($pluginPath . DS . 'src' . DS . 'Controller'); if (!empty($ctrlFolder)) { $files = $Folder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === $plugin . 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $Folder->path . DS . $f ]; } } return $controllers; }
php
public function getControllersForPlugin($plugin, $pluginPath) { $controllers = []; $Folder = new Folder(); $ctrlFolder = $Folder->cd($pluginPath . DS . 'src' . DS . 'Controller'); if (!empty($ctrlFolder)) { $files = $Folder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === $plugin . 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $Folder->path . DS . $f ]; } } return $controllers; }
[ "public", "function", "getControllersForPlugin", "(", "$", "plugin", ",", "$", "pluginPath", ")", "{", "$", "controllers", "=", "[", "]", ";", "$", "Folder", "=", "new", "Folder", "(", ")", ";", "$", "ctrlFolder", "=", "$", "Folder", "->", "cd", "(", ...
Retrieve all controller names + paths for a given plugin. @param string $plugin The name of the plugin. @param string $pluginPath The path of the plugin. @return array @todo: Refactor https://scrutinizer-ci.com/g/wasabi-cms/core/indices/834500/duplications/543470
[ "Retrieve", "all", "controller", "names", "+", "paths", "for", "a", "given", "plugin", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L354-L378
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.getControllersForApp
public function getControllersForApp() { $controllers = []; $ctrlFolder = new Folder(); /** @var Folder $ctrlFolder */ $ctrlFolder->cd(ROOT . DS . 'src' . DS . 'Controller'); if (!empty($ctrlFolder)) { $files = $ctrlFolder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f ]; } $subFolders = $ctrlFolder->read(true, false, true)[0]; foreach ($subFolders as $subFolder) { $ctrlFolder->cd($subFolder); $files = $ctrlFolder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f ]; } } } return $controllers; }
php
public function getControllersForApp() { $controllers = []; $ctrlFolder = new Folder(); /** @var Folder $ctrlFolder */ $ctrlFolder->cd(ROOT . DS . 'src' . DS . 'Controller'); if (!empty($ctrlFolder)) { $files = $ctrlFolder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f ]; } $subFolders = $ctrlFolder->read(true, false, true)[0]; foreach ($subFolders as $subFolder) { $ctrlFolder->cd($subFolder); $files = $ctrlFolder->find('.*Controller\.php$'); $subLength = strlen('Controller.php'); foreach ($files as $f) { $filename = basename($f); if ($filename === 'AppController.php') { continue; } $ctrlName = substr($filename, 0, strlen($filename) - $subLength); $controllers[] = [ 'name' => $ctrlName, 'path' => $ctrlFolder->path . DS . $f ]; } } } return $controllers; }
[ "public", "function", "getControllersForApp", "(", ")", "{", "$", "controllers", "=", "[", "]", ";", "$", "ctrlFolder", "=", "new", "Folder", "(", ")", ";", "/** @var Folder $ctrlFolder */", "$", "ctrlFolder", "->", "cd", "(", "ROOT", ".", "DS", ".", "'src...
Retrieve all controller names + paths for the app src. @return array
[ "Retrieve", "all", "controller", "names", "+", "paths", "for", "the", "app", "src", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L385-L427
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent.introspectController
public function introspectController($controllerPath) { $content = file_get_contents($controllerPath); preg_match_all('/public\s+function\s+\&?\s*([^(]+)/', $content, $methods); $guardableActions = []; foreach ($methods[1] as $m) { if (in_array($m, ['__construct', 'initialize', 'isAuthorized', 'setRequest', 'invokeAction', 'beforeFilter', 'beforeRender', 'beforeRedirect', 'afterFilter'])) { continue; } $guardableActions[] = $m; } return $guardableActions; }
php
public function introspectController($controllerPath) { $content = file_get_contents($controllerPath); preg_match_all('/public\s+function\s+\&?\s*([^(]+)/', $content, $methods); $guardableActions = []; foreach ($methods[1] as $m) { if (in_array($m, ['__construct', 'initialize', 'isAuthorized', 'setRequest', 'invokeAction', 'beforeFilter', 'beforeRender', 'beforeRedirect', 'afterFilter'])) { continue; } $guardableActions[] = $m; } return $guardableActions; }
[ "public", "function", "introspectController", "(", "$", "controllerPath", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "controllerPath", ")", ";", "preg_match_all", "(", "'/public\\s+function\\s+\\&?\\s*([^(]+)/'", ",", "$", "content", ",", "$", "me...
Retrieve all controller actions from a given controller. @param string $controllerPath The path of a specific controller. @return array
[ "Retrieve", "all", "controller", "actions", "from", "a", "given", "controller", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L435-L449
train
wasabi-cms/core
src/Controller/Component/GuardianComponent.php
GuardianComponent._getGroupPermissions
protected function _getGroupPermissions() { if (get_class($this->GroupPermissions) === 'GroupPermission') { return $this->GroupPermissions; } return $this->GroupPermissions = TableRegistry::get('Wasabi/Core.GroupPermissions'); }
php
protected function _getGroupPermissions() { if (get_class($this->GroupPermissions) === 'GroupPermission') { return $this->GroupPermissions; } return $this->GroupPermissions = TableRegistry::get('Wasabi/Core.GroupPermissions'); }
[ "protected", "function", "_getGroupPermissions", "(", ")", "{", "if", "(", "get_class", "(", "$", "this", "->", "GroupPermissions", ")", "===", "'GroupPermission'", ")", "{", "return", "$", "this", "->", "GroupPermissions", ";", "}", "return", "$", "this", "...
Get or initialize an instance of the GroupPermissionsTable. @return GroupPermissionsTable
[ "Get", "or", "initialize", "an", "instance", "of", "the", "GroupPermissionsTable", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/Component/GuardianComponent.php#L456-L462
train
webriq/core
module/Core/src/Grid/Core/Model/Captcha.php
Captcha.isValid
public function isValid( $id, $value, $context = null ) { return $this->createRegeneratable( array( 'id' => $id ) ) ->isValid( $value, $context ); }
php
public function isValid( $id, $value, $context = null ) { return $this->createRegeneratable( array( 'id' => $id ) ) ->isValid( $value, $context ); }
[ "public", "function", "isValid", "(", "$", "id", ",", "$", "value", ",", "$", "context", "=", "null", ")", "{", "return", "$", "this", "->", "createRegeneratable", "(", "array", "(", "'id'", "=>", "$", "id", ")", ")", "->", "isValid", "(", "$", "va...
A captcha is valid by id @param string $id @param string $value @param array|object $context @return bool
[ "A", "captcha", "is", "valid", "by", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Captcha.php#L50-L54
train
narrowspark/automatic-common
Traits/PhpFileMarkerTrait.php
PhpFileMarkerTrait.isFileMarked
protected function isFileMarked(string $packageName, string $file): bool { return \is_file($file) && \strpos(\file_get_contents($file), \sprintf('/** > %s **/', $packageName)) !== false; }
php
protected function isFileMarked(string $packageName, string $file): bool { return \is_file($file) && \strpos(\file_get_contents($file), \sprintf('/** > %s **/', $packageName)) !== false; }
[ "protected", "function", "isFileMarked", "(", "string", "$", "packageName", ",", "string", "$", "file", ")", ":", "bool", "{", "return", "\\", "is_file", "(", "$", "file", ")", "&&", "\\", "strpos", "(", "\\", "file_get_contents", "(", "$", "file", ")", ...
Check if file is marked. @param string $packageName @param string $file @return bool
[ "Check", "if", "file", "is", "marked", "." ]
415f0d566932847c3ca799e06f27e588bd244881
https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Traits/PhpFileMarkerTrait.php#L15-L18
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.doRequest
protected function doRequest(Client $client, $url, $options = array()) { $options += array( 'urlParams' => array(), 'queryParams' => array(), 'method' => static::METHOD_GET, ); $token = $client->getToken(); // Replace parameters in the url. $urlReplacements = $this->getParameterReplacements($options['urlParams'], $token); $url = str_replace(array_keys($urlReplacements), array_values($urlReplacements), $url); // Replace query parameters. $queryReplacements = $this->getParameterReplacements($options['queryParams'], $token); $queryParams = array_merge($options['queryParams'], $queryReplacements); // Process query parameters. $queryParams = $this->processQueryParameters($queryParams); // Set the request uri. $client->setUri($this->credentials->getEnvironment()->getBaseUrl() . $url); // Set the parameters. switch ($options['method']) { case static::METHOD_POST: $client->setParameterPost($queryParams); break; case static::METHOD_GET: default: $client->setParameterGet($queryParams); break; } // Set the request method and send the request. $client->setMethod($options['method']); $response = $client->send(); // Below are all possible error codes as described bij de api // documentation. $statusCode = $response->getStatusCode(); switch ($statusCode) { // No content. case 204: return null; // Bad request. case 400: // Missing Authorization header. case 401: // Unauthorized. case 403: // Not found. case 404: // Misdirected request. case 421: // Any other undocumented error codes. case $statusCode >= 400: throw new BibException($response->getReasonPhrase(), $response->getStatusCode()); } $doc = new \DOMDocument(); $doc->loadXML($response->getBody()); return $doc; }
php
protected function doRequest(Client $client, $url, $options = array()) { $options += array( 'urlParams' => array(), 'queryParams' => array(), 'method' => static::METHOD_GET, ); $token = $client->getToken(); // Replace parameters in the url. $urlReplacements = $this->getParameterReplacements($options['urlParams'], $token); $url = str_replace(array_keys($urlReplacements), array_values($urlReplacements), $url); // Replace query parameters. $queryReplacements = $this->getParameterReplacements($options['queryParams'], $token); $queryParams = array_merge($options['queryParams'], $queryReplacements); // Process query parameters. $queryParams = $this->processQueryParameters($queryParams); // Set the request uri. $client->setUri($this->credentials->getEnvironment()->getBaseUrl() . $url); // Set the parameters. switch ($options['method']) { case static::METHOD_POST: $client->setParameterPost($queryParams); break; case static::METHOD_GET: default: $client->setParameterGet($queryParams); break; } // Set the request method and send the request. $client->setMethod($options['method']); $response = $client->send(); // Below are all possible error codes as described bij de api // documentation. $statusCode = $response->getStatusCode(); switch ($statusCode) { // No content. case 204: return null; // Bad request. case 400: // Missing Authorization header. case 401: // Unauthorized. case 403: // Not found. case 404: // Misdirected request. case 421: // Any other undocumented error codes. case $statusCode >= 400: throw new BibException($response->getReasonPhrase(), $response->getStatusCode()); } $doc = new \DOMDocument(); $doc->loadXML($response->getBody()); return $doc; }
[ "protected", "function", "doRequest", "(", "Client", "$", "client", ",", "$", "url", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "+=", "array", "(", "'urlParams'", "=>", "array", "(", ")", ",", "'queryParams'", "=>", "array",...
Executes a request. @param \ZendOAuth\Client $client The client that will execute the request. @param string $url The URL to request. @param array $options An array of options: - urlParams: An array of replacements for the url: $url: 'https://mijn.bibliotheek.be/openbibid/rest/library/id/:id' urlParams: [':id' => 2199] Values between {} are taken from the access token: $url: 'https://mijn.bibliotheek.be/openbibid/rest/user/info/:userId' urlParams: [':userId' => '{userId}'] - queryParams: An array of query parameters for GET requests or POST data for POST requests. - method: One of the \Zend\Http\Request::METHOD_* constants. @return \DOMDocument|null A \DOMDocument containing the XML from the response, null if HTTP status code 204 (No content) was returned. @throws \OpenBibIdApi\Exception\BibException When any of the 400, 401, 403, 404 or 421 status codes were returned.
[ "Executes", "a", "request", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L227-L290
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.getParameterReplacements
protected function getParameterReplacements($parameters, TokenInterface $token) { $replacements = $parameters; foreach ($parameters as $key => $param) { if (strpos($param, '{') === 0 && strpos($param, '}') === strlen($param) - 1) { $replacements[$key] = $token->getParam(substr($param, 1, -1)); } } return $replacements; }
php
protected function getParameterReplacements($parameters, TokenInterface $token) { $replacements = $parameters; foreach ($parameters as $key => $param) { if (strpos($param, '{') === 0 && strpos($param, '}') === strlen($param) - 1) { $replacements[$key] = $token->getParam(substr($param, 1, -1)); } } return $replacements; }
[ "protected", "function", "getParameterReplacements", "(", "$", "parameters", ",", "TokenInterface", "$", "token", ")", "{", "$", "replacements", "=", "$", "parameters", ";", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "param", ")", "{", ...
Replace values in an array with parameters from a token. @param array $parameters An array with parameters to replace. Values surrounded with {} will be replaced with their corresponding token parameter. @param \ZendOAuth\Token\TokenInterface $token The token with the parameters. @return array An array of replacements, keyed by the corresponding array key in $parameters.
[ "Replace", "values", "in", "an", "array", "with", "parameters", "from", "a", "token", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L305-L314
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.fetchRequestToken
protected function fetchRequestToken() { // Fetching a new request token. Remove any old access tokens. $this->storage->delete(static::BIB_ACCESS_TOKEN); // Fetch a request token. $token = $this->consumer->getRequestToken(); // Persist the token to storage. $this->storage->set(static::BIB_REQUEST_TOKEN, $token); return $this; }
php
protected function fetchRequestToken() { // Fetching a new request token. Remove any old access tokens. $this->storage->delete(static::BIB_ACCESS_TOKEN); // Fetch a request token. $token = $this->consumer->getRequestToken(); // Persist the token to storage. $this->storage->set(static::BIB_REQUEST_TOKEN, $token); return $this; }
[ "protected", "function", "fetchRequestToken", "(", ")", "{", "// Fetching a new request token. Remove any old access tokens.", "$", "this", "->", "storage", "->", "delete", "(", "static", "::", "BIB_ACCESS_TOKEN", ")", ";", "// Fetch a request token.", "$", "token", "=", ...
Fetches the request token. @return $this
[ "Fetches", "the", "request", "token", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L321-L331
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.fetchAccessToken
protected function fetchAccessToken($queryData, $retry = true) { if (!$this->hasRequestToken()) { $this->consumer->setCallbackUrl($this->getCurrentUri()); $this->fetchRequestToken(); $this->consumer->redirect(array('hint' => $this->getHint())); } try { $token = $this->consumer->getAccessToken( $queryData, $this->getRequestToken() ); } catch (InvalidArgumentException $e) { if ($retry) { // We might have a corrupt/invalid request token. Delete it and // retry once. $this->storage->delete(static::BIB_REQUEST_TOKEN); $this->storage->delete(static::BIB_ACCESS_TOKEN); return $this->fetchAccessToken($queryData, false); } throw $e; } // We got a new access token, we can remove the request token now. $this->storage->delete(static::BIB_REQUEST_TOKEN); $this->storage->set(static::BIB_ACCESS_TOKEN, $token); return $this; }
php
protected function fetchAccessToken($queryData, $retry = true) { if (!$this->hasRequestToken()) { $this->consumer->setCallbackUrl($this->getCurrentUri()); $this->fetchRequestToken(); $this->consumer->redirect(array('hint' => $this->getHint())); } try { $token = $this->consumer->getAccessToken( $queryData, $this->getRequestToken() ); } catch (InvalidArgumentException $e) { if ($retry) { // We might have a corrupt/invalid request token. Delete it and // retry once. $this->storage->delete(static::BIB_REQUEST_TOKEN); $this->storage->delete(static::BIB_ACCESS_TOKEN); return $this->fetchAccessToken($queryData, false); } throw $e; } // We got a new access token, we can remove the request token now. $this->storage->delete(static::BIB_REQUEST_TOKEN); $this->storage->set(static::BIB_ACCESS_TOKEN, $token); return $this; }
[ "protected", "function", "fetchAccessToken", "(", "$", "queryData", ",", "$", "retry", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "hasRequestToken", "(", ")", ")", "{", "$", "this", "->", "consumer", "->", "setCallbackUrl", "(", "$", "th...
Fetches the access token. @param array $queryData GET data returned in user's redirect from Provider. @param bool $retry Internal use only. @return $this @throws \ZendOAuth\Exception\InvalidArgumentException On invalid authorization token.
[ "Fetches", "the", "access", "token", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L346-L373
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.getCurrentUri
protected function getCurrentUri() { $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false; if (!$uri) { $uri = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['argv']) || isset($_SERVER['QUERY_STRING'])) { $uri .= '?'; $uri .= isset($_SERVER['argv']) ? $_SERVER['argv'][0] : $_SERVER['QUERY_STRING']; } } return 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . '/' . ltrim($uri, '/'); }
php
protected function getCurrentUri() { $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : false; if (!$uri) { $uri = $_SERVER['SCRIPT_NAME']; if (isset($_SERVER['argv']) || isset($_SERVER['QUERY_STRING'])) { $uri .= '?'; $uri .= isset($_SERVER['argv']) ? $_SERVER['argv'][0] : $_SERVER['QUERY_STRING']; } } return 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . '/' . ltrim($uri, '/'); }
[ "protected", "function", "getCurrentUri", "(", ")", "{", "$", "uri", "=", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", "?", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ":", "false", ";", "if", "(", "!", "$", "uri", ")", "{", "$", "u...
Gets the current uri. @return string The current uri.
[ "Gets", "the", "current", "uri", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L425-L445
train
digipolisgent/openbib-id-api
src/Consumer/BibConsumer.php
BibConsumer.processQueryParameters
protected function processQueryParameters($queryParams) { foreach ($queryParams as $name => $value) { if (is_bool($value)) { $queryParams[$name] = $value ? 'true' : 'false'; } } return $queryParams; }
php
protected function processQueryParameters($queryParams) { foreach ($queryParams as $name => $value) { if (is_bool($value)) { $queryParams[$name] = $value ? 'true' : 'false'; } } return $queryParams; }
[ "protected", "function", "processQueryParameters", "(", "$", "queryParams", ")", "{", "foreach", "(", "$", "queryParams", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "queryParams", "[", ...
Processes an array of query parameters to a readable format. @param array $queryParams The parameters to be processes. @return array The processed array of query parameters.
[ "Processes", "an", "array", "of", "query", "parameters", "to", "a", "readable", "format", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Consumer/BibConsumer.php#L456-L464
train
Zeeml/Dataset
src/DataSet.php
DataSet.prepare
public function prepare(Mapper $mapper) { if ($this->isPrepared()) { throw new DataSetPreparationException('DataSet is already prepared'); } //Split each row of the dataSet into inputs and outputs based on the mapper and the policies //Then re-parse the dataSet to fill in all the fields that used special policies (like Avg) and create the instances $this->map($mapper)->createInstances(); //mark the dataSet as prepared $this->isPrepared = true; }
php
public function prepare(Mapper $mapper) { if ($this->isPrepared()) { throw new DataSetPreparationException('DataSet is already prepared'); } //Split each row of the dataSet into inputs and outputs based on the mapper and the policies //Then re-parse the dataSet to fill in all the fields that used special policies (like Avg) and create the instances $this->map($mapper)->createInstances(); //mark the dataSet as prepared $this->isPrepared = true; }
[ "public", "function", "prepare", "(", "Mapper", "$", "mapper", ")", "{", "if", "(", "$", "this", "->", "isPrepared", "(", ")", ")", "{", "throw", "new", "DataSetPreparationException", "(", "'DataSet is already prepared'", ")", ";", "}", "//Split each row of the ...
Prepare data to be trained. MUST be called prior to any call @param Mapper $mapper Data Mapper @throws DataSetPreparationException
[ "Prepare", "data", "to", "be", "trained", ".", "MUST", "be", "called", "prior", "to", "any", "call" ]
8809ba48c99bce1e9fe7e6431be7022e02ff027a
https://github.com/Zeeml/Dataset/blob/8809ba48c99bce1e9fe7e6431be7022e02ff027a/src/DataSet.php#L46-L57
train
Zeeml/Dataset
src/DataSet.php
DataSet.map
protected function map(Mapper $mapper): DataSet { $this->mapper = $mapper; $this->instances = $this->inputsMatrix = $this->outputsMatrix = []; foreach ($this->rawData as &$row) { //Split each row of the raw DataSet into inputs and outputs list($inputs, $outputs) = $this->mapper->map($row); //If the mapping was successfully made (the cleaners allowed the row to pass) if ($inputs && $outputs) { //Increment size $this->size++; //Save the inputs matrix $this->inputsMatrix[] = $inputs; $this->numberOfInputs = $this->numberOfInputs ?? count($inputs); //save the output matrix $this->outputsMatrix[] = $outputs; $this->numberOfOutputs = $this->numberOfOutputs ?? count($outputs); } foreach ($row as $key => $value) { //calculate the frequency at which each value occurs $this->frequency[$key][$value] = $this->frequency[$key][$value] ?? 0; $this->frequency[$key][$value]++; //calculate the rawAverage of each column of the raw DataSet, since cleaners might ignore a row $this->rawAverage[$key] = $this->rawAverage[$key] ?? 0; $this->rawAverage[$key] += floatval($value) / $this->rawSize; } } return $this; }
php
protected function map(Mapper $mapper): DataSet { $this->mapper = $mapper; $this->instances = $this->inputsMatrix = $this->outputsMatrix = []; foreach ($this->rawData as &$row) { //Split each row of the raw DataSet into inputs and outputs list($inputs, $outputs) = $this->mapper->map($row); //If the mapping was successfully made (the cleaners allowed the row to pass) if ($inputs && $outputs) { //Increment size $this->size++; //Save the inputs matrix $this->inputsMatrix[] = $inputs; $this->numberOfInputs = $this->numberOfInputs ?? count($inputs); //save the output matrix $this->outputsMatrix[] = $outputs; $this->numberOfOutputs = $this->numberOfOutputs ?? count($outputs); } foreach ($row as $key => $value) { //calculate the frequency at which each value occurs $this->frequency[$key][$value] = $this->frequency[$key][$value] ?? 0; $this->frequency[$key][$value]++; //calculate the rawAverage of each column of the raw DataSet, since cleaners might ignore a row $this->rawAverage[$key] = $this->rawAverage[$key] ?? 0; $this->rawAverage[$key] += floatval($value) / $this->rawSize; } } return $this; }
[ "protected", "function", "map", "(", "Mapper", "$", "mapper", ")", ":", "DataSet", "{", "$", "this", "->", "mapper", "=", "$", "mapper", ";", "$", "this", "->", "instances", "=", "$", "this", "->", "inputsMatrix", "=", "$", "this", "->", "outputsMatrix...
Is called by the prepare method, maps the data grabbed by the processor into instances objects @param Mapper $mapper @return DataSet
[ "Is", "called", "by", "the", "prepare", "method", "maps", "the", "data", "grabbed", "by", "the", "processor", "into", "instances", "objects" ]
8809ba48c99bce1e9fe7e6431be7022e02ff027a
https://github.com/Zeeml/Dataset/blob/8809ba48c99bce1e9fe7e6431be7022e02ff027a/src/DataSet.php#L64-L97
train
osflab/application
OsfApplication.php
OsfApplication.run
public function run() { $this->init(); try { $this->bootstrap(); $this->route(); $this->dispatch(); } catch (Exception $e) { if (APPLICATION_ENV == self::ENV_DEV) { var_dump($e); } else { throw $e; } } return $this; }
php
public function run() { $this->init(); try { $this->bootstrap(); $this->route(); $this->dispatch(); } catch (Exception $e) { if (APPLICATION_ENV == self::ENV_DEV) { var_dump($e); } else { throw $e; } } return $this; }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "init", "(", ")", ";", "try", "{", "$", "this", "->", "bootstrap", "(", ")", ";", "$", "this", "->", "route", "(", ")", ";", "$", "this", "->", "dispatch", "(", ")", ";", "}", "ca...
bootstrap + route + dispatch @return $this @throws \Exception
[ "bootstrap", "+", "route", "+", "dispatch" ]
89386523f9749b6b455ecb0be853879b31b1bbf7
https://github.com/osflab/application/blob/89386523f9749b6b455ecb0be853879b31b1bbf7/OsfApplication.php#L56-L71
train
osflab/application
OsfApplication.php
OsfApplication.bootstrap
public function bootstrap() { $config = Container::getConfig(); $commonConfigFile = APPLICATION_PATH . '/App/' . Router::getDefaultControllerName(true) . '/Config/application.php'; $config->appendConfig(require $commonConfigFile); $bootstrapFile = APPLICATION_PATH . '/App/' . Router::getDefaultControllerName(true) . '/Bootstrap.php'; if (!file_exists($bootstrapFile)) { throw new ArchException('Bootstrap file ' . $bootstrapFile . ' is needed'); } //self::debug('Begin bootstrap'); Container::getBootstrap()->bootstrap(); //self::debug('End bootstrap'); return $this; }
php
public function bootstrap() { $config = Container::getConfig(); $commonConfigFile = APPLICATION_PATH . '/App/' . Router::getDefaultControllerName(true) . '/Config/application.php'; $config->appendConfig(require $commonConfigFile); $bootstrapFile = APPLICATION_PATH . '/App/' . Router::getDefaultControllerName(true) . '/Bootstrap.php'; if (!file_exists($bootstrapFile)) { throw new ArchException('Bootstrap file ' . $bootstrapFile . ' is needed'); } //self::debug('Begin bootstrap'); Container::getBootstrap()->bootstrap(); //self::debug('End bootstrap'); return $this; }
[ "public", "function", "bootstrap", "(", ")", "{", "$", "config", "=", "Container", "::", "getConfig", "(", ")", ";", "$", "commonConfigFile", "=", "APPLICATION_PATH", ".", "'/App/'", ".", "Router", "::", "getDefaultControllerName", "(", "true", ")", ".", "'/...
Configuration + Bootstraping @return $this @throws ArchException
[ "Configuration", "+", "Bootstraping" ]
89386523f9749b6b455ecb0be853879b31b1bbf7
https://github.com/osflab/application/blob/89386523f9749b6b455ecb0be853879b31b1bbf7/OsfApplication.php#L101-L115
train
osflab/application
OsfApplication.php
OsfApplication.route
public function route() { PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_ROUTE); Container::getRouter()->route(); self::debug('Route: ' . Container::getRouter()->buildUri()); PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_ROUTE); return $this; }
php
public function route() { PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_ROUTE); Container::getRouter()->route(); self::debug('Route: ' . Container::getRouter()->buildUri()); PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_ROUTE); return $this; }
[ "public", "function", "route", "(", ")", "{", "PluginManager", "::", "handleApplicationPlugins", "(", "PluginManager", "::", "STEP_BEFORE_ROUTE", ")", ";", "Container", "::", "getRouter", "(", ")", "->", "route", "(", ")", ";", "self", "::", "debug", "(", "'...
Call router before dispatching @return $this
[ "Call", "router", "before", "dispatching" ]
89386523f9749b6b455ecb0be853879b31b1bbf7
https://github.com/osflab/application/blob/89386523f9749b6b455ecb0be853879b31b1bbf7/OsfApplication.php#L121-L128
train
osflab/application
OsfApplication.php
OsfApplication.dispatch
public function dispatch() { $request = Container::getRequest(); $response = Container::getResponse(); PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_DISPATCH_LOOP); //self::debug('Begin dispatch loop...'); while (!$this->dispatched) { try { PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_ACTION); //self::debug('Begin dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']'); $this->dispatchProcess($request, $response); //self::debug('End dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']'); PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_ACTION); } catch (Exception $e) { if ($request->getController(false) == 'event' && $request->getAction(false) == 'error') { throw $e; } Container::getView()->addValue('exception', $e); $this->renderView = true; $request->setController('event')->setAction('error'); $this->setDispatched(false); } } PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_DISPATCH_LOOP); self::debug('End dispatch loop'); if ($this->dispatched && $this->renderLayout) { $layout = Container::getConfig()->getConfig('layout'); if ($layout !== null) { if (!file_exists($layout)) { throw new ArchException('Layout file ' . $layout . ' not found'); } $response->setBody(Container::getLayout(true)->render($layout)); } } if ($this->renderResponse) { $response->fixHeaders()->putTypeHeadersInResponse(); foreach ($response->getHeaders() as $header) { header($header); } $response->executeCallback(); if ($response->hasBody()) { echo $response->getBody(); } } return $this; }
php
public function dispatch() { $request = Container::getRequest(); $response = Container::getResponse(); PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_DISPATCH_LOOP); //self::debug('Begin dispatch loop...'); while (!$this->dispatched) { try { PluginManager::handleApplicationPlugins(PluginManager::STEP_BEFORE_ACTION); //self::debug('Begin dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']'); $this->dispatchProcess($request, $response); //self::debug('End dispatch ' . $request->getController() . '::' . $request->getAction() . ' [' . json_encode($request->getParams()) . ']'); PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_ACTION); } catch (Exception $e) { if ($request->getController(false) == 'event' && $request->getAction(false) == 'error') { throw $e; } Container::getView()->addValue('exception', $e); $this->renderView = true; $request->setController('event')->setAction('error'); $this->setDispatched(false); } } PluginManager::handleApplicationPlugins(PluginManager::STEP_AFTER_DISPATCH_LOOP); self::debug('End dispatch loop'); if ($this->dispatched && $this->renderLayout) { $layout = Container::getConfig()->getConfig('layout'); if ($layout !== null) { if (!file_exists($layout)) { throw new ArchException('Layout file ' . $layout . ' not found'); } $response->setBody(Container::getLayout(true)->render($layout)); } } if ($this->renderResponse) { $response->fixHeaders()->putTypeHeadersInResponse(); foreach ($response->getHeaders() as $header) { header($header); } $response->executeCallback(); if ($response->hasBody()) { echo $response->getBody(); } } return $this; }
[ "public", "function", "dispatch", "(", ")", "{", "$", "request", "=", "Container", "::", "getRequest", "(", ")", ";", "$", "response", "=", "Container", "::", "getResponse", "(", ")", ";", "PluginManager", "::", "handleApplicationPlugins", "(", "PluginManager"...
Launch the dispatch loop @throws \Exception @return $this
[ "Launch", "the", "dispatch", "loop" ]
89386523f9749b6b455ecb0be853879b31b1bbf7
https://github.com/osflab/application/blob/89386523f9749b6b455ecb0be853879b31b1bbf7/OsfApplication.php#L135-L184
train
99designs/ergo
classes/Ergo/Routing/FilteredController.php
FilteredController._applyFilter
private function _applyFilter($chain, $object) { foreach($chain as $filter) { if(!$object = call_user_func($filter, $object)) throw new Exception("Filter returned null"); } return $object; }
php
private function _applyFilter($chain, $object) { foreach($chain as $filter) { if(!$object = call_user_func($filter, $object)) throw new Exception("Filter returned null"); } return $object; }
[ "private", "function", "_applyFilter", "(", "$", "chain", ",", "$", "object", ")", "{", "foreach", "(", "$", "chain", "as", "$", "filter", ")", "{", "if", "(", "!", "$", "object", "=", "call_user_func", "(", "$", "filter", ",", "$", "object", ")", ...
Apply a chain of filters to an object @return object
[ "Apply", "a", "chain", "of", "filters", "to", "an", "object" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/FilteredController.php#L48-L57
train
99designs/ergo
classes/Ergo/Routing/FilteredController.php
FilteredController.filter
protected function filter($request) { return $this->_applyFilter($this->_responses, $this->_controller->execute( $this->_applyFilter($this->_requests, $request) )); }
php
protected function filter($request) { return $this->_applyFilter($this->_responses, $this->_controller->execute( $this->_applyFilter($this->_requests, $request) )); }
[ "protected", "function", "filter", "(", "$", "request", ")", "{", "return", "$", "this", "->", "_applyFilter", "(", "$", "this", "->", "_responses", ",", "$", "this", "->", "_controller", "->", "execute", "(", "$", "this", "->", "_applyFilter", "(", "$",...
Filter a request and response and return the response @return response
[ "Filter", "a", "request", "and", "response", "and", "return", "the", "response" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/FilteredController.php#L63-L69
train
koinephp/Http
lib/Koine/Http/Request.php
Request.getMethod
public function getMethod() { $fakeMethod = $this->params['_method']; if ($fakeMethod) { if (in_array($fakeMethod, $this->acceptedMethods)) { return $fakeMethod; } throw new Exceptions\InvalidRequestMethodException( "'$fakeMethod' is not a valid request method" ); } return $this->environment['REQUEST_METHOD']; }
php
public function getMethod() { $fakeMethod = $this->params['_method']; if ($fakeMethod) { if (in_array($fakeMethod, $this->acceptedMethods)) { return $fakeMethod; } throw new Exceptions\InvalidRequestMethodException( "'$fakeMethod' is not a valid request method" ); } return $this->environment['REQUEST_METHOD']; }
[ "public", "function", "getMethod", "(", ")", "{", "$", "fakeMethod", "=", "$", "this", "->", "params", "[", "'_method'", "]", ";", "if", "(", "$", "fakeMethod", ")", "{", "if", "(", "in_array", "(", "$", "fakeMethod", ",", "$", "this", "->", "accepte...
Get the request method @return string
[ "Get", "the", "request", "method" ]
90a777d779f326d691e1092de6e1936a94764691
https://github.com/koinephp/Http/blob/90a777d779f326d691e1092de6e1936a94764691/lib/Koine/Http/Request.php#L189-L204
train
kambo-1st/HttpMessage
src/Factories/String/UriFactory.php
UriFactory.create
public function create($uri) { list($scheme, $host, $port, $path, $query, $fragment, $user, $pass) = $this->parseUrl($uri); return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass); }
php
public function create($uri) { list($scheme, $host, $port, $path, $query, $fragment, $user, $pass) = $this->parseUrl($uri); return new Uri($scheme, $host, $port, $path, $query, $fragment, $user, $pass); }
[ "public", "function", "create", "(", "$", "uri", ")", "{", "list", "(", "$", "scheme", ",", "$", "host", ",", "$", "port", ",", "$", "path", ",", "$", "query", ",", "$", "fragment", ",", "$", "user", ",", "$", "pass", ")", "=", "$", "this", "...
Create new Uri from provided string. @param string $uri uri that will be parsed into URI object @return Uri Instance of Uri based on provided string
[ "Create", "new", "Uri", "from", "provided", "string", "." ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Factories/String/UriFactory.php#L23-L28
train
kambo-1st/HttpMessage
src/Factories/String/UriFactory.php
UriFactory.parseUrl
protected function parseUrl($uri) { $parsedUrl = parse_url($uri); return [ isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : '', isset($parsedUrl['host']) ? $parsedUrl['host'] : '', isset($parsedUrl['port']) ? $parsedUrl['port'] : null, isset($parsedUrl['path']) ? $parsedUrl['path'] : '/', isset($parsedUrl['query']) ? $parsedUrl['query'] : '', isset($parsedUrl['fragment']) ? $parsedUrl['fragment'] : '', isset($parsedUrl['user']) ? $parsedUrl['user'] : '', isset($parsedUrl['pass']) ? $parsedUrl['pass'] : '' ]; }
php
protected function parseUrl($uri) { $parsedUrl = parse_url($uri); return [ isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : '', isset($parsedUrl['host']) ? $parsedUrl['host'] : '', isset($parsedUrl['port']) ? $parsedUrl['port'] : null, isset($parsedUrl['path']) ? $parsedUrl['path'] : '/', isset($parsedUrl['query']) ? $parsedUrl['query'] : '', isset($parsedUrl['fragment']) ? $parsedUrl['fragment'] : '', isset($parsedUrl['user']) ? $parsedUrl['user'] : '', isset($parsedUrl['pass']) ? $parsedUrl['pass'] : '' ]; }
[ "protected", "function", "parseUrl", "(", "$", "uri", ")", "{", "$", "parsedUrl", "=", "parse_url", "(", "$", "uri", ")", ";", "return", "[", "isset", "(", "$", "parsedUrl", "[", "'scheme'", "]", ")", "?", "$", "parsedUrl", "[", "'scheme'", "]", ":",...
Parse uri to array with individual parts @param string $uri url that will be parsed into array with individual parts @return Array Individual parts of uri in array
[ "Parse", "uri", "to", "array", "with", "individual", "parts" ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Factories/String/UriFactory.php#L37-L51
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendTextMsgToXmlString
protected function sendTextMsgToXmlString(WxSendTextMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Content><![CDATA[%s]]></Content> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getContent() ); return $result; }
php
protected function sendTextMsgToXmlString(WxSendTextMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Content><![CDATA[%s]]></Content> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getContent() ); return $result; }
[ "protected", "function", "sendTextMsgToXmlString", "(", "WxSendTextMsg", "$", "msg", ")", "{", "$", "formatStr", "=", " <<<XML\n<xml>\n<ToUserName><![CDATA[%s]]></ToUserName>\n<FromUserName><![CDATA[%s]]></FromUserName>\n<CreateTime>%d</CreateTime>\n<MsgType><![CDATA[%s]]></MsgType>\n<Conten...
formatter WxSendTextMsg to xml string @param WxSendTextMsg $msg @return string
[ "formatter", "WxSendTextMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L36-L56
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendImageMsgToXmlString
protected function sendImageMsgToXmlString(WxSendImageMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Image> <MediaId><![CDATA[%s]]></MediaId> </Image> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
php
protected function sendImageMsgToXmlString(WxSendImageMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Image> <MediaId><![CDATA[%s]]></MediaId> </Image> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
[ "protected", "function", "sendImageMsgToXmlString", "(", "WxSendImageMsg", "$", "msg", ")", "{", "$", "formatStr", "=", " <<<XML\n<xml>\n<ToUserName><![CDATA[%s]]></ToUserName>\n<FromUserName><![CDATA[%s]]></FromUserName>\n<CreateTime>%d</CreateTime>\n<MsgType><![CDATA[%s]]></MsgType>\n<Imag...
formatter WxSendImageMsg to xml string @param WxSendImageMsg $msg @return string
[ "formatter", "WxSendImageMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L63-L85
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendVoiceMsgToXmlString
protected function sendVoiceMsgToXmlString(WxSendVoiceMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Voice> <MediaId><![CDATA[%s]]></MediaId> </Voice> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
php
protected function sendVoiceMsgToXmlString(WxSendVoiceMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Voice> <MediaId><![CDATA[%s]]></MediaId> </Voice> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
[ "protected", "function", "sendVoiceMsgToXmlString", "(", "WxSendVoiceMsg", "$", "msg", ")", "{", "$", "formatStr", "=", " <<<XML\n<xml>\n<ToUserName><![CDATA[%s]]></ToUserName>\n<FromUserName><![CDATA[%s]]></FromUserName>\n<CreateTime>%d</CreateTime>\n<MsgType><![CDATA[%s]]></MsgType>\n<Voic...
formatter WxSendVoiceMsg to xml string @param WxSendVoiceMsg $msg @return string
[ "formatter", "WxSendVoiceMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L92-L114
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendVideoMsgToXmlString
protected function sendVideoMsgToXmlString(WxSendVideoMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Video> <MediaId><![CDATA[%s]]></MediaId> <Title><![CDATA[%s]]></Title> <Description><![CDATA[%s]]></Description> </Video> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId(), $msg->getTitle(), $msg->getDescription() ); return $result; }
php
protected function sendVideoMsgToXmlString(WxSendVideoMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Video> <MediaId><![CDATA[%s]]></MediaId> <Title><![CDATA[%s]]></Title> <Description><![CDATA[%s]]></Description> </Video> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getMediaId(), $msg->getTitle(), $msg->getDescription() ); return $result; }
[ "protected", "function", "sendVideoMsgToXmlString", "(", "WxSendVideoMsg", "$", "msg", ")", "{", "$", "formatStr", "=", " <<<XML\n<xml>\n<ToUserName><![CDATA[%s]]></ToUserName>\n<FromUserName><![CDATA[%s]]></FromUserName>\n<CreateTime>%d</CreateTime>\n<MsgType><![CDATA[%s]]></MsgType>\n<Vide...
formatter WxSendVideoMsg to xml string @param WxSendVideoMsg $msg @return string
[ "formatter", "WxSendVideoMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L121-L146
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendMusicMsgToXmlString
protected function sendMusicMsgToXmlString(WxSendMusicMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Music> <Title><![CDATA[%s]]></Title> <Description><![CDATA[%s]]></Description> <MusicUrl><![CDATA[%s]]></MusicUrl> <HQMusicUrl><![CDATA[%s]]></HQMusicUrl> <ThumbMediaId><![CDATA[%s]]></ThumbMediaId> </Music> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getTitle(), $msg->getDescription(), $msg->getMusicUrl(), $msg->getHQMusicUrl(), $msg->getThumbMediaId() ); return $result; }
php
protected function sendMusicMsgToXmlString(WxSendMusicMsg $msg) { $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <Music> <Title><![CDATA[%s]]></Title> <Description><![CDATA[%s]]></Description> <MusicUrl><![CDATA[%s]]></MusicUrl> <HQMusicUrl><![CDATA[%s]]></HQMusicUrl> <ThumbMediaId><![CDATA[%s]]></ThumbMediaId> </Music> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getTitle(), $msg->getDescription(), $msg->getMusicUrl(), $msg->getHQMusicUrl(), $msg->getThumbMediaId() ); return $result; }
[ "protected", "function", "sendMusicMsgToXmlString", "(", "WxSendMusicMsg", "$", "msg", ")", "{", "$", "formatStr", "=", " <<<XML\n<xml>\n<ToUserName><![CDATA[%s]]></ToUserName>\n<FromUserName><![CDATA[%s]]></FromUserName>\n<CreateTime>%d</CreateTime>\n<MsgType><![CDATA[%s]]></MsgType>\n<Musi...
formatter WxSendMusicMsg to xml string @param WxSendMusicMsg $msg @return string
[ "formatter", "WxSendMusicMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L153-L182
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendNewsMsgToXmlString
protected function sendNewsMsgToXmlString(WxSendNewsMsg $msg) { $itemArray = $msg->getAllArticleItems(); $itemStr = ''; foreach ($itemArray as $item) { $itemStr .= $this->sendNewsItemToXmlString($item); } $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <ArticleCount>%d</ArticleCount> <Articles> %s </Articles> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getArticleCount(), $itemStr ); return $result; }
php
protected function sendNewsMsgToXmlString(WxSendNewsMsg $msg) { $itemArray = $msg->getAllArticleItems(); $itemStr = ''; foreach ($itemArray as $item) { $itemStr .= $this->sendNewsItemToXmlString($item); } $formatStr = <<<XML <xml> <ToUserName><![CDATA[%s]]></ToUserName> <FromUserName><![CDATA[%s]]></FromUserName> <CreateTime>%d</CreateTime> <MsgType><![CDATA[%s]]></MsgType> <ArticleCount>%d</ArticleCount> <Articles> %s </Articles> </xml> XML; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getFromUserName(), strtotime($msg->getCreateTime()), $msg->getMsgType(), $msg->getArticleCount(), $itemStr ); return $result; }
[ "protected", "function", "sendNewsMsgToXmlString", "(", "WxSendNewsMsg", "$", "msg", ")", "{", "$", "itemArray", "=", "$", "msg", "->", "getAllArticleItems", "(", ")", ";", "$", "itemStr", "=", "''", ";", "foreach", "(", "$", "itemArray", "as", "$", "item"...
formatter WxSendNewsMsg to xml string @param WxSendNewsMsg $msg @return string
[ "formatter", "WxSendNewsMsg", "to", "xml", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L189-L219
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.toJsonString
public function toJsonString(WxSendMsg $msg) { if ($msg instanceof WxSendTextMsg) { return $this->sendTextMsgToJsonString($msg); } elseif ($msg instanceof WxSendImageMsg) { return $this->sendImageMsgToJsonString($msg); } elseif ($msg instanceof WxSendVoiceMsg) { return $this->sendVoiceMsgToJsonString($msg); } elseif ($msg instanceof WxSendVideoMsg) { return $this->sendVideoMsgToJsonString($msg); } elseif ($msg instanceof WxSendMusicMsg) { return $this->sendMusicMsgToJsonString($msg); } elseif ($msg instanceof WxSendNewsMsg) { return $this->sendNewsMsgToJsonString($msg); } throw new \InvalidArgumentException("unknown wx send msg"); }
php
public function toJsonString(WxSendMsg $msg) { if ($msg instanceof WxSendTextMsg) { return $this->sendTextMsgToJsonString($msg); } elseif ($msg instanceof WxSendImageMsg) { return $this->sendImageMsgToJsonString($msg); } elseif ($msg instanceof WxSendVoiceMsg) { return $this->sendVoiceMsgToJsonString($msg); } elseif ($msg instanceof WxSendVideoMsg) { return $this->sendVideoMsgToJsonString($msg); } elseif ($msg instanceof WxSendMusicMsg) { return $this->sendMusicMsgToJsonString($msg); } elseif ($msg instanceof WxSendNewsMsg) { return $this->sendNewsMsgToJsonString($msg); } throw new \InvalidArgumentException("unknown wx send msg"); }
[ "public", "function", "toJsonString", "(", "WxSendMsg", "$", "msg", ")", "{", "if", "(", "$", "msg", "instanceof", "WxSendTextMsg", ")", "{", "return", "$", "this", "->", "sendTextMsgToJsonString", "(", "$", "msg", ")", ";", "}", "elseif", "(", "$", "msg...
formatter to json string @param WxSendMsg $msg @return string
[ "formatter", "to", "json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L252-L269
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendTextMsgToJsonString
protected function sendTextMsgToJsonString(WxSendTextMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "text": { "content":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getContent() ); return $result; }
php
protected function sendTextMsgToJsonString(WxSendTextMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "text": { "content":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getContent() ); return $result; }
[ "protected", "function", "sendTextMsgToJsonString", "(", "WxSendTextMsg", "$", "msg", ")", "{", "$", "formatStr", "=", "'{\n \"touser\":\"%s\",\n \"msgtype\":\"%s\",\n \"text\":\n {\n ...
formatter WxSendTextMsg to Json string @param WxSendTextMsg $msg @return string
[ "formatter", "WxSendTextMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L276-L293
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendImageMsgToJsonString
protected function sendImageMsgToJsonString(WxSendImageMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "image": { "media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
php
protected function sendImageMsgToJsonString(WxSendImageMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "image": { "media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
[ "protected", "function", "sendImageMsgToJsonString", "(", "WxSendImageMsg", "$", "msg", ")", "{", "$", "formatStr", "=", "'{\n \"touser\":\"%s\",\n \"msgtype\":\"%s\",\n \"image\":\n {\n ...
formatter WxSendImageMsg to Json string @param WxSendImageMsg $msg @return string
[ "formatter", "WxSendImageMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L300-L317
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendVoiceMsgToJsonString
protected function sendVoiceMsgToJsonString(WxSendVoiceMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "voice": { "media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
php
protected function sendVoiceMsgToJsonString(WxSendVoiceMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "voice": { "media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId() ); return $result; }
[ "protected", "function", "sendVoiceMsgToJsonString", "(", "WxSendVoiceMsg", "$", "msg", ")", "{", "$", "formatStr", "=", "'{\n \"touser\":\"%s\",\n \"msgtype\":\"%s\",\n \"voice\":\n {\n ...
formatter WxSendVoiceMsg to Json string @param WxSendVoiceMsg $msg @return string
[ "formatter", "WxSendVoiceMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L324-L341
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendVideoMsgToJsonString
protected function sendVideoMsgToJsonString(WxSendVideoMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "video": { "media_id":"%s", "thumb_media_id":"%s", "title":"%s", "description":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId(), $msg->getThumbMediaId(), $msg->getTitle(), $msg->getDescription() ); return $result; }
php
protected function sendVideoMsgToJsonString(WxSendVideoMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "video": { "media_id":"%s", "thumb_media_id":"%s", "title":"%s", "description":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getMediaId(), $msg->getThumbMediaId(), $msg->getTitle(), $msg->getDescription() ); return $result; }
[ "protected", "function", "sendVideoMsgToJsonString", "(", "WxSendVideoMsg", "$", "msg", ")", "{", "$", "formatStr", "=", "'{\n \"touser\":\"%s\",\n \"msgtype\":\"%s\",\n \"video\":\n {\n ...
formatter WxSendVideoMsg to Json string @param WxSendVideoMsg $msg @return string
[ "formatter", "WxSendVideoMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L348-L370
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendMusicMsgToJsonString
protected function sendMusicMsgToJsonString(WxSendMusicMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "music": { "title":"%s", "description":"%s", "musicurl":"%s", "hqmusicurl":"%s", "thumb_media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getTitle(), $msg->getDescription(), $msg->getMusicUrl(), $msg->getHQMusicUrl(), $msg->getThumbMediaId() ); return $result; }
php
protected function sendMusicMsgToJsonString(WxSendMusicMsg $msg) { $formatStr = '{ "touser":"%s", "msgtype":"%s", "music": { "title":"%s", "description":"%s", "musicurl":"%s", "hqmusicurl":"%s", "thumb_media_id":"%s" } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $msg->getTitle(), $msg->getDescription(), $msg->getMusicUrl(), $msg->getHQMusicUrl(), $msg->getThumbMediaId() ); return $result; }
[ "protected", "function", "sendMusicMsgToJsonString", "(", "WxSendMusicMsg", "$", "msg", ")", "{", "$", "formatStr", "=", "'{\n \"touser\":\"%s\",\n \"msgtype\":\"%s\",\n \"music\":\n {\n ...
formatter WxSendMusicMsg to Json string @param WxSendMusicMsg $msg @return string
[ "formatter", "WxSendMusicMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L377-L401
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendNewsMsgToJsonString
protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg) { $itemArray = $msg->getAllArticleItems(); $itemStr = ''; foreach ($itemArray as $item) { $itemStr .= $this->sendNewsItemToJsonString($item) . ','; } $itemStr = substr($itemStr, 0, -1); $formatStr = '{ "touser":"%s", "msgtype":"%s", "news":{ "articles": [ %s ] } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $itemStr ); return $result; }
php
protected function sendNewsMsgToJsonString(WxSendNewsMsg $msg) { $itemArray = $msg->getAllArticleItems(); $itemStr = ''; foreach ($itemArray as $item) { $itemStr .= $this->sendNewsItemToJsonString($item) . ','; } $itemStr = substr($itemStr, 0, -1); $formatStr = '{ "touser":"%s", "msgtype":"%s", "news":{ "articles": [ %s ] } }'; $result = sprintf($formatStr, $msg->getToUserName(), $msg->getMsgType(), $itemStr ); return $result; }
[ "protected", "function", "sendNewsMsgToJsonString", "(", "WxSendNewsMsg", "$", "msg", ")", "{", "$", "itemArray", "=", "$", "msg", "->", "getAllArticleItems", "(", ")", ";", "$", "itemStr", "=", "''", ";", "foreach", "(", "$", "itemArray", "as", "$", "item...
formatter WxSendNewsMsg to Json string @param WxSendNewsMsg $msg @return string
[ "formatter", "WxSendNewsMsg", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L408-L434
train
flavorzyb/wechat
src/Message/Formatter.php
Formatter.sendNewsItemToJsonString
protected function sendNewsItemToJsonString(WxSendNewsMsgItem $item) { $formatStr = '{ "title":"%s", "description":"%s", "url":"%s", "picurl":"%s" }'; $result = sprintf($formatStr, $item->getTitle(), $item->getDescription(), $item->getPicUrl(), $item->getUrl() ); return $result; }
php
protected function sendNewsItemToJsonString(WxSendNewsMsgItem $item) { $formatStr = '{ "title":"%s", "description":"%s", "url":"%s", "picurl":"%s" }'; $result = sprintf($formatStr, $item->getTitle(), $item->getDescription(), $item->getPicUrl(), $item->getUrl() ); return $result; }
[ "protected", "function", "sendNewsItemToJsonString", "(", "WxSendNewsMsgItem", "$", "item", ")", "{", "$", "formatStr", "=", "'{\n \"title\":\"%s\",\n \"description\":\"%s\",\n \"url\":\"%s\",\n \...
formatter WxSendNewsMsgItem to Json string @param WxSendNewsMsgItem $item @return string
[ "formatter", "WxSendNewsMsgItem", "to", "Json", "string" ]
e7854a193c4d23cc9b84afa465f4706c09e7e7c5
https://github.com/flavorzyb/wechat/blob/e7854a193c4d23cc9b84afa465f4706c09e7e7c5/src/Message/Formatter.php#L442-L457
train
Sowapps/orpheus-webtools
src/Config/AppConfig.php
AppConfig.load
public function load() { if( !$this->path ) { throw new \Exception('Unable to load AppConfig from undefined path'); } $this->data = json_decode(file_get_contents($this->path), true); }
php
public function load() { if( !$this->path ) { throw new \Exception('Unable to load AppConfig from undefined path'); } $this->data = json_decode(file_get_contents($this->path), true); }
[ "public", "function", "load", "(", ")", "{", "if", "(", "!", "$", "this", "->", "path", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to load AppConfig from undefined path'", ")", ";", "}", "$", "this", "->", "data", "=", "json_decode", "(", ...
Load config from filesystem @throws \Exception
[ "Load", "config", "from", "filesystem" ]
653682fcff6327a29c2b3ecbc796fae49e7c03ba
https://github.com/Sowapps/orpheus-webtools/blob/653682fcff6327a29c2b3ecbc796fae49e7c03ba/src/Config/AppConfig.php#L117-L122
train
FlexPress/component-templating
src/FlexPress/Components/Templating/Functions.php
Functions.getTwig
public function getTwig(\Twig_Environment $twig) { $this->functions->rewind(); while ($this->functions->valid()) { $function = $this->functions->current(); $twig->addFunction(new \Twig_SimpleFunction($function->getFunctionName(), array($function, 'getFunctionBody'))); $this->functions->next(); } return $twig; }
php
public function getTwig(\Twig_Environment $twig) { $this->functions->rewind(); while ($this->functions->valid()) { $function = $this->functions->current(); $twig->addFunction(new \Twig_SimpleFunction($function->getFunctionName(), array($function, 'getFunctionBody'))); $this->functions->next(); } return $twig; }
[ "public", "function", "getTwig", "(", "\\", "Twig_Environment", "$", "twig", ")", "{", "$", "this", "->", "functions", "->", "rewind", "(", ")", ";", "while", "(", "$", "this", "->", "functions", "->", "valid", "(", ")", ")", "{", "$", "function", "=...
Adds all the functions into the twig environment @param \Twig_Environment $twig @return \Twig_Environment @author Tim Perry
[ "Adds", "all", "the", "functions", "into", "the", "twig", "environment" ]
58d1cdd3cae3bfff41d987f8c8a493e6a6efd9cb
https://github.com/FlexPress/component-templating/blob/58d1cdd3cae3bfff41d987f8c8a493e6a6efd9cb/src/FlexPress/Components/Templating/Functions.php#L53-L67
train
hanamura/wp-post-type
src/WPPostType/PostType.php
PostType.onMapMetaCap
public function onMapMetaCap($caps, $cap, $user_id, $args) { // post type object // ---------------- $post_type_object = get_post_type_object($this->name); if (is_null($post_type_object)) { return $caps; } if ( $post_type_object->capability_type === 'post' || $post_type_object->capability_type === 'page' ) { return $caps; } // meta caps // --------- $edit_post = $post_type_object->cap->edit_post; $delete_post = $post_type_object->cap->delete_post; $read_post = $post_type_object->cap->read_post; // receiving meta caps? // -------------------- if ( $cap === $edit_post || $cap === $delete_post || $cap === $read_post ) { $post = get_post($args[0]); // map meta caps // ------------- switch ($cap) { case $edit_post: return $this->onCheckedMapMetaCapEditPost($user_id, $post, $post_type_object); case $delete_post: return $this->onCheckedMapMetaCapDeletePost($user_id, $post, $post_type_object); case $read_post: return $this->onCheckedMapMetaCapReadPost($user_id, $post, $post_type_object); } } // default // ------- return $caps; }
php
public function onMapMetaCap($caps, $cap, $user_id, $args) { // post type object // ---------------- $post_type_object = get_post_type_object($this->name); if (is_null($post_type_object)) { return $caps; } if ( $post_type_object->capability_type === 'post' || $post_type_object->capability_type === 'page' ) { return $caps; } // meta caps // --------- $edit_post = $post_type_object->cap->edit_post; $delete_post = $post_type_object->cap->delete_post; $read_post = $post_type_object->cap->read_post; // receiving meta caps? // -------------------- if ( $cap === $edit_post || $cap === $delete_post || $cap === $read_post ) { $post = get_post($args[0]); // map meta caps // ------------- switch ($cap) { case $edit_post: return $this->onCheckedMapMetaCapEditPost($user_id, $post, $post_type_object); case $delete_post: return $this->onCheckedMapMetaCapDeletePost($user_id, $post, $post_type_object); case $read_post: return $this->onCheckedMapMetaCapReadPost($user_id, $post, $post_type_object); } } // default // ------- return $caps; }
[ "public", "function", "onMapMetaCap", "(", "$", "caps", ",", "$", "cap", ",", "$", "user_id", ",", "$", "args", ")", "{", "// post type object", "// ----------------", "$", "post_type_object", "=", "get_post_type_object", "(", "$", "this", "->", "name", ")", ...
map meta cap
[ "map", "meta", "cap" ]
c21a529a7c5c6291427707c007c245e89a659cfc
https://github.com/hanamura/wp-post-type/blob/c21a529a7c5c6291427707c007c245e89a659cfc/src/WPPostType/PostType.php#L263-L315
train
asbsoft/yii2module-users_0_170112
models/ProfileForm.php
ProfileForm.save
public function save($isNewRecord) { if ($this->validate()) { $user = $this->user; $data = []; $fn = $user->formName(); if ($isNewRecord) { $data[$fn]['username'] = $this->username; } $data[$fn]['email'] = $this->email; $data[$fn]['password'] = $this->password_new; $data[$fn]['change_auth_key'] = $this->change_auth_key; $loaded = $user->load($data); if ($isNewRecord) { $user->scenario = $user::SCENARIO_CREATE; $user->status = $user::STATUS_REGISTERED; $saved = $user->insert(); } else { $saved = $user->update(); } if ($loaded && $saved) { $this->auth_key = $user->auth_key; return $saved; } else { $this->addErrors($user->errors); } } return false; }
php
public function save($isNewRecord) { if ($this->validate()) { $user = $this->user; $data = []; $fn = $user->formName(); if ($isNewRecord) { $data[$fn]['username'] = $this->username; } $data[$fn]['email'] = $this->email; $data[$fn]['password'] = $this->password_new; $data[$fn]['change_auth_key'] = $this->change_auth_key; $loaded = $user->load($data); if ($isNewRecord) { $user->scenario = $user::SCENARIO_CREATE; $user->status = $user::STATUS_REGISTERED; $saved = $user->insert(); } else { $saved = $user->update(); } if ($loaded && $saved) { $this->auth_key = $user->auth_key; return $saved; } else { $this->addErrors($user->errors); } } return false; }
[ "public", "function", "save", "(", "$", "isNewRecord", ")", "{", "if", "(", "$", "this", "->", "validate", "(", ")", ")", "{", "$", "user", "=", "$", "this", "->", "user", ";", "$", "data", "=", "[", "]", ";", "$", "fn", "=", "$", "user", "->...
Edit user's profile. @param boolean $isNewRecord @return integer|false the number of rows affected, or false if validation fails
[ "Edit", "user", "s", "profile", "." ]
3906fdde2d5fdd54637f2b5246d52fe91ec5f648
https://github.com/asbsoft/yii2module-users_0_170112/blob/3906fdde2d5fdd54637f2b5246d52fe91ec5f648/models/ProfileForm.php#L183-L212
train
projek-xyz/ci-common
src/Views.php
Views.addData
public function addData(array $data, $templates = null) { $this->engine->addData($data, $templates); return $this->engine; }
php
public function addData(array $data, $templates = null) { $this->engine->addData($data, $templates); return $this->engine; }
[ "public", "function", "addData", "(", "array", "$", "data", ",", "$", "templates", "=", "null", ")", "{", "$", "this", "->", "engine", "->", "addData", "(", "$", "data", ",", "$", "templates", ")", ";", "return", "$", "this", "->", "engine", ";", "...
Add data to render. @param array $data Data @param string $templates Template @return League\Plates\Engine
[ "Add", "data", "to", "render", "." ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Views.php#L56-L61
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.CopyLocal
public function CopyLocal($Name) { $Parsed = self::Parse($Name); $LocalPath = ''; $this->EventArguments['Parsed'] = $Parsed; $this->EventArguments['Path'] =& $LocalPath; $this->FireAs('Gdn_Upload')->FireEvent('CopyLocal'); if (!$LocalPath) { $LocalPath = PATH_UPLOADS.'/'.$Parsed['Name']; } return $LocalPath; }
php
public function CopyLocal($Name) { $Parsed = self::Parse($Name); $LocalPath = ''; $this->EventArguments['Parsed'] = $Parsed; $this->EventArguments['Path'] =& $LocalPath; $this->FireAs('Gdn_Upload')->FireEvent('CopyLocal'); if (!$LocalPath) { $LocalPath = PATH_UPLOADS.'/'.$Parsed['Name']; } return $LocalPath; }
[ "public", "function", "CopyLocal", "(", "$", "Name", ")", "{", "$", "Parsed", "=", "self", "::", "Parse", "(", "$", "Name", ")", ";", "$", "LocalPath", "=", "''", ";", "$", "this", "->", "EventArguments", "[", "'Parsed'", "]", "=", "$", "Parsed", "...
Copy an upload locally so that it can be operated on. @param string $Name
[ "Copy", "an", "upload", "locally", "so", "that", "it", "can", "be", "operated", "on", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L76-L88
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.Delete
public function Delete($Name) { $Parsed = $this->Parse($Name); // Throw an event so that plugins that have stored the file somewhere else can delete it. $this->EventArguments['Parsed'] =& $Parsed; $Handled = FALSE; $this->EventArguments['Handled'] =& $Handled; $this->FireAs('Gdn_Upload')->FireEvent('Delete'); if (!$Handled) { $Path = PATH_UPLOADS.'/'.ltrim($Name, '/'); @unlink($Path); } }
php
public function Delete($Name) { $Parsed = $this->Parse($Name); // Throw an event so that plugins that have stored the file somewhere else can delete it. $this->EventArguments['Parsed'] =& $Parsed; $Handled = FALSE; $this->EventArguments['Handled'] =& $Handled; $this->FireAs('Gdn_Upload')->FireEvent('Delete'); if (!$Handled) { $Path = PATH_UPLOADS.'/'.ltrim($Name, '/'); @unlink($Path); } }
[ "public", "function", "Delete", "(", "$", "Name", ")", "{", "$", "Parsed", "=", "$", "this", "->", "Parse", "(", "$", "Name", ")", ";", "// Throw an event so that plugins that have stored the file somewhere else can delete it.", "$", "this", "->", "EventArguments", ...
Delete an uploaded file. @param string $Name The name of the upload as saved in the database.
[ "Delete", "an", "uploaded", "file", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L95-L108
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.FormatFileSize
public static function FormatFileSize($Bytes, $Precision = 1) { $Units = array('B', 'K', 'M', 'G', 'T'); $Bytes = max((int)$Bytes, 0); $Pow = floor(($Bytes ? log($Bytes) : 0) / log(1024)); $Pow = min($Pow, count($Units) - 1); $Bytes /= pow(1024, $Pow); $Result = round($Bytes, $Precision).$Units[$Pow]; return $Result; }
php
public static function FormatFileSize($Bytes, $Precision = 1) { $Units = array('B', 'K', 'M', 'G', 'T'); $Bytes = max((int)$Bytes, 0); $Pow = floor(($Bytes ? log($Bytes) : 0) / log(1024)); $Pow = min($Pow, count($Units) - 1); $Bytes /= pow(1024, $Pow); $Result = round($Bytes, $Precision).$Units[$Pow]; return $Result; }
[ "public", "static", "function", "FormatFileSize", "(", "$", "Bytes", ",", "$", "Precision", "=", "1", ")", "{", "$", "Units", "=", "array", "(", "'B'", ",", "'K'", ",", "'M'", ",", "'G'", ",", "'T'", ")", ";", "$", "Bytes", "=", "max", "(", "(", ...
Format a number of bytes with the largest unit. @param int $Bytes The number of bytes. @param int $Precision The number of decimal places in the formatted number. @return string the formatted filesize.
[ "Format", "a", "number", "of", "bytes", "with", "the", "largest", "unit", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L115-L126
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.UnformatFileSize
public static function UnformatFileSize($Formatted) { $Units = array('B' => 1, 'K' => 1024, 'M' => 1024 * 1024, 'G' => 1024 * 1024 * 1024, 'T' => 1024 * 1024 * 1024 * 1024); if(preg_match('/([0-9.]+)\s*([A-Z]*)/i', $Formatted, $Matches)) { $Number = floatval($Matches[1]); $Unit = strtoupper(substr($Matches[2], 0, 1)); $Mult = GetValue($Unit, $Units, 1); $Result = round($Number * $Mult, 0); return $Result; } else { return FALSE; } }
php
public static function UnformatFileSize($Formatted) { $Units = array('B' => 1, 'K' => 1024, 'M' => 1024 * 1024, 'G' => 1024 * 1024 * 1024, 'T' => 1024 * 1024 * 1024 * 1024); if(preg_match('/([0-9.]+)\s*([A-Z]*)/i', $Formatted, $Matches)) { $Number = floatval($Matches[1]); $Unit = strtoupper(substr($Matches[2], 0, 1)); $Mult = GetValue($Unit, $Units, 1); $Result = round($Number * $Mult, 0); return $Result; } else { return FALSE; } }
[ "public", "static", "function", "UnformatFileSize", "(", "$", "Formatted", ")", "{", "$", "Units", "=", "array", "(", "'B'", "=>", "1", ",", "'K'", "=>", "1024", ",", "'M'", "=>", "1024", "*", "1024", ",", "'G'", "=>", "1024", "*", "1024", "*", "10...
Take a string formatted filesize and return the number of bytes. @param string $Formatted The formatted filesize. @return int The number of bytes in the string.
[ "Take", "a", "string", "formatted", "filesize", "and", "return", "the", "number", "of", "bytes", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L165-L178
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.Urls
public static function Urls($Type = NULL) { static $Urls = NULL; if ($Urls === NULL) { $Urls = array('' => Asset('/uploads', TRUE)); $Sender = new stdClass(); $Sender->Returns = array(); $Sender->EventArguments = array(); $Sender->EventArguments['Urls'] =& $Urls; Gdn::PluginManager()->CallEventHandlers($Sender, 'Gdn_Upload', 'GetUrls'); } if ($Type === NULL) return $Urls; if (isset($Urls[$Type])) return $Urls[$Type]; return FALSE; }
php
public static function Urls($Type = NULL) { static $Urls = NULL; if ($Urls === NULL) { $Urls = array('' => Asset('/uploads', TRUE)); $Sender = new stdClass(); $Sender->Returns = array(); $Sender->EventArguments = array(); $Sender->EventArguments['Urls'] =& $Urls; Gdn::PluginManager()->CallEventHandlers($Sender, 'Gdn_Upload', 'GetUrls'); } if ($Type === NULL) return $Urls; if (isset($Urls[$Type])) return $Urls[$Type]; return FALSE; }
[ "public", "static", "function", "Urls", "(", "$", "Type", "=", "NULL", ")", "{", "static", "$", "Urls", "=", "NULL", ";", "if", "(", "$", "Urls", "===", "NULL", ")", "{", "$", "Urls", "=", "array", "(", "''", "=>", "Asset", "(", "'/uploads'", ","...
Returns the url prefix for a given type. If there is a plugin that wants to store uploads at a different location or in a different way then they register themselves by subscribing to the Gdn_Upload_GetUrls_Handler event. After that they will be available here. @param string $Type The type of upload to get the prefix for. @return string The url prefix.
[ "Returns", "the", "url", "prefix", "for", "a", "given", "type", ".", "If", "there", "is", "a", "plugin", "that", "wants", "to", "store", "uploads", "at", "a", "different", "location", "or", "in", "a", "different", "way", "then", "they", "register", "them...
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L243-L262
train
bishopb/vanilla
library/core/class.upload.php
Gdn_Upload.ValidateUpload
public function ValidateUpload($InputName, $ThrowException = TRUE) { $Ex = FALSE; if (!array_key_exists($InputName, $_FILES) || (!is_uploaded_file($_FILES[$InputName]['tmp_name']) && GetValue('error', $_FILES[$InputName], 0) == 0)) { // Check the content length to see if we exceeded the max post size. $ContentLength = Gdn::Request()->GetValueFrom('server', 'CONTENT_LENGTH'); $MaxPostSize = self::UnformatFileSize(ini_get('post_max_size')); if($ContentLength > $MaxPostSize) { $Ex = sprintf(T('Gdn_Upload.Error.MaxPostSize', 'The file is larger than the maximum post size. (%s)'), self::FormatFileSize($MaxPostSize)); } else { $Ex = T('The file failed to upload.'); } } else { switch ($_FILES[$InputName]['error']) { case 1: case 2: $MaxFileSize = self::UnformatFileSize(ini_get('upload_max_filesize')); $Ex = sprintf(T('Gdn_Upload.Error.PhpMaxFileSize', 'The file is larger than the server\'s maximum file size. (%s)'), self::FormatFileSize($MaxFileSize)); break; case 3: case 4: $Ex = T('The file failed to upload.'); break; case 6: $Ex = T('The temporary upload folder has not been configured.'); break; case 7: $Ex = T('Failed to write the file to disk.'); break; case 8: $Ex = T('The upload was stopped by extension.'); break; } } $Foo = self::FormatFileSize($this->_MaxFileSize); // Check the maxfilesize again just in case the value was spoofed in the form. if (!$Ex && $this->_MaxFileSize > 0 && filesize($_FILES[$InputName]['tmp_name']) > $this->_MaxFileSize) { $Ex = sprintf(T('Gdn_Upload.Error.MaxFileSize', 'The file is larger than the maximum file size. (%s)'), self::FormatFileSize($this->_MaxFileSize)); } elseif(!$Ex) { // Make sure that the file extension is allowed. $Extension = pathinfo($_FILES[$InputName]['name'], PATHINFO_EXTENSION); if (!InArrayI($Extension, $this->_AllowedFileExtensions)) $Ex = sprintf(T('You cannot upload files with this extension (%s). Allowed extension(s) are %s.'), $Extension, implode(', ', $this->_AllowedFileExtensions)); } if($Ex) { if($ThrowException) { throw new Gdn_UserException($Ex); } else { $this->Exception = $Ex; return FALSE; } } else { // If all validations were successful, return the tmp name/location of the file. $this->_UploadedFile = $_FILES[$InputName]; return $this->_UploadedFile['tmp_name']; } }
php
public function ValidateUpload($InputName, $ThrowException = TRUE) { $Ex = FALSE; if (!array_key_exists($InputName, $_FILES) || (!is_uploaded_file($_FILES[$InputName]['tmp_name']) && GetValue('error', $_FILES[$InputName], 0) == 0)) { // Check the content length to see if we exceeded the max post size. $ContentLength = Gdn::Request()->GetValueFrom('server', 'CONTENT_LENGTH'); $MaxPostSize = self::UnformatFileSize(ini_get('post_max_size')); if($ContentLength > $MaxPostSize) { $Ex = sprintf(T('Gdn_Upload.Error.MaxPostSize', 'The file is larger than the maximum post size. (%s)'), self::FormatFileSize($MaxPostSize)); } else { $Ex = T('The file failed to upload.'); } } else { switch ($_FILES[$InputName]['error']) { case 1: case 2: $MaxFileSize = self::UnformatFileSize(ini_get('upload_max_filesize')); $Ex = sprintf(T('Gdn_Upload.Error.PhpMaxFileSize', 'The file is larger than the server\'s maximum file size. (%s)'), self::FormatFileSize($MaxFileSize)); break; case 3: case 4: $Ex = T('The file failed to upload.'); break; case 6: $Ex = T('The temporary upload folder has not been configured.'); break; case 7: $Ex = T('Failed to write the file to disk.'); break; case 8: $Ex = T('The upload was stopped by extension.'); break; } } $Foo = self::FormatFileSize($this->_MaxFileSize); // Check the maxfilesize again just in case the value was spoofed in the form. if (!$Ex && $this->_MaxFileSize > 0 && filesize($_FILES[$InputName]['tmp_name']) > $this->_MaxFileSize) { $Ex = sprintf(T('Gdn_Upload.Error.MaxFileSize', 'The file is larger than the maximum file size. (%s)'), self::FormatFileSize($this->_MaxFileSize)); } elseif(!$Ex) { // Make sure that the file extension is allowed. $Extension = pathinfo($_FILES[$InputName]['name'], PATHINFO_EXTENSION); if (!InArrayI($Extension, $this->_AllowedFileExtensions)) $Ex = sprintf(T('You cannot upload files with this extension (%s). Allowed extension(s) are %s.'), $Extension, implode(', ', $this->_AllowedFileExtensions)); } if($Ex) { if($ThrowException) { throw new Gdn_UserException($Ex); } else { $this->Exception = $Ex; return FALSE; } } else { // If all validations were successful, return the tmp name/location of the file. $this->_UploadedFile = $_FILES[$InputName]; return $this->_UploadedFile['tmp_name']; } }
[ "public", "function", "ValidateUpload", "(", "$", "InputName", ",", "$", "ThrowException", "=", "TRUE", ")", "{", "$", "Ex", "=", "FALSE", ";", "if", "(", "!", "array_key_exists", "(", "$", "InputName", ",", "$", "_FILES", ")", "||", "(", "!", "is_uplo...
Validates the uploaded file. Returns the temporary name of the uploaded file.
[ "Validates", "the", "uploaded", "file", ".", "Returns", "the", "temporary", "name", "of", "the", "uploaded", "file", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.upload.php#L267-L326
train
99designs/ergo
classes/Ergo/Routing/RoutedController.php
RoutedController._controllerFor
private function _controllerFor($name) { if(isset($this->_controllers[$name]) && is_string($this->_controllers[$name])) { return $this->_controllerFor($this->_controllers[$name]); } else if(isset($this->_controllers[$name]) && is_object($this->_controllers[$name])) { return $this->_controllers[$name]; } else if(isset($this->_controllerFactory)) { return $this->_controllerFactory->resolve($name); } else { throw new Exception("No controller found for $name"); } }
php
private function _controllerFor($name) { if(isset($this->_controllers[$name]) && is_string($this->_controllers[$name])) { return $this->_controllerFor($this->_controllers[$name]); } else if(isset($this->_controllers[$name]) && is_object($this->_controllers[$name])) { return $this->_controllers[$name]; } else if(isset($this->_controllerFactory)) { return $this->_controllerFactory->resolve($name); } else { throw new Exception("No controller found for $name"); } }
[ "private", "function", "_controllerFor", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_controllers", "[", "$", "name", "]", ")", "&&", "is_string", "(", "$", "this", "->", "_controllers", "[", "$", "name", "]", ")", ")", ...
Gets a controller for a path, either from a locally registered controller or one from a controller factory
[ "Gets", "a", "controller", "for", "a", "path", "either", "from", "a", "locally", "registered", "controller", "or", "one", "from", "a", "controller", "factory" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/RoutedController.php#L54-L72
train
99designs/ergo
classes/Ergo/Routing/RoutedController.php
RoutedController.connect
public function connect($url, $name, $controller=null) { $this->_router->connect($url, $name, $controller); // register the controller if one is provided if(!is_null($controller)) { $this->_controllers[$name] = $controller; } return $this; }
php
public function connect($url, $name, $controller=null) { $this->_router->connect($url, $name, $controller); // register the controller if one is provided if(!is_null($controller)) { $this->_controllers[$name] = $controller; } return $this; }
[ "public", "function", "connect", "(", "$", "url", ",", "$", "name", ",", "$", "controller", "=", "null", ")", "{", "$", "this", "->", "_router", "->", "connect", "(", "$", "url", ",", "$", "name", ",", "$", "controller", ")", ";", "// register the co...
Defines a url, a route name and an optional controller @param $url string the url to connect the route to @param $name string an arbitrary controller name, must be unique @param $controller mixed either a controller class, or the name of another route
[ "Defines", "a", "url", "a", "route", "name", "and", "an", "optional", "controller" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/RoutedController.php#L95-L106
train
requtize/atline
src/Atline/Environment.php
Environment.fequiv_mb_ucfirst
protected function fequiv_mb_ucfirst($string, $encoding = 'utf8') { return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1, mb_strlen($string, $encoding) - 1, $encoding); }
php
protected function fequiv_mb_ucfirst($string, $encoding = 'utf8') { return mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding).mb_substr($string, 1, mb_strlen($string, $encoding) - 1, $encoding); }
[ "protected", "function", "fequiv_mb_ucfirst", "(", "$", "string", ",", "$", "encoding", "=", "'utf8'", ")", "{", "return", "mb_strtoupper", "(", "mb_substr", "(", "$", "string", ",", "0", ",", "1", ",", "$", "encoding", ")", ",", "$", "encoding", ")", ...
Equivalent function to ucfirst with mbstring usage. @param string $string Input string. @param string $encoding Encoding. @return Transformed output string.
[ "Equivalent", "function", "to", "ucfirst", "with", "mbstring", "usage", "." ]
9a1b5fe70485f701b3d300fe41d81e6eccc0f27d
https://github.com/requtize/atline/blob/9a1b5fe70485f701b3d300fe41d81e6eccc0f27d/src/Atline/Environment.php#L100-L103
train
helloandre/pressing
src/Parser.php
Parser.parse
public static function parse($path) { if (!file_exists($path)) { throw new \Exception("$path not found"); } $src = file_get_contents($path); if (!$src) { throw new \Exception("could not read $path"); } // first of all do we have any frontmatter in there? preg_match(self::$frontmatter_regex, $src, $matches); if (!empty($matches)) { // if we have an empty frontmatter, this will fail // but we still want to act like there was something there if (!($frontmatter = json_decode(trim($matches[1]), true))) { $frontmatter = array(); } } else { $frontmatter = false; } // remove any frontmatter $plain_src = preg_replace(self::$frontmatter_regex, "", $src); return array( 'frontmatter' => $frontmatter, 'content' => $plain_src ); }
php
public static function parse($path) { if (!file_exists($path)) { throw new \Exception("$path not found"); } $src = file_get_contents($path); if (!$src) { throw new \Exception("could not read $path"); } // first of all do we have any frontmatter in there? preg_match(self::$frontmatter_regex, $src, $matches); if (!empty($matches)) { // if we have an empty frontmatter, this will fail // but we still want to act like there was something there if (!($frontmatter = json_decode(trim($matches[1]), true))) { $frontmatter = array(); } } else { $frontmatter = false; } // remove any frontmatter $plain_src = preg_replace(self::$frontmatter_regex, "", $src); return array( 'frontmatter' => $frontmatter, 'content' => $plain_src ); }
[ "public", "static", "function", "parse", "(", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"$path not found\"", ")", ";", "}", "$", "src", "=", "file_get_contents", "("...
parse out the frontmatter and content from the file @param String $path - absolute path @return Array - 'frontmatter' and 'content' values
[ "parse", "out", "the", "frontmatter", "and", "content", "from", "the", "file" ]
e4244c7bbe90c38fa7d45e3c2da5d4b9153a0f54
https://github.com/helloandre/pressing/blob/e4244c7bbe90c38fa7d45e3c2da5d4b9153a0f54/src/Parser.php#L27-L56
train
samurai-fw/samurai
src/Samurai/Component/Request/CliRequest.php
CliRequest.add
public function add($key, $value) { if (! isset($this->_params[$key])) { $this->_params[$key] = array(); } $this->_params[$key][] = $value; }
php
public function add($key, $value) { if (! isset($this->_params[$key])) { $this->_params[$key] = array(); } $this->_params[$key][] = $value; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_params", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "_params", "[", "$", "key", "]", "=", "array", "(",...
add param. @access public @param string $key @param string $value
[ "add", "param", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Request/CliRequest.php#L119-L125
train
samurai-fw/samurai
src/Samurai/Component/Request/CliRequest.php
CliRequest.getAsArray
public function getAsArray($key, array $default = array()) { $value = parent::get($key, $default); if (is_array($value) && !$value) $value = $default; return (array)$value; }
php
public function getAsArray($key, array $default = array()) { $value = parent::get($key, $default); if (is_array($value) && !$value) $value = $default; return (array)$value; }
[ "public", "function", "getAsArray", "(", "$", "key", ",", "array", "$", "default", "=", "array", "(", ")", ")", "{", "$", "value", "=", "parent", "::", "get", "(", "$", "key", ",", "$", "default", ")", ";", "if", "(", "is_array", "(", "$", "value...
Get param as array. @access public @param string $key @param array $default @return array
[ "Get", "param", "as", "array", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Request/CliRequest.php#L154-L159
train