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
mtoolkit/mtoolkit-view
src/MImage.php
MImage.scaled
public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO ) { switch( $aspectRatioMode ) { case AspectRatioMode::IGNORE_ASPECT_RATIO: break; case AspectRatioMode::KEEP_ASPECT_RATIO: $height = ($width * $this->getHeight()) / $this->getWidth(); break; case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING: $width = ($height * $this->getWidth()) / $this->getHeight(); break; } $newResource = imagecreatetruecolor( $width, $height ); imagealphablending( $newResource, false ); imagesavealpha( $newResource, true ); imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() ); $newImage = MImage::fromResource( $newResource ); $newImage->type = $this->type; return $newImage; }
php
public function scaled( $width, $height, $aspectRatioMode = AspectRatioMode::IGNORE_ASPECT_RATIO ) { switch( $aspectRatioMode ) { case AspectRatioMode::IGNORE_ASPECT_RATIO: break; case AspectRatioMode::KEEP_ASPECT_RATIO: $height = ($width * $this->getHeight()) / $this->getWidth(); break; case AspectRatioMode::KEEP_ASPECT_RATIO_BY_EXPANDING: $width = ($height * $this->getWidth()) / $this->getHeight(); break; } $newResource = imagecreatetruecolor( $width, $height ); imagealphablending( $newResource, false ); imagesavealpha( $newResource, true ); imagecopyresampled( $newResource, $this->resource, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight() ); $newImage = MImage::fromResource( $newResource ); $newImage->type = $this->type; return $newImage; }
[ "public", "function", "scaled", "(", "$", "width", ",", "$", "height", ",", "$", "aspectRatioMode", "=", "AspectRatioMode", "::", "IGNORE_ASPECT_RATIO", ")", "{", "switch", "(", "$", "aspectRatioMode", ")", "{", "case", "AspectRatioMode", "::", "IGNORE_ASPECT_RA...
Returns a copy of the image scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode. If either the width or the height is zero or negative, this function returns a null image. @param int $width @param int $height @param int|AspectRatioMode $aspectRatioMode @return MImage Description
[ "Returns", "a", "copy", "of", "the", "image", "scaled", "to", "a", "rectangle", "with", "the", "given", "width", "and", "height", "according", "to", "the", "given", "aspectRatioMode", "and", "transformMode", ".", "If", "either", "the", "width", "or", "the", ...
ab2c66600992028d7726cbc736cbce274f731f65
https://github.com/mtoolkit/mtoolkit-view/blob/ab2c66600992028d7726cbc736cbce274f731f65/src/MImage.php#L194-L218
train
mtoolkit/mtoolkit-view
src/MImage.php
MImage.valid
public function valid( $x, $y ) { return ($x > 0 && $x < $this->getWidth() && $y > 0 && $y < $this->getHeight()); }
php
public function valid( $x, $y ) { return ($x > 0 && $x < $this->getWidth() && $y > 0 && $y < $this->getHeight()); }
[ "public", "function", "valid", "(", "$", "x", ",", "$", "y", ")", "{", "return", "(", "$", "x", ">", "0", "&&", "$", "x", "<", "$", "this", "->", "getWidth", "(", ")", "&&", "$", "y", ">", "0", "&&", "$", "y", "<", "$", "this", "->", "get...
Returns true if pos is a valid coordinate pair within the image; otherwise returns false. @param int $x @param int $y @return boolean
[ "Returns", "true", "if", "pos", "is", "a", "valid", "coordinate", "pair", "within", "the", "image", ";", "otherwise", "returns", "false", "." ]
ab2c66600992028d7726cbc736cbce274f731f65
https://github.com/mtoolkit/mtoolkit-view/blob/ab2c66600992028d7726cbc736cbce274f731f65/src/MImage.php#L359-L362
train
PHPComponent/AtomicFile
src/AtomicFileWriter.php
AtomicFileWriter.rollbackOpeningFile
private function rollbackOpeningFile($temp_file = null) { flock($this->getFile(), LOCK_UN); fclose($this->getFile()); if(is_resource($temp_file)) { fclose($temp_file); unlink($this->getTempFilePath()); } }
php
private function rollbackOpeningFile($temp_file = null) { flock($this->getFile(), LOCK_UN); fclose($this->getFile()); if(is_resource($temp_file)) { fclose($temp_file); unlink($this->getTempFilePath()); } }
[ "private", "function", "rollbackOpeningFile", "(", "$", "temp_file", "=", "null", ")", "{", "flock", "(", "$", "this", "->", "getFile", "(", ")", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "this", "->", "getFile", "(", ")", ")", ";", "if", "(", ...
Used only when failed to open temp file in OpenFile @param resource|null $temp_file @return void
[ "Used", "only", "when", "failed", "to", "open", "temp", "file", "in", "OpenFile" ]
9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8
https://github.com/PHPComponent/AtomicFile/blob/9ca88297bdbdeb3bcbecdcbe884e4f412bb2cfe8/src/AtomicFileWriter.php#L192-L201
train
strackovski/semtools
src/Classifiers/uClassify/UclassifyReader.php
UclassifyReader.classifierExists
private function classifierExists($classifier) { if (strpos($classifier, '/') !== false) { $classifierArray = array_map('strtolower', explode('/', $classifier)); $testArray = array_change_key_case($this->classifiers); // Remap classifiers list to lowercase before validation foreach ($testArray as $key => $values) { $testArray [$key] = array_map('strtolower', $values); } if (!array_key_exists($classifierArray[0], $testArray)) { throw new \Exception("Classifier namespace {$classifierArray[0]} does not exist in Classifiers list"); } if (!in_array($classifierArray[1], $testArray[$classifierArray[0]])) { throw new \Exception("Classifier {$classifierArray[1]} does not exist in Classifiers list"); } return array($classifierArray[0], $classifierArray[1]); } return false; }
php
private function classifierExists($classifier) { if (strpos($classifier, '/') !== false) { $classifierArray = array_map('strtolower', explode('/', $classifier)); $testArray = array_change_key_case($this->classifiers); // Remap classifiers list to lowercase before validation foreach ($testArray as $key => $values) { $testArray [$key] = array_map('strtolower', $values); } if (!array_key_exists($classifierArray[0], $testArray)) { throw new \Exception("Classifier namespace {$classifierArray[0]} does not exist in Classifiers list"); } if (!in_array($classifierArray[1], $testArray[$classifierArray[0]])) { throw new \Exception("Classifier {$classifierArray[1]} does not exist in Classifiers list"); } return array($classifierArray[0], $classifierArray[1]); } return false; }
[ "private", "function", "classifierExists", "(", "$", "classifier", ")", "{", "if", "(", "strpos", "(", "$", "classifier", ",", "'/'", ")", "!==", "false", ")", "{", "$", "classifierArray", "=", "array_map", "(", "'strtolower'", ",", "explode", "(", "'/'", ...
Verify if the requested classifier exists @param string $classifier Classifier name, including provider namespace: namespace/classifier @return array|bool Array with namespace and classifier if it exists, false if it doesn't @throws \Exception
[ "Verify", "if", "the", "requested", "classifier", "exists" ]
6a11eff4eaa18e2939b08382bca5d60d9864a4fa
https://github.com/strackovski/semtools/blob/6a11eff4eaa18e2939b08382bca5d60d9864a4fa/src/Classifiers/uClassify/UclassifyReader.php#L181-L204
train
aberdnikov/meerkat-core
classes/Kodoc.php
Kodoc.classes
public static function classes(array $list = null) { if ($list === null) { $list = Kohana::list_files('classes'); } $namespaces = Kohana::$config->load('userguide.namespaces'); Debug::stop($namespaces); $namespaces = \Arr::map(function ($namespace) { $namespace = trim($namespace, '/'); $namespace = trim($namespace, '\\'); return str_replace('/', '\\', $namespace); }, $namespaces); $namespaces = Arr::flatten($namespaces); //Debug::info($namespaces); $namespaces = array_unique($namespaces); $classes = array(); // This will be used a lot! $ext_length = strlen(EXT); foreach ($list as $name => $path) { if (is_array($path)) { $classes += Kodoc::classes($path); } elseif (substr($name, -$ext_length) === EXT) { // Remove "classes/" and the extension $class = substr($name, 8, -$ext_length); // Convert slashes to underscores $class = str_replace(DIRECTORY_SEPARATOR, '_', $class); $ret = ''; //print '<hr />1) ' . $name . '<br />'; //print '2) ' . $class . '<hr />'; foreach ($namespaces as $namespace) { $_namespace = str_replace('\\', '_', $namespace); //print '4) ' . $_namespace . '<br />'; if (mb_strpos($class, $_namespace) === 0) { $class = '\\'.$namespace.'\\'.str_replace($_namespace.'_', '', $class); break; } } $classes[$class] = $class; } } return $classes; }
php
public static function classes(array $list = null) { if ($list === null) { $list = Kohana::list_files('classes'); } $namespaces = Kohana::$config->load('userguide.namespaces'); Debug::stop($namespaces); $namespaces = \Arr::map(function ($namespace) { $namespace = trim($namespace, '/'); $namespace = trim($namespace, '\\'); return str_replace('/', '\\', $namespace); }, $namespaces); $namespaces = Arr::flatten($namespaces); //Debug::info($namespaces); $namespaces = array_unique($namespaces); $classes = array(); // This will be used a lot! $ext_length = strlen(EXT); foreach ($list as $name => $path) { if (is_array($path)) { $classes += Kodoc::classes($path); } elseif (substr($name, -$ext_length) === EXT) { // Remove "classes/" and the extension $class = substr($name, 8, -$ext_length); // Convert slashes to underscores $class = str_replace(DIRECTORY_SEPARATOR, '_', $class); $ret = ''; //print '<hr />1) ' . $name . '<br />'; //print '2) ' . $class . '<hr />'; foreach ($namespaces as $namespace) { $_namespace = str_replace('\\', '_', $namespace); //print '4) ' . $_namespace . '<br />'; if (mb_strpos($class, $_namespace) === 0) { $class = '\\'.$namespace.'\\'.str_replace($_namespace.'_', '', $class); break; } } $classes[$class] = $class; } } return $classes; }
[ "public", "static", "function", "classes", "(", "array", "$", "list", "=", "null", ")", "{", "if", "(", "$", "list", "===", "null", ")", "{", "$", "list", "=", "Kohana", "::", "list_files", "(", "'classes'", ")", ";", "}", "$", "namespaces", "=", "...
Returns an array of all the classes available, built by listing all files in the classes folder. @param array array of files, obtained using Kohana::list_files @return array an array of all the class names
[ "Returns", "an", "array", "of", "all", "the", "classes", "available", "built", "by", "listing", "all", "files", "in", "the", "classes", "folder", "." ]
9aab1555919d76f1920198c64e21fd3faf9b5f5d
https://github.com/aberdnikov/meerkat-core/blob/9aab1555919d76f1920198c64e21fd3faf9b5f5d/classes/Kodoc.php#L11-L54
train
mickeyhead7/mickeyhead7-rsvp
src/Resource/Item.php
Item.getIncluded
public function getIncluded() { $data = []; $include_params = $this->getIncludeParams(); if (!$include_params) { return $include_params; } foreach ($include_params->getData() as $key => $params) { $method = 'include' . ucfirst($key); $transformer = $this->getTransformer(); $allowed = $transformer->getAllowedIncludes(); if (in_array($key, $allowed) && method_exists($transformer, $method)) { $result = $transformer->$method($this->getData(), $params); $data[$key] = $result; } } return $data; }
php
public function getIncluded() { $data = []; $include_params = $this->getIncludeParams(); if (!$include_params) { return $include_params; } foreach ($include_params->getData() as $key => $params) { $method = 'include' . ucfirst($key); $transformer = $this->getTransformer(); $allowed = $transformer->getAllowedIncludes(); if (in_array($key, $allowed) && method_exists($transformer, $method)) { $result = $transformer->$method($this->getData(), $params); $data[$key] = $result; } } return $data; }
[ "public", "function", "getIncluded", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "include_params", "=", "$", "this", "->", "getIncludeParams", "(", ")", ";", "if", "(", "!", "$", "include_params", ")", "{", "return", "$", "include_params", ";"...
Get the includes to be parsed @param Item $item @return array
[ "Get", "the", "includes", "to", "be", "parsed" ]
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Resource/Item.php#L14-L35
train
sios13/simox
src/Model.php
Model.getColumns
private function getColumns() { $columns = array(); /** * Use call_user_func to make sure only public vars are returned */ $vars = call_user_func('get_object_vars', $this); foreach ( $vars as $key => $value ) { $columns[] = array( "name" => $key ); } return $columns; }
php
private function getColumns() { $columns = array(); /** * Use call_user_func to make sure only public vars are returned */ $vars = call_user_func('get_object_vars', $this); foreach ( $vars as $key => $value ) { $columns[] = array( "name" => $key ); } return $columns; }
[ "private", "function", "getColumns", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "/**\r\n * Use call_user_func to make sure only public vars are returned\r\n */", "$", "vars", "=", "call_user_func", "(", "'get_object_vars'", ",", "$", "this...
Helper function, returns an array describing the model columns
[ "Helper", "function", "returns", "an", "array", "describing", "the", "model", "columns" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L46-L63
train
sios13/simox
src/Model.php
Model.getAttributes
private function getAttributes() { $attributes = array(); foreach ( $this->_columns as $column ) { $attributes[$column["name"]] = $this->{$column["name"]}; } return $attributes; }
php
private function getAttributes() { $attributes = array(); foreach ( $this->_columns as $column ) { $attributes[$column["name"]] = $this->{$column["name"]}; } return $attributes; }
[ "private", "function", "getAttributes", "(", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_columns", "as", "$", "column", ")", "{", "$", "attributes", "[", "$", "column", "[", "\"name\"", "]", "]", "="...
Helper function, returns the model attributes as an array
[ "Helper", "function", "returns", "the", "model", "attributes", "as", "an", "array" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L68-L78
train
sios13/simox
src/Model.php
Model.createModel
private static function createModel( $row ) { $table_name = get_called_class(); $model = new $table_name(); $model->setExists( true ); foreach ( $row as $key => $value ) { if ( !is_int($key) ) { $model->$key = $value; $model->_snapshot[$key] = $value; } } return $model; }
php
private static function createModel( $row ) { $table_name = get_called_class(); $model = new $table_name(); $model->setExists( true ); foreach ( $row as $key => $value ) { if ( !is_int($key) ) { $model->$key = $value; $model->_snapshot[$key] = $value; } } return $model; }
[ "private", "static", "function", "createModel", "(", "$", "row", ")", "{", "$", "table_name", "=", "get_called_class", "(", ")", ";", "$", "model", "=", "new", "$", "table_name", "(", ")", ";", "$", "model", "->", "setExists", "(", "true", ")", ";", ...
Helper function to create and initialize a model
[ "Helper", "function", "to", "create", "and", "initialize", "a", "model" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L83-L101
train
sios13/simox
src/Model.php
Model.findFirst
public static function findFirst( $sub_sql = null, $params = null ) { $params["find_first"] = true; return self::find( $sub_sql, $params ); }
php
public static function findFirst( $sub_sql = null, $params = null ) { $params["find_first"] = true; return self::find( $sub_sql, $params ); }
[ "public", "static", "function", "findFirst", "(", "$", "sub_sql", "=", "null", ",", "$", "params", "=", "null", ")", "{", "$", "params", "[", "\"find_first\"", "]", "=", "true", ";", "return", "self", "::", "find", "(", "$", "sub_sql", ",", "$", "par...
Returns only the first model
[ "Returns", "only", "the", "first", "model" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L173-L178
train
sios13/simox
src/Model.php
Model.save
public function save() { $di = DI::getDefault(); $database = $di->getService( "database" ); /** * Decide if we should update or insert * (if we know the record exists in the database...) */ if ( $this->_exists_in_db ) { /** * Retrieve a query from the query builder */ $query = $database->buildQuery( $this->_table_name, "update", array("columns" => $this->_columns) ); /** * Create an array with the model attributes (binding parameters) */ $attributes = $this->getAttributes(); /** * Add "snap_" prefix to the snapshot in order to not get index conflict when we merge attributes and snapshot */ $snapshot = array(); foreach ( $this->_snapshot as $key => $value ) { $snapshot["snap_" . $key] = $value; } /** * Merge our binding parameters. * Bind the parameters to the query and return the result. */ return $query->execute( array_merge($attributes, $snapshot) ); } else { /** * Retrieve a query from the query builder */ $query = $database->buildQuery( $this->_table_name, "insert", array("columns" => $this->_columns) ); /** * Create an array with the model attributes (binding parameters) */ $attributes = $this->getAttributes(); /** * Bind the parameters and return the result */ return $query->execute( $attributes ); } }
php
public function save() { $di = DI::getDefault(); $database = $di->getService( "database" ); /** * Decide if we should update or insert * (if we know the record exists in the database...) */ if ( $this->_exists_in_db ) { /** * Retrieve a query from the query builder */ $query = $database->buildQuery( $this->_table_name, "update", array("columns" => $this->_columns) ); /** * Create an array with the model attributes (binding parameters) */ $attributes = $this->getAttributes(); /** * Add "snap_" prefix to the snapshot in order to not get index conflict when we merge attributes and snapshot */ $snapshot = array(); foreach ( $this->_snapshot as $key => $value ) { $snapshot["snap_" . $key] = $value; } /** * Merge our binding parameters. * Bind the parameters to the query and return the result. */ return $query->execute( array_merge($attributes, $snapshot) ); } else { /** * Retrieve a query from the query builder */ $query = $database->buildQuery( $this->_table_name, "insert", array("columns" => $this->_columns) ); /** * Create an array with the model attributes (binding parameters) */ $attributes = $this->getAttributes(); /** * Bind the parameters and return the result */ return $query->execute( $attributes ); } }
[ "public", "function", "save", "(", ")", "{", "$", "di", "=", "DI", "::", "getDefault", "(", ")", ";", "$", "database", "=", "$", "di", "->", "getService", "(", "\"database\"", ")", ";", "/**\r\n * Decide if we should update or insert\r\n * (if we k...
Inserts or updates the database table
[ "Inserts", "or", "updates", "the", "database", "table" ]
8be964949ef179aba7eceb3fc6439815a1af2ad2
https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Model.php#L183-L238
train
infotech-ru/yii-document-generator
src/Service/GeneratorService.php
GeneratorService.setRenderersConfig
public function setRenderersConfig(array $renderers) { foreach ($renderers as $name => $class) { $renderer = new $class; if (!$renderer instanceof RendererInterface) { throw new GeneratorServiceException( 'Configured class of renderer must implement' . ' Infotech\DocumentGenerator\Renderer\RendererInterface interface' ); } $this->registerRenderer($name, $renderer); } }
php
public function setRenderersConfig(array $renderers) { foreach ($renderers as $name => $class) { $renderer = new $class; if (!$renderer instanceof RendererInterface) { throw new GeneratorServiceException( 'Configured class of renderer must implement' . ' Infotech\DocumentGenerator\Renderer\RendererInterface interface' ); } $this->registerRenderer($name, $renderer); } }
[ "public", "function", "setRenderersConfig", "(", "array", "$", "renderers", ")", "{", "foreach", "(", "$", "renderers", "as", "$", "name", "=>", "$", "class", ")", "{", "$", "renderer", "=", "new", "$", "class", ";", "if", "(", "!", "$", "renderer", ...
Instantiate and registering document renderers @param array $renderers Renderers configuration map [name => fully qualified class name] @throws GeneratorServiceException if map contains name of class that is not implementing RendererInterface @throws GeneratorServiceException if map contains renderer name that already has been registered
[ "Instantiate", "and", "registering", "document", "renderers" ]
70e418a84c34930662f2f6a8e12687e2c8492849
https://github.com/infotech-ru/yii-document-generator/blob/70e418a84c34930662f2f6a8e12687e2c8492849/src/Service/GeneratorService.php#L55-L67
train
infotech-ru/yii-document-generator
src/Service/GeneratorService.php
GeneratorService.setDocumentTypesConfig
public function setDocumentTypesConfig(array $documentTypes) { foreach ($documentTypes as $name => $class) { $documentType = new $class; if (!$documentType instanceof AbstractDocumentType) { throw new GeneratorServiceException( 'Configured class of document type must be descendant of' . ' Infotech\DocumentGenerator\DocumentType\AbstractDocumentType class' ); } $this->registerDocumentType($name, $documentType); } }
php
public function setDocumentTypesConfig(array $documentTypes) { foreach ($documentTypes as $name => $class) { $documentType = new $class; if (!$documentType instanceof AbstractDocumentType) { throw new GeneratorServiceException( 'Configured class of document type must be descendant of' . ' Infotech\DocumentGenerator\DocumentType\AbstractDocumentType class' ); } $this->registerDocumentType($name, $documentType); } }
[ "public", "function", "setDocumentTypesConfig", "(", "array", "$", "documentTypes", ")", "{", "foreach", "(", "$", "documentTypes", "as", "$", "name", "=>", "$", "class", ")", "{", "$", "documentType", "=", "new", "$", "class", ";", "if", "(", "!", "$", ...
Instantiate and registering document types @param array $documentTypes Document types configuration map [name => fully qualified class name] @throws GeneratorServiceException if map contains name of class that is not descendant of AbstractDocumentType @throws GeneratorServiceException if map contains type name that already has been registered
[ "Instantiate", "and", "registering", "document", "types" ]
70e418a84c34930662f2f6a8e12687e2c8492849
https://github.com/infotech-ru/yii-document-generator/blob/70e418a84c34930662f2f6a8e12687e2c8492849/src/Service/GeneratorService.php#L76-L88
train
gossi/trixionary
src/model/Base/ObjectQuery.php
ObjectQuery.filterByFixed
public function filterByFixed($fixed = null, $comparison = null) { if (is_string($fixed)) { $fixed = in_array(strtolower($fixed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(ObjectTableMap::COL_FIXED, $fixed, $comparison); }
php
public function filterByFixed($fixed = null, $comparison = null) { if (is_string($fixed)) { $fixed = in_array(strtolower($fixed), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(ObjectTableMap::COL_FIXED, $fixed, $comparison); }
[ "public", "function", "filterByFixed", "(", "$", "fixed", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "fixed", ")", ")", "{", "$", "fixed", "=", "in_array", "(", "strtolower", "(", "$", "fixed", ")", ...
Filter the query on the fixed column Example usage: <code> $query->filterByFixed(true); // WHERE fixed = true $query->filterByFixed('yes'); // WHERE fixed = true </code> @param boolean|string $fixed The value to use as filter. Non-boolean arguments are converted using the following rules: * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * 0, '0', 'false', 'off', and 'no' are converted to boolean false Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildObjectQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "fixed", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L382-L389
train
gossi/trixionary
src/model/Base/ObjectQuery.php
ObjectQuery.filterBySportId
public function filterBySportId($sportId = null, $comparison = null) { if (is_array($sportId)) { $useMinMax = false; if (isset($sportId['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($sportId['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId, $comparison); }
php
public function filterBySportId($sportId = null, $comparison = null) { if (is_array($sportId)) { $useMinMax = false; if (isset($sportId['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($sportId['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SPORT_ID, $sportId, $comparison); }
[ "public", "function", "filterBySportId", "(", "$", "sportId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "sportId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", ...
Filter the query on the sport_id column Example usage: <code> $query->filterBySportId(1234); // WHERE sport_id = 1234 $query->filterBySportId(array(12, 34)); // WHERE sport_id IN (12, 34) $query->filterBySportId(array('min' => 12)); // WHERE sport_id > 12 </code> @see filterBySport() @param mixed $sportId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildObjectQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "sport_id", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L440-L461
train
gossi/trixionary
src/model/Base/ObjectQuery.php
ObjectQuery.filterBySkillCount
public function filterBySkillCount($skillCount = null, $comparison = null) { if (is_array($skillCount)) { $useMinMax = false; if (isset($skillCount['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($skillCount['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount, $comparison); }
php
public function filterBySkillCount($skillCount = null, $comparison = null) { if (is_array($skillCount)) { $useMinMax = false; if (isset($skillCount['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($skillCount['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount, $comparison); }
[ "public", "function", "filterBySkillCount", "(", "$", "skillCount", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "skillCount", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", ...
Filter the query on the skill_count column Example usage: <code> $query->filterBySkillCount(1234); // WHERE skill_count = 1234 $query->filterBySkillCount(array(12, 34)); // WHERE skill_count IN (12, 34) $query->filterBySkillCount(array('min' => 12)); // WHERE skill_count > 12 </code> @param mixed $skillCount The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildObjectQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "skill_count", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L481-L502
train
jetfirephp/debugbar
src/DebugBar/DataCollector/PDO/TracedStatement.php
TracedStatement.getParameters
public function getParameters() { $params = array(); foreach ($this->parameters as $name => $param) { $params[$name] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); } return $params; }
php
public function getParameters() { $params = array(); foreach ($this->parameters as $name => $param) { $params[$name] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); } return $params; }
[ "public", "function", "getParameters", "(", ")", "{", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "name", "=>", "$", "param", ")", "{", "$", "params", "[", "$", "name", "]", "=", "htmlenti...
Returns an array of parameters used with the query @return array
[ "Returns", "an", "array", "of", "parameters", "used", "with", "the", "query" ]
ee083ebf60536d13aecf05d250d8455f4693f730
https://github.com/jetfirephp/debugbar/blob/ee083ebf60536d13aecf05d250d8455f4693f730/src/DebugBar/DataCollector/PDO/TracedStatement.php#L137-L144
train
kambo-1st/HttpMessage
src/Factories/Environment/Superglobal/HeadersFactory.php
HeadersFactory.resolveHeaders
private function resolveHeaders($headersForResolve) { $headers = []; foreach ($headersForResolve as $name => $value) { if (strpos($name, 'REDIRECT_') === 0) { $name = substr($name, 9); // Do not replace existing variables if (array_key_exists($name, $headersForResolve)) { continue; } } if (substr($name, 0, 5) == 'HTTP_' || isset($this->specialHeaders[$name])) { $headers[$name] = $value; } } return $headers; }
php
private function resolveHeaders($headersForResolve) { $headers = []; foreach ($headersForResolve as $name => $value) { if (strpos($name, 'REDIRECT_') === 0) { $name = substr($name, 9); // Do not replace existing variables if (array_key_exists($name, $headersForResolve)) { continue; } } if (substr($name, 0, 5) == 'HTTP_' || isset($this->specialHeaders[$name])) { $headers[$name] = $value; } } return $headers; }
[ "private", "function", "resolveHeaders", "(", "$", "headersForResolve", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "headersForResolve", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "name", ",",...
Resolve headers from provided array @param array $headersForResolve array compatible with $_SERVER superglobal variable @return Headers Instance of Headers object from environment
[ "Resolve", "headers", "from", "provided", "array" ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Factories/Environment/Superglobal/HeadersFactory.php#L51-L71
train
webriq/core
module/Core/src/Grid/Core/Model/Rpc/Json.php
Json.error
public function error( $message, $code = null, $data = null ) { if ( null === $code && isset( $this->errorCodes[$message] ) ) { $code = $this->errorCodes[$message]; } return $this->getResponse( 'error', (object) array( 'code' => $code, 'message' => $message, 'data' => $data, ) ); }
php
public function error( $message, $code = null, $data = null ) { if ( null === $code && isset( $this->errorCodes[$message] ) ) { $code = $this->errorCodes[$message]; } return $this->getResponse( 'error', (object) array( 'code' => $code, 'message' => $message, 'data' => $data, ) ); }
[ "public", "function", "error", "(", "$", "message", ",", "$", "code", "=", "null", ",", "$", "data", "=", "null", ")", "{", "if", "(", "null", "===", "$", "code", "&&", "isset", "(", "$", "this", "->", "errorCodes", "[", "$", "message", "]", ")",...
Send error result @param string $message @param int $code @param mixed $data
[ "Send", "error", "result" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Rpc/Json.php#L123-L135
train
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.generateRouteFromText
public function generateRouteFromText($text, $withSlash = false) { if ($withSlash) { $result = ''; foreach (explode('/', $text) as $value) { if ('' !== $value = trim($value)) { $result .= '/' . Urlizer::urlize($value); } } return $result ?: '/'; } return $this->normalizeRoute(Urlizer::urlize($text)); }
php
public function generateRouteFromText($text, $withSlash = false) { if ($withSlash) { $result = ''; foreach (explode('/', $text) as $value) { if ('' !== $value = trim($value)) { $result .= '/' . Urlizer::urlize($value); } } return $result ?: '/'; } return $this->normalizeRoute(Urlizer::urlize($text)); }
[ "public", "function", "generateRouteFromText", "(", "$", "text", ",", "$", "withSlash", "=", "false", ")", "{", "if", "(", "$", "withSlash", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "explode", "(", "'/'", ",", "$", "text", ")", "as", ...
Generate route from text. @param string $text @param bool $withSlash @return string
[ "Generate", "route", "from", "text", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L49-L63
train
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.generateUniqueRoute
public function generateUniqueRoute(RouteInterface $route, $withSlash = false) { $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash); if ($originalRoutePattern) { $key = 0; $routePattern = $this->normalizeRoute($originalRoutePattern); while ($this->hasRoute($routePattern, $route->getName())) { $key++; $routePattern = $originalRoutePattern . '-' . $key; } $route->setRoutePattern($routePattern); return $route; } return null; }
php
public function generateUniqueRoute(RouteInterface $route, $withSlash = false) { $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash); if ($originalRoutePattern) { $key = 0; $routePattern = $this->normalizeRoute($originalRoutePattern); while ($this->hasRoute($routePattern, $route->getName())) { $key++; $routePattern = $originalRoutePattern . '-' . $key; } $route->setRoutePattern($routePattern); return $route; } return null; }
[ "public", "function", "generateUniqueRoute", "(", "RouteInterface", "$", "route", ",", "$", "withSlash", "=", "false", ")", "{", "$", "originalRoutePattern", "=", "$", "this", "->", "generateRouteFromText", "(", "$", "route", "->", "getRoutePattern", "(", ")", ...
Generate unique route. @param RouteInterface $route @param bool $withSlash @return null|RouteInterface
[ "Generate", "unique", "route", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L73-L92
train
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.hasRoute
private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return ((null !== $route) && ($routeName !== $route->getName())); }
php
private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return ((null !== $route) && ($routeName !== $route->getName())); }
[ "private", "function", "hasRoute", "(", "$", "routePattern", ",", "$", "routeName", ")", "{", "if", "(", "!", "$", "routeName", ")", "{", "throw", "new", "RoutingRuntimeException", "(", "'Route name is empty!'", ")", ";", "}", "$", "route", "=", "$", "this...
Has route. @param string $routePattern @param string $routeName @return bool @throws RoutingRuntimeException
[ "Has", "route", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L104-L113
train
todstoychev/websafe-colors
src/Wsc.php
Wsc.createRgbArray
private static function createRgbArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = ['r' => $r, 'g' => $g, 'b' => $b]; } } } return $colors; }
php
private static function createRgbArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = ['r' => $r, 'g' => $g, 'b' => $b]; } } } return $colors; }
[ "private", "static", "function", "createRgbArray", "(", "array", "$", "vals", ")", "{", "foreach", "(", "$", "vals", "as", "$", "r", ")", "{", "foreach", "(", "$", "vals", "as", "$", "g", ")", "{", "foreach", "(", "$", "vals", "as", "$", "b", ")"...
Creates rgb codes array @example [ ['r' => 0, 'g' => 0, 'b' => 0], ['r' => 0, 'g' => 51, 'b' => 0], ['r' => 0, 'g' => 0, 'b' => 51], ... ] @param array $vals Initial values @return array
[ "Creates", "rgb", "codes", "array" ]
3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958
https://github.com/todstoychev/websafe-colors/blob/3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958/src/Wsc.php#L79-L90
train
todstoychev/websafe-colors
src/Wsc.php
Wsc.createHexArray
private static function createHexArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = self::rgbToHex($r, $g, $b); } } } return $colors; }
php
private static function createHexArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = self::rgbToHex($r, $g, $b); } } } return $colors; }
[ "private", "static", "function", "createHexArray", "(", "array", "$", "vals", ")", "{", "foreach", "(", "$", "vals", "as", "$", "r", ")", "{", "foreach", "(", "$", "vals", "as", "$", "g", ")", "{", "foreach", "(", "$", "vals", "as", "$", "b", ")"...
Creates hex values array @example [ 000000, 003300, 000033, ... ] @param array $vals initial values @return array
[ "Creates", "hex", "values", "array" ]
3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958
https://github.com/todstoychev/websafe-colors/blob/3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958/src/Wsc.php#L104-L115
train
rozaverta/cmf
core/Cmd/Api/Host/Host.php
Host.setWww
public function setWww( bool $www = true ) { $this->www = $www; $this->invoke("www", $www); return $this; }
php
public function setWww( bool $www = true ) { $this->www = $www; $this->invoke("www", $www); return $this; }
[ "public", "function", "setWww", "(", "bool", "$", "www", "=", "true", ")", "{", "$", "this", "->", "www", "=", "$", "www", ";", "$", "this", "->", "invoke", "(", "\"www\"", ",", "$", "www", ")", ";", "return", "$", "this", ";", "}" ]
Use or not WWW prefix for domain @param bool $www @return $this
[ "Use", "or", "not", "WWW", "prefix", "for", "domain" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Cmd/Api/Host/Host.php#L159-L164
train
simplecomplex/php-config
src/IniSectionedFlatConfig.php
IniSectionedFlatConfig.getMultiple
public function getMultiple(string $section, $keys, $default = null) { $concatted = []; foreach ($keys as $key) { $concatted[] = $section . $this->sectionKeyDelimiter . $key; } return $this->cacheStore->getMultiple($concatted, $default); }
php
public function getMultiple(string $section, $keys, $default = null) { $concatted = []; foreach ($keys as $key) { $concatted[] = $section . $this->sectionKeyDelimiter . $key; } return $this->cacheStore->getMultiple($concatted, $default); }
[ "public", "function", "getMultiple", "(", "string", "$", "section", ",", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "concatted", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "concatted", "[", ...
Retrieves multiple config items by their unique section+keys, from cache. @see SectionedConfigInterface::getMultiple() @inheritdoc
[ "Retrieves", "multiple", "config", "items", "by", "their", "unique", "section", "+", "keys", "from", "cache", "." ]
0d8450bc7523e8991452ef70f4f57f3d3e67f0d4
https://github.com/simplecomplex/php-config/blob/0d8450bc7523e8991452ef70f4f57f3d3e67f0d4/src/IniSectionedFlatConfig.php#L127-L134
train
simplecomplex/php-config
src/IniSectionedFlatConfig.php
IniSectionedFlatConfig.setMultiple
public function setMultiple(string $section, $values) : bool { $concatted = []; foreach ($values as $key => $value) { $concatted[$section . $this->sectionKeyDelimiter . $key] = $value; } return $this->cacheStore->setMultiple($concatted); }
php
public function setMultiple(string $section, $values) : bool { $concatted = []; foreach ($values as $key => $value) { $concatted[$section . $this->sectionKeyDelimiter . $key] = $value; } return $this->cacheStore->setMultiple($concatted); }
[ "public", "function", "setMultiple", "(", "string", "$", "section", ",", "$", "values", ")", ":", "bool", "{", "$", "concatted", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "concatted", "[...
Persists a set of section+key => value pairs; in the cache, not .ini file. @see SectionedConfigInterface::setMultiple() @inheritdoc
[ "Persists", "a", "set", "of", "section", "+", "key", "=", ">", "value", "pairs", ";", "in", "the", "cache", "not", ".", "ini", "file", "." ]
0d8450bc7523e8991452ef70f4f57f3d3e67f0d4
https://github.com/simplecomplex/php-config/blob/0d8450bc7523e8991452ef70f4f57f3d3e67f0d4/src/IniSectionedFlatConfig.php#L144-L151
train
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.convert
public function convert() { //Verify the record exists before proceeding if(empty($this->record) || $this->record===false || !$this->record->exists()) { return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found')); } return $this->customise(array( 'Title'=>_t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'), 'Content'=>null, 'Form'=>$this->ConvertObjectForm(), 'KapostObject'=>$this->record ))->renderWith('KapostAdmin_ConvertDialog'); }
php
public function convert() { //Verify the record exists before proceeding if(empty($this->record) || $this->record===false || !$this->record->exists()) { return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found')); } return $this->customise(array( 'Title'=>_t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'), 'Content'=>null, 'Form'=>$this->ConvertObjectForm(), 'KapostObject'=>$this->record ))->renderWith('KapostAdmin_ConvertDialog'); }
[ "public", "function", "convert", "(", ")", "{", "//Verify the record exists before proceeding", "if", "(", "empty", "(", "$", "this", "->", "record", ")", "||", "$", "this", "->", "record", "===", "false", "||", "!", "$", "this", "->", "record", "->", "exi...
Handles requests for the convert dialog @return string HTML to be sent to the browser
[ "Handles", "requests", "for", "the", "convert", "dialog" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L52-L64
train
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.getDestinationClass
private function getDestinationClass() { if(empty($this->record) || $this->record===false) { return false; } $convertToClass=false; if(class_exists($this->record->DestinationClass) && is_subclass_of($this->record->DestinationClass, 'SiteTree')) { $convertToClass=$this->record->DestinationClass; }else { $parentClasses=array_reverse(ClassInfo::dataClassesFor($this->record->ClassName)); unset($parentClasses[$this->record->ClassName]); unset($parentClasses['KapostObject']); if(count($parentClasses)>0) { foreach($parentClasses as $class) { $sng=singleton($class); if(class_exists($sng->DestinationClass) && is_subclass_of($sng->DestinationClass, 'SiteTree')) { $convertToClass=$sng->DestinationClass; break; } } if(isset($sng)) { unset($sng); } } } return $convertToClass; }
php
private function getDestinationClass() { if(empty($this->record) || $this->record===false) { return false; } $convertToClass=false; if(class_exists($this->record->DestinationClass) && is_subclass_of($this->record->DestinationClass, 'SiteTree')) { $convertToClass=$this->record->DestinationClass; }else { $parentClasses=array_reverse(ClassInfo::dataClassesFor($this->record->ClassName)); unset($parentClasses[$this->record->ClassName]); unset($parentClasses['KapostObject']); if(count($parentClasses)>0) { foreach($parentClasses as $class) { $sng=singleton($class); if(class_exists($sng->DestinationClass) && is_subclass_of($sng->DestinationClass, 'SiteTree')) { $convertToClass=$sng->DestinationClass; break; } } if(isset($sng)) { unset($sng); } } } return $convertToClass; }
[ "private", "function", "getDestinationClass", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "record", ")", "||", "$", "this", "->", "record", "===", "false", ")", "{", "return", "false", ";", "}", "$", "convertToClass", "=", "false", ";", ...
Gets the destination class for the record @return string|bool Returns the destination class name or false if it can't be found
[ "Gets", "the", "destination", "class", "for", "the", "record" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L571-L601
train
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.cleanUpExpiredPreviews
private function cleanUpExpiredPreviews() { $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes'))); if($expiredPreviews->count()>0) { foreach($expiredPreviews as $kapostObj) { $kapostObj->delete(); } } }
php
private function cleanUpExpiredPreviews() { $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes'))); if($expiredPreviews->count()>0) { foreach($expiredPreviews as $kapostObj) { $kapostObj->delete(); } } }
[ "private", "function", "cleanUpExpiredPreviews", "(", ")", "{", "$", "expiredPreviews", "=", "KapostObject", "::", "get", "(", ")", "->", "filter", "(", "'IsKapostPreview'", ",", "true", ")", "->", "filter", "(", "'LastEdited:LessThan'", ",", "date", "(", "'Y-...
Cleans up expired Kapost previews after twice the token expiry
[ "Cleans", "up", "expired", "Kapost", "previews", "after", "twice", "the", "token", "expiry" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L606-L613
train
a3020/cron-expression
src/Cron/CronExpression.php
CronExpression.getPreviousRunDate
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); }
php
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); }
[ "public", "function", "getPreviousRunDate", "(", "$", "currentTime", "=", "'now'", ",", "$", "nth", "=", "0", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "return", "$", "this", "->", "getRunDate", "(", "$", "currentTime", ",", "$", "nth", ",", ...
Get a previous run date relative to the current date or a specific date @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return \DateTime @throws \RuntimeException on too many iterations @see \Cron\CronExpression::getNextRunDate
[ "Get", "a", "previous", "run", "date", "relative", "to", "the", "current", "date", "or", "a", "specific", "date" ]
a78465476b01b302ca35253780999b6fc122c248
https://github.com/a3020/cron-expression/blob/a78465476b01b302ca35253780999b6fc122c248/src/Cron/CronExpression.php#L211-L214
train
a3020/cron-expression
src/Cron/CronExpression.php
CronExpression.getRunDate
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = clone $currentTime; } elseif ($currentTime instanceof DateTimeImmutable) { $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); $currentDate->setTimezone($currentTime->getTimezone()); } else { $currentDate = new DateTime($currentTime ?: 'now'); $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); } $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); $nextRun = clone $currentDate; $nth = (int) $nth; // We don't have to satisfy * or null fields $parts = array(); $fields = array(); foreach (self::$order as $position) { $part = $this->getExpression($position); if (null === $part || '*' === $part) { continue; } $parts[$position] = $part; $fields[$position] = $this->fieldFactory->getField($position); } // Set a hard limit to bail on an impossible date for ($i = 0; $i < $this->maxIterationCount; $i++) { foreach ($parts as $position => $part) { $satisfied = false; // Get the field object used to validate this part $field = $fields[$position]; // Check if this is singular or a list if (strpos($part, ',') === false) { $satisfied = $field->isSatisfiedBy($nextRun, $part); } else { foreach (array_map('trim', explode(',', $part)) as $listPart) { if ($field->isSatisfiedBy($nextRun, $listPart)) { $satisfied = true; break; } } } // If the field is not satisfied, then start over if (!$satisfied) { $field->increment($nextRun, $invert, $part); continue 2; } } // Skip this match if needed if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null); continue; } return $nextRun; } // @codeCoverageIgnoreStart throw new RuntimeException('Impossible CRON expression'); // @codeCoverageIgnoreEnd }
php
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = clone $currentTime; } elseif ($currentTime instanceof DateTimeImmutable) { $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); $currentDate->setTimezone($currentTime->getTimezone()); } else { $currentDate = new DateTime($currentTime ?: 'now'); $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); } $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); $nextRun = clone $currentDate; $nth = (int) $nth; // We don't have to satisfy * or null fields $parts = array(); $fields = array(); foreach (self::$order as $position) { $part = $this->getExpression($position); if (null === $part || '*' === $part) { continue; } $parts[$position] = $part; $fields[$position] = $this->fieldFactory->getField($position); } // Set a hard limit to bail on an impossible date for ($i = 0; $i < $this->maxIterationCount; $i++) { foreach ($parts as $position => $part) { $satisfied = false; // Get the field object used to validate this part $field = $fields[$position]; // Check if this is singular or a list if (strpos($part, ',') === false) { $satisfied = $field->isSatisfiedBy($nextRun, $part); } else { foreach (array_map('trim', explode(',', $part)) as $listPart) { if ($field->isSatisfiedBy($nextRun, $listPart)) { $satisfied = true; break; } } } // If the field is not satisfied, then start over if (!$satisfied) { $field->increment($nextRun, $invert, $part); continue 2; } } // Skip this match if needed if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null); continue; } return $nextRun; } // @codeCoverageIgnoreStart throw new RuntimeException('Impossible CRON expression'); // @codeCoverageIgnoreEnd }
[ "protected", "function", "getRunDate", "(", "$", "currentTime", "=", "null", ",", "$", "nth", "=", "0", ",", "$", "invert", "=", "false", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "if", "(", "$", "currentTime", "instanceof", "DateTime", ")", ...
Get the next or previous run date of the expression relative to a date @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning @param bool $invert Set to TRUE to go backwards in time @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return \DateTime @throws \RuntimeException on too many iterations
[ "Get", "the", "next", "or", "previous", "run", "date", "of", "the", "expression", "relative", "to", "a", "date" ]
a78465476b01b302ca35253780999b6fc122c248
https://github.com/a3020/cron-expression/blob/a78465476b01b302ca35253780999b6fc122c248/src/Cron/CronExpression.php#L322-L388
train
deasilworks/api
src/UUID.php
UUID.getV4
public static function getV4() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); }
php
public static function getV4() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); }
[ "public", "static", "function", "getV4", "(", ")", "{", "return", "sprintf", "(", "'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff",...
Get a UUID v4. @ApiAction() @return string
[ "Get", "a", "UUID", "v4", "." ]
f3ba8900b246e8ea1777692b16168fd7295670fc
https://github.com/deasilworks/api/blob/f3ba8900b246e8ea1777692b16168fd7295670fc/src/UUID.php#L45-L54
train
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.handle
public function handle() { foreach ($this->loaders as $loader) { if ($language = call_user_func($loader)) { if (in_array($language, $this->supportedLanguages)) { return $language; } $special = strpos($language, '-') !== false; if ($special && $this->allowFallback && in_array(substr($language, 0, 2), $this->supportedLanguages)) { return substr($language, 0, 2); } if ( ! $special && $this->allowAdvance) { foreach ($this->supportedLanguages as $supportedLanguage) { if ($language === substr($supportedLanguage, 0, 2)) { return $supportedLanguage; } } } } } return false; }
php
public function handle() { foreach ($this->loaders as $loader) { if ($language = call_user_func($loader)) { if (in_array($language, $this->supportedLanguages)) { return $language; } $special = strpos($language, '-') !== false; if ($special && $this->allowFallback && in_array(substr($language, 0, 2), $this->supportedLanguages)) { return substr($language, 0, 2); } if ( ! $special && $this->allowAdvance) { foreach ($this->supportedLanguages as $supportedLanguage) { if ($language === substr($supportedLanguage, 0, 2)) { return $supportedLanguage; } } } } } return false; }
[ "public", "function", "handle", "(", ")", "{", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "if", "(", "$", "language", "=", "call_user_func", "(", "$", "loader", ")", ")", "{", "if", "(", "in_array", "(", "$", "lang...
Run all loaders returns a language string or false. @return bool|string
[ "Run", "all", "loaders", "returns", "a", "language", "string", "or", "false", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L99-L124
train
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromHttpHeader
protected function loadFromHttpHeader() { foreach (Yii::$app->request->getAcceptableLanguages() as $language) { if (in_array($language, $this->supportedLanguages)) { return $language; } } return false; }
php
protected function loadFromHttpHeader() { foreach (Yii::$app->request->getAcceptableLanguages() as $language) { if (in_array($language, $this->supportedLanguages)) { return $language; } } return false; }
[ "protected", "function", "loadFromHttpHeader", "(", ")", "{", "foreach", "(", "Yii", "::", "$", "app", "->", "request", "->", "getAcceptableLanguages", "(", ")", "as", "$", "language", ")", "{", "if", "(", "in_array", "(", "$", "language", ",", "$", "thi...
Load language from HTTP header. @return string|bool
[ "Load", "language", "from", "HTTP", "header", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L131-L140
train
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromCookie
protected function loadFromCookie() { if ($this->cookieLanguageField && ($language = Yii::$app->request->cookies->has($this->cookieLanguageField))) { return $language; } return false; }
php
protected function loadFromCookie() { if ($this->cookieLanguageField && ($language = Yii::$app->request->cookies->has($this->cookieLanguageField))) { return $language; } return false; }
[ "protected", "function", "loadFromCookie", "(", ")", "{", "if", "(", "$", "this", "->", "cookieLanguageField", "&&", "(", "$", "language", "=", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "has", "(", "$", "this", "->", "cookieLanguag...
Load language from client cookie. @return string|bool
[ "Load", "language", "from", "client", "cookie", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L147-L154
train
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromQueryParam
protected function loadFromQueryParam() { if ( ! $this->queryParamField) { return false; } if (Yii::$app->state < WebApplication::STATE_HANDLING_REQUEST) { Yii::$app->request->resolve(); } if (($language = Yii::$app->request->get($this->queryParamField, false))) { return $language; } return false; }
php
protected function loadFromQueryParam() { if ( ! $this->queryParamField) { return false; } if (Yii::$app->state < WebApplication::STATE_HANDLING_REQUEST) { Yii::$app->request->resolve(); } if (($language = Yii::$app->request->get($this->queryParamField, false))) { return $language; } return false; }
[ "protected", "function", "loadFromQueryParam", "(", ")", "{", "if", "(", "!", "$", "this", "->", "queryParamField", ")", "{", "return", "false", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "state", "<", "WebApplication", "::", "STATE_HANDLING_REQUE...
Load language from url query param. @return string|bool
[ "Load", "language", "from", "url", "query", "param", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L161-L176
train
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromUri
protected function loadFromUri() { if ( ! $this->uriPosition) { return false; } $url = Yii::$app->request->getAbsoluteUrl(); $parse = parse_url($url); if ( ! empty($parse)) { $path = explode('/', trim($parse['path']), $this->uriPosition + 1); is_string($path) and $path = [$path]; if (isset($parse[$this->uriPosition - 1])) { return $parse[0]; } } return false; }
php
protected function loadFromUri() { if ( ! $this->uriPosition) { return false; } $url = Yii::$app->request->getAbsoluteUrl(); $parse = parse_url($url); if ( ! empty($parse)) { $path = explode('/', trim($parse['path']), $this->uriPosition + 1); is_string($path) and $path = [$path]; if (isset($parse[$this->uriPosition - 1])) { return $parse[0]; } } return false; }
[ "protected", "function", "loadFromUri", "(", ")", "{", "if", "(", "!", "$", "this", "->", "uriPosition", ")", "{", "return", "false", ";", "}", "$", "url", "=", "Yii", "::", "$", "app", "->", "request", "->", "getAbsoluteUrl", "(", ")", ";", "$", "...
Load language from uri position. @return bool
[ "Load", "language", "from", "uri", "position", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L183-L200
train
vinala/kernel
src/Plugins/Plugins.php
Plugins.getInfo
protected static function getInfo() { $files = self::getFiles(); // foreach ($files as $path) { $data = self::convert(self::readFile($path.'/vinala.json'), $path); $data = $data['system']; $data['path'] = $path; if (array_key_exists('alias', $data)) { self::$infos[$data['alias']] = $data; } else { // die($path."/.info"); } } // return self::$infos; }
php
protected static function getInfo() { $files = self::getFiles(); // foreach ($files as $path) { $data = self::convert(self::readFile($path.'/vinala.json'), $path); $data = $data['system']; $data['path'] = $path; if (array_key_exists('alias', $data)) { self::$infos[$data['alias']] = $data; } else { // die($path."/.info"); } } // return self::$infos; }
[ "protected", "static", "function", "getInfo", "(", ")", "{", "$", "files", "=", "self", "::", "getFiles", "(", ")", ";", "//", "foreach", "(", "$", "files", "as", "$", "path", ")", "{", "$", "data", "=", "self", "::", "convert", "(", "self", "::", ...
Get infos about plug-ins.
[ "Get", "infos", "about", "plug", "-", "ins", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L61-L78
train
vinala/kernel
src/Plugins/Plugins.php
Plugins.convert
protected static function convert($string, $path) { $data = json_decode($string, true); // if (json_last_error() == JSON_ERROR_SYNTAX) { throw new InfoStructureException($path); } // return $data; }
php
protected static function convert($string, $path) { $data = json_decode($string, true); // if (json_last_error() == JSON_ERROR_SYNTAX) { throw new InfoStructureException($path); } // return $data; }
[ "protected", "static", "function", "convert", "(", "$", "string", ",", "$", "path", ")", "{", "$", "data", "=", "json_decode", "(", "$", "string", ",", "true", ")", ";", "//", "if", "(", "json_last_error", "(", ")", "==", "JSON_ERROR_SYNTAX", ")", "{",...
Convert JSON to PHP array.
[ "Convert", "JSON", "to", "PHP", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L98-L107
train
vinala/kernel
src/Plugins/Plugins.php
Plugins.getFiles
protected static function getFiles() { $files = []; // foreach (glob(Application::$root.'plugins/*') as $value) { $files[] = $value; } // return $files; }
php
protected static function getFiles() { $files = []; // foreach (glob(Application::$root.'plugins/*') as $value) { $files[] = $value; } // return $files; }
[ "protected", "static", "function", "getFiles", "(", ")", "{", "$", "files", "=", "[", "]", ";", "//", "foreach", "(", "glob", "(", "Application", "::", "$", "root", ".", "'plugins/*'", ")", "as", "$", "value", ")", "{", "$", "files", "[", "]", "=",...
Get all info files path.
[ "Get", "all", "info", "files", "path", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L120-L129
train
vinala/kernel
src/Plugins/Plugins.php
Plugins.setAlias
public static function setAlias($alias) { if (self::isConfigKeyExist($alias, 'shortcuts')) { $shortcuts = self::$config[$alias]['shortcuts']; // foreach ($shortcuts as $alias => $target) { $target = Strings::replace($target, '/', '\\'); Alias::set($target, $alias); } } }
php
public static function setAlias($alias) { if (self::isConfigKeyExist($alias, 'shortcuts')) { $shortcuts = self::$config[$alias]['shortcuts']; // foreach ($shortcuts as $alias => $target) { $target = Strings::replace($target, '/', '\\'); Alias::set($target, $alias); } } }
[ "public", "static", "function", "setAlias", "(", "$", "alias", ")", "{", "if", "(", "self", "::", "isConfigKeyExist", "(", "$", "alias", ",", "'shortcuts'", ")", ")", "{", "$", "shortcuts", "=", "self", "::", "$", "config", "[", "$", "alias", "]", "[...
Set classes aliases.
[ "Set", "classes", "aliases", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L188-L198
train
vinala/kernel
src/Plugins/Plugins.php
Plugins.getCore
public static function getCore($alias, $param) { if (self::isInfoKeyExist($alias, 'core', $param)) { return self::$infos[$alias]['core'][$param]; } else { return; } }
php
public static function getCore($alias, $param) { if (self::isInfoKeyExist($alias, 'core', $param)) { return self::$infos[$alias]['core'][$param]; } else { return; } }
[ "public", "static", "function", "getCore", "(", "$", "alias", ",", "$", "param", ")", "{", "if", "(", "self", "::", "isInfoKeyExist", "(", "$", "alias", ",", "'core'", ",", "$", "param", ")", ")", "{", "return", "self", "::", "$", "infos", "[", "$"...
Get core.
[ "Get", "core", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L211-L218
train
slickframework/template
src/Extension/Text.php
Text.getFilters
public function getFilters() { return [ new \Twig_SimpleFilter( 'truncate', function ($value, $len=75, $ter='...', $preserve = false) { return \Slick\Template\Utils\Text::truncate( $value, $len, $ter, $preserve ); } ), new \Twig_SimpleFilter( 'wordwrap', function ($value, $length = 75, $break = "\n", $cut = false) { return \Slick\Template\Utils\Text::wordwrap( $value, $length, $break, $cut ); } ) ]; }
php
public function getFilters() { return [ new \Twig_SimpleFilter( 'truncate', function ($value, $len=75, $ter='...', $preserve = false) { return \Slick\Template\Utils\Text::truncate( $value, $len, $ter, $preserve ); } ), new \Twig_SimpleFilter( 'wordwrap', function ($value, $length = 75, $break = "\n", $cut = false) { return \Slick\Template\Utils\Text::wordwrap( $value, $length, $break, $cut ); } ) ]; }
[ "public", "function", "getFilters", "(", ")", "{", "return", "[", "new", "\\", "Twig_SimpleFilter", "(", "'truncate'", ",", "function", "(", "$", "value", ",", "$", "len", "=", "75", ",", "$", "ter", "=", "'...'", ",", "$", "preserve", "=", "false", ...
Returns a list of filters @return array
[ "Returns", "a", "list", "of", "filters" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Extension/Text.php#L37-L63
train
coolms/authentication
src/Adapter/AbstractAdapter.php
AbstractAdapter.setSatisfied
public function setSatisfied($bool = true) { $storage = $this->getStorage()->read() ?: []; $storage['is_satisfied'] = $bool; $this->getStorage()->write($storage); return $this; }
php
public function setSatisfied($bool = true) { $storage = $this->getStorage()->read() ?: []; $storage['is_satisfied'] = $bool; $this->getStorage()->write($storage); return $this; }
[ "public", "function", "setSatisfied", "(", "$", "bool", "=", "true", ")", "{", "$", "storage", "=", "$", "this", "->", "getStorage", "(", ")", "->", "read", "(", ")", "?", ":", "[", "]", ";", "$", "storage", "[", "'is_satisfied'", "]", "=", "$", ...
Set if this adapter is satisfied or not @param bool $bool @return self
[ "Set", "if", "this", "adapter", "is", "satisfied", "or", "not" ]
4563cc4cc3a4d777db45977bd179cc5bd3f57cd8
https://github.com/coolms/authentication/blob/4563cc4cc3a4d777db45977bd179cc5bd3f57cd8/src/Adapter/AbstractAdapter.php#L70-L77
train
phn-io/template
spec/Phn/Template/LexerSpec.php
LexerSpec.it_tokenize_templates
function it_tokenize_templates() { $this->tokenize(new Cursor("TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT"))->shouldBeLike([ new Token(Token::TYPE_TEXT, 'TEXT ', 1), new Token(Token::TYPE_OPEN_TAG | Token::TYPE_SYMBOL, '<{', 1), new Token(Token::TYPE_SYMBOL, '...', 1), new Token(Token::TYPE_SYMBOL, '.', 1), new Token(Token::TYPE_KEYWORD | Token::TYPE_IDENTIFIER, 'keyword', 1), new Token(Token::TYPE_STRING | Token::TYPE_SINGLE_QUOTED, 'string', 1), new Token(Token::TYPE_STRING | Token::TYPE_DOUBLE_QUOTED, 'string', 1), new Token(Token::TYPE_NUMBER, '3.14', 1), new Token(Token::TYPE_IDENTIFIER, 'var', 1), new Token(Token::TYPE_CONSTANT, 'null', 1), new Token(Token::TYPE_CONSTANT, 'true', 1), new Token(Token::TYPE_CONSTANT, 'false', 1), new Token(Token::TYPE_CLOSE_TAG | Token::TYPE_SYMBOL, '}>', 1), new Token(Token::TYPE_TEXT, ' TEXT', 1), new Token(Token::TYPE_EOF, null, 1), ]); }
php
function it_tokenize_templates() { $this->tokenize(new Cursor("TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT"))->shouldBeLike([ new Token(Token::TYPE_TEXT, 'TEXT ', 1), new Token(Token::TYPE_OPEN_TAG | Token::TYPE_SYMBOL, '<{', 1), new Token(Token::TYPE_SYMBOL, '...', 1), new Token(Token::TYPE_SYMBOL, '.', 1), new Token(Token::TYPE_KEYWORD | Token::TYPE_IDENTIFIER, 'keyword', 1), new Token(Token::TYPE_STRING | Token::TYPE_SINGLE_QUOTED, 'string', 1), new Token(Token::TYPE_STRING | Token::TYPE_DOUBLE_QUOTED, 'string', 1), new Token(Token::TYPE_NUMBER, '3.14', 1), new Token(Token::TYPE_IDENTIFIER, 'var', 1), new Token(Token::TYPE_CONSTANT, 'null', 1), new Token(Token::TYPE_CONSTANT, 'true', 1), new Token(Token::TYPE_CONSTANT, 'false', 1), new Token(Token::TYPE_CLOSE_TAG | Token::TYPE_SYMBOL, '}>', 1), new Token(Token::TYPE_TEXT, ' TEXT', 1), new Token(Token::TYPE_EOF, null, 1), ]); }
[ "function", "it_tokenize_templates", "(", ")", "{", "$", "this", "->", "tokenize", "(", "new", "Cursor", "(", "\"TEXT <{ ... . keyword 'string' \\\"string\\\" 3.14 var null true false }> TEXT\"", ")", ")", "->", "shouldBeLike", "(", "[", "new", "Token", "(", "Token", ...
It tokenize templates.
[ "It", "tokenize", "templates", "." ]
7d89c2a54347069340ff9b545b4c64b5512da1c3
https://github.com/phn-io/template/blob/7d89c2a54347069340ff9b545b4c64b5512da1c3/spec/Phn/Template/LexerSpec.php#L48-L67
train
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.optimizeUrls
protected function optimizeUrls($content, $file) { preg_match_all('/url\((.[^\)]*)\)/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = $match[1]; // Remove the apostrophs if (strpos($uri, '\'') === 0 || strpos($uri, '"') === 0) { $uri = substr($uri, 1, -1); } // If the uri is an absolute url we do not change anything if (strpos($uri, 'http') === 0) { continue; } $additionalData = $this->getAdditionalUriData($uri); $uri = $this->removeAdditionalUriData($uri); $path = dirname($file); $fullFilePath = realpath($path . '/' . $uri); $fileInformation = pathinfo($fullFilePath); $imageExtensions = array('png', 'jpg', 'jpeg', 'gif'); if (in_array($fileInformation['extension'], $imageExtensions)) { // Load the file content $fileContent = $this->fileBackend->loadFromFile($fullFilePath); // Encode the file content $encodedContent = base64_encode($fileContent); $urlData = 'data:image/gif;base64,' . $encodedContent; // Replace the reference in the css content $content = str_replace($match[1], '\'' . $urlData . '\'', $content); } else { $type = AssetManager::BINARY; // Cache the file $cachedFile = $this->assetCacheManager->generateCachedFile($type, $fullFilePath); $url = $this->assetCacheManager->getUrlToTheAssetLoader($cachedFile['file']); // Add the additional data if ($additionalData !== '') { $url .= $additionalData; } // Replace the reference in the css content $content = str_replace($match[1], '\'' . $url . '\'', $content); } } return $content; }
php
protected function optimizeUrls($content, $file) { preg_match_all('/url\((.[^\)]*)\)/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = $match[1]; // Remove the apostrophs if (strpos($uri, '\'') === 0 || strpos($uri, '"') === 0) { $uri = substr($uri, 1, -1); } // If the uri is an absolute url we do not change anything if (strpos($uri, 'http') === 0) { continue; } $additionalData = $this->getAdditionalUriData($uri); $uri = $this->removeAdditionalUriData($uri); $path = dirname($file); $fullFilePath = realpath($path . '/' . $uri); $fileInformation = pathinfo($fullFilePath); $imageExtensions = array('png', 'jpg', 'jpeg', 'gif'); if (in_array($fileInformation['extension'], $imageExtensions)) { // Load the file content $fileContent = $this->fileBackend->loadFromFile($fullFilePath); // Encode the file content $encodedContent = base64_encode($fileContent); $urlData = 'data:image/gif;base64,' . $encodedContent; // Replace the reference in the css content $content = str_replace($match[1], '\'' . $urlData . '\'', $content); } else { $type = AssetManager::BINARY; // Cache the file $cachedFile = $this->assetCacheManager->generateCachedFile($type, $fullFilePath); $url = $this->assetCacheManager->getUrlToTheAssetLoader($cachedFile['file']); // Add the additional data if ($additionalData !== '') { $url .= $additionalData; } // Replace the reference in the css content $content = str_replace($match[1], '\'' . $url . '\'', $content); } } return $content; }
[ "protected", "function", "optimizeUrls", "(", "$", "content", ",", "$", "file", ")", "{", "preg_match_all", "(", "'/url\\((.[^\\)]*)\\)/is'", ",", "$", "content", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "matches", "as", "$"...
Optimizes the urls in the css content. @access protected @param string $content @param string $file @return string
[ "Optimizes", "the", "urls", "in", "the", "css", "content", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L99-L153
train
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.getAdditionalUriData
protected function getAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, strpos($uri, '#')); } return ''; }
php
protected function getAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, strpos($uri, '#')); } return ''; }
[ "protected", "function", "getAdditionalUriData", "(", "$", "uri", ")", "{", "if", "(", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "strpos", "(", "$", "uri", ",", "'?'", ")", ")", ...
Returns the additional uri data of the given uri. @access protected @param string $uri @return string
[ "Returns", "the", "additional", "uri", "data", "of", "the", "given", "uri", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L162-L171
train
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.removeAdditionalUriData
protected function removeAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, 0, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, 0, strpos($uri, '#')); } return $uri; }
php
protected function removeAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, 0, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, 0, strpos($uri, '#')); } return $uri; }
[ "protected", "function", "removeAdditionalUriData", "(", "$", "uri", ")", "{", "if", "(", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "0", ",", "strpos", "(", "$", "uri", ",", "'?'...
Returns the uri without any additional uri data. @access protected @param string $uri @return string
[ "Returns", "the", "uri", "without", "any", "additional", "uri", "data", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L180-L189
train
webbuilders-group/silverstripe-kapost-bridge
code/model/KapostPage.php
KapostPage.createConversionHistory
public function createConversionHistory($destinationID) { $obj=new KapostConversionHistory(); $obj->Title=$this->Title; $obj->KapostChangeType=$this->KapostChangeType; $obj->KapostRefID=$this->KapostRefID; $obj->KapostAuthor=$this->KapostAuthor; $obj->DestinationType=$this->DestinationClass; $obj->DestinationID=$destinationID; $obj->ConverterName=Member::currentUser()->Name; $obj->write(); return $obj; }
php
public function createConversionHistory($destinationID) { $obj=new KapostConversionHistory(); $obj->Title=$this->Title; $obj->KapostChangeType=$this->KapostChangeType; $obj->KapostRefID=$this->KapostRefID; $obj->KapostAuthor=$this->KapostAuthor; $obj->DestinationType=$this->DestinationClass; $obj->DestinationID=$destinationID; $obj->ConverterName=Member::currentUser()->Name; $obj->write(); return $obj; }
[ "public", "function", "createConversionHistory", "(", "$", "destinationID", ")", "{", "$", "obj", "=", "new", "KapostConversionHistory", "(", ")", ";", "$", "obj", "->", "Title", "=", "$", "this", "->", "Title", ";", "$", "obj", "->", "KapostChangeType", "...
Used for recording a conversion history record @param int $destinationID ID of the destination object when converting @return KapostConversionHistory
[ "Used", "for", "recording", "a", "conversion", "history", "record" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostPage.php#L66-L78
train
webbuilders-group/silverstripe-kapost-bridge
code/model/KapostPage.php
KapostPage.renderPreview
public function renderPreview() { $previewFieldMap=array( 'ClassName'=>$this->DestinationClass, 'IsKapostPreview'=>true, 'Children'=>false, 'Menu'=>false, 'MetaTags'=>false, 'Breadcrumbs'=>false, 'current_stage'=>Versioned::current_stage(), 'SilverStripeNavigator'=>false ); //Allow extensions to add onto the array $extensions=$this->extend('updatePreviewFieldMap'); $extensions=array_filter($extensions, function($v) {return !is_null($v) && is_array($v);}); if(count($extensions)>0) { foreach($extensions as $ext) { $previewFieldMap=array_merge($previewFieldMap, $ext); } } //Find the controller class $ancestry=ClassInfo::ancestry($this->DestinationClass); while($class=array_pop($ancestry)) { if(class_exists($class."_Controller")) { break; } } $controller=($class!==null ? "{$class}_Controller":"ContentController"); return $controller::create($this)->customise($previewFieldMap); }
php
public function renderPreview() { $previewFieldMap=array( 'ClassName'=>$this->DestinationClass, 'IsKapostPreview'=>true, 'Children'=>false, 'Menu'=>false, 'MetaTags'=>false, 'Breadcrumbs'=>false, 'current_stage'=>Versioned::current_stage(), 'SilverStripeNavigator'=>false ); //Allow extensions to add onto the array $extensions=$this->extend('updatePreviewFieldMap'); $extensions=array_filter($extensions, function($v) {return !is_null($v) && is_array($v);}); if(count($extensions)>0) { foreach($extensions as $ext) { $previewFieldMap=array_merge($previewFieldMap, $ext); } } //Find the controller class $ancestry=ClassInfo::ancestry($this->DestinationClass); while($class=array_pop($ancestry)) { if(class_exists($class."_Controller")) { break; } } $controller=($class!==null ? "{$class}_Controller":"ContentController"); return $controller::create($this)->customise($previewFieldMap); }
[ "public", "function", "renderPreview", "(", ")", "{", "$", "previewFieldMap", "=", "array", "(", "'ClassName'", "=>", "$", "this", "->", "DestinationClass", ",", "'IsKapostPreview'", "=>", "true", ",", "'Children'", "=>", "false", ",", "'Menu'", "=>", "false",...
Handles rendering of the preview for this object @return string Preview to be rendered
[ "Handles", "rendering", "of", "the", "preview", "for", "this", "object" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostPage.php#L84-L117
train
rinvex/renamed-tags
src/Models/Tag.php
Tag.findByName
public static function findByName($tags, string $group = null, string $locale = null): Collection { $locale = $locale ?? app()->getLocale(); return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) { return ($exists = static::firstByName($tag, $group, $locale)) ? $exists->getKey() : null; })->filter()->unique(); }
php
public static function findByName($tags, string $group = null, string $locale = null): Collection { $locale = $locale ?? app()->getLocale(); return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) { return ($exists = static::firstByName($tag, $group, $locale)) ? $exists->getKey() : null; })->filter()->unique(); }
[ "public", "static", "function", "findByName", "(", "$", "tags", ",", "string", "$", "group", "=", "null", ",", "string", "$", "locale", "=", "null", ")", ":", "Collection", "{", "$", "locale", "=", "$", "locale", "??", "app", "(", ")", "->", "getLoca...
Find tag by name. @param mixed $tags @param string|null $group @param string|null $locale @return \Illuminate\Support\Collection
[ "Find", "tag", "by", "name", "." ]
b7f0a9758236da057ceaf1b30748646503399c89
https://github.com/rinvex/renamed-tags/blob/b7f0a9758236da057ceaf1b30748646503399c89/src/Models/Tag.php#L199-L206
train
rinvex/renamed-tags
src/Models/Tag.php
Tag.firstByName
public static function firstByName(string $tag, string $group = null, string $locale = null) { $locale = $locale ?? app()->getLocale(); return static::query()->where("name->{$locale}", $tag)->when($group, function (Builder $builder) use ($group) { return $builder->where('group', $group); })->first(); }
php
public static function firstByName(string $tag, string $group = null, string $locale = null) { $locale = $locale ?? app()->getLocale(); return static::query()->where("name->{$locale}", $tag)->when($group, function (Builder $builder) use ($group) { return $builder->where('group', $group); })->first(); }
[ "public", "static", "function", "firstByName", "(", "string", "$", "tag", ",", "string", "$", "group", "=", "null", ",", "string", "$", "locale", "=", "null", ")", "{", "$", "locale", "=", "$", "locale", "??", "app", "(", ")", "->", "getLocale", "(",...
Get first tag by name. @param string $tag @param string|null $group @param string|null $locale @return static|null
[ "Get", "first", "tag", "by", "name", "." ]
b7f0a9758236da057ceaf1b30748646503399c89
https://github.com/rinvex/renamed-tags/blob/b7f0a9758236da057ceaf1b30748646503399c89/src/Models/Tag.php#L217-L224
train
lukaszmakuch/haringo
src/BuildingStrategy/Impl/BuildingStrategyTpl.php
BuildingStrategyTpl.findMatchingMethods
protected function findMatchingMethods( \ReflectionClass $reflectedClass, MethodSelector $selector ) { try { return $this->findMatchingMethodsImpl($reflectedClass, $selector); } catch (UnsupportedMatcher $e) { throw new UnableToBuild(); } }
php
protected function findMatchingMethods( \ReflectionClass $reflectedClass, MethodSelector $selector ) { try { return $this->findMatchingMethodsImpl($reflectedClass, $selector); } catch (UnsupportedMatcher $e) { throw new UnableToBuild(); } }
[ "protected", "function", "findMatchingMethods", "(", "\\", "ReflectionClass", "$", "reflectedClass", ",", "MethodSelector", "$", "selector", ")", "{", "try", "{", "return", "$", "this", "->", "findMatchingMethodsImpl", "(", "$", "reflectedClass", ",", "$", "select...
Finds all methods matching the given selector. @return ReflectionMethod[] @throws UnableToBuild
[ "Finds", "all", "methods", "matching", "the", "given", "selector", "." ]
7a2ff30f4e7b215b2573a9562ed449f6495d303d
https://github.com/lukaszmakuch/haringo/blob/7a2ff30f4e7b215b2573a9562ed449f6495d303d/src/BuildingStrategy/Impl/BuildingStrategyTpl.php#L113-L122
train
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.computeCredentialsName
protected function computeCredentialsName($prefix = null) { if (!$prefix) { $paths = $this->get('paths'); if ($paths && isset($paths['default'])) { $prefix = $paths['default']; } } preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix); if (count($prefix)) return end($prefix); return basename($this->repository->getDir()); }
php
protected function computeCredentialsName($prefix = null) { if (!$prefix) { $paths = $this->get('paths'); if ($paths && isset($paths['default'])) { $prefix = $paths['default']; } } preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix); if (count($prefix)) return end($prefix); return basename($this->repository->getDir()); }
[ "protected", "function", "computeCredentialsName", "(", "$", "prefix", "=", "null", ")", "{", "if", "(", "!", "$", "prefix", ")", "{", "$", "paths", "=", "$", "this", "->", "get", "(", "'paths'", ")", ";", "if", "(", "$", "paths", "&&", "isset", "(...
Compute the repository credentials name @return string
[ "Compute", "the", "repository", "credentials", "name" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L63-L73
train
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.rm
protected function rm($configOption) { if (isset($this->configuration[$configOption])) unset($this->configuration[$configOption]); return $this; }
php
protected function rm($configOption) { if (isset($this->configuration[$configOption])) unset($this->configuration[$configOption]); return $this; }
[ "protected", "function", "rm", "(", "$", "configOption", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configuration", "[", "$", "configOption", "]", ")", ")", "unset", "(", "$", "this", "->", "configuration", "[", "$", "configOption", "]", ")...
Remove a config option @param string $configOption The config option to write @return Configuration
[ "Remove", "a", "config", "option" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L106-L110
train
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.save
protected function save() { // write contents modify in hgrc if ($fileConfig = @fopen($this->repository->getDir() . $this->repository->getFileConfig() . "hgrc", 'w+')) { $ret = fwrite($fileConfig, $this->arr2ini($this->configuration)); fclose($fileConfig); return $ret; } return false; }
php
protected function save() { // write contents modify in hgrc if ($fileConfig = @fopen($this->repository->getDir() . $this->repository->getFileConfig() . "hgrc", 'w+')) { $ret = fwrite($fileConfig, $this->arr2ini($this->configuration)); fclose($fileConfig); return $ret; } return false; }
[ "protected", "function", "save", "(", ")", "{", "// write contents modify in hgrc", "if", "(", "$", "fileConfig", "=", "@", "fopen", "(", "$", "this", "->", "repository", "->", "getDir", "(", ")", ".", "$", "this", "->", "repository", "->", "getFileConfig", ...
Save the config to file @return boolean
[ "Save", "the", "config", "to", "file" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L117-L125
train
bytic/translation
src/TranslatorServiceProvider.php
TranslatorServiceProvider.registerTranslator
protected function registerTranslator() { $this->getContainer() ->share('translator', function () { $translator = new Translator('en'); $translator->addLoader('php', new PhpFileLoader()); return $translator; }); }
php
protected function registerTranslator() { $this->getContainer() ->share('translator', function () { $translator = new Translator('en'); $translator->addLoader('php', new PhpFileLoader()); return $translator; }); }
[ "protected", "function", "registerTranslator", "(", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "share", "(", "'translator'", ",", "function", "(", ")", "{", "$", "translator", "=", "new", "Translator", "(", "'en'", ")", ";", "$", "trans...
Register the session manager instance. @return void
[ "Register", "the", "session", "manager", "instance", "." ]
974e57099d901126c4117010f4a269fe1f80b651
https://github.com/bytic/translation/blob/974e57099d901126c4117010f4a269fe1f80b651/src/TranslatorServiceProvider.php#L44-L52
train
koriym/Any.Serializer
src/Any/Serializer/Serializer.php
Serializer.removeUnrealizableInArray
private function removeUnrealizableInArray(array &$array) { $this->removeReferenceItemInArray($array); foreach ($array as &$value) { if (is_object($value)) { $value = $this->removeUnserializable($value); } if (is_array($value)) { $this->removeUnrealizableInArray($value); } if ($this->isUnserializable($value)) { $value = null; } } return $array; }
php
private function removeUnrealizableInArray(array &$array) { $this->removeReferenceItemInArray($array); foreach ($array as &$value) { if (is_object($value)) { $value = $this->removeUnserializable($value); } if (is_array($value)) { $this->removeUnrealizableInArray($value); } if ($this->isUnserializable($value)) { $value = null; } } return $array; }
[ "private", "function", "removeUnrealizableInArray", "(", "array", "&", "$", "array", ")", "{", "$", "this", "->", "removeReferenceItemInArray", "(", "$", "array", ")", ";", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "is_o...
remove Unrealizable In Array @param array &$array @return array
[ "remove", "Unrealizable", "In", "Array" ]
06426462fbcbd8c824206390959e30f54da58392
https://github.com/koriym/Any.Serializer/blob/06426462fbcbd8c824206390959e30f54da58392/src/Any/Serializer/Serializer.php#L89-L105
train
koriym/Any.Serializer
src/Any/Serializer/Serializer.php
Serializer.removeReferenceItemInArray
private function removeReferenceItemInArray(array &$room) { $roomCopy = $room; $keys = array_keys($room); foreach ($keys as $key) { if (is_array($roomCopy[$key])) { $roomCopy[$key]['_test'] = true; if (isset($room[$key]['_test'])) { // It's a reference unset($room[$key]); } } } }
php
private function removeReferenceItemInArray(array &$room) { $roomCopy = $room; $keys = array_keys($room); foreach ($keys as $key) { if (is_array($roomCopy[$key])) { $roomCopy[$key]['_test'] = true; if (isset($room[$key]['_test'])) { // It's a reference unset($room[$key]); } } } }
[ "private", "function", "removeReferenceItemInArray", "(", "array", "&", "$", "room", ")", "{", "$", "roomCopy", "=", "$", "room", ";", "$", "keys", "=", "array_keys", "(", "$", "room", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{"...
Remove reference item in array @param array &$room @return void @see http://stackoverflow.com/questions/3148125/php-check-if-object-array-is-a-reference @author Chris Smith (original source)
[ "Remove", "reference", "item", "in", "array" ]
06426462fbcbd8c824206390959e30f54da58392
https://github.com/koriym/Any.Serializer/blob/06426462fbcbd8c824206390959e30f54da58392/src/Any/Serializer/Serializer.php#L117-L130
train
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.setBundleInfo
public function setBundleInfo(array $bundleInfo) { $this->kernel->setDrupalBundles($this->getAutoloadedBundles($bundleInfo)); $this->bundlesBooted = false; }
php
public function setBundleInfo(array $bundleInfo) { $this->kernel->setDrupalBundles($this->getAutoloadedBundles($bundleInfo)); $this->bundlesBooted = false; }
[ "public", "function", "setBundleInfo", "(", "array", "$", "bundleInfo", ")", "{", "$", "this", "->", "kernel", "->", "setDrupalBundles", "(", "$", "this", "->", "getAutoloadedBundles", "(", "$", "bundleInfo", ")", ")", ";", "$", "this", "->", "bundlesBooted"...
Set bundle info @param array $bundleInfo
[ "Set", "bundle", "info" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L60-L63
train
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.getContainer
public function getContainer() { // kernel will only boot if necessary $this->kernel->boot(); // boot bundles if necessary if (!$this->bundlesBooted) { foreach ($this->kernel->getBundles() as $bundle) { $bundle->boot(); } $this->bundlesBooted = true; } return $this->kernel->getContainer(); }
php
public function getContainer() { // kernel will only boot if necessary $this->kernel->boot(); // boot bundles if necessary if (!$this->bundlesBooted) { foreach ($this->kernel->getBundles() as $bundle) { $bundle->boot(); } $this->bundlesBooted = true; } return $this->kernel->getContainer(); }
[ "public", "function", "getContainer", "(", ")", "{", "// kernel will only boot if necessary", "$", "this", "->", "kernel", "->", "boot", "(", ")", ";", "// boot bundles if necessary", "if", "(", "!", "$", "this", "->", "bundlesBooted", ")", "{", "foreach", "(", ...
Retrieves the container @return ContainerInterface
[ "Retrieves", "the", "container" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L70-L83
train
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.flushCaches
public function flushCaches($all = false) { $dir = $this->kernel->getCacheDir(); if ($all) { $dir .= '/..'; } $fs = new Filesystem(); $fs->remove(realpath($dir)); }
php
public function flushCaches($all = false) { $dir = $this->kernel->getCacheDir(); if ($all) { $dir .= '/..'; } $fs = new Filesystem(); $fs->remove(realpath($dir)); }
[ "public", "function", "flushCaches", "(", "$", "all", "=", "false", ")", "{", "$", "dir", "=", "$", "this", "->", "kernel", "->", "getCacheDir", "(", ")", ";", "if", "(", "$", "all", ")", "{", "$", "dir", ".=", "'/..'", ";", "}", "$", "fs", "="...
Cleanup cache files
[ "Cleanup", "cache", "files" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L88-L95
train
cyberspectrum/i18n
src/JobBuilder/CopyJobBuilder.php
CopyJobBuilder.copyStringToFlag
private function copyStringToFlag($value): int { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return CopyDictionaryJob::COPY; case 'no' === $value: case 'false' === $value: case false === $value: return CopyDictionaryJob::DO_NOT_COPY; case 'if-empty' === $value: return CopyDictionaryJob::COPY_IF_EMPTY; default: throw new \InvalidArgumentException('Invalid value for copy flag.'); } }
php
private function copyStringToFlag($value): int { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return CopyDictionaryJob::COPY; case 'no' === $value: case 'false' === $value: case false === $value: return CopyDictionaryJob::DO_NOT_COPY; case 'if-empty' === $value: return CopyDictionaryJob::COPY_IF_EMPTY; default: throw new \InvalidArgumentException('Invalid value for copy flag.'); } }
[ "private", "function", "copyStringToFlag", "(", "$", "value", ")", ":", "int", "{", "switch", "(", "true", ")", "{", "case", "'true'", "===", "$", "value", ":", "case", "true", "===", "$", "value", ":", "case", "'yes'", "===", "$", "value", ":", "ret...
Convert the passed value to a copy flag. @param string|bool|null $value The value. @return int @throws \InvalidArgumentException When the value can not be converted.
[ "Convert", "the", "passed", "value", "to", "a", "copy", "flag", "." ]
138e81d7119db82c2420bd33967a566e02b1d2f5
https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/JobBuilder/CopyJobBuilder.php#L89-L105
train
cyberspectrum/i18n
src/JobBuilder/CopyJobBuilder.php
CopyJobBuilder.boolishToFlag
private function boolishToFlag($value): bool { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return true; case 'no' === $value: case 'false' === $value: case false === $value: return false; default: throw new \InvalidArgumentException('Invalid value for remove-obsolete flag.'); } }
php
private function boolishToFlag($value): bool { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return true; case 'no' === $value: case 'false' === $value: case false === $value: return false; default: throw new \InvalidArgumentException('Invalid value for remove-obsolete flag.'); } }
[ "private", "function", "boolishToFlag", "(", "$", "value", ")", ":", "bool", "{", "switch", "(", "true", ")", "{", "case", "'true'", "===", "$", "value", ":", "case", "true", "===", "$", "value", ":", "case", "'yes'", "===", "$", "value", ":", "retur...
Convert the passed value to a bool. @param string|bool|null $value The value. @return bool @throws \InvalidArgumentException When the value can not be converted.
[ "Convert", "the", "passed", "value", "to", "a", "bool", "." ]
138e81d7119db82c2420bd33967a566e02b1d2f5
https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/JobBuilder/CopyJobBuilder.php#L116-L130
train
AnonymPHP/Anonym-Library
src/Anonym/Security/Authentication/Guard.php
Guard.isLogined
public function isLogined() { $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); $login = unserialize(base64_decode($login)); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } return $this->isSameIp($login); }
php
public function isLogined() { $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); $login = unserialize(base64_decode($login)); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } return $this->isSameIp($login); }
[ "public", "function", "isLogined", "(", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "cookie", "=", "$", "this", "->", "getCookie", "(", ")", ";", "if", "(", "$", "cookie", "->", "has", "(", "self", "::", "U...
check is login usered @return bool
[ "check", "is", "login", "usered" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Security/Authentication/Guard.php#L36-L51
train
AnonymPHP/Anonym-Library
src/Anonym/Security/Authentication/Guard.php
Guard.hasRole
public function hasRole($role = ''){ $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } $roleLogin = $login['role']; if (is_string($role)) { return $roleLogin === $role; }elseif(is_array($role)){ return array_search($roleLogin, $role); } return false; }
php
public function hasRole($role = ''){ $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } $roleLogin = $login['role']; if (is_string($role)) { return $roleLogin === $role; }elseif(is_array($role)){ return array_search($roleLogin, $role); } return false; }
[ "public", "function", "hasRole", "(", "$", "role", "=", "''", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "cookie", "=", "$", "this", "->", "getCookie", "(", ")", ";", "if", "(", "$", "cookie", "->", "has",...
check the user role @param string|int $role @return bool
[ "check", "the", "user", "role" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Security/Authentication/Guard.php#L74-L97
train
nubs/sensible
src/Pager.php
Pager.viewFile
public function viewFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function viewFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "viewFile", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "filePath", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_pagerCommand", ")", "->", "setArguments", "(", "[", "$", "...
View the given file using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $filePath The path to the file to view. @return \Symfony\Component\Process\Process The already-executed process.
[ "View", "the", "given", "file", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Pager.php#L35-L41
train
nubs/sensible
src/Pager.php
Pager.viewData
public function viewData(ProcessBuilder $processBuilder, $data) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setInput($data)->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function viewData(ProcessBuilder $processBuilder, $data) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setInput($data)->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "viewData", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "data", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_pagerCommand", ")", "->", "setInput", "(", "$", "data", ")", ...
View the given data using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $data The data to view. @return \Symfony\Component\Process\Process The already-executed process.
[ "View", "the", "given", "data", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Pager.php#L53-L59
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.pollFeed
public function pollFeed($url) { $self = $this; $eventEmitter = $this->getEventEmitter(); $logger = $this->getLogger(); $logger->info('Sending request for feed URL', array('url' => $url)); $request = new HttpRequest(array( 'url' => $url, 'resolveCallback' => function($data) use ($url, $self) { $self->processFeed($url, $data); }, 'rejectCallback' => function($error) use ($url, $self) { $self->processFailure($url, $error); } )); $eventEmitter->emit('http.request', array($request)); }
php
public function pollFeed($url) { $self = $this; $eventEmitter = $this->getEventEmitter(); $logger = $this->getLogger(); $logger->info('Sending request for feed URL', array('url' => $url)); $request = new HttpRequest(array( 'url' => $url, 'resolveCallback' => function($data) use ($url, $self) { $self->processFeed($url, $data); }, 'rejectCallback' => function($error) use ($url, $self) { $self->processFailure($url, $error); } )); $eventEmitter->emit('http.request', array($request)); }
[ "public", "function", "pollFeed", "(", "$", "url", ")", "{", "$", "self", "=", "$", "this", ";", "$", "eventEmitter", "=", "$", "this", "->", "getEventEmitter", "(", ")", ";", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", ...
Polls an individual feed for new content to syndicate to channels or users. This method is public so that queuePoll() can invoke it as a callback. It should not be invoked outside of this class. @param string $url Feed URL
[ "Polls", "an", "individual", "feed", "for", "new", "content", "to", "syndicate", "to", "channels", "or", "users", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L180-L196
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.processFeed
public function processFeed($url, $data) { $logger = $this->getLogger(); $logger->info('Processing feed', array('url' => $url)); $logger->debug('Received feed data', array('data' => $data)); try { $new = iterator_to_array(FeedReader::importString($data)); $old = isset($this->cache[$url]) ? $this->cache[$url] : array(); $diff = $this->getNewFeedItems($new, $old); if ($old) { $this->syndicateFeedItems($diff); } $this->cache[$url] = $new; } catch (\Exception $e) { $logger->warning( 'Failed to process feed', array( 'url' => $url, 'data' => $data, 'error' => $e, ) ); } $this->queuePoll($url); }
php
public function processFeed($url, $data) { $logger = $this->getLogger(); $logger->info('Processing feed', array('url' => $url)); $logger->debug('Received feed data', array('data' => $data)); try { $new = iterator_to_array(FeedReader::importString($data)); $old = isset($this->cache[$url]) ? $this->cache[$url] : array(); $diff = $this->getNewFeedItems($new, $old); if ($old) { $this->syndicateFeedItems($diff); } $this->cache[$url] = $new; } catch (\Exception $e) { $logger->warning( 'Failed to process feed', array( 'url' => $url, 'data' => $data, 'error' => $e, ) ); } $this->queuePoll($url); }
[ "public", "function", "processFeed", "(", "$", "url", ",", "$", "data", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "logger", "->", "info", "(", "'Processing feed'", ",", "array", "(", "'url'", "=>", "$", "url", ...
Processes content from successfully polled feeds. @param string $url URL of the polled feed @param string $data Content received from the feed poll
[ "Processes", "content", "from", "successfully", "polled", "feeds", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L204-L230
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getNewFeedItems
protected function getNewFeedItems(array $new, array $old) { $map = array(); $getKey = function($item) { return $item->getPermalink(); }; $logger = $this->getLogger(); foreach ($new as $item) { $key = $getKey($item); $logger->debug('New: ' . $key); $map[$key] = $item; } foreach ($old as $item) { $key = $getKey($item); $logger->debug('Old: ' . $key); unset($map[$key]); } $logger->debug('Diff: ' . implode(' ', array_keys($map))); return array_values($map); }
php
protected function getNewFeedItems(array $new, array $old) { $map = array(); $getKey = function($item) { return $item->getPermalink(); }; $logger = $this->getLogger(); foreach ($new as $item) { $key = $getKey($item); $logger->debug('New: ' . $key); $map[$key] = $item; } foreach ($old as $item) { $key = $getKey($item); $logger->debug('Old: ' . $key); unset($map[$key]); } $logger->debug('Diff: ' . implode(' ', array_keys($map))); return array_values($map); }
[ "protected", "function", "getNewFeedItems", "(", "array", "$", "new", ",", "array", "$", "old", ")", "{", "$", "map", "=", "array", "(", ")", ";", "$", "getKey", "=", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "getPermalink"...
Locates new items in a feed given newer and older lists of items from the feed. @param \Zend\Feed\Reader\Entry\EntryInterface[] $new @param \Zend\Feed\Reader\Entry\EntryInterface[] $old
[ "Locates", "new", "items", "in", "a", "feed", "given", "newer", "and", "older", "lists", "of", "items", "from", "the", "feed", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L239-L258
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.syndicateFeedItems
protected function syndicateFeedItems(array $items) { $messages = array(); foreach ($items as $item) { $messages[] = $this->formatter->format($item); } foreach ($this->targets as $connection => $targets) { $this->getEventQueue($connection)->then( function($queue) use ($targets, $messages) { foreach ($targets as $target) { foreach ($messages as $message) { $queue->ircPrivmsg($target, $message); } } } ); } }
php
protected function syndicateFeedItems(array $items) { $messages = array(); foreach ($items as $item) { $messages[] = $this->formatter->format($item); } foreach ($this->targets as $connection => $targets) { $this->getEventQueue($connection)->then( function($queue) use ($targets, $messages) { foreach ($targets as $target) { foreach ($messages as $message) { $queue->ircPrivmsg($target, $message); } } } ); } }
[ "protected", "function", "syndicateFeedItems", "(", "array", "$", "items", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "messages", "[", "]", "=", "$", "this", "->", "formatte...
Syndicates a given list of feed items to all targets. @param \Zend\Feed\Reader\Entry\EntryInterface[] $items
[ "Syndicates", "a", "given", "list", "of", "feed", "items", "to", "all", "targets", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L265-L283
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.processFailure
public function processFailure($url, $error) { $this->getLogger()->warning( 'Failed to poll feed', array( 'url' => $url, 'error' => $error, ) ); $this->queuePoll($url); }
php
public function processFailure($url, $error) { $this->getLogger()->warning( 'Failed to poll feed', array( 'url' => $url, 'error' => $error, ) ); $this->queuePoll($url); }
[ "public", "function", "processFailure", "(", "$", "url", ",", "$", "error", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "warning", "(", "'Failed to poll feed'", ",", "array", "(", "'url'", "=>", "$", "url", ",", "'error'", "=>", "$", "err...
Logs feed poll failures. @param string $url URL of the feed for which a poll failure occurred @param string $error Message describing the failure
[ "Logs", "feed", "poll", "failures", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L291-L302
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.queuePoll
protected function queuePoll($url) { $self = $this; $this->loop->addTimer( $this->interval, function() use ($url, $self) { $self->pollFeed($url); } ); }
php
protected function queuePoll($url) { $self = $this; $this->loop->addTimer( $this->interval, function() use ($url, $self) { $self->pollFeed($url); } ); }
[ "protected", "function", "queuePoll", "(", "$", "url", ")", "{", "$", "self", "=", "$", "this", ";", "$", "this", "->", "loop", "->", "addTimer", "(", "$", "this", "->", "interval", ",", "function", "(", ")", "use", "(", "$", "url", ",", "$", "se...
Sets up a callback to poll a specified feed. @param string $url Feed URL
[ "Sets", "up", "a", "callback", "to", "poll", "a", "specified", "feed", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L309-L318
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getEventQueueDeferred
protected function getEventQueueDeferred($mask) { if (!isset($this->queues[$mask])) { $this->queues[$mask] = new Deferred; } return $this->queues[$mask]; }
php
protected function getEventQueueDeferred($mask) { if (!isset($this->queues[$mask])) { $this->queues[$mask] = new Deferred; } return $this->queues[$mask]; }
[ "protected", "function", "getEventQueueDeferred", "(", "$", "mask", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "queues", "[", "$", "mask", "]", ")", ")", "{", "$", "this", "->", "queues", "[", "$", "mask", "]", "=", "new", "Deferred...
Creates a deferred for the event queue of a given connection. @param string $mask Mask for the connection @return \React\Promise\Deferred
[ "Creates", "a", "deferred", "for", "the", "event", "queue", "of", "a", "given", "connection", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L326-L332
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.setEventQueue
public function setEventQueue(Event $event, Queue $queue) { $mask = $this->getConnectionMask($event->getConnection()); $this->getEventQueueDeferred($mask)->resolve($queue); }
php
public function setEventQueue(Event $event, Queue $queue) { $mask = $this->getConnectionMask($event->getConnection()); $this->getEventQueueDeferred($mask)->resolve($queue); }
[ "public", "function", "setEventQueue", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ")", "{", "$", "mask", "=", "$", "this", "->", "getConnectionMask", "(", "$", "event", "->", "getConnection", "(", ")", ")", ";", "$", "this", "->", "getEven...
Stores a reference to the event queue for the connection on which a USER event occurs. @param \Phergie\Irc\EventInterface $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Stores", "a", "reference", "to", "the", "event", "queue", "for", "the", "connection", "on", "which", "a", "USER", "event", "occurs", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L341-L345
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getUrls
protected function getUrls(array $config) { if (!isset($config['urls']) || !is_array($config['urls']) || array_filter($config['urls'], 'is_string') != $config['urls']) { throw new \DomainException( 'urls must be a list of strings containing feed URLs', self::ERR_URLS_INVALID ); } return $config['urls']; }
php
protected function getUrls(array $config) { if (!isset($config['urls']) || !is_array($config['urls']) || array_filter($config['urls'], 'is_string') != $config['urls']) { throw new \DomainException( 'urls must be a list of strings containing feed URLs', self::ERR_URLS_INVALID ); } return $config['urls']; }
[ "protected", "function", "getUrls", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'urls'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'urls'", "]", ")", "||", "array_filter", "(", "$", "co...
Extracts feed URLs from configuration. @param array $config @return array @throws \DomainException if urls setting is invalid
[ "Extracts", "feed", "URLs", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L380-L391
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getTargets
protected function getTargets(array $config) { if (!isset($config['targets']) || !is_array($config['targets']) || array_filter($config['targets'], 'is_array') != $config['targets']) { throw new \DomainException( 'targets must be an array of arrays', self::ERR_TARGETS_INVALID ); } return $config['targets']; }
php
protected function getTargets(array $config) { if (!isset($config['targets']) || !is_array($config['targets']) || array_filter($config['targets'], 'is_array') != $config['targets']) { throw new \DomainException( 'targets must be an array of arrays', self::ERR_TARGETS_INVALID ); } return $config['targets']; }
[ "protected", "function", "getTargets", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'targets'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'targets'", "]", ")", "||", "array_filter", "(", "...
Extracts targets from configuration. @param array $config @return array @throws \DomainException if targets setting is invalid
[ "Extracts", "targets", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L400-L411
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getInterval
protected function getInterval(array $config) { if (isset($config['interval'])) { if (!is_int($config['interval']) || $config['interval'] <= 0) { throw new \DomainException( 'interval must reference a positive integer value', self::ERR_INTERVAL_INVALID ); } return $config['interval']; } return 300; // default to 5 minutes }
php
protected function getInterval(array $config) { if (isset($config['interval'])) { if (!is_int($config['interval']) || $config['interval'] <= 0) { throw new \DomainException( 'interval must reference a positive integer value', self::ERR_INTERVAL_INVALID ); } return $config['interval']; } return 300; // default to 5 minutes }
[ "protected", "function", "getInterval", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'interval'", "]", ")", ")", "{", "if", "(", "!", "is_int", "(", "$", "config", "[", "'interval'", "]", ")", "||", "$", "con...
Extracts the interval on which to update feeds from configuration. @param array $config @return int @throws \DomainException if interval setting is invalid
[ "Extracts", "the", "interval", "on", "which", "to", "update", "feeds", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L420-L432
train
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getFormatter
protected function getFormatter(array $config) { if (isset($config['formatter'])) { if (!$config['formatter'] instanceof FormatterInterface) { throw new \DomainException( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface', self::ERR_FORMATTER_INVALID ); } return $config['formatter']; } return new DefaultFormatter; }
php
protected function getFormatter(array $config) { if (isset($config['formatter'])) { if (!$config['formatter'] instanceof FormatterInterface) { throw new \DomainException( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface', self::ERR_FORMATTER_INVALID ); } return $config['formatter']; } return new DefaultFormatter; }
[ "protected", "function", "getFormatter", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'formatter'", "]", ")", ")", "{", "if", "(", "!", "$", "config", "[", "'formatter'", "]", "instanceof", "FormatterInterface", ")...
Extracts the feed item formatter from configuration. @param array $config @return \Phergie\Irc\Plugin\React\FeedTicker\FormatterInterface @throws \DomainException if formatter setting is invalid
[ "Extracts", "the", "feed", "item", "formatter", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L441-L453
train
alevilar/MtSites
Utility/MtSites.php
MtSites.loadConfigFiles
public static function loadConfigFiles () { // Read configuration file from ini file if ( self::isTenant() ) { if ( file_exists( TENANT_PATH . DS . self::getSiteName() . DS . 'settings.ini' ) ) { App::uses('IniReader', 'Configure'); Configure::config('ini', new IniReader( TENANT_PATH . DS . self::getSiteName() . DS )); Configure::load( 'settings', 'ini'); App::uses('CakeNumber', 'Utility'); CakeNumber::defaultCurrency(Configure::read('Geo.currency_code')); } else { throw new CakeException("El archivo de configuracion para el sitio ". self::getSiteName(). " no pudo ser encontrado"); } } }
php
public static function loadConfigFiles () { // Read configuration file from ini file if ( self::isTenant() ) { if ( file_exists( TENANT_PATH . DS . self::getSiteName() . DS . 'settings.ini' ) ) { App::uses('IniReader', 'Configure'); Configure::config('ini', new IniReader( TENANT_PATH . DS . self::getSiteName() . DS )); Configure::load( 'settings', 'ini'); App::uses('CakeNumber', 'Utility'); CakeNumber::defaultCurrency(Configure::read('Geo.currency_code')); } else { throw new CakeException("El archivo de configuracion para el sitio ". self::getSiteName(). " no pudo ser encontrado"); } } }
[ "public", "static", "function", "loadConfigFiles", "(", ")", "{", "// Read configuration file from ini file", "if", "(", "self", "::", "isTenant", "(", ")", ")", "{", "if", "(", "file_exists", "(", "TENANT_PATH", ".", "DS", ".", "self", "::", "getSiteName", "(...
Loads settings files from Tenant folder
[ "Loads", "settings", "files", "from", "Tenant", "folder" ]
5b1cdc52a929ca86a220ae12add84c52027a3c20
https://github.com/alevilar/MtSites/blob/5b1cdc52a929ca86a220ae12add84c52027a3c20/Utility/MtSites.php#L115-L131
train
prototypemvc/prototypemvc
Core/Data.php
Data.count
public static function count($data = false) { if ($data && Validate::isArray($data)) { return count($data); } else if ($data && Validate::isObject($data)) { return count(get_object_vars($data)); } return 0; }
php
public static function count($data = false) { if ($data && Validate::isArray($data)) { return count($data); } else if ($data && Validate::isObject($data)) { return count(get_object_vars($data)); } return 0; }
[ "public", "static", "function", "count", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", "&&", "Validate", "::", "isArray", "(", "$", "data", ")", ")", "{", "return", "count", "(", "$", "data", ")", ";", "}", "else", "if", "(", ...
Count the numbers of keys in a given array or object. @param array || object @return int numbers of keys
[ "Count", "the", "numbers", "of", "keys", "in", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L15-L26
train
prototypemvc/prototypemvc
Core/Data.php
Data.keys
public static function keys($data = false) { if ($data && Validate::isArray($data)) { return array_keys($data); } else if ($data && Validate::isObject($data)) { return get_object_vars($data); } return false; }
php
public static function keys($data = false) { if ($data && Validate::isArray($data)) { return array_keys($data); } else if ($data && Validate::isObject($data)) { return get_object_vars($data); } return false; }
[ "public", "static", "function", "keys", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", "&&", "Validate", "::", "isArray", "(", "$", "data", ")", ")", "{", "return", "array_keys", "(", "$", "data", ")", ";", "}", "else", "if", "...
Get all keys from a given array or object. @param array || object @return array
[ "Get", "all", "keys", "from", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L69-L80
train
prototypemvc/prototypemvc
Core/Data.php
Data.random
public static function random($data = false) { if($data) { if(Validate::isObject($data)) { $data = Format::objectToArray($data); } if(Validate::isArray($data)) { return $data[array_rand($data, 1)]; } } return false; }
php
public static function random($data = false) { if($data) { if(Validate::isObject($data)) { $data = Format::objectToArray($data); } if(Validate::isArray($data)) { return $data[array_rand($data, 1)]; } } return false; }
[ "public", "static", "function", "random", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", ")", "{", "if", "(", "Validate", "::", "isObject", "(", "$", "data", ")", ")", "{", "$", "data", "=", "Format", "::", "objectToArray", "(", ...
Return a random value from a given array or object. @param array || object @return string random value
[ "Return", "a", "random", "value", "from", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L147-L163
train
prototypemvc/prototypemvc
Core/Data.php
Data.sanitize
public function sanitize($input = false) { if($input) { if(Validate::isArray($input)) { return filter_var_array($input,FILTER_SANITIZE_STRING); } if(Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_STRING); } } return false; }
php
public function sanitize($input = false) { if($input) { if(Validate::isArray($input)) { return filter_var_array($input,FILTER_SANITIZE_STRING); } if(Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_STRING); } } return false; }
[ "public", "function", "sanitize", "(", "$", "input", "=", "false", ")", "{", "if", "(", "$", "input", ")", "{", "if", "(", "Validate", "::", "isArray", "(", "$", "input", ")", ")", "{", "return", "filter_var_array", "(", "$", "input", ",", "FILTER_SA...
Sanitize input. @param array || string @return array || string
[ "Sanitize", "input", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L190-L205
train
prototypemvc/prototypemvc
Core/Data.php
Data.type
public static function type($data = false) { if ($data) { $dataType = gettype($data); if ($dataType === 'string') { if (Validate::isJson($data)) { $dataType = 'json'; } } return $dataType; } return false; }
php
public static function type($data = false) { if ($data) { $dataType = gettype($data); if ($dataType === 'string') { if (Validate::isJson($data)) { $dataType = 'json'; } } return $dataType; } return false; }
[ "public", "static", "function", "type", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", ")", "{", "$", "dataType", "=", "gettype", "(", "$", "data", ")", ";", "if", "(", "$", "dataType", "===", "'string'", ")", "{", "if", "(", ...
Return type of a given variable. @param array || double || integer || json || object || string @return string type of variable
[ "Return", "type", "of", "a", "given", "variable", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L232-L249
train
XTAIN/JoomlaBundle
Resources/joomla/com_symfony/site/views/symfony/view.html.php
SymfonyViewSymfony.display
public function display($tpl = null) { $attributes = array(); $query = array(); $app = JFactory::getApplication(); $input = $app->input; $routeName = $input->get('route', null, 'string'); $path = $input->get('path', null, 'string'); $route = self::$router->getRouteCollection()->get($routeName); $defaults = $route->getDefaults(); if ($path !== null) { $path = rtrim($route->getPath(), '/') . '/' . $path; $defaults = self::$router->match($path, null, false); } unset($attributes['_controller']); foreach ($defaults as $key => $default) { if (!isset($attributes[$key])) { $attributes[$key] = $default; } } $subRequest = self::$requestStack->getCurrentRequest()->duplicate($query, null, $attributes); $this->response = self::$kernel->handle( $subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST, false ); // Display the view parent::display($tpl); }
php
public function display($tpl = null) { $attributes = array(); $query = array(); $app = JFactory::getApplication(); $input = $app->input; $routeName = $input->get('route', null, 'string'); $path = $input->get('path', null, 'string'); $route = self::$router->getRouteCollection()->get($routeName); $defaults = $route->getDefaults(); if ($path !== null) { $path = rtrim($route->getPath(), '/') . '/' . $path; $defaults = self::$router->match($path, null, false); } unset($attributes['_controller']); foreach ($defaults as $key => $default) { if (!isset($attributes[$key])) { $attributes[$key] = $default; } } $subRequest = self::$requestStack->getCurrentRequest()->duplicate($query, null, $attributes); $this->response = self::$kernel->handle( $subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST, false ); // Display the view parent::display($tpl); }
[ "public", "function", "display", "(", "$", "tpl", "=", "null", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "$", "query", "=", "array", "(", ")", ";", "$", "app", "=", "JFactory", "::", "getApplication", "(", ")", ";", "$", "input", ...
Display the Hello World view @param string $tpl The name of the template file to parse; automatically searches through the template paths. @return void
[ "Display", "the", "Hello", "World", "view" ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Resources/joomla/com_symfony/site/views/symfony/view.html.php#L85-L122
train
aleksip/patternengine-php-tpl
src/aleksip/PatternEngine/Tpl/Loaders/PatternLoader.php
PatternLoader.render
public function render($options = array()) { $pattern = $options['pattern']; $data = $options['data']; return $this->renderTpl($pattern, $data); }
php
public function render($options = array()) { $pattern = $options['pattern']; $data = $options['data']; return $this->renderTpl($pattern, $data); }
[ "public", "function", "render", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "pattern", "=", "$", "options", "[", "'pattern'", "]", ";", "$", "data", "=", "$", "options", "[", "'data'", "]", ";", "return", "$", "this", "->", "renderT...
Render a pattern. @param array $options Options @return string The rendered result
[ "Render", "a", "pattern", "." ]
08b56cff240481855a012f85eb94b10ddb994d59
https://github.com/aleksip/patternengine-php-tpl/blob/08b56cff240481855a012f85eb94b10ddb994d59/src/aleksip/PatternEngine/Tpl/Loaders/PatternLoader.php#L17-L23
train
nirix/radium
src/Database/Model/SecurePassword.php
SecurePassword.preparePassword
public function preparePassword() { $this->{$this->securePasswordField} = crypt( $this->{$this->securePasswordField}, '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$' ); }
php
public function preparePassword() { $this->{$this->securePasswordField} = crypt( $this->{$this->securePasswordField}, '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$' ); }
[ "public", "function", "preparePassword", "(", ")", "{", "$", "this", "->", "{", "$", "this", "->", "securePasswordField", "}", "=", "crypt", "(", "$", "this", "->", "{", "$", "this", "->", "securePasswordField", "}", ",", "'$2y$10$'", ".", "sha1", "(", ...
Crypts the users password.
[ "Crypts", "the", "users", "password", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/SecurePassword.php#L35-L41
train
agencms/auth
src/Handlers/AgencmsHandler.php
AgencmsHandler.registerUsersAdmin
private static function registerUsersAdmin() { if (!Gate::allows('users_read')) { return; } Agencms::registerRoute( Route::init('users', ['Users' => 'Manage Users'], '/agencms-auth/users') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->required()->list(), Field::related('roleids', 'Roles')->model( Relationship::make('roles') ) ), Group::small('Extra')->addField( Field::boolean('active', 'Active')->list(), Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
php
private static function registerUsersAdmin() { if (!Gate::allows('users_read')) { return; } Agencms::registerRoute( Route::init('users', ['Users' => 'Manage Users'], '/agencms-auth/users') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->required()->list(), Field::related('roleids', 'Roles')->model( Relationship::make('roles') ) ), Group::small('Extra')->addField( Field::boolean('active', 'Active')->list(), Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
[ "private", "static", "function", "registerUsersAdmin", "(", ")", "{", "if", "(", "!", "Gate", "::", "allows", "(", "'users_read'", ")", ")", "{", "return", ";", "}", "Agencms", "::", "registerRoute", "(", "Route", "::", "init", "(", "'users'", ",", "[", ...
Register the Agencms endpoints for User administration @return void
[ "Register", "the", "Agencms", "endpoints", "for", "User", "administration" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Handlers/AgencmsHandler.php#L38-L62
train
agencms/auth
src/Handlers/AgencmsHandler.php
AgencmsHandler.registerUserProfile
private static function registerUserProfile() { Agencms::registerRoute( Route::initSingle('profile', '', '/agencms-auth/profile') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->readonly()->list() ), Group::small('Extra')->addField( Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
php
private static function registerUserProfile() { Agencms::registerRoute( Route::initSingle('profile', '', '/agencms-auth/profile') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->readonly()->list() ), Group::small('Extra')->addField( Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
[ "private", "static", "function", "registerUserProfile", "(", ")", "{", "Agencms", "::", "registerRoute", "(", "Route", "::", "initSingle", "(", "'profile'", ",", "''", ",", "'/agencms-auth/profile'", ")", "->", "icon", "(", "'person'", ")", "->", "addGroup", "...
Register the Agencms endpoints for the User's account profile @return void
[ "Register", "the", "Agencms", "endpoints", "for", "the", "User", "s", "account", "profile" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Handlers/AgencmsHandler.php#L69-L85
train
happyDemon/elements
classes/Kohana/Element/Render.php
Kohana_Element_Render.get_view_path
public function get_view_path() { return $this->_element->view ? $this->_element->view : self::VIEWS_DIR.DIRECTORY_SEPARATOR.$this->_template_dir.DIRECTORY_SEPARATOR.$this->template; }
php
public function get_view_path() { return $this->_element->view ? $this->_element->view : self::VIEWS_DIR.DIRECTORY_SEPARATOR.$this->_template_dir.DIRECTORY_SEPARATOR.$this->template; }
[ "public", "function", "get_view_path", "(", ")", "{", "return", "$", "this", "->", "_element", "->", "view", "?", "$", "this", "->", "_element", "->", "view", ":", "self", "::", "VIEWS_DIR", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "_template_di...
Get the path of the view file @return string
[ "Get", "the", "path", "of", "the", "view", "file" ]
19534fcbf4735a12a0219f8aada49f30e3b690e1
https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element/Render.php#L84-L87
train
prototypemvc/prototypemvc
Core/Number.php
Number.average
public static function average($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round((array_sum($array) / count($array)), $decimals); } return false; }
php
public static function average($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round((array_sum($array) / count($array)), $decimals); } return false; }
[ "public", "static", "function", "average", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "("...
Get the average value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "average", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L15-L23
train
prototypemvc/prototypemvc
Core/Number.php
Number.max
public static function max($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(max($array), $decimals); } return false; }
php
public static function max($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(max($array), $decimals); } return false; }
[ "public", "static", "function", "max", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "3", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", ...
Get the heighest value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "heighest", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L31-L39
train
prototypemvc/prototypemvc
Core/Number.php
Number.min
public static function min($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(min($array), $decimals); } return false; }
php
public static function min($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(min($array), $decimals); } return false; }
[ "public", "static", "function", "min", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "3", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", ...
Get the lowest value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "lowest", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L47-L55
train
prototypemvc/prototypemvc
Core/Number.php
Number.percentage
public static function percentage($number1 = false, $number2 = false, $decimals = 2) { if($number1 && $number2) { return self::round(($number1 / $number2) * 100, $decimals); } return false; }
php
public static function percentage($number1 = false, $number2 = false, $decimals = 2) { if($number1 && $number2) { return self::round(($number1 / $number2) * 100, $decimals); } return false; }
[ "public", "static", "function", "percentage", "(", "$", "number1", "=", "false", ",", "$", "number2", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "number1", "&&", "$", "number2", ")", "{", "return", "self", "::", "round", ...
Get the percentage. @param float number part @param float number total @param numbes of decimals @return int || float
[ "Get", "the", "percentage", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L64-L72
train
prototypemvc/prototypemvc
Core/Number.php
Number.round
public static function round($number = false, $decimals = false) { if($number) { return number_format((float)$number, $decimals); } return false; }
php
public static function round($number = false, $decimals = false) { if($number) { return number_format((float)$number, $decimals); } return false; }
[ "public", "static", "function", "round", "(", "$", "number", "=", "false", ",", "$", "decimals", "=", "false", ")", "{", "if", "(", "$", "number", ")", "{", "return", "number_format", "(", "(", "float", ")", "$", "number", ",", "$", "decimals", ")", ...
Get a round number. @example round(15, 2) - will return 15.00 @example round(15.123, 2) - will return 15.12 @param float number @param int number of decimals @return int || float
[ "Get", "a", "round", "number", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L93-L101
train
prototypemvc/prototypemvc
Core/Number.php
Number.total
public static function total($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
php
public static function total($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
[ "public", "static", "function", "total", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", ...
Get the sum total of a given array's values. @param array with values @return int || float
[ "Get", "the", "sum", "total", "of", "a", "given", "array", "s", "values", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L130-L138
train
opsbears/piccolo-web-io-standard
src/StandardOutputProcessor.php
StandardOutputProcessor.execute
public function execute(ResponseInterface $httpResponse) { $headerFunction = $this->headerFunction; $bodyFunction = $this->bodyFunction; $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase()); foreach ($httpResponse->getHeaders() as $name => $values) { foreach ($values as $value) { $headerFunction(sprintf('%s: %s', $name, $value)); } } $bodyFunction($httpResponse->getBody()); }
php
public function execute(ResponseInterface $httpResponse) { $headerFunction = $this->headerFunction; $bodyFunction = $this->bodyFunction; $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase()); foreach ($httpResponse->getHeaders() as $name => $values) { foreach ($values as $value) { $headerFunction(sprintf('%s: %s', $name, $value)); } } $bodyFunction($httpResponse->getBody()); }
[ "public", "function", "execute", "(", "ResponseInterface", "$", "httpResponse", ")", "{", "$", "headerFunction", "=", "$", "this", "->", "headerFunction", ";", "$", "bodyFunction", "=", "$", "this", "->", "bodyFunction", ";", "$", "headerFunction", "(", "'HTTP...
Process a ResponseInterface into an output. @param ResponseInterface $httpResponse
[ "Process", "a", "ResponseInterface", "into", "an", "output", "." ]
ee8638bfded26d68a93a7fc3e0fed3f6add8d196
https://github.com/opsbears/piccolo-web-io-standard/blob/ee8638bfded26d68a93a7fc3e0fed3f6add8d196/src/StandardOutputProcessor.php#L57-L69
train