id
int32
0
241k
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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
3,000
SlabPHP/input-manager
src/Manager.php
Manager.supplementGetArray
private function supplementGetArray() { if (empty($_SERVER["REQUEST_URI"])) { return; } $queryStringBegins = strpos($_SERVER["REQUEST_URI"], '?'); if (empty($queryStringBegins)) { return; } $queryString = substr($_SERVER["REQUEST_URI"], $queryStringBegins + 1); $getArray = array(); parse_str($queryString, $getArray); foreach ($getArray as $variable => $value) { $this->getParams[$variable] = $this->cleanVariable($value); } }
php
private function supplementGetArray() { if (empty($_SERVER["REQUEST_URI"])) { return; } $queryStringBegins = strpos($_SERVER["REQUEST_URI"], '?'); if (empty($queryStringBegins)) { return; } $queryString = substr($_SERVER["REQUEST_URI"], $queryStringBegins + 1); $getArray = array(); parse_str($queryString, $getArray); foreach ($getArray as $variable => $value) { $this->getParams[$variable] = $this->cleanVariable($value); } }
[ "private", "function", "supplementGetArray", "(", ")", "{", "if", "(", "empty", "(", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ")", ")", "{", "return", ";", "}", "$", "queryStringBegins", "=", "strpos", "(", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ",", "'?'", ")", ";", "if", "(", "empty", "(", "$", "queryStringBegins", ")", ")", "{", "return", ";", "}", "$", "queryString", "=", "substr", "(", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ",", "$", "queryStringBegins", "+", "1", ")", ";", "$", "getArray", "=", "array", "(", ")", ";", "parse_str", "(", "$", "queryString", ",", "$", "getArray", ")", ";", "foreach", "(", "$", "getArray", "as", "$", "variable", "=>", "$", "value", ")", "{", "$", "this", "->", "getParams", "[", "$", "variable", "]", "=", "$", "this", "->", "cleanVariable", "(", "$", "value", ")", ";", "}", "}" ]
Some servers will not populate the remaining get params because of the mod rewrite redirect This will solve it.
[ "Some", "servers", "will", "not", "populate", "the", "remaining", "get", "params", "because", "of", "the", "mod", "rewrite", "redirect" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L102-L124
3,001
SlabPHP/input-manager
src/Manager.php
Manager.initializeAndCleanSuperGlobal
private function initializeAndCleanSuperGlobal(&$superGlobal, &$localStorage) { $localStorage = []; if (!empty($superGlobal)) { foreach ($superGlobal as $variableName => $variableValue) { $localStorage[$variableName] = $this->cleanVariable($variableValue); } } }
php
private function initializeAndCleanSuperGlobal(&$superGlobal, &$localStorage) { $localStorage = []; if (!empty($superGlobal)) { foreach ($superGlobal as $variableName => $variableValue) { $localStorage[$variableName] = $this->cleanVariable($variableValue); } } }
[ "private", "function", "initializeAndCleanSuperGlobal", "(", "&", "$", "superGlobal", ",", "&", "$", "localStorage", ")", "{", "$", "localStorage", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "superGlobal", ")", ")", "{", "foreach", "(", "$", "superGlobal", "as", "$", "variableName", "=>", "$", "variableValue", ")", "{", "$", "localStorage", "[", "$", "variableName", "]", "=", "$", "this", "->", "cleanVariable", "(", "$", "variableValue", ")", ";", "}", "}", "}" ]
Initialize local storage of a super global and kill the super global version @param array $superGlobal @param string $localStorage
[ "Initialize", "local", "storage", "of", "a", "super", "global", "and", "kill", "the", "super", "global", "version" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L132-L140
3,002
SlabPHP/input-manager
src/Manager.php
Manager.cleanVariable
private function cleanVariable($input) { if (is_string($input)) { if ($this->shouldSanitizeInput) { return trim(strip_tags($input)); } else { return trim($input); } } else { return $input; } }
php
private function cleanVariable($input) { if (is_string($input)) { if ($this->shouldSanitizeInput) { return trim(strip_tags($input)); } else { return trim($input); } } else { return $input; } }
[ "private", "function", "cleanVariable", "(", "$", "input", ")", "{", "if", "(", "is_string", "(", "$", "input", ")", ")", "{", "if", "(", "$", "this", "->", "shouldSanitizeInput", ")", "{", "return", "trim", "(", "strip_tags", "(", "$", "input", ")", ")", ";", "}", "else", "{", "return", "trim", "(", "$", "input", ")", ";", "}", "}", "else", "{", "return", "$", "input", ";", "}", "}" ]
Cleans a variable from input @param string $input @return string
[ "Cleans", "a", "variable", "from", "input" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L148-L159
3,003
SlabPHP/input-manager
src/Manager.php
Manager.request
public function request($variable) { $order = ini_get('request_order'); if (empty($order)) { $order = ini_get('variables_order'); } $len = strlen($order); for ($i = 0; $i < $len; ++$i) { $character = strtoupper($order[$i]); if ($character == 'G') { if ($this->get($variable)) return $this->get($variable); } else if ($character == 'P') { if ($this->post($variable)) return $this->post($variable); } else if ($character == 'C') { if ($this->cookie($variable)) return $this->cookie($variable); } } return null; }
php
public function request($variable) { $order = ini_get('request_order'); if (empty($order)) { $order = ini_get('variables_order'); } $len = strlen($order); for ($i = 0; $i < $len; ++$i) { $character = strtoupper($order[$i]); if ($character == 'G') { if ($this->get($variable)) return $this->get($variable); } else if ($character == 'P') { if ($this->post($variable)) return $this->post($variable); } else if ($character == 'C') { if ($this->cookie($variable)) return $this->cookie($variable); } } return null; }
[ "public", "function", "request", "(", "$", "variable", ")", "{", "$", "order", "=", "ini_get", "(", "'request_order'", ")", ";", "if", "(", "empty", "(", "$", "order", ")", ")", "{", "$", "order", "=", "ini_get", "(", "'variables_order'", ")", ";", "}", "$", "len", "=", "strlen", "(", "$", "order", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "++", "$", "i", ")", "{", "$", "character", "=", "strtoupper", "(", "$", "order", "[", "$", "i", "]", ")", ";", "if", "(", "$", "character", "==", "'G'", ")", "{", "if", "(", "$", "this", "->", "get", "(", "$", "variable", ")", ")", "return", "$", "this", "->", "get", "(", "$", "variable", ")", ";", "}", "else", "if", "(", "$", "character", "==", "'P'", ")", "{", "if", "(", "$", "this", "->", "post", "(", "$", "variable", ")", ")", "return", "$", "this", "->", "post", "(", "$", "variable", ")", ";", "}", "else", "if", "(", "$", "character", "==", "'C'", ")", "{", "if", "(", "$", "this", "->", "cookie", "(", "$", "variable", ")", ")", "return", "$", "this", "->", "cookie", "(", "$", "variable", ")", ";", "}", "}", "return", "null", ";", "}" ]
Check get, post, and cookie for return @param string $variable @return mixed
[ "Check", "get", "post", "and", "cookie", "for", "return" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L167-L190
3,004
SlabPHP/input-manager
src/Manager.php
Manager.get
public function get($variable = null, $default = '', $validator = null) { $value = $this->returnLocalParam('getParams', $variable, $default); return $value; }
php
public function get($variable = null, $default = '', $validator = null) { $value = $this->returnLocalParam('getParams', $variable, $default); return $value; }
[ "public", "function", "get", "(", "$", "variable", "=", "null", ",", "$", "default", "=", "''", ",", "$", "validator", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "returnLocalParam", "(", "'getParams'", ",", "$", "variable", ",", "$", "default", ")", ";", "return", "$", "value", ";", "}" ]
Return a GET parameter, enter null for the entire array @param string $variable @param string $default @param mixed $validator @return string
[ "Return", "a", "GET", "parameter", "enter", "null", "for", "the", "entire", "array" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L200-L205
3,005
SlabPHP/input-manager
src/Manager.php
Manager.post
public function post($variable = null, $default = '', $validator = null) { $value = $this->returnLocalParam('postParams', $variable, $default); return $value; }
php
public function post($variable = null, $default = '', $validator = null) { $value = $this->returnLocalParam('postParams', $variable, $default); return $value; }
[ "public", "function", "post", "(", "$", "variable", "=", "null", ",", "$", "default", "=", "''", ",", "$", "validator", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "returnLocalParam", "(", "'postParams'", ",", "$", "variable", ",", "$", "default", ")", ";", "return", "$", "value", ";", "}" ]
Return a POSt parameter, enter null for the entire array @param string $variable @param string $default @param mixed $validator @return string
[ "Return", "a", "POSt", "parameter", "enter", "null", "for", "the", "entire", "array" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L216-L221
3,006
SlabPHP/input-manager
src/Manager.php
Manager.setCookie
public function setCookie($variable, $value) { if (!empty($value)) { $this->cookieParams[$variable] = $value; return; } unset($this->cookieParams[$variable]); }
php
public function setCookie($variable, $value) { if (!empty($value)) { $this->cookieParams[$variable] = $value; return; } unset($this->cookieParams[$variable]); }
[ "public", "function", "setCookie", "(", "$", "variable", ",", "$", "value", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "this", "->", "cookieParams", "[", "$", "variable", "]", "=", "$", "value", ";", "return", ";", "}", "unset", "(", "$", "this", "->", "cookieParams", "[", "$", "variable", "]", ")", ";", "}" ]
Set the current page's instance of a cookie value. Does not actually set a cookie @param string $variable @param mixed $value
[ "Set", "the", "current", "page", "s", "instance", "of", "a", "cookie", "value", ".", "Does", "not", "actually", "set", "a", "cookie" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L284-L292
3,007
SlabPHP/input-manager
src/Manager.php
Manager.returnLocalParam
private function returnLocalParam($localStorage, $variable, $default = false) { if (!empty($variable)) { if (isset($this->{$localStorage}[$variable])) { return $this->{$localStorage}[$variable]; } else { return $default; } } else { return $this->{$localStorage}; } }
php
private function returnLocalParam($localStorage, $variable, $default = false) { if (!empty($variable)) { if (isset($this->{$localStorage}[$variable])) { return $this->{$localStorage}[$variable]; } else { return $default; } } else { return $this->{$localStorage}; } }
[ "private", "function", "returnLocalParam", "(", "$", "localStorage", ",", "$", "variable", ",", "$", "default", "=", "false", ")", "{", "if", "(", "!", "empty", "(", "$", "variable", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "{", "$", "localStorage", "}", "[", "$", "variable", "]", ")", ")", "{", "return", "$", "this", "->", "{", "$", "localStorage", "}", "[", "$", "variable", "]", ";", "}", "else", "{", "return", "$", "default", ";", "}", "}", "else", "{", "return", "$", "this", "->", "{", "$", "localStorage", "}", ";", "}", "}" ]
Return a stored local variable @param string $localStorage @param string $variable @param bool $default
[ "Return", "a", "stored", "local", "variable" ]
0f2f7ae76cfb6c0483ec501e403826387bca46c5
https://github.com/SlabPHP/input-manager/blob/0f2f7ae76cfb6c0483ec501e403826387bca46c5/src/Manager.php#L301-L312
3,008
Attibee/Bumble-Form
src/Element/Select.php
Select.addOption
public function addOption( array $config ) { $opt = new Option; $opt->setAttributes( $config ); $this->addChild( $opt ); }
php
public function addOption( array $config ) { $opt = new Option; $opt->setAttributes( $config ); $this->addChild( $opt ); }
[ "public", "function", "addOption", "(", "array", "$", "config", ")", "{", "$", "opt", "=", "new", "Option", ";", "$", "opt", "->", "setAttributes", "(", "$", "config", ")", ";", "$", "this", "->", "addChild", "(", "$", "opt", ")", ";", "}" ]
Adds an option given the config array. @param $config an array of config
[ "Adds", "an", "option", "given", "the", "config", "array", "." ]
546c4b01806c68d8ffc09766f74dc157d9ab4960
https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Element/Select.php#L36-L42
3,009
Attibee/Bumble-Form
src/Element/Select.php
Select.setAttribute
public function setAttribute( $name, $value ) { if( strtolower( $name ) == 'value' ) { $this->setSelectedOption( $value ); } else { parent::setAttribute( $name, $value ); } }
php
public function setAttribute( $name, $value ) { if( strtolower( $name ) == 'value' ) { $this->setSelectedOption( $value ); } else { parent::setAttribute( $name, $value ); } }
[ "public", "function", "setAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "name", ")", "==", "'value'", ")", "{", "$", "this", "->", "setSelectedOption", "(", "$", "value", ")", ";", "}", "else", "{", "parent", "::", "setAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}" ]
Handles the value attribute. If the "value" attribute is set, the option with the attribute's value is then selected. @param $name the name of the attribute @param $value the value of the attribute
[ "Handles", "the", "value", "attribute", ".", "If", "the", "value", "attribute", "is", "set", "the", "option", "with", "the", "attribute", "s", "value", "is", "then", "selected", "." ]
546c4b01806c68d8ffc09766f74dc157d9ab4960
https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Element/Select.php#L60-L66
3,010
Cheezykins/RestAPICore
util/PropertyAccessor.php
PropertyAccessor.getResourceIdFromUrl
public static function getResourceIdFromUrl($url) { $url = rtrim($url, '/'); $parts = explode('/', $url); return (int)array_pop($parts); }
php
public static function getResourceIdFromUrl($url) { $url = rtrim($url, '/'); $parts = explode('/', $url); return (int)array_pop($parts); }
[ "public", "static", "function", "getResourceIdFromUrl", "(", "$", "url", ")", "{", "$", "url", "=", "rtrim", "(", "$", "url", ",", "'/'", ")", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "url", ")", ";", "return", "(", "int", ")", "array_pop", "(", "$", "parts", ")", ";", "}" ]
Gets the resource ID from a given URL @param string $url @return int
[ "Gets", "the", "resource", "ID", "from", "a", "given", "URL" ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/util/PropertyAccessor.php#L30-L35
3,011
Cheezykins/RestAPICore
util/PropertyAccessor.php
PropertyAccessor.getSafeDateProperty
public static function getSafeDateProperty(\stdClass $object, ...$properties) { $val = self::getSafeProperty($object, ...$properties); if ($val === null) { return null; } $val = preg_replace('/\.\d+/', '', $val); return new Carbon($val); }
php
public static function getSafeDateProperty(\stdClass $object, ...$properties) { $val = self::getSafeProperty($object, ...$properties); if ($val === null) { return null; } $val = preg_replace('/\.\d+/', '', $val); return new Carbon($val); }
[ "public", "static", "function", "getSafeDateProperty", "(", "\\", "stdClass", "$", "object", ",", "...", "$", "properties", ")", "{", "$", "val", "=", "self", "::", "getSafeProperty", "(", "$", "object", ",", "...", "$", "properties", ")", ";", "if", "(", "$", "val", "===", "null", ")", "{", "return", "null", ";", "}", "$", "val", "=", "preg_replace", "(", "'/\\.\\d+/'", ",", "''", ",", "$", "val", ")", ";", "return", "new", "Carbon", "(", "$", "val", ")", ";", "}" ]
Returns a Carbon object for a given date time. @param \stdClass $object @param array ...$properties @return Carbon|null
[ "Returns", "a", "Carbon", "object", "for", "a", "given", "date", "time", "." ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/util/PropertyAccessor.php#L44-L52
3,012
Cheezykins/RestAPICore
util/PropertyAccessor.php
PropertyAccessor.getSafeDatePropertyFromTimestamp
public static function getSafeDatePropertyFromTimestamp(\stdClass $object, ...$properties) { $val = self::getSafeProperty($object, ...$properties); if ($val === null || !\is_numeric($val)) { return null; } $return = new Carbon(); $return->setTimestamp($val); return $return; }
php
public static function getSafeDatePropertyFromTimestamp(\stdClass $object, ...$properties) { $val = self::getSafeProperty($object, ...$properties); if ($val === null || !\is_numeric($val)) { return null; } $return = new Carbon(); $return->setTimestamp($val); return $return; }
[ "public", "static", "function", "getSafeDatePropertyFromTimestamp", "(", "\\", "stdClass", "$", "object", ",", "...", "$", "properties", ")", "{", "$", "val", "=", "self", "::", "getSafeProperty", "(", "$", "object", ",", "...", "$", "properties", ")", ";", "if", "(", "$", "val", "===", "null", "||", "!", "\\", "is_numeric", "(", "$", "val", ")", ")", "{", "return", "null", ";", "}", "$", "return", "=", "new", "Carbon", "(", ")", ";", "$", "return", "->", "setTimestamp", "(", "$", "val", ")", ";", "return", "$", "return", ";", "}" ]
Returns a carbon object for a given timestamp. @param \stdClass $object @param array ...$properties @return Carbon|null
[ "Returns", "a", "carbon", "object", "for", "a", "given", "timestamp", "." ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/util/PropertyAccessor.php#L60-L70
3,013
Cheezykins/RestAPICore
util/PropertyAccessor.php
PropertyAccessor.getSafeCollectionProperty
public static function getSafeCollectionProperty(\stdClass $object, ...$properties) { $property = self::getSafeProperty($object, ...$properties); if ($property === null || !is_array($property)) { return []; } return $property; }
php
public static function getSafeCollectionProperty(\stdClass $object, ...$properties) { $property = self::getSafeProperty($object, ...$properties); if ($property === null || !is_array($property)) { return []; } return $property; }
[ "public", "static", "function", "getSafeCollectionProperty", "(", "\\", "stdClass", "$", "object", ",", "...", "$", "properties", ")", "{", "$", "property", "=", "self", "::", "getSafeProperty", "(", "$", "object", ",", "...", "$", "properties", ")", ";", "if", "(", "$", "property", "===", "null", "||", "!", "is_array", "(", "$", "property", ")", ")", "{", "return", "[", "]", ";", "}", "return", "$", "property", ";", "}" ]
Returns a collection of objects for the given property map. @param \stdClass $object @param array ...$properties @return array
[ "Returns", "a", "collection", "of", "objects", "for", "the", "given", "property", "map", "." ]
35c0b40b9b71db93da1ff8ecd1849f18b616705a
https://github.com/Cheezykins/RestAPICore/blob/35c0b40b9b71db93da1ff8ecd1849f18b616705a/util/PropertyAccessor.php#L95-L102
3,014
ripaclub/aclman
library/Storage/Adapter/ArrayAdapter/ArrayAdapter.php
ArrayAdapter.checkRoleResource
protected function checkRoleResource($role, $resource) { $resource = $this->checkResource($resource); $role = $this->checkRole($role); $roleId = ($role->getRoleId() == null) ? StorageInterface::ALL_ROLES : $role->getRoleId(); $resrcId = ($resource->getResourceId() == null) ? StorageInterface::ALL_RESOURCES : $resource->getResourceId(); if (!isset($this->permission[$roleId][self::NODE_RESOURCES][$resrcId][self::NODE_PERMISSION])) { $this->permission[$roleId][self::NODE_RESOURCES][$resrcId][self::NODE_PERMISSION] = []; } return $this; }
php
protected function checkRoleResource($role, $resource) { $resource = $this->checkResource($resource); $role = $this->checkRole($role); $roleId = ($role->getRoleId() == null) ? StorageInterface::ALL_ROLES : $role->getRoleId(); $resrcId = ($resource->getResourceId() == null) ? StorageInterface::ALL_RESOURCES : $resource->getResourceId(); if (!isset($this->permission[$roleId][self::NODE_RESOURCES][$resrcId][self::NODE_PERMISSION])) { $this->permission[$roleId][self::NODE_RESOURCES][$resrcId][self::NODE_PERMISSION] = []; } return $this; }
[ "protected", "function", "checkRoleResource", "(", "$", "role", ",", "$", "resource", ")", "{", "$", "resource", "=", "$", "this", "->", "checkResource", "(", "$", "resource", ")", ";", "$", "role", "=", "$", "this", "->", "checkRole", "(", "$", "role", ")", ";", "$", "roleId", "=", "(", "$", "role", "->", "getRoleId", "(", ")", "==", "null", ")", "?", "StorageInterface", "::", "ALL_ROLES", ":", "$", "role", "->", "getRoleId", "(", ")", ";", "$", "resrcId", "=", "(", "$", "resource", "->", "getResourceId", "(", ")", "==", "null", ")", "?", "StorageInterface", "::", "ALL_RESOURCES", ":", "$", "resource", "->", "getResourceId", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "permission", "[", "$", "roleId", "]", "[", "self", "::", "NODE_RESOURCES", "]", "[", "$", "resrcId", "]", "[", "self", "::", "NODE_PERMISSION", "]", ")", ")", "{", "$", "this", "->", "permission", "[", "$", "roleId", "]", "[", "self", "::", "NODE_RESOURCES", "]", "[", "$", "resrcId", "]", "[", "self", "::", "NODE_PERMISSION", "]", "=", "[", "]", ";", "}", "return", "$", "this", ";", "}" ]
Check if already exists a resource permission node config, if not exist add it @param $role @param $resource @return $this
[ "Check", "if", "already", "exists", "a", "resource", "permission", "node", "config", "if", "not", "exist", "add", "it" ]
ca7c65fdb3291654f293829c70ced9fb2e1566f8
https://github.com/ripaclub/aclman/blob/ca7c65fdb3291654f293829c70ced9fb2e1566f8/library/Storage/Adapter/ArrayAdapter/ArrayAdapter.php#L424-L435
3,015
Silvestra/Silvestra
src/Silvestra/Bundle/MediaBundle/SilvestraMediaBundle.php
SilvestraMediaBundle.addRegisterMappingsPass
private function addRegisterMappingsPass(ContainerBuilder $container) { $mappings = array( realpath(__DIR__ . '/Resources/config/doctrine/model') => 'Silvestra\Component\Media\Model', ); $ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass'; if (class_exists($ormCompilerClass)) { $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); } }
php
private function addRegisterMappingsPass(ContainerBuilder $container) { $mappings = array( realpath(__DIR__ . '/Resources/config/doctrine/model') => 'Silvestra\Component\Media\Model', ); $ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass'; if (class_exists($ormCompilerClass)) { $container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings)); } }
[ "private", "function", "addRegisterMappingsPass", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "mappings", "=", "array", "(", "realpath", "(", "__DIR__", ".", "'/Resources/config/doctrine/model'", ")", "=>", "'Silvestra\\Component\\Media\\Model'", ",", ")", ";", "$", "ormCompilerClass", "=", "'Doctrine\\Bundle\\DoctrineBundle\\DependencyInjection\\Compiler\\DoctrineOrmMappingsPass'", ";", "if", "(", "class_exists", "(", "$", "ormCompilerClass", ")", ")", "{", "$", "container", "->", "addCompilerPass", "(", "DoctrineOrmMappingsPass", "::", "createXmlMappingDriver", "(", "$", "mappings", ")", ")", ";", "}", "}" ]
Add register mappings pass. @param ContainerBuilder $container
[ "Add", "register", "mappings", "pass", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/MediaBundle/SilvestraMediaBundle.php#L40-L50
3,016
afonzeca/arun-core
src/ArunCore/Traits/Builder/PlaceholderManipulator.php
PlaceholderManipulator.replaceParam
private function replaceParam($name, $value, &$schema) { $schema = str_replace( sprintf('##!%s!##', $name), $value, $schema ); }
php
private function replaceParam($name, $value, &$schema) { $schema = str_replace( sprintf('##!%s!##', $name), $value, $schema ); }
[ "private", "function", "replaceParam", "(", "$", "name", ",", "$", "value", ",", "&", "$", "schema", ")", "{", "$", "schema", "=", "str_replace", "(", "sprintf", "(", "'##!%s!##'", ",", "$", "name", ")", ",", "$", "value", ",", "$", "schema", ")", ";", "}" ]
Method for manipulating .skm files variables @param $name @param $value @param $schema
[ "Method", "for", "manipulating", ".", "skm", "files", "variables" ]
7a8af37e326187ff9ed7e2ff7bde6a489a9803a2
https://github.com/afonzeca/arun-core/blob/7a8af37e326187ff9ed7e2ff7bde6a489a9803a2/src/ArunCore/Traits/Builder/PlaceholderManipulator.php#L35-L42
3,017
pletfix/core
src/Services/Migrator.php
Migrator.loadMigrations
private function loadMigrations() { // Load the migrations already performed $migrated = []; $rows = $this->db->table('_migrations')->select('name')->all(); foreach ($rows as $row) { $migrated[] = $row['name']; } // Load the outstanding migrations $migrations = []; // read migrations from folder $files = []; list_files($files, $this->migrationPath, ['php']); foreach ($files as $file) { $name = basename($file, '.php'); $migrations[$name] = $file; } // read migrations included by plugins $migrations = array_merge($migrations, $this->pluginMigrations()); // remove migrations already performed foreach ($migrations as $name => $file) { if (in_array($name, $migrated)) { unset($migrations[$name]); } } return $migrations; }
php
private function loadMigrations() { // Load the migrations already performed $migrated = []; $rows = $this->db->table('_migrations')->select('name')->all(); foreach ($rows as $row) { $migrated[] = $row['name']; } // Load the outstanding migrations $migrations = []; // read migrations from folder $files = []; list_files($files, $this->migrationPath, ['php']); foreach ($files as $file) { $name = basename($file, '.php'); $migrations[$name] = $file; } // read migrations included by plugins $migrations = array_merge($migrations, $this->pluginMigrations()); // remove migrations already performed foreach ($migrations as $name => $file) { if (in_array($name, $migrated)) { unset($migrations[$name]); } } return $migrations; }
[ "private", "function", "loadMigrations", "(", ")", "{", "// Load the migrations already performed", "$", "migrated", "=", "[", "]", ";", "$", "rows", "=", "$", "this", "->", "db", "->", "table", "(", "'_migrations'", ")", "->", "select", "(", "'name'", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "migrated", "[", "]", "=", "$", "row", "[", "'name'", "]", ";", "}", "// Load the outstanding migrations", "$", "migrations", "=", "[", "]", ";", "// read migrations from folder", "$", "files", "=", "[", "]", ";", "list_files", "(", "$", "files", ",", "$", "this", "->", "migrationPath", ",", "[", "'php'", "]", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "name", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "$", "migrations", "[", "$", "name", "]", "=", "$", "file", ";", "}", "// read migrations included by plugins", "$", "migrations", "=", "array_merge", "(", "$", "migrations", ",", "$", "this", "->", "pluginMigrations", "(", ")", ")", ";", "// remove migrations already performed", "foreach", "(", "$", "migrations", "as", "$", "name", "=>", "$", "file", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "migrated", ")", ")", "{", "unset", "(", "$", "migrations", "[", "$", "name", "]", ")", ";", "}", "}", "return", "$", "migrations", ";", "}" ]
Load the outstanding migrations. @return array
[ "Load", "the", "outstanding", "migrations", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Migrator.php#L128-L161
3,018
pletfix/core
src/Services/Migrator.php
Migrator.loadPerformedMigrations
private function loadPerformedMigrations($batch) { $migrations = []; $pluginMigrations = $this->pluginMigrations(); /** @noinspection SqlDialectInspection */ $rows = $this->db->table('_migrations')->select('name')->whereCondition('batch = ?', [$batch])->all(); foreach ($rows as $row) { $name = $row['name']; $migrations[$name] = isset($pluginMigrations[$name]) ? $pluginMigrations[$name] : $this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php'; } return $migrations; }
php
private function loadPerformedMigrations($batch) { $migrations = []; $pluginMigrations = $this->pluginMigrations(); /** @noinspection SqlDialectInspection */ $rows = $this->db->table('_migrations')->select('name')->whereCondition('batch = ?', [$batch])->all(); foreach ($rows as $row) { $name = $row['name']; $migrations[$name] = isset($pluginMigrations[$name]) ? $pluginMigrations[$name] : $this->migrationPath . DIRECTORY_SEPARATOR . $name . '.php'; } return $migrations; }
[ "private", "function", "loadPerformedMigrations", "(", "$", "batch", ")", "{", "$", "migrations", "=", "[", "]", ";", "$", "pluginMigrations", "=", "$", "this", "->", "pluginMigrations", "(", ")", ";", "/** @noinspection SqlDialectInspection */", "$", "rows", "=", "$", "this", "->", "db", "->", "table", "(", "'_migrations'", ")", "->", "select", "(", "'name'", ")", "->", "whereCondition", "(", "'batch = ?'", ",", "[", "$", "batch", "]", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "name", "=", "$", "row", "[", "'name'", "]", ";", "$", "migrations", "[", "$", "name", "]", "=", "isset", "(", "$", "pluginMigrations", "[", "$", "name", "]", ")", "?", "$", "pluginMigrations", "[", "$", "name", "]", ":", "$", "this", "->", "migrationPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ".", "'.php'", ";", "}", "return", "$", "migrations", ";", "}" ]
Load the migrations already performed by batch number @param int $batch @return array
[ "Load", "the", "migrations", "already", "performed", "by", "batch", "number" ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Migrator.php#L169-L183
3,019
pletfix/core
src/Services/Migrator.php
Migrator.pluginMigrations
private function pluginMigrations() { $files = []; if (file_exists($this->pluginManifestOfMigrations)) { $basePath = base_path(); /** @noinspection PhpIncludeInspection */ $migrations = include $this->pluginManifestOfMigrations; foreach ($migrations as $name => $file) { $files[$name] = $basePath . DIRECTORY_SEPARATOR . $file; } } return $files; }
php
private function pluginMigrations() { $files = []; if (file_exists($this->pluginManifestOfMigrations)) { $basePath = base_path(); /** @noinspection PhpIncludeInspection */ $migrations = include $this->pluginManifestOfMigrations; foreach ($migrations as $name => $file) { $files[$name] = $basePath . DIRECTORY_SEPARATOR . $file; } } return $files; }
[ "private", "function", "pluginMigrations", "(", ")", "{", "$", "files", "=", "[", "]", ";", "if", "(", "file_exists", "(", "$", "this", "->", "pluginManifestOfMigrations", ")", ")", "{", "$", "basePath", "=", "base_path", "(", ")", ";", "/** @noinspection PhpIncludeInspection */", "$", "migrations", "=", "include", "$", "this", "->", "pluginManifestOfMigrations", ";", "foreach", "(", "$", "migrations", "as", "$", "name", "=>", "$", "file", ")", "{", "$", "files", "[", "$", "name", "]", "=", "$", "basePath", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ";", "}", "}", "return", "$", "files", ";", "}" ]
Read migrations included by plugins. @return array
[ "Read", "migrations", "included", "by", "plugins", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Migrator.php#L190-L204
3,020
pletfix/core
src/Services/Migrator.php
Migrator.makeMigrationClass
private function makeMigrationClass($name, $file) { if (($pos = strpos($name, '_')) === false) { throw new MigrationException('Name of the migration file "' . $name . '.php" is invalid. Format "<timestamp>_<classname>.php" expected.'); } $class = substr($name, $pos + 1); /** @noinspection PhpIncludeInspection */ require_once $file; if (!class_exists($class, false)) { throw new MigrationException('Migration class "' . $class . '" is not defined in file "' . $name . '.php".'); } $instance = new $class; if (!($instance instanceof Migration)) { throw new MigrationException('Migration "' . $name . '" is invalid. The Class have to implements the interface \Core\Services\Contracts\Migration.'); } return $instance; }
php
private function makeMigrationClass($name, $file) { if (($pos = strpos($name, '_')) === false) { throw new MigrationException('Name of the migration file "' . $name . '.php" is invalid. Format "<timestamp>_<classname>.php" expected.'); } $class = substr($name, $pos + 1); /** @noinspection PhpIncludeInspection */ require_once $file; if (!class_exists($class, false)) { throw new MigrationException('Migration class "' . $class . '" is not defined in file "' . $name . '.php".'); } $instance = new $class; if (!($instance instanceof Migration)) { throw new MigrationException('Migration "' . $name . '" is invalid. The Class have to implements the interface \Core\Services\Contracts\Migration.'); } return $instance; }
[ "private", "function", "makeMigrationClass", "(", "$", "name", ",", "$", "file", ")", "{", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "name", ",", "'_'", ")", ")", "===", "false", ")", "{", "throw", "new", "MigrationException", "(", "'Name of the migration file \"'", ".", "$", "name", ".", "'.php\" is invalid. Format \"<timestamp>_<classname>.php\" expected.'", ")", ";", "}", "$", "class", "=", "substr", "(", "$", "name", ",", "$", "pos", "+", "1", ")", ";", "/** @noinspection PhpIncludeInspection */", "require_once", "$", "file", ";", "if", "(", "!", "class_exists", "(", "$", "class", ",", "false", ")", ")", "{", "throw", "new", "MigrationException", "(", "'Migration class \"'", ".", "$", "class", ".", "'\" is not defined in file \"'", ".", "$", "name", ".", "'.php\".'", ")", ";", "}", "$", "instance", "=", "new", "$", "class", ";", "if", "(", "!", "(", "$", "instance", "instanceof", "Migration", ")", ")", "{", "throw", "new", "MigrationException", "(", "'Migration \"'", ".", "$", "name", ".", "'\" is invalid. The Class have to implements the interface \\Core\\Services\\Contracts\\Migration.'", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Create a new migration class. @param string $name @param string $file @return Migration @throws \Exception
[ "Create", "a", "new", "migration", "class", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Migrator.php#L214-L235
3,021
phplegends/view
src/View.php
View.resolveDataValue
public function resolveDataValue($data) { if ($data instanceof Data) { return $this->setData($data); } elseif (is_array($data)) { return $this->setData(new Data($data)); } throw new \InvalidArgumentException( "Data must be View\Data or array value" ); }
php
public function resolveDataValue($data) { if ($data instanceof Data) { return $this->setData($data); } elseif (is_array($data)) { return $this->setData(new Data($data)); } throw new \InvalidArgumentException( "Data must be View\Data or array value" ); }
[ "public", "function", "resolveDataValue", "(", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "Data", ")", "{", "return", "$", "this", "->", "setData", "(", "$", "data", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "setData", "(", "new", "Data", "(", "$", "data", ")", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Data must be View\\Data or array value\"", ")", ";", "}" ]
Resolves value for data @param \PHPLegends\View\Data | array $data @throws \InvalidArgumentException @return void
[ "Resolves", "value", "for", "data" ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/View.php#L76-L90
3,022
phplegends/view
src/View.php
View.getContents
public function getContents() { ob_start(); $callback = $this->hasContext() ? $this->getClosureForContextRender() : $this->callContextRender(); call_user_func($callback, $this->getFilename(), $this->getData()->toArray()); return ltrim(ob_get_clean()); }
php
public function getContents() { ob_start(); $callback = $this->hasContext() ? $this->getClosureForContextRender() : $this->callContextRender(); call_user_func($callback, $this->getFilename(), $this->getData()->toArray()); return ltrim(ob_get_clean()); }
[ "public", "function", "getContents", "(", ")", "{", "ob_start", "(", ")", ";", "$", "callback", "=", "$", "this", "->", "hasContext", "(", ")", "?", "$", "this", "->", "getClosureForContextRender", "(", ")", ":", "$", "this", "->", "callContextRender", "(", ")", ";", "call_user_func", "(", "$", "callback", ",", "$", "this", "->", "getFilename", "(", ")", ",", "$", "this", "->", "getData", "(", ")", "->", "toArray", "(", ")", ")", ";", "return", "ltrim", "(", "ob_get_clean", "(", ")", ")", ";", "}" ]
Get the contents of View @return string
[ "Get", "the", "contents", "of", "View" ]
01ac2d2ae14f697fb51cf317e50279049e5f1c44
https://github.com/phplegends/view/blob/01ac2d2ae14f697fb51cf317e50279049e5f1c44/src/View.php#L140-L150
3,023
gregoriohc/argentum-common
src/Common/Person.php
Person.validate
public function validate() { $this->validateRequiredParameters(); if (!is_string($this->getId())) { throw new InvalidPersonException("The id parameter must be a string"); } if (!is_string($this->getName())) { throw new InvalidPersonException("The name parameter must be a string"); } if ($this->hasParameter('type')) { if (!is_string($this->getType())) { throw new InvalidPersonException("The type parameter must be a string"); } } if ($this->hasParameter('email')) { if (!filter_var($this->getEmail(), FILTER_VALIDATE_EMAIL)) { throw new InvalidPersonException("The email parameter must be a valid email"); } } if ($this->hasParameter('phone')) { if (!is_string($this->getPhone())) { throw new InvalidPersonException("The phone parameter must be a string"); } } if ($this->hasParameter('fax')) { if (!is_string($this->getFax())) { throw new InvalidPersonException("The fax parameter must be a string"); } } if ($this->hasParameter('address')) { $address = $this->getAddress(); if (!($address instanceof Address)) { throw new InvalidPersonException("The address parameter must be an Address object"); } $address->validate(); } }
php
public function validate() { $this->validateRequiredParameters(); if (!is_string($this->getId())) { throw new InvalidPersonException("The id parameter must be a string"); } if (!is_string($this->getName())) { throw new InvalidPersonException("The name parameter must be a string"); } if ($this->hasParameter('type')) { if (!is_string($this->getType())) { throw new InvalidPersonException("The type parameter must be a string"); } } if ($this->hasParameter('email')) { if (!filter_var($this->getEmail(), FILTER_VALIDATE_EMAIL)) { throw new InvalidPersonException("The email parameter must be a valid email"); } } if ($this->hasParameter('phone')) { if (!is_string($this->getPhone())) { throw new InvalidPersonException("The phone parameter must be a string"); } } if ($this->hasParameter('fax')) { if (!is_string($this->getFax())) { throw new InvalidPersonException("The fax parameter must be a string"); } } if ($this->hasParameter('address')) { $address = $this->getAddress(); if (!($address instanceof Address)) { throw new InvalidPersonException("The address parameter must be an Address object"); } $address->validate(); } }
[ "public", "function", "validate", "(", ")", "{", "$", "this", "->", "validateRequiredParameters", "(", ")", ";", "if", "(", "!", "is_string", "(", "$", "this", "->", "getId", "(", ")", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The id parameter must be a string\"", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "this", "->", "getName", "(", ")", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The name parameter must be a string\"", ")", ";", "}", "if", "(", "$", "this", "->", "hasParameter", "(", "'type'", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "getType", "(", ")", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The type parameter must be a string\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasParameter", "(", "'email'", ")", ")", "{", "if", "(", "!", "filter_var", "(", "$", "this", "->", "getEmail", "(", ")", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The email parameter must be a valid email\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasParameter", "(", "'phone'", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "getPhone", "(", ")", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The phone parameter must be a string\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasParameter", "(", "'fax'", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "getFax", "(", ")", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The fax parameter must be a string\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "hasParameter", "(", "'address'", ")", ")", "{", "$", "address", "=", "$", "this", "->", "getAddress", "(", ")", ";", "if", "(", "!", "(", "$", "address", "instanceof", "Address", ")", ")", "{", "throw", "new", "InvalidPersonException", "(", "\"The address parameter must be an Address object\"", ")", ";", "}", "$", "address", "->", "validate", "(", ")", ";", "}", "}" ]
Validate this person. If the person is invalid, InvalidPersonException is thrown. @throws InvalidPersonException @return void
[ "Validate", "this", "person", ".", "If", "the", "person", "is", "invalid", "InvalidPersonException", "is", "thrown", "." ]
9d914d19aa6ed25d33f00d603eff486484f0f3ba
https://github.com/gregoriohc/argentum-common/blob/9d914d19aa6ed25d33f00d603eff486484f0f3ba/src/Common/Person.php#L66-L109
3,024
gregoriohc/argentum-common
src/Common/Person.php
Person.setAddress
public function setAddress($value) { if (is_array($value)) { $value = new Address($value); } return $this->setParameter('address', $value); }
php
public function setAddress($value) { if (is_array($value)) { $value = new Address($value); } return $this->setParameter('address', $value); }
[ "public", "function", "setAddress", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "new", "Address", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "setParameter", "(", "'address'", ",", "$", "value", ")", ";", "}" ]
Set person address @param array|Address $value Parameter value @return Person provides a fluent interface.
[ "Set", "person", "address" ]
9d914d19aa6ed25d33f00d603eff486484f0f3ba
https://github.com/gregoriohc/argentum-common/blob/9d914d19aa6ed25d33f00d603eff486484f0f3ba/src/Common/Person.php#L274-L280
3,025
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/StaticFilter.php
StaticFilter.execute
public static function execute($value, $classBaseName, array $args = []) { $plugins = static::getPluginManager(); $filter = $plugins->get($classBaseName, $args); return $filter->filter($value); }
php
public static function execute($value, $classBaseName, array $args = []) { $plugins = static::getPluginManager(); $filter = $plugins->get($classBaseName, $args); return $filter->filter($value); }
[ "public", "static", "function", "execute", "(", "$", "value", ",", "$", "classBaseName", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "plugins", "=", "static", "::", "getPluginManager", "(", ")", ";", "$", "filter", "=", "$", "plugins", "->", "get", "(", "$", "classBaseName", ",", "$", "args", ")", ";", "return", "$", "filter", "->", "filter", "(", "$", "value", ")", ";", "}" ]
Returns a value filtered through a specified filter class, without requiring separate instantiation of the filter object. The first argument of this method is a data input value, that you would have filtered. The second argument is a string, which corresponds to the basename of the filter class, relative to the Zend\Filter namespace. This method automatically loads the class, creates an instance, and applies the filter() method to the data input. You can also pass an array of constructor arguments, if they are needed for the filter class. @param mixed $value @param string $classBaseName @param array $args OPTIONAL @return mixed @throws Exception\ExceptionInterface
[ "Returns", "a", "value", "filtered", "through", "a", "specified", "filter", "class", "without", "requiring", "separate", "instantiation", "of", "the", "filter", "object", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/StaticFilter.php#L62-L68
3,026
nextalk/webim-php
src/WebIM/Client.php
Client.presence
function presence($show, $status = null){ $data = $this->reqdata(); $data['nick'] = $this->endpoint->nick; $data['show'] = $show; if($status) $data['status'] = $status; return $this->request('presences/show', $data, 'POST'); }
php
function presence($show, $status = null){ $data = $this->reqdata(); $data['nick'] = $this->endpoint->nick; $data['show'] = $show; if($status) $data['status'] = $status; return $this->request('presences/show', $data, 'POST'); }
[ "function", "presence", "(", "$", "show", ",", "$", "status", "=", "null", ")", "{", "$", "data", "=", "$", "this", "->", "reqdata", "(", ")", ";", "$", "data", "[", "'nick'", "]", "=", "$", "this", "->", "endpoint", "->", "nick", ";", "$", "data", "[", "'show'", "]", "=", "$", "show", ";", "if", "(", "$", "status", ")", "$", "data", "[", "'status'", "]", "=", "$", "status", ";", "return", "$", "this", "->", "request", "(", "'presences/show'", ",", "$", "data", ",", "'POST'", ")", ";", "}" ]
Send presence. @param string $show: 'available' | 'away' | 'chat' | 'dnd' | 'invisible' | 'unavailable' @param string $status @return ok
[ "Send", "presence", "." ]
78419878f9499d96169cb098ffc9565c6890ae9e
https://github.com/nextalk/webim-php/blob/78419878f9499d96169cb098ffc9565c6890ae9e/src/WebIM/Client.php#L161-L167
3,027
nextalk/webim-php
src/WebIM/Client.php
Client.status
public function status($to, $show){ $data = array_merge($this->reqdata(), array( 'nick' => $this->endpoint->nick, 'to' => $to, 'show' => $show, )); return $this->request('statuses', $data, 'POST'); }
php
public function status($to, $show){ $data = array_merge($this->reqdata(), array( 'nick' => $this->endpoint->nick, 'to' => $to, 'show' => $show, )); return $this->request('statuses', $data, 'POST'); }
[ "public", "function", "status", "(", "$", "to", ",", "$", "show", ")", "{", "$", "data", "=", "array_merge", "(", "$", "this", "->", "reqdata", "(", ")", ",", "array", "(", "'nick'", "=>", "$", "this", "->", "endpoint", "->", "nick", ",", "'to'", "=>", "$", "to", ",", "'show'", "=>", "$", "show", ",", ")", ")", ";", "return", "$", "this", "->", "request", "(", "'statuses'", ",", "$", "data", ",", "'POST'", ")", ";", "}" ]
Send endpoint chat status to other. @param string $to status receiver @param string $show status @return ok
[ "Send", "endpoint", "chat", "status", "to", "other", "." ]
78419878f9499d96169cb098ffc9565c6890ae9e
https://github.com/nextalk/webim-php/blob/78419878f9499d96169cb098ffc9565c6890ae9e/src/WebIM/Client.php#L179-L186
3,028
acacha/ebre_escool_model
src/User.php
User.getNameAttribute
public function getNameAttribute($value) { if ($this->person) return $this->person->givenName . ' ' . $this->person->sn1 . ' ' . $this->person->sn2; return $value; }
php
public function getNameAttribute($value) { if ($this->person) return $this->person->givenName . ' ' . $this->person->sn1 . ' ' . $this->person->sn2; return $value; }
[ "public", "function", "getNameAttribute", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "person", ")", "return", "$", "this", "->", "person", "->", "givenName", ".", "' '", ".", "$", "this", "->", "person", "->", "sn1", ".", "' '", ".", "$", "this", "->", "person", "->", "sn2", ";", "return", "$", "value", ";", "}" ]
Accessor for name attribute. @param $value @return string
[ "Accessor", "for", "name", "attribute", "." ]
91c0b870714490baa9500215a6dc07935e525a75
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/User.php#L32-L36
3,029
acacha/ebre_escool_model
src/User.php
User.getEmailFromUser
public function getEmailFromUser() { $email = null; try { $email = $this->email; } catch (\Exception $e){ return $this->getEmailFromPerson($this->person_id); } if(!$email) { return $this->getEmailFromPerson($this->person_id); } return $email; }
php
public function getEmailFromUser() { $email = null; try { $email = $this->email; } catch (\Exception $e){ return $this->getEmailFromPerson($this->person_id); } if(!$email) { return $this->getEmailFromPerson($this->person_id); } return $email; }
[ "public", "function", "getEmailFromUser", "(", ")", "{", "$", "email", "=", "null", ";", "try", "{", "$", "email", "=", "$", "this", "->", "email", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "getEmailFromPerson", "(", "$", "this", "->", "person_id", ")", ";", "}", "if", "(", "!", "$", "email", ")", "{", "return", "$", "this", "->", "getEmailFromPerson", "(", "$", "this", "->", "person_id", ")", ";", "}", "return", "$", "email", ";", "}" ]
Get email from user. @param $user @return null
[ "Get", "email", "from", "user", "." ]
91c0b870714490baa9500215a6dc07935e525a75
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/User.php#L76-L88
3,030
acacha/ebre_escool_model
src/User.php
User.getEmailFromPerson
protected function getEmailFromPerson($personId) { if ($personId) { try { return \Scool\EbreEscoolModel\Person::find($personId)->person_email; } catch (\Exception $e){ info($e->getMessage()); } } return null; }
php
protected function getEmailFromPerson($personId) { if ($personId) { try { return \Scool\EbreEscoolModel\Person::find($personId)->person_email; } catch (\Exception $e){ info($e->getMessage()); } } return null; }
[ "protected", "function", "getEmailFromPerson", "(", "$", "personId", ")", "{", "if", "(", "$", "personId", ")", "{", "try", "{", "return", "\\", "Scool", "\\", "EbreEscoolModel", "\\", "Person", "::", "find", "(", "$", "personId", ")", "->", "person_email", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "info", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Get email from person. @param $personId @return null
[ "Get", "email", "from", "person", "." ]
91c0b870714490baa9500215a6dc07935e525a75
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/User.php#L96-L106
3,031
LasseHaslev/api-response
src/Responses/ResponseTrait.php
ResponseTrait.response
protected function response() { if ( $this->responseObject ) { return $this->responseObject; } $this->responseObject = new Response; return $this->responseObject; }
php
protected function response() { if ( $this->responseObject ) { return $this->responseObject; } $this->responseObject = new Response; return $this->responseObject; }
[ "protected", "function", "response", "(", ")", "{", "if", "(", "$", "this", "->", "responseObject", ")", "{", "return", "$", "this", "->", "responseObject", ";", "}", "$", "this", "->", "responseObject", "=", "new", "Response", ";", "return", "$", "this", "->", "responseObject", ";", "}" ]
Get the response factory instance @return LasseHaslev\ApiResponse\Response\Factory
[ "Get", "the", "response", "factory", "instance" ]
323be67cb1013d7ef73b8175a139f3e5937fa90f
https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Responses/ResponseTrait.php#L25-L33
3,032
aedart/model
src/Traits/Strings/IsicV4Trait.php
IsicV4Trait.getIsicV4
public function getIsicV4() : ?string { if ( ! $this->hasIsicV4()) { $this->setIsicV4($this->getDefaultIsicV4()); } return $this->isicV4; }
php
public function getIsicV4() : ?string { if ( ! $this->hasIsicV4()) { $this->setIsicV4($this->getDefaultIsicV4()); } return $this->isicV4; }
[ "public", "function", "getIsicV4", "(", ")", ":", "?", "string", "{", "if", "(", "!", "$", "this", "->", "hasIsicV4", "(", ")", ")", "{", "$", "this", "->", "setIsicV4", "(", "$", "this", "->", "getDefaultIsicV4", "(", ")", ")", ";", "}", "return", "$", "this", "->", "isicV4", ";", "}" ]
Get isic v4 If no "isic v4" value has been set, this method will set and return a default "isic v4" value, if any such value is available @see getDefaultIsicV4() @return string|null isic v4 or null if no isic v4 has been set
[ "Get", "isic", "v4" ]
9a562c1c53a276d01ace0ab71f5305458bea542f
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/IsicV4Trait.php#L48-L54
3,033
Dhii/iterator-helper-base
src/ResolveIteratorCapableTrait.php
ResolveIteratorCapableTrait._resolveIterator
protected function _resolveIterator(Traversable $iterator, $test = null, $limit = null) { $origIterator = $iterator; // Default test function if (!is_callable($test)) { $test = function (Traversable $subject) { return $subject instanceof Iterator; }; } if (is_null($limit)) { $limit = 100; } else { $limit = $this->_normalizeInt($limit); } $i = 0; while (!$test($iterator) && $i < $limit) { if (!($iterator instanceof IteratorAggregate)) { break; } $_it = $iterator->getIterator(); if ($iterator === $_it) { throw $this->_createOutOfRangeException( $this->__('Infinite recursion: looks like the traversable wraps itself on level %1$d', [$i]), null, null, $origIterator ); } $iterator = $_it; ++$i; } if (!$test($iterator)) { throw $this->_createOutOfRangeException( $this->__('The deepest iterator is not a match (limit is %1$d)', [$limit]), null, null, $origIterator ); } return $iterator; }
php
protected function _resolveIterator(Traversable $iterator, $test = null, $limit = null) { $origIterator = $iterator; // Default test function if (!is_callable($test)) { $test = function (Traversable $subject) { return $subject instanceof Iterator; }; } if (is_null($limit)) { $limit = 100; } else { $limit = $this->_normalizeInt($limit); } $i = 0; while (!$test($iterator) && $i < $limit) { if (!($iterator instanceof IteratorAggregate)) { break; } $_it = $iterator->getIterator(); if ($iterator === $_it) { throw $this->_createOutOfRangeException( $this->__('Infinite recursion: looks like the traversable wraps itself on level %1$d', [$i]), null, null, $origIterator ); } $iterator = $_it; ++$i; } if (!$test($iterator)) { throw $this->_createOutOfRangeException( $this->__('The deepest iterator is not a match (limit is %1$d)', [$limit]), null, null, $origIterator ); } return $iterator; }
[ "protected", "function", "_resolveIterator", "(", "Traversable", "$", "iterator", ",", "$", "test", "=", "null", ",", "$", "limit", "=", "null", ")", "{", "$", "origIterator", "=", "$", "iterator", ";", "// Default test function", "if", "(", "!", "is_callable", "(", "$", "test", ")", ")", "{", "$", "test", "=", "function", "(", "Traversable", "$", "subject", ")", "{", "return", "$", "subject", "instanceof", "Iterator", ";", "}", ";", "}", "if", "(", "is_null", "(", "$", "limit", ")", ")", "{", "$", "limit", "=", "100", ";", "}", "else", "{", "$", "limit", "=", "$", "this", "->", "_normalizeInt", "(", "$", "limit", ")", ";", "}", "$", "i", "=", "0", ";", "while", "(", "!", "$", "test", "(", "$", "iterator", ")", "&&", "$", "i", "<", "$", "limit", ")", "{", "if", "(", "!", "(", "$", "iterator", "instanceof", "IteratorAggregate", ")", ")", "{", "break", ";", "}", "$", "_it", "=", "$", "iterator", "->", "getIterator", "(", ")", ";", "if", "(", "$", "iterator", "===", "$", "_it", ")", "{", "throw", "$", "this", "->", "_createOutOfRangeException", "(", "$", "this", "->", "__", "(", "'Infinite recursion: looks like the traversable wraps itself on level %1$d'", ",", "[", "$", "i", "]", ")", ",", "null", ",", "null", ",", "$", "origIterator", ")", ";", "}", "$", "iterator", "=", "$", "_it", ";", "++", "$", "i", ";", "}", "if", "(", "!", "$", "test", "(", "$", "iterator", ")", ")", "{", "throw", "$", "this", "->", "_createOutOfRangeException", "(", "$", "this", "->", "__", "(", "'The deepest iterator is not a match (limit is %1$d)'", ",", "[", "$", "limit", "]", ")", ",", "null", ",", "null", ",", "$", "origIterator", ")", ";", "}", "return", "$", "iterator", ";", "}" ]
Finds the deepest iterator that matches. Because the given traversable can be an {@see IteratorAggregate}, it will try to get its inner iterator. On each iterator, it will run the test function. It will keep going inwards until one of these conditions occurs: - The iterator matches (test function returns `true`). This can also be the supplied iterator. In this case the iterator will be returned. - The limit or the maximal depth are reached. In this case, if the iterator is not a match, an exception will be thrown. @since [*next-version*] @param Traversable $iterator The iterator to resolve. @param callable $test The test function which determines when the iterator is considered to be resolved. Default: Returns `true` on first found instance of {@see Iterator}. @param $limit int|float|string|Stringable The depth limit for resolution. @throws InvalidArgumentException If limit is not a valid integer representation. @throws OutOfRangeException If infinite recursion is detected, or the iterator could not be resolved within the depth limit. @return Iterator The inner-most iterator, or whatever the test function allows.
[ "Finds", "the", "deepest", "iterator", "that", "matches", "." ]
cf62fb9f8b658a82815f15a2d906d8d1ff5c52ce
https://github.com/Dhii/iterator-helper-base/blob/cf62fb9f8b658a82815f15a2d906d8d1ff5c52ce/src/ResolveIteratorCapableTrait.php#L43-L90
3,034
weckx/wcx-syslog
library/Wcx/Syslog/Transport/Tcp.php
Tcp.send
public function send(MessageInterface $message, $target) { //Add EOL to message so the receiver knows it has ended $msg = $message->getMessageString() . "\n"; if (strpos($target, ':')) { list($host, $port) = explode(':', $target); } else { $host = $target; $port = self::DEFAULT_TCP_PORT; } $sock = fsockopen($host, $port, $errorCode, $errorMsg, $this->timeout); if ($sock === false) { throw new \RuntimeException("Error connecting to {$server}: [{$errorCode}] {$errorMsg}"); } $written = fwrite($sock, $msg); fclose($sock); if ($written != strlen($msg)) { throw new \RuntimeException("Error sending message to {$server} not all bytes sent."); } return $this; }
php
public function send(MessageInterface $message, $target) { //Add EOL to message so the receiver knows it has ended $msg = $message->getMessageString() . "\n"; if (strpos($target, ':')) { list($host, $port) = explode(':', $target); } else { $host = $target; $port = self::DEFAULT_TCP_PORT; } $sock = fsockopen($host, $port, $errorCode, $errorMsg, $this->timeout); if ($sock === false) { throw new \RuntimeException("Error connecting to {$server}: [{$errorCode}] {$errorMsg}"); } $written = fwrite($sock, $msg); fclose($sock); if ($written != strlen($msg)) { throw new \RuntimeException("Error sending message to {$server} not all bytes sent."); } return $this; }
[ "public", "function", "send", "(", "MessageInterface", "$", "message", ",", "$", "target", ")", "{", "//Add EOL to message so the receiver knows it has ended", "$", "msg", "=", "$", "message", "->", "getMessageString", "(", ")", ".", "\"\\n\"", ";", "if", "(", "strpos", "(", "$", "target", ",", "':'", ")", ")", "{", "list", "(", "$", "host", ",", "$", "port", ")", "=", "explode", "(", "':'", ",", "$", "target", ")", ";", "}", "else", "{", "$", "host", "=", "$", "target", ";", "$", "port", "=", "self", "::", "DEFAULT_TCP_PORT", ";", "}", "$", "sock", "=", "fsockopen", "(", "$", "host", ",", "$", "port", ",", "$", "errorCode", ",", "$", "errorMsg", ",", "$", "this", "->", "timeout", ")", ";", "if", "(", "$", "sock", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Error connecting to {$server}: [{$errorCode}] {$errorMsg}\"", ")", ";", "}", "$", "written", "=", "fwrite", "(", "$", "sock", ",", "$", "msg", ")", ";", "fclose", "(", "$", "sock", ")", ";", "if", "(", "$", "written", "!=", "strlen", "(", "$", "msg", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Error sending message to {$server} not all bytes sent.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Send the syslog to target host using the TCP protocol.Automatically adds a \n character to end of the message string @param MessageInterface $message @param string $target Host:port, if port not specified uses default 514 @return void @throws \RuntimeException If there's an error creating the socket
[ "Send", "the", "syslog", "to", "target", "host", "using", "the", "TCP", "protocol", ".", "Automatically", "adds", "a", "\\", "n", "character", "to", "end", "of", "the", "message", "string" ]
2ec40409a7b5393751ebf9051a33d829e6fc313e
https://github.com/weckx/wcx-syslog/blob/2ec40409a7b5393751ebf9051a33d829e6fc313e/library/Wcx/Syslog/Transport/Tcp.php#L59-L84
3,035
laraning/flame
src/FlameServiceProvider.php
FlameServiceProvider.loadConfigurationGroups
protected function loadConfigurationGroups() { collect(config('flame'))->each(function ($item, $key) { $this->loadViewsFrom($item['path'], $key); }); }
php
protected function loadConfigurationGroups() { collect(config('flame'))->each(function ($item, $key) { $this->loadViewsFrom($item['path'], $key); }); }
[ "protected", "function", "loadConfigurationGroups", "(", ")", "{", "collect", "(", "config", "(", "'flame'", ")", ")", "->", "each", "(", "function", "(", "$", "item", ",", "$", "key", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "$", "item", "[", "'path'", "]", ",", "$", "key", ")", ";", "}", ")", ";", "}" ]
Loads the flame configuration groups from your configuration file. Each group will be located via the view hint given by the namespace name. @return void
[ "Loads", "the", "flame", "configuration", "groups", "from", "your", "configuration", "file", ".", "Each", "group", "will", "be", "located", "via", "the", "view", "hint", "given", "by", "the", "namespace", "name", "." ]
42bdc99fd3b7c200707bcc407d7d87390b3a7c37
https://github.com/laraning/flame/blob/42bdc99fd3b7c200707bcc407d7d87390b3a7c37/src/FlameServiceProvider.php#L55-L60
3,036
agalbourdin/agl-core
src/Loader/Loader.php
Loader.getInstance
public static function getInstance($pClass, array $pArgs = array()) { if (strpos($pClass, Agl::AGL_CORE_POOL) === 0 or strpos($pClass, Agl::AGL_MORE_POOL) === 0) { $moduleArr = explode('/', $pClass); $moduleArr = array_map('ucfirst', $moduleArr); if (count($moduleArr) == 2) { $moduleArr[] = $moduleArr[1]; } if (strpos($pClass, Agl::AGL_MORE_POOL) === 0) { self::$_loadedModules[strtolower(implode('/', $moduleArr))] = true; } $path = '\\' . Autoload::AGL_POOL . '\\' . implode('\\', $moduleArr); if (empty($pArgs)) { return new $path(); } else { $reflect = new ReflectionClass($path); return $reflect->newInstanceArgs($pArgs); } } else if (strpos($pClass, ModelInterface::APP_PHP_HELPER_DIR) === 0) { return self::getHelper(str_replace(ModelInterface::APP_PHP_HELPER_DIR . '/', '', $pClass)); } else if (strpos($pClass, ModelInterface::APP_PHP_DIR) === 0) { return self::getModel(str_replace(ModelInterface::APP_PHP_DIR . '/', '', $pClass)); } else if (strpos($pClass, CollectionInterface::APP_PHP_DIR) === 0) { return self::getCollection(str_replace(CollectionInterface::APP_PHP_DIR . '/', '', $pClass)); } try { $reflect = new ReflectionClass($pClass); return $reflect->newInstanceArgs($pArgs); } catch (ReflectionException $e) { return NULL; } }
php
public static function getInstance($pClass, array $pArgs = array()) { if (strpos($pClass, Agl::AGL_CORE_POOL) === 0 or strpos($pClass, Agl::AGL_MORE_POOL) === 0) { $moduleArr = explode('/', $pClass); $moduleArr = array_map('ucfirst', $moduleArr); if (count($moduleArr) == 2) { $moduleArr[] = $moduleArr[1]; } if (strpos($pClass, Agl::AGL_MORE_POOL) === 0) { self::$_loadedModules[strtolower(implode('/', $moduleArr))] = true; } $path = '\\' . Autoload::AGL_POOL . '\\' . implode('\\', $moduleArr); if (empty($pArgs)) { return new $path(); } else { $reflect = new ReflectionClass($path); return $reflect->newInstanceArgs($pArgs); } } else if (strpos($pClass, ModelInterface::APP_PHP_HELPER_DIR) === 0) { return self::getHelper(str_replace(ModelInterface::APP_PHP_HELPER_DIR . '/', '', $pClass)); } else if (strpos($pClass, ModelInterface::APP_PHP_DIR) === 0) { return self::getModel(str_replace(ModelInterface::APP_PHP_DIR . '/', '', $pClass)); } else if (strpos($pClass, CollectionInterface::APP_PHP_DIR) === 0) { return self::getCollection(str_replace(CollectionInterface::APP_PHP_DIR . '/', '', $pClass)); } try { $reflect = new ReflectionClass($pClass); return $reflect->newInstanceArgs($pArgs); } catch (ReflectionException $e) { return NULL; } }
[ "public", "static", "function", "getInstance", "(", "$", "pClass", ",", "array", "$", "pArgs", "=", "array", "(", ")", ")", "{", "if", "(", "strpos", "(", "$", "pClass", ",", "Agl", "::", "AGL_CORE_POOL", ")", "===", "0", "or", "strpos", "(", "$", "pClass", ",", "Agl", "::", "AGL_MORE_POOL", ")", "===", "0", ")", "{", "$", "moduleArr", "=", "explode", "(", "'/'", ",", "$", "pClass", ")", ";", "$", "moduleArr", "=", "array_map", "(", "'ucfirst'", ",", "$", "moduleArr", ")", ";", "if", "(", "count", "(", "$", "moduleArr", ")", "==", "2", ")", "{", "$", "moduleArr", "[", "]", "=", "$", "moduleArr", "[", "1", "]", ";", "}", "if", "(", "strpos", "(", "$", "pClass", ",", "Agl", "::", "AGL_MORE_POOL", ")", "===", "0", ")", "{", "self", "::", "$", "_loadedModules", "[", "strtolower", "(", "implode", "(", "'/'", ",", "$", "moduleArr", ")", ")", "]", "=", "true", ";", "}", "$", "path", "=", "'\\\\'", ".", "Autoload", "::", "AGL_POOL", ".", "'\\\\'", ".", "implode", "(", "'\\\\'", ",", "$", "moduleArr", ")", ";", "if", "(", "empty", "(", "$", "pArgs", ")", ")", "{", "return", "new", "$", "path", "(", ")", ";", "}", "else", "{", "$", "reflect", "=", "new", "ReflectionClass", "(", "$", "path", ")", ";", "return", "$", "reflect", "->", "newInstanceArgs", "(", "$", "pArgs", ")", ";", "}", "}", "else", "if", "(", "strpos", "(", "$", "pClass", ",", "ModelInterface", "::", "APP_PHP_HELPER_DIR", ")", "===", "0", ")", "{", "return", "self", "::", "getHelper", "(", "str_replace", "(", "ModelInterface", "::", "APP_PHP_HELPER_DIR", ".", "'/'", ",", "''", ",", "$", "pClass", ")", ")", ";", "}", "else", "if", "(", "strpos", "(", "$", "pClass", ",", "ModelInterface", "::", "APP_PHP_DIR", ")", "===", "0", ")", "{", "return", "self", "::", "getModel", "(", "str_replace", "(", "ModelInterface", "::", "APP_PHP_DIR", ".", "'/'", ",", "''", ",", "$", "pClass", ")", ")", ";", "}", "else", "if", "(", "strpos", "(", "$", "pClass", ",", "CollectionInterface", "::", "APP_PHP_DIR", ")", "===", "0", ")", "{", "return", "self", "::", "getCollection", "(", "str_replace", "(", "CollectionInterface", "::", "APP_PHP_DIR", ".", "'/'", ",", "''", ",", "$", "pClass", ")", ")", ";", "}", "try", "{", "$", "reflect", "=", "new", "ReflectionClass", "(", "$", "pClass", ")", ";", "return", "$", "reflect", "->", "newInstanceArgs", "(", "$", "pArgs", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "return", "NULL", ";", "}", "}" ]
Create a new instance of the requested class. @param string $pClass Class path @param array $pArgs Arguments to construct the requested class @return mixed
[ "Create", "a", "new", "instance", "of", "the", "requested", "class", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Loader/Loader.php#L39-L74
3,037
agalbourdin/agl-core
src/Loader/Loader.php
Loader.getSingleton
public static function getSingleton($pClass, array $pArgs = array()) { if (strpos($pClass, Agl::AGL_CORE_POOL) === 0 or strpos($pClass, Agl::AGL_MORE_POOL) === 0) { $moduleArr = explode('/', $pClass); if (count($moduleArr) == 2) { $moduleArr[] = $moduleArr[1]; $pClass = implode('/', $moduleArr); } } $registryKey = '_singleton/' . strtolower($pClass); $instance = Registry::get($registryKey); if (! $instance) { $instance = self::getInstance($pClass, $pArgs); if ($instance === NULL) { return NULL; } Registry::set($registryKey, $instance); } return $instance; }
php
public static function getSingleton($pClass, array $pArgs = array()) { if (strpos($pClass, Agl::AGL_CORE_POOL) === 0 or strpos($pClass, Agl::AGL_MORE_POOL) === 0) { $moduleArr = explode('/', $pClass); if (count($moduleArr) == 2) { $moduleArr[] = $moduleArr[1]; $pClass = implode('/', $moduleArr); } } $registryKey = '_singleton/' . strtolower($pClass); $instance = Registry::get($registryKey); if (! $instance) { $instance = self::getInstance($pClass, $pArgs); if ($instance === NULL) { return NULL; } Registry::set($registryKey, $instance); } return $instance; }
[ "public", "static", "function", "getSingleton", "(", "$", "pClass", ",", "array", "$", "pArgs", "=", "array", "(", ")", ")", "{", "if", "(", "strpos", "(", "$", "pClass", ",", "Agl", "::", "AGL_CORE_POOL", ")", "===", "0", "or", "strpos", "(", "$", "pClass", ",", "Agl", "::", "AGL_MORE_POOL", ")", "===", "0", ")", "{", "$", "moduleArr", "=", "explode", "(", "'/'", ",", "$", "pClass", ")", ";", "if", "(", "count", "(", "$", "moduleArr", ")", "==", "2", ")", "{", "$", "moduleArr", "[", "]", "=", "$", "moduleArr", "[", "1", "]", ";", "$", "pClass", "=", "implode", "(", "'/'", ",", "$", "moduleArr", ")", ";", "}", "}", "$", "registryKey", "=", "'_singleton/'", ".", "strtolower", "(", "$", "pClass", ")", ";", "$", "instance", "=", "Registry", "::", "get", "(", "$", "registryKey", ")", ";", "if", "(", "!", "$", "instance", ")", "{", "$", "instance", "=", "self", "::", "getInstance", "(", "$", "pClass", ",", "$", "pArgs", ")", ";", "if", "(", "$", "instance", "===", "NULL", ")", "{", "return", "NULL", ";", "}", "Registry", "::", "set", "(", "$", "registryKey", ",", "$", "instance", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Create a new instance of the requested class as a singleton. @param string $pClass Class path @param array $pArgs Arguments to construct the requested class @return mixed
[ "Create", "a", "new", "instance", "of", "the", "requested", "class", "as", "a", "singleton", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Loader/Loader.php#L83-L105
3,038
agalbourdin/agl-core
src/Loader/Loader.php
Loader.getModel
public static function getModel($pModel, array $pFields = array()) { $fileName = strtolower($pModel); $className = $fileName . ModelInterface::APP_SUFFIX; if (Agl::isInitialized()) { $modelPath = APP_PATH . Agl::APP_PHP_DIR . ModelInterface::APP_PHP_DIR . DS . $fileName . Agl::PHP_EXT; if (is_readable($modelPath)) { return self::getInstance($className, array($pModel, $pFields)); } else { return new Model($pModel, $pFields); } } else { return new Model($pModel, $pFields); } }
php
public static function getModel($pModel, array $pFields = array()) { $fileName = strtolower($pModel); $className = $fileName . ModelInterface::APP_SUFFIX; if (Agl::isInitialized()) { $modelPath = APP_PATH . Agl::APP_PHP_DIR . ModelInterface::APP_PHP_DIR . DS . $fileName . Agl::PHP_EXT; if (is_readable($modelPath)) { return self::getInstance($className, array($pModel, $pFields)); } else { return new Model($pModel, $pFields); } } else { return new Model($pModel, $pFields); } }
[ "public", "static", "function", "getModel", "(", "$", "pModel", ",", "array", "$", "pFields", "=", "array", "(", ")", ")", "{", "$", "fileName", "=", "strtolower", "(", "$", "pModel", ")", ";", "$", "className", "=", "$", "fileName", ".", "ModelInterface", "::", "APP_SUFFIX", ";", "if", "(", "Agl", "::", "isInitialized", "(", ")", ")", "{", "$", "modelPath", "=", "APP_PATH", ".", "Agl", "::", "APP_PHP_DIR", ".", "ModelInterface", "::", "APP_PHP_DIR", ".", "DS", ".", "$", "fileName", ".", "Agl", "::", "PHP_EXT", ";", "if", "(", "is_readable", "(", "$", "modelPath", ")", ")", "{", "return", "self", "::", "getInstance", "(", "$", "className", ",", "array", "(", "$", "pModel", ",", "$", "pFields", ")", ")", ";", "}", "else", "{", "return", "new", "Model", "(", "$", "pModel", ",", "$", "pFields", ")", ";", "}", "}", "else", "{", "return", "new", "Model", "(", "$", "pModel", ",", "$", "pFields", ")", ";", "}", "}" ]
Return an instance of the requested model. @param string $pModel @param array $pFields Attributes to add to the item @return mixed
[ "Return", "an", "instance", "of", "the", "requested", "model", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Loader/Loader.php#L114-L135
3,039
agalbourdin/agl-core
src/Loader/Loader.php
Loader.getCollection
public static function getCollection($pCollection) { $fileName = strtolower($pCollection); $className = $fileName . CollectionInterface::APP_SUFFIX; if (Agl::isInitialized()) { $collectionPath = APP_PATH . Agl::APP_PHP_DIR . CollectionInterface::APP_PHP_DIR . DS . $fileName . Agl::PHP_EXT; if (is_readable($collectionPath)) { return self::getInstance($className, array($pCollection)); } else { return new Collection($pCollection); } } else { return new Collection($pCollection); } }
php
public static function getCollection($pCollection) { $fileName = strtolower($pCollection); $className = $fileName . CollectionInterface::APP_SUFFIX; if (Agl::isInitialized()) { $collectionPath = APP_PATH . Agl::APP_PHP_DIR . CollectionInterface::APP_PHP_DIR . DS . $fileName . Agl::PHP_EXT; if (is_readable($collectionPath)) { return self::getInstance($className, array($pCollection)); } else { return new Collection($pCollection); } } else { return new Collection($pCollection); } }
[ "public", "static", "function", "getCollection", "(", "$", "pCollection", ")", "{", "$", "fileName", "=", "strtolower", "(", "$", "pCollection", ")", ";", "$", "className", "=", "$", "fileName", ".", "CollectionInterface", "::", "APP_SUFFIX", ";", "if", "(", "Agl", "::", "isInitialized", "(", ")", ")", "{", "$", "collectionPath", "=", "APP_PATH", ".", "Agl", "::", "APP_PHP_DIR", ".", "CollectionInterface", "::", "APP_PHP_DIR", ".", "DS", ".", "$", "fileName", ".", "Agl", "::", "PHP_EXT", ";", "if", "(", "is_readable", "(", "$", "collectionPath", ")", ")", "{", "return", "self", "::", "getInstance", "(", "$", "className", ",", "array", "(", "$", "pCollection", ")", ")", ";", "}", "else", "{", "return", "new", "Collection", "(", "$", "pCollection", ")", ";", "}", "}", "else", "{", "return", "new", "Collection", "(", "$", "pCollection", ")", ";", "}", "}" ]
Return an instance of the requested collection. @param string $pCollection @return mixed
[ "Return", "an", "instance", "of", "the", "requested", "collection", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Loader/Loader.php#L143-L164
3,040
arnulfojr/apihistogram
ApiHistogram/ApiHistogramBundle/Cleaners/YahooStockCleaner.php
YahooStockCleaner.clean
public function clean(Response $response) { $body = $response->json(); $resources = $body["list"]["resources"]; $cleaned = array_pop($resources); return $cleaned; }
php
public function clean(Response $response) { $body = $response->json(); $resources = $body["list"]["resources"]; $cleaned = array_pop($resources); return $cleaned; }
[ "public", "function", "clean", "(", "Response", "$", "response", ")", "{", "$", "body", "=", "$", "response", "->", "json", "(", ")", ";", "$", "resources", "=", "$", "body", "[", "\"list\"", "]", "[", "\"resources\"", "]", ";", "$", "cleaned", "=", "array_pop", "(", "$", "resources", ")", ";", "return", "$", "cleaned", ";", "}" ]
This method process the response data to remove all unnecessary fields in the response @param $response @return mixed
[ "This", "method", "process", "the", "response", "data", "to", "remove", "all", "unnecessary", "fields", "in", "the", "response" ]
842b126211996c81c121cb3128199e17f105e1f4
https://github.com/arnulfojr/apihistogram/blob/842b126211996c81c121cb3128199e17f105e1f4/ApiHistogram/ApiHistogramBundle/Cleaners/YahooStockCleaner.php#L20-L28
3,041
valorin/pinpusher
src/Pin/Color.php
Color.foreground
public static function foreground($color) { list($red, $green, $blue) = str_split(substr($color, 1), 2); $red = hexdec($red); $green = hexdec($green); $blue = hexdec($blue); return ($red < 200 && $green < 100 && $blue < 200) ? self::WHITE : self::BLACK; }
php
public static function foreground($color) { list($red, $green, $blue) = str_split(substr($color, 1), 2); $red = hexdec($red); $green = hexdec($green); $blue = hexdec($blue); return ($red < 200 && $green < 100 && $blue < 200) ? self::WHITE : self::BLACK; }
[ "public", "static", "function", "foreground", "(", "$", "color", ")", "{", "list", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "=", "str_split", "(", "substr", "(", "$", "color", ",", "1", ")", ",", "2", ")", ";", "$", "red", "=", "hexdec", "(", "$", "red", ")", ";", "$", "green", "=", "hexdec", "(", "$", "green", ")", ";", "$", "blue", "=", "hexdec", "(", "$", "blue", ")", ";", "return", "(", "$", "red", "<", "200", "&&", "$", "green", "<", "100", "&&", "$", "blue", "<", "200", ")", "?", "self", "::", "WHITE", ":", "self", "::", "BLACK", ";", "}" ]
Returns a colour string for use as a foreground colour with the specified background colour. @param string $color @return string
[ "Returns", "a", "colour", "string", "for", "use", "as", "a", "foreground", "colour", "with", "the", "specified", "background", "colour", "." ]
e6e5d52ee9b9ded1adf74596a8a97407d43a0435
https://github.com/valorin/pinpusher/blob/e6e5d52ee9b9ded1adf74596a8a97407d43a0435/src/Pin/Color.php#L157-L166
3,042
kambo-1st/HttpMessage
src/Uri.php
Uri.isStandardPort
private function isStandardPort() { return ($this->scheme === self::HTTP && $this->port === self::HTTP_PORT) || ($this->scheme === self::HTTPS && $this->port === self::HTTPS_PORT); }
php
private function isStandardPort() { return ($this->scheme === self::HTTP && $this->port === self::HTTP_PORT) || ($this->scheme === self::HTTPS && $this->port === self::HTTPS_PORT); }
[ "private", "function", "isStandardPort", "(", ")", "{", "return", "(", "$", "this", "->", "scheme", "===", "self", "::", "HTTP", "&&", "$", "this", "->", "port", "===", "self", "::", "HTTP_PORT", ")", "||", "(", "$", "this", "->", "scheme", "===", "self", "::", "HTTPS", "&&", "$", "this", "->", "port", "===", "self", "::", "HTTPS_PORT", ")", ";", "}" ]
Check if Uri use a standard port. @return bool
[ "Check", "if", "Uri", "use", "a", "standard", "port", "." ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Uri.php#L588-L592
3,043
kambo-1st/HttpMessage
src/Uri.php
Uri.normalizeScheme
private function normalizeScheme($scheme) { if (!is_string($scheme) && !method_exists($scheme, '__toString')) { throw new InvalidArgumentException('Uri scheme must be a string'); } $scheme = str_replace('://', '', strtolower((string) $scheme)); if (!isset($this->validSchema[$scheme])) { throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"'); } return $scheme; }
php
private function normalizeScheme($scheme) { if (!is_string($scheme) && !method_exists($scheme, '__toString')) { throw new InvalidArgumentException('Uri scheme must be a string'); } $scheme = str_replace('://', '', strtolower((string) $scheme)); if (!isset($this->validSchema[$scheme])) { throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"'); } return $scheme; }
[ "private", "function", "normalizeScheme", "(", "$", "scheme", ")", "{", "if", "(", "!", "is_string", "(", "$", "scheme", ")", "&&", "!", "method_exists", "(", "$", "scheme", ",", "'__toString'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Uri scheme must be a string'", ")", ";", "}", "$", "scheme", "=", "str_replace", "(", "'://'", ",", "''", ",", "strtolower", "(", "(", "string", ")", "$", "scheme", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "validSchema", "[", "$", "scheme", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Uri scheme must be one of: \"\", \"https\", \"http\"'", ")", ";", "}", "return", "$", "scheme", ";", "}" ]
Normalize scheme part of Uri. @param string $scheme Raw Uri scheme. @return string Normalized Uri @throws InvalidArgumentException If the Uri scheme is not a string. @throws InvalidArgumentException If Uri scheme is not "", "https", or "http".
[ "Normalize", "scheme", "part", "of", "Uri", "." ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Uri.php#L604-L616
3,044
kambo-1st/HttpMessage
src/Uri.php
Uri.normalizePath
private function normalizePath($path) { if (!is_string($path) && !method_exists($path, '__toString')) { throw new InvalidArgumentException('Uri path must be a string'); } $path = $this->urlEncode($path); if (empty($path)) { return ''; } if ($path[0] !== '/') { return $path; } // Ensure only one leading slash return '/' . ltrim($path, '/'); }
php
private function normalizePath($path) { if (!is_string($path) && !method_exists($path, '__toString')) { throw new InvalidArgumentException('Uri path must be a string'); } $path = $this->urlEncode($path); if (empty($path)) { return ''; } if ($path[0] !== '/') { return $path; } // Ensure only one leading slash return '/' . ltrim($path, '/'); }
[ "private", "function", "normalizePath", "(", "$", "path", ")", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", "&&", "!", "method_exists", "(", "$", "path", ",", "'__toString'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Uri path must be a string'", ")", ";", "}", "$", "path", "=", "$", "this", "->", "urlEncode", "(", "$", "path", ")", ";", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "path", "[", "0", "]", "!==", "'/'", ")", "{", "return", "$", "path", ";", "}", "// Ensure only one leading slash", "return", "'/'", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "}" ]
Normalize path part of Uri and ensure it is properly encoded.. @param string $path Raw Uri path. @return string Normalized Uri path @throws InvalidArgumentException If the Uri scheme is not a string.
[ "Normalize", "path", "part", "of", "Uri", "and", "ensure", "it", "is", "properly", "encoded", ".." ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Uri.php#L627-L645
3,045
spipremix/facteur
lib/markdownify/markdownify_extra.php
Markdownify_Extra.flushStacked_abbr
function flushStacked_abbr() { $out = array(); foreach ($this->stack['abbr'] as $k => $tag) { if (!isset($tag['unstacked'])) { array_push($out, ' *['.$tag['text'].']: '.$tag['title']); $tag['unstacked'] = true; $this->stack['abbr'][$k] = $tag; } } if (!empty($out)) { $this->out("\n\n".implode("\n", $out)); } }
php
function flushStacked_abbr() { $out = array(); foreach ($this->stack['abbr'] as $k => $tag) { if (!isset($tag['unstacked'])) { array_push($out, ' *['.$tag['text'].']: '.$tag['title']); $tag['unstacked'] = true; $this->stack['abbr'][$k] = $tag; } } if (!empty($out)) { $this->out("\n\n".implode("\n", $out)); } }
[ "function", "flushStacked_abbr", "(", ")", "{", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "stack", "[", "'abbr'", "]", "as", "$", "k", "=>", "$", "tag", ")", "{", "if", "(", "!", "isset", "(", "$", "tag", "[", "'unstacked'", "]", ")", ")", "{", "array_push", "(", "$", "out", ",", "' *['", ".", "$", "tag", "[", "'text'", "]", ".", "']: '", ".", "$", "tag", "[", "'title'", "]", ")", ";", "$", "tag", "[", "'unstacked'", "]", "=", "true", ";", "$", "this", "->", "stack", "[", "'abbr'", "]", "[", "$", "k", "]", "=", "$", "tag", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "out", ")", ")", "{", "$", "this", "->", "out", "(", "\"\\n\\n\"", ".", "implode", "(", "\"\\n\"", ",", "$", "out", ")", ")", ";", "}", "}" ]
flush stacked abbr tags @param void @return void
[ "flush", "stacked", "abbr", "tags" ]
9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca
https://github.com/spipremix/facteur/blob/9cdca595d1f8f9a66c29e5c74e8666d81ebc65ca/lib/markdownify/markdownify_extra.php#L170-L182
3,046
sagebind/libnntp
src/HeaderBag.php
HeaderBag.parse
public static function parse(string $data): self { if (preg_match_all('/([^:\r\n]+):\s+([^\r\n]*(\r\n[ \t][^\r\n]+)*)\r\n/', $data, $matches, PREG_SET_ORDER) === false) { throw new FormatException('Invalid header format'); } foreach ($matches as $match) { // Undo header folding. $value = preg_replace('/\r\n[ \t]([^\r\n]+)/', ' $1', $match[2]); $headers[$match[1]] = $value; } return new self($headers); }
php
public static function parse(string $data): self { if (preg_match_all('/([^:\r\n]+):\s+([^\r\n]*(\r\n[ \t][^\r\n]+)*)\r\n/', $data, $matches, PREG_SET_ORDER) === false) { throw new FormatException('Invalid header format'); } foreach ($matches as $match) { // Undo header folding. $value = preg_replace('/\r\n[ \t]([^\r\n]+)/', ' $1', $match[2]); $headers[$match[1]] = $value; } return new self($headers); }
[ "public", "static", "function", "parse", "(", "string", "$", "data", ")", ":", "self", "{", "if", "(", "preg_match_all", "(", "'/([^:\\r\\n]+):\\s+([^\\r\\n]*(\\r\\n[ \\t][^\\r\\n]+)*)\\r\\n/'", ",", "$", "data", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", "===", "false", ")", "{", "throw", "new", "FormatException", "(", "'Invalid header format'", ")", ";", "}", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "// Undo header folding.", "$", "value", "=", "preg_replace", "(", "'/\\r\\n[ \\t]([^\\r\\n]+)/'", ",", "' $1'", ",", "$", "match", "[", "2", "]", ")", ";", "$", "headers", "[", "$", "match", "[", "1", "]", "]", "=", "$", "value", ";", "}", "return", "new", "self", "(", "$", "headers", ")", ";", "}" ]
Parses headers from a string.
[ "Parses", "headers", "from", "a", "string", "." ]
4bb81847ec08df89bb77377e5da0b017613a0447
https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/HeaderBag.php#L19-L33
3,047
sagebind/libnntp
src/HeaderBag.php
HeaderBag.get
public function get(string $name): string { $name = strtolower($name); return isset($this->headers[$name]) ? $this->headers[$name] : ''; }
php
public function get(string $name): string { $name = strtolower($name); return isset($this->headers[$name]) ? $this->headers[$name] : ''; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "string", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", "?", "$", "this", "->", "headers", "[", "$", "name", "]", ":", "''", ";", "}" ]
Gets the value of a header.
[ "Gets", "the", "value", "of", "a", "header", "." ]
4bb81847ec08df89bb77377e5da0b017613a0447
https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/HeaderBag.php#L62-L66
3,048
shakahl/hups-util-phptemplate
src/Hups/Util/PHPTemplate.php
PHPTemplate.findTemplateFile
public function findTemplateFile($filename) { foreach ($this->dir as $index => $dirname) { if (is_dir($dirname) && file_exists($dirname . '/' . $filename)) { return $dirname . '/' . $filename; } } return null; }
php
public function findTemplateFile($filename) { foreach ($this->dir as $index => $dirname) { if (is_dir($dirname) && file_exists($dirname . '/' . $filename)) { return $dirname . '/' . $filename; } } return null; }
[ "public", "function", "findTemplateFile", "(", "$", "filename", ")", "{", "foreach", "(", "$", "this", "->", "dir", "as", "$", "index", "=>", "$", "dirname", ")", "{", "if", "(", "is_dir", "(", "$", "dirname", ")", "&&", "file_exists", "(", "$", "dirname", ".", "'/'", ".", "$", "filename", ")", ")", "{", "return", "$", "dirname", ".", "'/'", ".", "$", "filename", ";", "}", "}", "return", "null", ";", "}" ]
Find a file in the template directories @param string $filename @return string|null
[ "Find", "a", "file", "in", "the", "template", "directories" ]
a336ef948046b23b7b72b2c2bd90df9a1baff24d
https://github.com/shakahl/hups-util-phptemplate/blob/a336ef948046b23b7b72b2c2bd90df9a1baff24d/src/Hups/Util/PHPTemplate.php#L69-L79
3,049
shakahl/hups-util-phptemplate
src/Hups/Util/PHPTemplate.php
PHPTemplate.setVars
public function setVars($vars, $clear = false) { if ($clear) { $this->vars = $vars; } else { if (is_array($vars)) $this->vars = array_merge($this->vars, $vars); } return $this; }
php
public function setVars($vars, $clear = false) { if ($clear) { $this->vars = $vars; } else { if (is_array($vars)) $this->vars = array_merge($this->vars, $vars); } return $this; }
[ "public", "function", "setVars", "(", "$", "vars", ",", "$", "clear", "=", "false", ")", "{", "if", "(", "$", "clear", ")", "{", "$", "this", "->", "vars", "=", "$", "vars", ";", "}", "else", "{", "if", "(", "is_array", "(", "$", "vars", ")", ")", "$", "this", "->", "vars", "=", "array_merge", "(", "$", "this", "->", "vars", ",", "$", "vars", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set a bunch of variables at once using an associative array. @param array $vars array of vars to set @param bool $clear whether to completely overwrite the existing vars @return Hups\Util\PHPTemplate
[ "Set", "a", "bunch", "of", "variables", "at", "once", "using", "an", "associative", "array", "." ]
a336ef948046b23b7b72b2c2bd90df9a1baff24d
https://github.com/shakahl/hups-util-phptemplate/blob/a336ef948046b23b7b72b2c2bd90df9a1baff24d/src/Hups/Util/PHPTemplate.php#L150-L158
3,050
railsphp/framework
src/Rails/Assets/Assets.php
Assets.compileFileBody
protected function compileFileBody($file) { $tempFilePath = $this->tempFolder() . '/' . $file->subPathsPath() . $file->name() . '-body' . ($this->config['compress'] ? '-c' : '') . '.' . $file->type(); $dir = pathinfo($tempFilePath, PATHINFO_DIRNAME); if (!is_dir($dir)) { mkdir($dir, 0775, true); } $recompile = true; if (is_file($tempFilePath)) { $tempFileMTime = filemtime($tempFilePath); if (filemtime($file->originalFilePath()) <= $tempFileMTime) { $recompile = false; } } if ($recompile) { $processor = new Processor\Processor($this); $compiledFile = $processor->compileFile($file); $compiledFile = $this->compressCompiledFile($file->type(), $compiledFile); # Cache compiled file. file_put_contents($tempFilePath, $compiledFile); } return [ 'file' => $file, 'tempFilePath' => $tempFilePath ]; }
php
protected function compileFileBody($file) { $tempFilePath = $this->tempFolder() . '/' . $file->subPathsPath() . $file->name() . '-body' . ($this->config['compress'] ? '-c' : '') . '.' . $file->type(); $dir = pathinfo($tempFilePath, PATHINFO_DIRNAME); if (!is_dir($dir)) { mkdir($dir, 0775, true); } $recompile = true; if (is_file($tempFilePath)) { $tempFileMTime = filemtime($tempFilePath); if (filemtime($file->originalFilePath()) <= $tempFileMTime) { $recompile = false; } } if ($recompile) { $processor = new Processor\Processor($this); $compiledFile = $processor->compileFile($file); $compiledFile = $this->compressCompiledFile($file->type(), $compiledFile); # Cache compiled file. file_put_contents($tempFilePath, $compiledFile); } return [ 'file' => $file, 'tempFilePath' => $tempFilePath ]; }
[ "protected", "function", "compileFileBody", "(", "$", "file", ")", "{", "$", "tempFilePath", "=", "$", "this", "->", "tempFolder", "(", ")", ".", "'/'", ".", "$", "file", "->", "subPathsPath", "(", ")", ".", "$", "file", "->", "name", "(", ")", ".", "'-body'", ".", "(", "$", "this", "->", "config", "[", "'compress'", "]", "?", "'-c'", ":", "''", ")", ".", "'.'", ".", "$", "file", "->", "type", "(", ")", ";", "$", "dir", "=", "pathinfo", "(", "$", "tempFilePath", ",", "PATHINFO_DIRNAME", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "$", "recompile", "=", "true", ";", "if", "(", "is_file", "(", "$", "tempFilePath", ")", ")", "{", "$", "tempFileMTime", "=", "filemtime", "(", "$", "tempFilePath", ")", ";", "if", "(", "filemtime", "(", "$", "file", "->", "originalFilePath", "(", ")", ")", "<=", "$", "tempFileMTime", ")", "{", "$", "recompile", "=", "false", ";", "}", "}", "if", "(", "$", "recompile", ")", "{", "$", "processor", "=", "new", "Processor", "\\", "Processor", "(", "$", "this", ")", ";", "$", "compiledFile", "=", "$", "processor", "->", "compileFile", "(", "$", "file", ")", ";", "$", "compiledFile", "=", "$", "this", "->", "compressCompiledFile", "(", "$", "file", "->", "type", "(", ")", ",", "$", "compiledFile", ")", ";", "# Cache compiled file.", "file_put_contents", "(", "$", "tempFilePath", ",", "$", "compiledFile", ")", ";", "}", "return", "[", "'file'", "=>", "$", "file", ",", "'tempFilePath'", "=>", "$", "tempFilePath", "]", ";", "}" ]
Compiles the file without executing directives.
[ "Compiles", "the", "file", "without", "executing", "directives", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Assets/Assets.php#L230-L266
3,051
kamalkhan/php-parser
src/SplatToCallUserFuncArrayVisitor.php
SplatToCallUserFuncArrayVisitor.getSplatCallVars
protected function getSplatCallVars($args) { $isSplatCall = false; $variables = []; foreach ($args as $arg) { if ($arg->unpack) { $isSplatCall = true; } $variables[] = $arg->value; } if (! $isSplatCall) { return; } return $variables; }
php
protected function getSplatCallVars($args) { $isSplatCall = false; $variables = []; foreach ($args as $arg) { if ($arg->unpack) { $isSplatCall = true; } $variables[] = $arg->value; } if (! $isSplatCall) { return; } return $variables; }
[ "protected", "function", "getSplatCallVars", "(", "$", "args", ")", "{", "$", "isSplatCall", "=", "false", ";", "$", "variables", "=", "[", "]", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "$", "arg", "->", "unpack", ")", "{", "$", "isSplatCall", "=", "true", ";", "}", "$", "variables", "[", "]", "=", "$", "arg", "->", "value", ";", "}", "if", "(", "!", "$", "isSplatCall", ")", "{", "return", ";", "}", "return", "$", "variables", ";", "}" ]
Get variables of the splat function call. @param array[\PhpParser\Node\Arg] $args Node arguments @return array[\PhpParser\Node\Expr\Variable] Node variables
[ "Get", "variables", "of", "the", "splat", "function", "call", "." ]
fc9dbd18455230e9d294d6666c3d923c21b27eba
https://github.com/kamalkhan/php-parser/blob/fc9dbd18455230e9d294d6666c3d923c21b27eba/src/SplatToCallUserFuncArrayVisitor.php#L58-L72
3,052
kamalkhan/php-parser
src/SplatToCallUserFuncArrayVisitor.php
SplatToCallUserFuncArrayVisitor.splatToCallUserFuncArray
protected function splatToCallUserFuncArray($callee, $variables) { $totalVars = count($variables); $splatVar = $variables[$totalVars - 1]; $mergeVars = []; for ($i = 0; $i < $totalVars - 1; $i++) { $mergeVars[] = $variables[$i]; } return new Expr\FuncCall( new Name('call_user_func_array'), [ $callee, new Expr\FuncCall( new Name('array_merge'), [new Expr\Array_($mergeVars), $splatVar] ) ] ); }
php
protected function splatToCallUserFuncArray($callee, $variables) { $totalVars = count($variables); $splatVar = $variables[$totalVars - 1]; $mergeVars = []; for ($i = 0; $i < $totalVars - 1; $i++) { $mergeVars[] = $variables[$i]; } return new Expr\FuncCall( new Name('call_user_func_array'), [ $callee, new Expr\FuncCall( new Name('array_merge'), [new Expr\Array_($mergeVars), $splatVar] ) ] ); }
[ "protected", "function", "splatToCallUserFuncArray", "(", "$", "callee", ",", "$", "variables", ")", "{", "$", "totalVars", "=", "count", "(", "$", "variables", ")", ";", "$", "splatVar", "=", "$", "variables", "[", "$", "totalVars", "-", "1", "]", ";", "$", "mergeVars", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "totalVars", "-", "1", ";", "$", "i", "++", ")", "{", "$", "mergeVars", "[", "]", "=", "$", "variables", "[", "$", "i", "]", ";", "}", "return", "new", "Expr", "\\", "FuncCall", "(", "new", "Name", "(", "'call_user_func_array'", ")", ",", "[", "$", "callee", ",", "new", "Expr", "\\", "FuncCall", "(", "new", "Name", "(", "'array_merge'", ")", ",", "[", "new", "Expr", "\\", "Array_", "(", "$", "mergeVars", ")", ",", "$", "splatVar", "]", ")", "]", ")", ";", "}" ]
Splact function call to call_user_func_array. @param \PhpParser\Node $callee Callee node @param array[\PhpParser\Node\Expr\Variable] $variables Node variables @return \PhpParser\Node\Expr\FuncCall call_user_func_array node
[ "Splact", "function", "call", "to", "call_user_func_array", "." ]
fc9dbd18455230e9d294d6666c3d923c21b27eba
https://github.com/kamalkhan/php-parser/blob/fc9dbd18455230e9d294d6666c3d923c21b27eba/src/SplatToCallUserFuncArrayVisitor.php#L80-L99
3,053
Rockbeat-Sky/framework
src/core/Cache.php
Cache.write
function write($filename,$content){ if(!Config::read('App.Base.enable_cache')){ return; } $expire = time() + ($this->getConfig('cache_expiration') * 60); $filename = md5($filename); $filepath = $this->getConfig('cache_path').$filename.'.tmp'; if ( ! $fp = @fopen($filepath, 'w')){ Loader::getClass('Sky.core.Log')->write(400,'Unable to write cache file: '.$filepath); Exceptions::showError('error', "Unable to write cache file: ".$filepath); } if (flock($fp, LOCK_EX)) { fwrite($fp, $expire.'T_SKY-->'.$content); flock($fp, LOCK_UN); } else{ Loader::getClass('Sky.core.Log')->write(300,'Unable to secure a file lock for file at: '.$filepath); return; } fclose($fp); @chmod($filepath,0755); }
php
function write($filename,$content){ if(!Config::read('App.Base.enable_cache')){ return; } $expire = time() + ($this->getConfig('cache_expiration') * 60); $filename = md5($filename); $filepath = $this->getConfig('cache_path').$filename.'.tmp'; if ( ! $fp = @fopen($filepath, 'w')){ Loader::getClass('Sky.core.Log')->write(400,'Unable to write cache file: '.$filepath); Exceptions::showError('error', "Unable to write cache file: ".$filepath); } if (flock($fp, LOCK_EX)) { fwrite($fp, $expire.'T_SKY-->'.$content); flock($fp, LOCK_UN); } else{ Loader::getClass('Sky.core.Log')->write(300,'Unable to secure a file lock for file at: '.$filepath); return; } fclose($fp); @chmod($filepath,0755); }
[ "function", "write", "(", "$", "filename", ",", "$", "content", ")", "{", "if", "(", "!", "Config", "::", "read", "(", "'App.Base.enable_cache'", ")", ")", "{", "return", ";", "}", "$", "expire", "=", "time", "(", ")", "+", "(", "$", "this", "->", "getConfig", "(", "'cache_expiration'", ")", "*", "60", ")", ";", "$", "filename", "=", "md5", "(", "$", "filename", ")", ";", "$", "filepath", "=", "$", "this", "->", "getConfig", "(", "'cache_path'", ")", ".", "$", "filename", ".", "'.tmp'", ";", "if", "(", "!", "$", "fp", "=", "@", "fopen", "(", "$", "filepath", ",", "'w'", ")", ")", "{", "Loader", "::", "getClass", "(", "'Sky.core.Log'", ")", "->", "write", "(", "400", ",", "'Unable to write cache file: '", ".", "$", "filepath", ")", ";", "Exceptions", "::", "showError", "(", "'error'", ",", "\"Unable to write cache file: \"", ".", "$", "filepath", ")", ";", "}", "if", "(", "flock", "(", "$", "fp", ",", "LOCK_EX", ")", ")", "{", "fwrite", "(", "$", "fp", ",", "$", "expire", ".", "'T_SKY-->'", ".", "$", "content", ")", ";", "flock", "(", "$", "fp", ",", "LOCK_UN", ")", ";", "}", "else", "{", "Loader", "::", "getClass", "(", "'Sky.core.Log'", ")", "->", "write", "(", "300", ",", "'Unable to secure a file lock for file at: '", ".", "$", "filepath", ")", ";", "return", ";", "}", "fclose", "(", "$", "fp", ")", ";", "@", "chmod", "(", "$", "filepath", ",", "0755", ")", ";", "}" ]
Write or create new cache file @param string @param string | html @return void
[ "Write", "or", "create", "new", "cache", "file" ]
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Cache.php#L54-L80
3,054
Rockbeat-Sky/framework
src/core/Cache.php
Cache.read
function read($filename){ $filename = md5($filename); $filepath = $this->getConfig('cache_path').$filename.'.tmp'; if(!file_exists($filepath)){ return FALSE; } if ( ! $fp = @fopen($filepath, 'r')){ return FALSE; } flock($fp, LOCK_SH); $cache = ''; if (filesize($filepath) > 0) { $cache = fread($fp, filesize($filepath)); } flock($fp, LOCK_UN); fclose($fp); // Strip out the embedded timestamp if ( ! preg_match("/(\d+T_SKY-->)/", $cache, $match)) { return FALSE; } // Has the file expired? If so we'll delete it. if (time() >= trim(str_replace('TS--->', '', $match['1']))) { if (is_writable($filepath)) { @unlink($filepath); return FALSE; } } // Display the cache return str_replace($match['0'], '', $cache); }
php
function read($filename){ $filename = md5($filename); $filepath = $this->getConfig('cache_path').$filename.'.tmp'; if(!file_exists($filepath)){ return FALSE; } if ( ! $fp = @fopen($filepath, 'r')){ return FALSE; } flock($fp, LOCK_SH); $cache = ''; if (filesize($filepath) > 0) { $cache = fread($fp, filesize($filepath)); } flock($fp, LOCK_UN); fclose($fp); // Strip out the embedded timestamp if ( ! preg_match("/(\d+T_SKY-->)/", $cache, $match)) { return FALSE; } // Has the file expired? If so we'll delete it. if (time() >= trim(str_replace('TS--->', '', $match['1']))) { if (is_writable($filepath)) { @unlink($filepath); return FALSE; } } // Display the cache return str_replace($match['0'], '', $cache); }
[ "function", "read", "(", "$", "filename", ")", "{", "$", "filename", "=", "md5", "(", "$", "filename", ")", ";", "$", "filepath", "=", "$", "this", "->", "getConfig", "(", "'cache_path'", ")", ".", "$", "filename", ".", "'.tmp'", ";", "if", "(", "!", "file_exists", "(", "$", "filepath", ")", ")", "{", "return", "FALSE", ";", "}", "if", "(", "!", "$", "fp", "=", "@", "fopen", "(", "$", "filepath", ",", "'r'", ")", ")", "{", "return", "FALSE", ";", "}", "flock", "(", "$", "fp", ",", "LOCK_SH", ")", ";", "$", "cache", "=", "''", ";", "if", "(", "filesize", "(", "$", "filepath", ")", ">", "0", ")", "{", "$", "cache", "=", "fread", "(", "$", "fp", ",", "filesize", "(", "$", "filepath", ")", ")", ";", "}", "flock", "(", "$", "fp", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "fp", ")", ";", "// Strip out the embedded timestamp", "if", "(", "!", "preg_match", "(", "\"/(\\d+T_SKY-->)/\"", ",", "$", "cache", ",", "$", "match", ")", ")", "{", "return", "FALSE", ";", "}", "// Has the file expired? If so we'll delete it.", "if", "(", "time", "(", ")", ">=", "trim", "(", "str_replace", "(", "'TS--->'", ",", "''", ",", "$", "match", "[", "'1'", "]", ")", ")", ")", "{", "if", "(", "is_writable", "(", "$", "filepath", ")", ")", "{", "@", "unlink", "(", "$", "filepath", ")", ";", "return", "FALSE", ";", "}", "}", "// Display the cache", "return", "str_replace", "(", "$", "match", "[", "'0'", "]", ",", "''", ",", "$", "cache", ")", ";", "}" ]
read and get cache file @param string @return html
[ "read", "and", "get", "cache", "file" ]
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Cache.php#L87-L126
3,055
MichaelJ2324/OO-cURL
src/Response/AbstractResponse.php
AbstractResponse.reset
public function reset(){ $this->status = NULL; $this->body = NULL; $this->headers = NULL; $this->info = array(); }
php
public function reset(){ $this->status = NULL; $this->body = NULL; $this->headers = NULL; $this->info = array(); }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "status", "=", "NULL", ";", "$", "this", "->", "body", "=", "NULL", ";", "$", "this", "->", "headers", "=", "NULL", ";", "$", "this", "->", "info", "=", "array", "(", ")", ";", "}" ]
Reset the Response Object
[ "Reset", "the", "Response", "Object" ]
067a29f7e5fe1941d870819658952be6d4a1f9b4
https://github.com/MichaelJ2324/OO-cURL/blob/067a29f7e5fe1941d870819658952be6d4a1f9b4/src/Response/AbstractResponse.php#L66-L71
3,056
MichaelJ2324/OO-cURL
src/Response/AbstractResponse.php
AbstractResponse.extractInfo
protected function extractInfo($curlResource) { $this->info = curl_getinfo($curlResource); foreach(static::$_CURL_EXTRA_INFO as $option){ $this->info[$option] = curl_getinfo($curlResource,$option); } $this->status = $this->info['http_code']; }
php
protected function extractInfo($curlResource) { $this->info = curl_getinfo($curlResource); foreach(static::$_CURL_EXTRA_INFO as $option){ $this->info[$option] = curl_getinfo($curlResource,$option); } $this->status = $this->info['http_code']; }
[ "protected", "function", "extractInfo", "(", "$", "curlResource", ")", "{", "$", "this", "->", "info", "=", "curl_getinfo", "(", "$", "curlResource", ")", ";", "foreach", "(", "static", "::", "$", "_CURL_EXTRA_INFO", "as", "$", "option", ")", "{", "$", "this", "->", "info", "[", "$", "option", "]", "=", "curl_getinfo", "(", "$", "curlResource", ",", "$", "option", ")", ";", "}", "$", "this", "->", "status", "=", "$", "this", "->", "info", "[", "'http_code'", "]", ";", "}" ]
Extract the information from the Curl Request via curl_getinfo Setup the Status property to be equal to the http_code @param $curlResource - cURL Resource
[ "Extract", "the", "information", "from", "the", "Curl", "Request", "via", "curl_getinfo", "Setup", "the", "Status", "property", "to", "be", "equal", "to", "the", "http_code" ]
067a29f7e5fe1941d870819658952be6d4a1f9b4
https://github.com/MichaelJ2324/OO-cURL/blob/067a29f7e5fe1941d870819658952be6d4a1f9b4/src/Response/AbstractResponse.php#L102-L109
3,057
joegreen88/zf1-components-base
src/Zend/Loader/AutoloaderFactory.php
Zend_Loader_AutoloaderFactory.factory
public static function factory($options = null) { if (null === $options) { if (!isset(self::$loaders[self::STANDARD_AUTOLOADER])) { $autoloader = self::getStandardAutoloader(); $autoloader->register(); self::$loaders[self::STANDARD_AUTOLOADER] = $autoloader; } // Return so we don't hit the next check's exception (we're done here anyway) return; } if (!is_array($options) && !($options instanceof Traversable)) { throw new Zend_Loader_Exception_InvalidArgumentException( 'Options provided must be an array or Traversable' ); } foreach ($options as $class => $options) { if (!isset(self::$loaders[$class])) { $autoloader = self::getStandardAutoloader(); if (!class_exists($class) && !$autoloader->autoload($class)) { throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( 'Autoloader class "%s" not loaded', $class )); } // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case if (version_compare(PHP_VERSION, '5.3.7', '>=')) { if (!is_subclass_of($class, 'Zend_Loader_SplAutoloader')) { throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( 'Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class )); } } if ($class === self::STANDARD_AUTOLOADER) { $autoloader->setOptions($options); } else { $autoloader = new $class($options); } $autoloader->register(); self::$loaders[$class] = $autoloader; } else { self::$loaders[$class]->setOptions($options); } } }
php
public static function factory($options = null) { if (null === $options) { if (!isset(self::$loaders[self::STANDARD_AUTOLOADER])) { $autoloader = self::getStandardAutoloader(); $autoloader->register(); self::$loaders[self::STANDARD_AUTOLOADER] = $autoloader; } // Return so we don't hit the next check's exception (we're done here anyway) return; } if (!is_array($options) && !($options instanceof Traversable)) { throw new Zend_Loader_Exception_InvalidArgumentException( 'Options provided must be an array or Traversable' ); } foreach ($options as $class => $options) { if (!isset(self::$loaders[$class])) { $autoloader = self::getStandardAutoloader(); if (!class_exists($class) && !$autoloader->autoload($class)) { throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( 'Autoloader class "%s" not loaded', $class )); } // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case if (version_compare(PHP_VERSION, '5.3.7', '>=')) { if (!is_subclass_of($class, 'Zend_Loader_SplAutoloader')) { throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( 'Autoloader class %s must implement Zend\\Loader\\SplAutoloader', $class )); } } if ($class === self::STANDARD_AUTOLOADER) { $autoloader->setOptions($options); } else { $autoloader = new $class($options); } $autoloader->register(); self::$loaders[$class] = $autoloader; } else { self::$loaders[$class]->setOptions($options); } } }
[ "public", "static", "function", "factory", "(", "$", "options", "=", "null", ")", "{", "if", "(", "null", "===", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "loaders", "[", "self", "::", "STANDARD_AUTOLOADER", "]", ")", ")", "{", "$", "autoloader", "=", "self", "::", "getStandardAutoloader", "(", ")", ";", "$", "autoloader", "->", "register", "(", ")", ";", "self", "::", "$", "loaders", "[", "self", "::", "STANDARD_AUTOLOADER", "]", "=", "$", "autoloader", ";", "}", "// Return so we don't hit the next check's exception (we're done here anyway)", "return", ";", "}", "if", "(", "!", "is_array", "(", "$", "options", ")", "&&", "!", "(", "$", "options", "instanceof", "Traversable", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "'Options provided must be an array or Traversable'", ")", ";", "}", "foreach", "(", "$", "options", "as", "$", "class", "=>", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "loaders", "[", "$", "class", "]", ")", ")", "{", "$", "autoloader", "=", "self", "::", "getStandardAutoloader", "(", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", "&&", "!", "$", "autoloader", "->", "autoload", "(", "$", "class", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "sprintf", "(", "'Autoloader class \"%s\" not loaded'", ",", "$", "class", ")", ")", ";", "}", "// unfortunately is_subclass_of is broken on some 5.3 versions", "// additionally instanceof is also broken for this use case", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.3.7'", ",", "'>='", ")", ")", "{", "if", "(", "!", "is_subclass_of", "(", "$", "class", ",", "'Zend_Loader_SplAutoloader'", ")", ")", "{", "throw", "new", "Zend_Loader_Exception_InvalidArgumentException", "(", "sprintf", "(", "'Autoloader class %s must implement Zend\\\\Loader\\\\SplAutoloader'", ",", "$", "class", ")", ")", ";", "}", "}", "if", "(", "$", "class", "===", "self", "::", "STANDARD_AUTOLOADER", ")", "{", "$", "autoloader", "->", "setOptions", "(", "$", "options", ")", ";", "}", "else", "{", "$", "autoloader", "=", "new", "$", "class", "(", "$", "options", ")", ";", "}", "$", "autoloader", "->", "register", "(", ")", ";", "self", "::", "$", "loaders", "[", "$", "class", "]", "=", "$", "autoloader", ";", "}", "else", "{", "self", "::", "$", "loaders", "[", "$", "class", "]", "->", "setOptions", "(", "$", "options", ")", ";", "}", "}", "}" ]
Factory for autoloaders Options should be an array or Traversable object of the following structure: <code> array( '<autoloader class name>' => $autoloaderOptions, ) </code> The factory will then loop through and instantiate each autoloader with the specified options, and register each with the spl_autoloader. You may retrieve the concrete autoloader instances later using {@link getRegisteredAutoloaders()}. Note that the class names must be resolvable on the include_path or via the Zend library, using PSR-0 rules (unless the class has already been loaded). @param array|Traversable $options (optional) options to use. Defaults to Zend_Loader_StandardAutoloader @return void @throws Zend_Loader_Exception_InvalidArgumentException for invalid options @throws Zend_Loader_Exception_InvalidArgumentException for unloadable autoloader classes
[ "Factory", "for", "autoloaders" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/AutoloaderFactory.php#L69-L123
3,058
joegreen88/zf1-components-base
src/Zend/Loader/AutoloaderFactory.php
Zend_Loader_AutoloaderFactory.unregisterAutoloader
public static function unregisterAutoloader($autoloaderClass) { if (!isset(self::$loaders[$autoloaderClass])) { return false; } $autoloader = self::$loaders[$autoloaderClass]; spl_autoload_unregister(array($autoloader, 'autoload')); unset(self::$loaders[$autoloaderClass]); return true; }
php
public static function unregisterAutoloader($autoloaderClass) { if (!isset(self::$loaders[$autoloaderClass])) { return false; } $autoloader = self::$loaders[$autoloaderClass]; spl_autoload_unregister(array($autoloader, 'autoload')); unset(self::$loaders[$autoloaderClass]); return true; }
[ "public", "static", "function", "unregisterAutoloader", "(", "$", "autoloaderClass", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "loaders", "[", "$", "autoloaderClass", "]", ")", ")", "{", "return", "false", ";", "}", "$", "autoloader", "=", "self", "::", "$", "loaders", "[", "$", "autoloaderClass", "]", ";", "spl_autoload_unregister", "(", "array", "(", "$", "autoloader", ",", "'autoload'", ")", ")", ";", "unset", "(", "self", "::", "$", "loaders", "[", "$", "autoloaderClass", "]", ")", ";", "return", "true", ";", "}" ]
Unregister a single autoloader by class name @param string $autoloaderClass @return bool
[ "Unregister", "a", "single", "autoloader", "by", "class", "name" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/AutoloaderFactory.php#L173-L183
3,059
joegreen88/zf1-components-base
src/Zend/Loader/AutoloaderFactory.php
Zend_Loader_AutoloaderFactory.getStandardAutoloader
protected static function getStandardAutoloader() { if (null !== self::$standardAutoloader) { return self::$standardAutoloader; } // Extract the filename from the classname $stdAutoloader = substr(strrchr(self::STANDARD_AUTOLOADER, '_'), 1); if (!class_exists(self::STANDARD_AUTOLOADER)) { } $loader = new Zend_Loader_StandardAutoloader(); self::$standardAutoloader = $loader; return self::$standardAutoloader; }
php
protected static function getStandardAutoloader() { if (null !== self::$standardAutoloader) { return self::$standardAutoloader; } // Extract the filename from the classname $stdAutoloader = substr(strrchr(self::STANDARD_AUTOLOADER, '_'), 1); if (!class_exists(self::STANDARD_AUTOLOADER)) { } $loader = new Zend_Loader_StandardAutoloader(); self::$standardAutoloader = $loader; return self::$standardAutoloader; }
[ "protected", "static", "function", "getStandardAutoloader", "(", ")", "{", "if", "(", "null", "!==", "self", "::", "$", "standardAutoloader", ")", "{", "return", "self", "::", "$", "standardAutoloader", ";", "}", "// Extract the filename from the classname", "$", "stdAutoloader", "=", "substr", "(", "strrchr", "(", "self", "::", "STANDARD_AUTOLOADER", ",", "'_'", ")", ",", "1", ")", ";", "if", "(", "!", "class_exists", "(", "self", "::", "STANDARD_AUTOLOADER", ")", ")", "{", "}", "$", "loader", "=", "new", "Zend_Loader_StandardAutoloader", "(", ")", ";", "self", "::", "$", "standardAutoloader", "=", "$", "loader", ";", "return", "self", "::", "$", "standardAutoloader", ";", "}" ]
Get an instance of the standard autoloader Used to attempt to resolve autoloader classes, using the StandardAutoloader. The instance is marked as a fallback autoloader, to allow resolving autoloaders not under the "Zend" or "Zend" namespaces. @return Zend_Loader_SplAutoloader
[ "Get", "an", "instance", "of", "the", "standard", "autoloader" ]
d4591a2234c2db3094b54c08bcdc4303f7bf4819
https://github.com/joegreen88/zf1-components-base/blob/d4591a2234c2db3094b54c08bcdc4303f7bf4819/src/Zend/Loader/AutoloaderFactory.php#L194-L209
3,060
Fenzland/Htsl.php
libs/Parser/Node/CommentNode.php
CommentNode.open
public function open():string { return $this->htmlComment ? '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)): '<?php /* '.substr($this->line->getContent(),2); }
php
public function open():string { return $this->htmlComment ? '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)): '<?php /* '.substr($this->line->getContent(),2); }
[ "public", "function", "open", "(", ")", ":", "string", "{", "return", "$", "this", "->", "htmlComment", "?", "'<!--'", ".", "str_replace", "(", "'-->'", ",", "'--'", ".", "chr", "(", "0xC", ")", ".", "'>'", ",", "substr", "(", "$", "this", "->", "line", "->", "getContent", "(", ")", ",", "1", ")", ")", ":", "'<?php /* '", ".", "substr", "(", "$", "this", "->", "line", "->", "getContent", "(", ")", ",", "2", ")", ";", "}" ]
Opening this node, and returning node opener. @access public @return string
[ "Opening", "this", "node", "and", "returning", "node", "opener", "." ]
28ecc4afd1a5bdb29dea3589c8132adba87f3947
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/CommentNode.php#L42-L47
3,061
romeOz/rock-di
src/Container.php
Container.getAll
public static function getAll(array $only = [], array $exclude = [], $alias = false) { return $alias === true ? ArrayHelper::only(static::$classAliases, $only, $exclude) : ArrayHelper::only(static::$classNames, $only, $exclude); }
php
public static function getAll(array $only = [], array $exclude = [], $alias = false) { return $alias === true ? ArrayHelper::only(static::$classAliases, $only, $exclude) : ArrayHelper::only(static::$classNames, $only, $exclude); }
[ "public", "static", "function", "getAll", "(", "array", "$", "only", "=", "[", "]", ",", "array", "$", "exclude", "=", "[", "]", ",", "$", "alias", "=", "false", ")", "{", "return", "$", "alias", "===", "true", "?", "ArrayHelper", "::", "only", "(", "static", "::", "$", "classAliases", ",", "$", "only", ",", "$", "exclude", ")", ":", "ArrayHelper", "::", "only", "(", "static", "::", "$", "classNames", ",", "$", "only", ",", "$", "exclude", ")", ";", "}" ]
Returns all configs. @param bool $alias by alias @param array $only list of items whose value needs to be returned. @param array $exclude list of items whose value should NOT be returned. @return array the array representation of the collection.
[ "Returns", "all", "configs", "." ]
dc031110a0554deb6debe5d041abcb00ca270978
https://github.com/romeOz/rock-di/blob/dc031110a0554deb6debe5d041abcb00ca270978/src/Container.php#L127-L132
3,062
romeOz/rock-di
src/Container.php
Container.register
public static function register($alias, $config) { if (is_array($config)) { $name = $config['class']; $singleton = !empty($config['singleton']); unset($config['class'], $config['singleton']); static::$classNames[$name] = static::$classAliases[$alias] = [ 'singleton' => $singleton, 'class' => $name, 'alias' => $alias, 'properties' => $config, ]; } elseif (is_callable($config)) { static::$classAliases[$alias] = ['class' => $config, 'alias' => $alias, 'properties' => []]; } else { throw new ContainerException('Configuration must be an array or callable.'); } unset(static::$instances[$alias]); }
php
public static function register($alias, $config) { if (is_array($config)) { $name = $config['class']; $singleton = !empty($config['singleton']); unset($config['class'], $config['singleton']); static::$classNames[$name] = static::$classAliases[$alias] = [ 'singleton' => $singleton, 'class' => $name, 'alias' => $alias, 'properties' => $config, ]; } elseif (is_callable($config)) { static::$classAliases[$alias] = ['class' => $config, 'alias' => $alias, 'properties' => []]; } else { throw new ContainerException('Configuration must be an array or callable.'); } unset(static::$instances[$alias]); }
[ "public", "static", "function", "register", "(", "$", "alias", ",", "$", "config", ")", "{", "if", "(", "is_array", "(", "$", "config", ")", ")", "{", "$", "name", "=", "$", "config", "[", "'class'", "]", ";", "$", "singleton", "=", "!", "empty", "(", "$", "config", "[", "'singleton'", "]", ")", ";", "unset", "(", "$", "config", "[", "'class'", "]", ",", "$", "config", "[", "'singleton'", "]", ")", ";", "static", "::", "$", "classNames", "[", "$", "name", "]", "=", "static", "::", "$", "classAliases", "[", "$", "alias", "]", "=", "[", "'singleton'", "=>", "$", "singleton", ",", "'class'", "=>", "$", "name", ",", "'alias'", "=>", "$", "alias", ",", "'properties'", "=>", "$", "config", ",", "]", ";", "}", "elseif", "(", "is_callable", "(", "$", "config", ")", ")", "{", "static", "::", "$", "classAliases", "[", "$", "alias", "]", "=", "[", "'class'", "=>", "$", "config", ",", "'alias'", "=>", "$", "alias", ",", "'properties'", "=>", "[", "]", "]", ";", "}", "else", "{", "throw", "new", "ContainerException", "(", "'Configuration must be an array or callable.'", ")", ";", "}", "unset", "(", "static", "::", "$", "instances", "[", "$", "alias", "]", ")", ";", "}" ]
Registry class. @param string $alias alias of class. @param array|\Closure $config @throws ContainerException
[ "Registry", "class", "." ]
dc031110a0554deb6debe5d041abcb00ca270978
https://github.com/romeOz/rock-di/blob/dc031110a0554deb6debe5d041abcb00ca270978/src/Container.php#L141-L160
3,063
romeOz/rock-di
src/Container.php
Container.isSingleton
public static function isSingleton($name) { if (!static::exists($name)) { return false; } if (empty(static::$classNames[$name]['singleton']) && empty(static::$classAliases[$name]['singleton']) ) { return false; } return true; }
php
public static function isSingleton($name) { if (!static::exists($name)) { return false; } if (empty(static::$classNames[$name]['singleton']) && empty(static::$classAliases[$name]['singleton']) ) { return false; } return true; }
[ "public", "static", "function", "isSingleton", "(", "$", "name", ")", "{", "if", "(", "!", "static", "::", "exists", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "static", "::", "$", "classNames", "[", "$", "name", "]", "[", "'singleton'", "]", ")", "&&", "empty", "(", "static", "::", "$", "classAliases", "[", "$", "name", "]", "[", "'singleton'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is single of class. @param string $name name/alias of class. @return null
[ "Is", "single", "of", "class", "." ]
dc031110a0554deb6debe5d041abcb00ca270978
https://github.com/romeOz/rock-di/blob/dc031110a0554deb6debe5d041abcb00ca270978/src/Container.php#L230-L242
3,064
loopsframework/base
src/Loops/ErrorPage.php
ErrorPage.getPagePath
public function getPagePath() { $core = $this->getLoops()->getService("web_core"); $page = $core->page; $pagepath = $page === $this ? "" : WebCore::getPagePathFromClassname($page, $core->page_parameter); return implode("/", $pagepath ? array_merge([$pagepath], $core->parameter) : $core->parameter); }
php
public function getPagePath() { $core = $this->getLoops()->getService("web_core"); $page = $core->page; $pagepath = $page === $this ? "" : WebCore::getPagePathFromClassname($page, $core->page_parameter); return implode("/", $pagepath ? array_merge([$pagepath], $core->parameter) : $core->parameter); }
[ "public", "function", "getPagePath", "(", ")", "{", "$", "core", "=", "$", "this", "->", "getLoops", "(", ")", "->", "getService", "(", "\"web_core\"", ")", ";", "$", "page", "=", "$", "core", "->", "page", ";", "$", "pagepath", "=", "$", "page", "===", "$", "this", "?", "\"\"", ":", "WebCore", "::", "getPagePathFromClassname", "(", "$", "page", ",", "$", "core", "->", "page_parameter", ")", ";", "return", "implode", "(", "\"/\"", ",", "$", "pagepath", "?", "array_merge", "(", "[", "$", "pagepath", "]", ",", "$", "core", "->", "parameter", ")", ":", "$", "core", "->", "parameter", ")", ";", "}" ]
Returns the page path This method will return the requested url.
[ "Returns", "the", "page", "path" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ErrorPage.php#L43-L48
3,065
vedmaka/Mediawiki-Model
Model.class.php
Model.load
public function load( $id ) { $this->isNew = false; $dbr = wfGetDB( DB_SLAVE ); /* Fetch entity by id */ $entity = $dbr->selectRow( static::$table, '*', array( 'id' => intval( $id ) ) ); if ( !$entity ) { $this->error = true; return false; throw new Exception(get_called_class() . ": there is no entity with id = $id in table " . static::$table); } /* Set all properties by $properties array */ foreach ( $this->properties as $prop => $type ) { if ( !isset($entity->$prop) && $entity->$prop !== null ) throw new Exception(get_called_class() . ": No such field $prop in table " . static::$table . "."); if ( $prop == 'id' ) { $this->id = $entity->$prop; continue; } /* Data type: int or string */ if ( $type == 'int' ) { $this->values[$prop] = intval( $entity->$prop ); } else { $this->values[$prop] = $entity->$prop; } } return true; }
php
public function load( $id ) { $this->isNew = false; $dbr = wfGetDB( DB_SLAVE ); /* Fetch entity by id */ $entity = $dbr->selectRow( static::$table, '*', array( 'id' => intval( $id ) ) ); if ( !$entity ) { $this->error = true; return false; throw new Exception(get_called_class() . ": there is no entity with id = $id in table " . static::$table); } /* Set all properties by $properties array */ foreach ( $this->properties as $prop => $type ) { if ( !isset($entity->$prop) && $entity->$prop !== null ) throw new Exception(get_called_class() . ": No such field $prop in table " . static::$table . "."); if ( $prop == 'id' ) { $this->id = $entity->$prop; continue; } /* Data type: int or string */ if ( $type == 'int' ) { $this->values[$prop] = intval( $entity->$prop ); } else { $this->values[$prop] = $entity->$prop; } } return true; }
[ "public", "function", "load", "(", "$", "id", ")", "{", "$", "this", "->", "isNew", "=", "false", ";", "$", "dbr", "=", "wfGetDB", "(", "DB_SLAVE", ")", ";", "/* Fetch entity by id */", "$", "entity", "=", "$", "dbr", "->", "selectRow", "(", "static", "::", "$", "table", ",", "'*'", ",", "array", "(", "'id'", "=>", "intval", "(", "$", "id", ")", ")", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "$", "this", "->", "error", "=", "true", ";", "return", "false", ";", "throw", "new", "Exception", "(", "get_called_class", "(", ")", ".", "\": there is no entity with id = $id in table \"", ".", "static", "::", "$", "table", ")", ";", "}", "/* Set all properties by $properties array */", "foreach", "(", "$", "this", "->", "properties", "as", "$", "prop", "=>", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "entity", "->", "$", "prop", ")", "&&", "$", "entity", "->", "$", "prop", "!==", "null", ")", "throw", "new", "Exception", "(", "get_called_class", "(", ")", ".", "\": No such field $prop in table \"", ".", "static", "::", "$", "table", ".", "\".\"", ")", ";", "if", "(", "$", "prop", "==", "'id'", ")", "{", "$", "this", "->", "id", "=", "$", "entity", "->", "$", "prop", ";", "continue", ";", "}", "/* Data type: int or string */", "if", "(", "$", "type", "==", "'int'", ")", "{", "$", "this", "->", "values", "[", "$", "prop", "]", "=", "intval", "(", "$", "entity", "->", "$", "prop", ")", ";", "}", "else", "{", "$", "this", "->", "values", "[", "$", "prop", "]", "=", "$", "entity", "->", "$", "prop", ";", "}", "}", "return", "true", ";", "}" ]
Loads entity from database. @param $id @return bool @throws Exception
[ "Loads", "entity", "from", "database", "." ]
f4549e17ada74d7123393f9dbd7b3d417b921ad1
https://github.com/vedmaka/Mediawiki-Model/blob/f4549e17ada74d7123393f9dbd7b3d417b921ad1/Model.class.php#L89-L129
3,066
vedmaka/Mediawiki-Model
Model.class.php
Model.count
public function count( $where = 'all', $options = array() ) { $dbr = wfGetDB( DB_SLAVE ); if ( !is_array( $where ) && $where == 'all' ) { /* Fetch all entities */ $collection = $dbr->select( static::$table, 'id', array(), __METHOD__, $options ); } else { /* Fetch conditional entities */ $collection = $dbr->select( static::$table, 'id', $where, __METHOD__, $options ); } /* Check result */ if ( !$collection ) return 0; $count = $dbr->numRows( $collection ); return $count; }
php
public function count( $where = 'all', $options = array() ) { $dbr = wfGetDB( DB_SLAVE ); if ( !is_array( $where ) && $where == 'all' ) { /* Fetch all entities */ $collection = $dbr->select( static::$table, 'id', array(), __METHOD__, $options ); } else { /* Fetch conditional entities */ $collection = $dbr->select( static::$table, 'id', $where, __METHOD__, $options ); } /* Check result */ if ( !$collection ) return 0; $count = $dbr->numRows( $collection ); return $count; }
[ "public", "function", "count", "(", "$", "where", "=", "'all'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "dbr", "=", "wfGetDB", "(", "DB_SLAVE", ")", ";", "if", "(", "!", "is_array", "(", "$", "where", ")", "&&", "$", "where", "==", "'all'", ")", "{", "/* Fetch all entities */", "$", "collection", "=", "$", "dbr", "->", "select", "(", "static", "::", "$", "table", ",", "'id'", ",", "array", "(", ")", ",", "__METHOD__", ",", "$", "options", ")", ";", "}", "else", "{", "/* Fetch conditional entities */", "$", "collection", "=", "$", "dbr", "->", "select", "(", "static", "::", "$", "table", ",", "'id'", ",", "$", "where", ",", "__METHOD__", ",", "$", "options", ")", ";", "}", "/* Check result */", "if", "(", "!", "$", "collection", ")", "return", "0", ";", "$", "count", "=", "$", "dbr", "->", "numRows", "(", "$", "collection", ")", ";", "return", "$", "count", ";", "}" ]
Count entities. There some code that should be fixed. @param string $where @param array $options @return int
[ "Count", "entities", ".", "There", "some", "code", "that", "should", "be", "fixed", "." ]
f4549e17ada74d7123393f9dbd7b3d417b921ad1
https://github.com/vedmaka/Mediawiki-Model/blob/f4549e17ada74d7123393f9dbd7b3d417b921ad1/Model.class.php#L137-L171
3,067
vedmaka/Mediawiki-Model
Model.class.php
Model.save
public function save( $propvalues = null, $reserved = false ) { $dbr = wfGetDB( DB_MASTER ); $dbr->begin(); $sourceprops = $this->properties; $insertId = null; foreach ( $sourceprops as $prop => $type ) { $sourceprops[$prop] = (isset($this->values[$prop])) ? $this->values[$prop] : ''; } /* New values from passed $propvalues array */ if ( $propvalues != null && is_array( $propvalues ) ) { if ( array_key_exists( 'id', $propvalues ) ) throw new Exception('ORM.Model: `id` parameter cant be passed in poperties array.'); foreach ( $propvalues as $prop => $value ) { if ( isset($this->properties[$prop]) ) $sourceprops[$prop] = $value; } } $sourceprops['id'] = $this->id; if ( $this->isNew ) { /* New entity */ $dbr->insert( static::$table, $sourceprops, __METHOD__ ); $insertId = $dbr->insertId(); } else { /* Check id, just for sure */ if ( !is_numeric( $this->id ) ) throw new Exception('WikivoteVoting: There is no `id` field on exesting entity update. Fatal error.'); /* Update existing entity */ $dbr->update( static::$table, $sourceprops, array( 'id' => $this->id ), __METHOD__ ); $insertId = $this->id; } $dbr->commit(); return $insertId; }
php
public function save( $propvalues = null, $reserved = false ) { $dbr = wfGetDB( DB_MASTER ); $dbr->begin(); $sourceprops = $this->properties; $insertId = null; foreach ( $sourceprops as $prop => $type ) { $sourceprops[$prop] = (isset($this->values[$prop])) ? $this->values[$prop] : ''; } /* New values from passed $propvalues array */ if ( $propvalues != null && is_array( $propvalues ) ) { if ( array_key_exists( 'id', $propvalues ) ) throw new Exception('ORM.Model: `id` parameter cant be passed in poperties array.'); foreach ( $propvalues as $prop => $value ) { if ( isset($this->properties[$prop]) ) $sourceprops[$prop] = $value; } } $sourceprops['id'] = $this->id; if ( $this->isNew ) { /* New entity */ $dbr->insert( static::$table, $sourceprops, __METHOD__ ); $insertId = $dbr->insertId(); } else { /* Check id, just for sure */ if ( !is_numeric( $this->id ) ) throw new Exception('WikivoteVoting: There is no `id` field on exesting entity update. Fatal error.'); /* Update existing entity */ $dbr->update( static::$table, $sourceprops, array( 'id' => $this->id ), __METHOD__ ); $insertId = $this->id; } $dbr->commit(); return $insertId; }
[ "public", "function", "save", "(", "$", "propvalues", "=", "null", ",", "$", "reserved", "=", "false", ")", "{", "$", "dbr", "=", "wfGetDB", "(", "DB_MASTER", ")", ";", "$", "dbr", "->", "begin", "(", ")", ";", "$", "sourceprops", "=", "$", "this", "->", "properties", ";", "$", "insertId", "=", "null", ";", "foreach", "(", "$", "sourceprops", "as", "$", "prop", "=>", "$", "type", ")", "{", "$", "sourceprops", "[", "$", "prop", "]", "=", "(", "isset", "(", "$", "this", "->", "values", "[", "$", "prop", "]", ")", ")", "?", "$", "this", "->", "values", "[", "$", "prop", "]", ":", "''", ";", "}", "/* New values from passed $propvalues array */", "if", "(", "$", "propvalues", "!=", "null", "&&", "is_array", "(", "$", "propvalues", ")", ")", "{", "if", "(", "array_key_exists", "(", "'id'", ",", "$", "propvalues", ")", ")", "throw", "new", "Exception", "(", "'ORM.Model: `id` parameter cant be passed in poperties array.'", ")", ";", "foreach", "(", "$", "propvalues", "as", "$", "prop", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "$", "prop", "]", ")", ")", "$", "sourceprops", "[", "$", "prop", "]", "=", "$", "value", ";", "}", "}", "$", "sourceprops", "[", "'id'", "]", "=", "$", "this", "->", "id", ";", "if", "(", "$", "this", "->", "isNew", ")", "{", "/* New entity */", "$", "dbr", "->", "insert", "(", "static", "::", "$", "table", ",", "$", "sourceprops", ",", "__METHOD__", ")", ";", "$", "insertId", "=", "$", "dbr", "->", "insertId", "(", ")", ";", "}", "else", "{", "/* Check id, just for sure */", "if", "(", "!", "is_numeric", "(", "$", "this", "->", "id", ")", ")", "throw", "new", "Exception", "(", "'WikivoteVoting: There is no `id` field on exesting entity update. Fatal error.'", ")", ";", "/* Update existing entity */", "$", "dbr", "->", "update", "(", "static", "::", "$", "table", ",", "$", "sourceprops", ",", "array", "(", "'id'", "=>", "$", "this", "->", "id", ")", ",", "__METHOD__", ")", ";", "$", "insertId", "=", "$", "this", "->", "id", ";", "}", "$", "dbr", "->", "commit", "(", ")", ";", "return", "$", "insertId", ";", "}" ]
Save entity instance in database. @param null $propvalues @param bool $reserved @return int @throws Exception
[ "Save", "entity", "instance", "in", "database", "." ]
f4549e17ada74d7123393f9dbd7b3d417b921ad1
https://github.com/vedmaka/Mediawiki-Model/blob/f4549e17ada74d7123393f9dbd7b3d417b921ad1/Model.class.php#L180-L236
3,068
vedmaka/Mediawiki-Model
Model.class.php
Model.find
public static function find( $where = 'all', $options = array() ) { $dbr = wfGetDB( DB_SLAVE ); if ( !is_array( $where ) && $where == 'all' ) { /* Fetch all entities */ $collection = $dbr->select( static::$table, 'id', array(), __METHOD__, $options ); } else { /* Fetch conditional entities */ $collection = $dbr->select( static::$table, 'id', $where, __METHOD__, $options ); } /* Check result */ if ( !$collection ) return array(); /* Generate array of entities for return */ $entities = array(); foreach ( $collection as $row ) { /* Create entity */ $modelClass = get_called_class(); $entity = new $modelClass($row->id); $entities[] = $entity; } if ( !count( $entities ) ) return array(); return $entities; }
php
public static function find( $where = 'all', $options = array() ) { $dbr = wfGetDB( DB_SLAVE ); if ( !is_array( $where ) && $where == 'all' ) { /* Fetch all entities */ $collection = $dbr->select( static::$table, 'id', array(), __METHOD__, $options ); } else { /* Fetch conditional entities */ $collection = $dbr->select( static::$table, 'id', $where, __METHOD__, $options ); } /* Check result */ if ( !$collection ) return array(); /* Generate array of entities for return */ $entities = array(); foreach ( $collection as $row ) { /* Create entity */ $modelClass = get_called_class(); $entity = new $modelClass($row->id); $entities[] = $entity; } if ( !count( $entities ) ) return array(); return $entities; }
[ "public", "static", "function", "find", "(", "$", "where", "=", "'all'", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "dbr", "=", "wfGetDB", "(", "DB_SLAVE", ")", ";", "if", "(", "!", "is_array", "(", "$", "where", ")", "&&", "$", "where", "==", "'all'", ")", "{", "/* Fetch all entities */", "$", "collection", "=", "$", "dbr", "->", "select", "(", "static", "::", "$", "table", ",", "'id'", ",", "array", "(", ")", ",", "__METHOD__", ",", "$", "options", ")", ";", "}", "else", "{", "/* Fetch conditional entities */", "$", "collection", "=", "$", "dbr", "->", "select", "(", "static", "::", "$", "table", ",", "'id'", ",", "$", "where", ",", "__METHOD__", ",", "$", "options", ")", ";", "}", "/* Check result */", "if", "(", "!", "$", "collection", ")", "return", "array", "(", ")", ";", "/* Generate array of entities for return */", "$", "entities", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "row", ")", "{", "/* Create entity */", "$", "modelClass", "=", "get_called_class", "(", ")", ";", "$", "entity", "=", "new", "$", "modelClass", "(", "$", "row", "->", "id", ")", ";", "$", "entities", "[", "]", "=", "$", "entity", ";", "}", "if", "(", "!", "count", "(", "$", "entities", ")", ")", "return", "array", "(", ")", ";", "return", "$", "entities", ";", "}" ]
Fetch collection of entities @param string|array $options
[ "Fetch", "collection", "of", "entities" ]
f4549e17ada74d7123393f9dbd7b3d417b921ad1
https://github.com/vedmaka/Mediawiki-Model/blob/f4549e17ada74d7123393f9dbd7b3d417b921ad1/Model.class.php#L258-L304
3,069
vedmaka/Mediawiki-Model
Model.class.php
Model.validate
public function validate( $req = array(), $input = null ) { global $wgRequest; if ( !is_array( $req ) ) $req = array( $req ); if ( $input == null ) { $input = $wgRequest->getValues(); } /* Fix: mediawiki pass `title` param and override POST `title` param. fix it */ if ( isset($_POST['title']) ) { $input['title'] = htmlspecialchars( $_POST['title'] ); } foreach ( $input as $param => $value ) { #if (is_array($value) && !method_exists($this,'_set'.$param)) continue; if ( array_key_exists( $param, $this->properties ) ) { /* Validation rules * TODO: make them work */ switch ( $this->properties[$param] ) { case 'int': //if (!is_integer($value)) return false; break; case 'string': //if (!is_string($value)) return false; break; } /* Required */ if ( (empty($value) || $value == '') && array_key_exists( $param, $req ) ) return false; $this->$param = $value; } } return true; }
php
public function validate( $req = array(), $input = null ) { global $wgRequest; if ( !is_array( $req ) ) $req = array( $req ); if ( $input == null ) { $input = $wgRequest->getValues(); } /* Fix: mediawiki pass `title` param and override POST `title` param. fix it */ if ( isset($_POST['title']) ) { $input['title'] = htmlspecialchars( $_POST['title'] ); } foreach ( $input as $param => $value ) { #if (is_array($value) && !method_exists($this,'_set'.$param)) continue; if ( array_key_exists( $param, $this->properties ) ) { /* Validation rules * TODO: make them work */ switch ( $this->properties[$param] ) { case 'int': //if (!is_integer($value)) return false; break; case 'string': //if (!is_string($value)) return false; break; } /* Required */ if ( (empty($value) || $value == '') && array_key_exists( $param, $req ) ) return false; $this->$param = $value; } } return true; }
[ "public", "function", "validate", "(", "$", "req", "=", "array", "(", ")", ",", "$", "input", "=", "null", ")", "{", "global", "$", "wgRequest", ";", "if", "(", "!", "is_array", "(", "$", "req", ")", ")", "$", "req", "=", "array", "(", "$", "req", ")", ";", "if", "(", "$", "input", "==", "null", ")", "{", "$", "input", "=", "$", "wgRequest", "->", "getValues", "(", ")", ";", "}", "/* Fix: mediawiki pass `title` param and override POST `title` param. fix it */", "if", "(", "isset", "(", "$", "_POST", "[", "'title'", "]", ")", ")", "{", "$", "input", "[", "'title'", "]", "=", "htmlspecialchars", "(", "$", "_POST", "[", "'title'", "]", ")", ";", "}", "foreach", "(", "$", "input", "as", "$", "param", "=>", "$", "value", ")", "{", "#if (is_array($value) && !method_exists($this,'_set'.$param)) continue;", "if", "(", "array_key_exists", "(", "$", "param", ",", "$", "this", "->", "properties", ")", ")", "{", "/* Validation rules\n\t\t\t\t* TODO: make them work\n\t\t\t\t*/", "switch", "(", "$", "this", "->", "properties", "[", "$", "param", "]", ")", "{", "case", "'int'", ":", "//if (!is_integer($value)) return false;", "break", ";", "case", "'string'", ":", "//if (!is_string($value)) return false;", "break", ";", "}", "/* Required */", "if", "(", "(", "empty", "(", "$", "value", ")", "||", "$", "value", "==", "''", ")", "&&", "array_key_exists", "(", "$", "param", ",", "$", "req", ")", ")", "return", "false", ";", "$", "this", "->", "$", "param", "=", "$", "value", ";", "}", "}", "return", "true", ";", "}" ]
Invalidates model from request @param null $input
[ "Invalidates", "model", "from", "request" ]
f4549e17ada74d7123393f9dbd7b3d417b921ad1
https://github.com/vedmaka/Mediawiki-Model/blob/f4549e17ada74d7123393f9dbd7b3d417b921ad1/Model.class.php#L388-L436
3,070
rezzza/jobflow
src/Rezzza/Jobflow/Extension/BaseExtension.php
BaseExtension.initTransports
private function initTransports() { $this->transports = array(); foreach ($this->loadTransports() as $transport) { if (!$transport instanceof TransportInterface) { throw new \InvalidArgumentException(sprintf('Transport %s should implements TransportInterface', get_class($transport))); } $this->transports[$transport->getName()] = $transport; } }
php
private function initTransports() { $this->transports = array(); foreach ($this->loadTransports() as $transport) { if (!$transport instanceof TransportInterface) { throw new \InvalidArgumentException(sprintf('Transport %s should implements TransportInterface', get_class($transport))); } $this->transports[$transport->getName()] = $transport; } }
[ "private", "function", "initTransports", "(", ")", "{", "$", "this", "->", "transports", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "loadTransports", "(", ")", "as", "$", "transport", ")", "{", "if", "(", "!", "$", "transport", "instanceof", "TransportInterface", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Transport %s should implements TransportInterface'", ",", "get_class", "(", "$", "transport", ")", ")", ")", ";", "}", "$", "this", "->", "transports", "[", "$", "transport", "->", "getName", "(", ")", "]", "=", "$", "transport", ";", "}", "}" ]
Initializes the transports.
[ "Initializes", "the", "transports", "." ]
80ded8ac6ed6a2f4500b8f86e2958701ec84fd65
https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/Extension/BaseExtension.php#L162-L173
3,071
osflab/view
OsfView.php
OsfView.mergeValues
protected function mergeValues(array $values, $merge = true) { $this->values = $merge ? array_merge($this->values, $values) : $values; return $this; }
php
protected function mergeValues(array $values, $merge = true) { $this->values = $merge ? array_merge($this->values, $values) : $values; return $this; }
[ "protected", "function", "mergeValues", "(", "array", "$", "values", ",", "$", "merge", "=", "true", ")", "{", "$", "this", "->", "values", "=", "$", "merge", "?", "array_merge", "(", "$", "this", "->", "values", ",", "$", "values", ")", ":", "$", "values", ";", "return", "$", "this", ";", "}" ]
Add values to view @param array $values @param bool $merge @return $this
[ "Add", "values", "to", "view" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/OsfView.php#L88-L92
3,072
axypro/cli-bin
Task.php
Task.error
final protected function error($message, $status = null, $nl = true) { $this->io->error($message, $status, $nl); }
php
final protected function error($message, $status = null, $nl = true) { $this->io->error($message, $status, $nl); }
[ "final", "protected", "function", "error", "(", "$", "message", ",", "$", "status", "=", "null", ",", "$", "nl", "=", "true", ")", "{", "$", "this", "->", "io", "->", "error", "(", "$", "message", ",", "$", "status", ",", "$", "nl", ")", ";", "}" ]
Write to STDERR @param string $message @param int $status [optional] @param bool $nl [optional]
[ "Write", "to", "STDERR" ]
b2212f137ff3bb313fdafc3dfaa6783302d89326
https://github.com/axypro/cli-bin/blob/b2212f137ff3bb313fdafc3dfaa6783302d89326/Task.php#L113-L116
3,073
axypro/cli-bin
Task.php
Task.silentRead
final protected function silentRead($prompt = null, $nl = null) { if ($prompt !== null) { $this->io->write($prompt, false); } return $this->io->silentReadLine($nl); }
php
final protected function silentRead($prompt = null, $nl = null) { if ($prompt !== null) { $this->io->write($prompt, false); } return $this->io->silentReadLine($nl); }
[ "final", "protected", "function", "silentRead", "(", "$", "prompt", "=", "null", ",", "$", "nl", "=", "null", ")", "{", "if", "(", "$", "prompt", "!==", "null", ")", "{", "$", "this", "->", "io", "->", "write", "(", "$", "prompt", ",", "false", ")", ";", "}", "return", "$", "this", "->", "io", "->", "silentReadLine", "(", "$", "nl", ")", ";", "}" ]
Silent read from STDIN @param string $prompt [optional] @param bool $nl [optional] @return string
[ "Silent", "read", "from", "STDIN" ]
b2212f137ff3bb313fdafc3dfaa6783302d89326
https://github.com/axypro/cli-bin/blob/b2212f137ff3bb313fdafc3dfaa6783302d89326/Task.php#L125-L131
3,074
novuso/common
src/Domain/Messaging/Query/QueryMessage.php
QueryMessage.create
public static function create(Query $query): QueryMessage { $timestamp = DateTime::now(); $id = MessageId::generate(); $metaData = MetaData::create(); return new static($id, $timestamp, $query, $metaData); }
php
public static function create(Query $query): QueryMessage { $timestamp = DateTime::now(); $id = MessageId::generate(); $metaData = MetaData::create(); return new static($id, $timestamp, $query, $metaData); }
[ "public", "static", "function", "create", "(", "Query", "$", "query", ")", ":", "QueryMessage", "{", "$", "timestamp", "=", "DateTime", "::", "now", "(", ")", ";", "$", "id", "=", "MessageId", "::", "generate", "(", ")", ";", "$", "metaData", "=", "MetaData", "::", "create", "(", ")", ";", "return", "new", "static", "(", "$", "id", ",", "$", "timestamp", ",", "$", "query", ",", "$", "metaData", ")", ";", "}" ]
Creates instance for a query @param Query $query The query @return QueryMessage
[ "Creates", "instance", "for", "a", "query" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Messaging/Query/QueryMessage.php#L44-L51
3,075
inceddy/ieu_http
src/ieu/Http/Router.php
Router.middleware
public function middleware(...$middlewares) { foreach ($middlewares as $middleware) { $this->currentContext->addMiddleware($middleware); } return $this; }
php
public function middleware(...$middlewares) { foreach ($middlewares as $middleware) { $this->currentContext->addMiddleware($middleware); } return $this; }
[ "public", "function", "middleware", "(", "...", "$", "middlewares", ")", "{", "foreach", "(", "$", "middlewares", "as", "$", "middleware", ")", "{", "$", "this", "->", "currentContext", "->", "addMiddleware", "(", "$", "middleware", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds middleware to the current context @param array $middlewares The middlewares to ad @return self
[ "Adds", "middleware", "to", "the", "current", "context" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Router.php#L86-L93
3,076
inceddy/ieu_http
src/ieu/Http/Router.php
Router.request
public function request(string $path, int $methods, $handler) { $path = $this->currentContext->getPrefixedPath( trim($path, "\n\r\t/ ") ); return $this->route(new Route($path, $methods), $handler); }
php
public function request(string $path, int $methods, $handler) { $path = $this->currentContext->getPrefixedPath( trim($path, "\n\r\t/ ") ); return $this->route(new Route($path, $methods), $handler); }
[ "public", "function", "request", "(", "string", "$", "path", ",", "int", "$", "methods", ",", "$", "handler", ")", "{", "$", "path", "=", "$", "this", "->", "currentContext", "->", "getPrefixedPath", "(", "trim", "(", "$", "path", ",", "\"\\n\\r\\t/ \"", ")", ")", ";", "return", "$", "this", "->", "route", "(", "new", "Route", "(", "$", "path", ",", "$", "methods", ")", ",", "$", "handler", ")", ";", "}" ]
Adds a new route with given path to the current context that accepts the given methods requests. @param string $path The route path @param int $methods The accepted route methods @param callable $handler The route handler @return self
[ "Adds", "a", "new", "route", "with", "given", "path", "to", "the", "current", "context", "that", "accepts", "the", "given", "methods", "requests", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Router.php#L131-L138
3,077
inceddy/ieu_http
src/ieu/Http/Router.php
Router.resultToResponse
private function resultToResponse($result) : Response { switch (true) { // Response object case $result instanceof Response: return $result; // String -> transform to response case is_string($result) || is_numeric($result): return new Response($result); // Array -> transform to json response case is_array($result) || is_object($result): return new JsonResponse($result); default: throw new Exception('Invalid route handler return value'); } }
php
private function resultToResponse($result) : Response { switch (true) { // Response object case $result instanceof Response: return $result; // String -> transform to response case is_string($result) || is_numeric($result): return new Response($result); // Array -> transform to json response case is_array($result) || is_object($result): return new JsonResponse($result); default: throw new Exception('Invalid route handler return value'); } }
[ "private", "function", "resultToResponse", "(", "$", "result", ")", ":", "Response", "{", "switch", "(", "true", ")", "{", "// Response object\r", "case", "$", "result", "instanceof", "Response", ":", "return", "$", "result", ";", "// String -> transform to response\r", "case", "is_string", "(", "$", "result", ")", "||", "is_numeric", "(", "$", "result", ")", ":", "return", "new", "Response", "(", "$", "result", ")", ";", "// Array -> transform to json response\r", "case", "is_array", "(", "$", "result", ")", "||", "is_object", "(", "$", "result", ")", ":", "return", "new", "JsonResponse", "(", "$", "result", ")", ";", "default", ":", "throw", "new", "Exception", "(", "'Invalid route handler return value'", ")", ";", "}", "}" ]
Transforms any skalar handler result to a ieu\Http\Response object @param mixed $result The handler result to be transformed @return ieu\Http\Response The response
[ "Transforms", "any", "skalar", "handler", "result", "to", "a", "ieu", "\\", "Http", "\\", "Response", "object" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Router.php#L309-L324
3,078
gplcart/xss
Main.php
Main.hookFilter
public function hookFilter($text, $filter, &$filtered) { if (!isset($filtered) && (!isset($filter['filter_id']) || $filter['filter_id'] === 'xss')) { $filtered = $this->filter($text); } }
php
public function hookFilter($text, $filter, &$filtered) { if (!isset($filtered) && (!isset($filter['filter_id']) || $filter['filter_id'] === 'xss')) { $filtered = $this->filter($text); } }
[ "public", "function", "hookFilter", "(", "$", "text", ",", "$", "filter", ",", "&", "$", "filtered", ")", "{", "if", "(", "!", "isset", "(", "$", "filtered", ")", "&&", "(", "!", "isset", "(", "$", "filter", "[", "'filter_id'", "]", ")", "||", "$", "filter", "[", "'filter_id'", "]", "===", "'xss'", ")", ")", "{", "$", "filtered", "=", "$", "this", "->", "filter", "(", "$", "text", ")", ";", "}", "}" ]
Implements hook "filter" @param string $text @param array $filter @param null|string $filtered
[ "Implements", "hook", "filter" ]
85c98028b28da188a0a4e415df32b0c3e3761524
https://github.com/gplcart/xss/blob/85c98028b28da188a0a4e415df32b0c3e3761524/Main.php#L64-L69
3,079
hnhdigital-os/laravel-navigation-builder
src/Navigation.php
Navigation.has
public function has($key) { $menu = $this->getMenu($key); return !is_null($menu) && $menu->count() > 0; }
php
public function has($key) { $menu = $this->getMenu($key); return !is_null($menu) && $menu->count() > 0; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "menu", "=", "$", "this", "->", "getMenu", "(", "$", "key", ")", ";", "return", "!", "is_null", "(", "$", "menu", ")", "&&", "$", "menu", "->", "count", "(", ")", ">", "0", ";", "}" ]
Check if there are navigation items. @param string $key @return Menu
[ "Check", "if", "there", "are", "navigation", "items", "." ]
37c3868a18b6cbb582a58800dbda64963828994b
https://github.com/hnhdigital-os/laravel-navigation-builder/blob/37c3868a18b6cbb582a58800dbda64963828994b/src/Navigation.php#L177-L182
3,080
rodrigopedra/record-processor
src/RecordProcessor/Helpers/Excel/CellWriter.php
CellWriter.setUrl
public function setUrl( $url ) { // Only set cell value for single cells if (!str_contains( $this->cells, ':' )) { $this->sheet->getCell( $this->cells )->getHyperlink()->setUrl( $url ); } return $this; }
php
public function setUrl( $url ) { // Only set cell value for single cells if (!str_contains( $this->cells, ':' )) { $this->sheet->getCell( $this->cells )->getHyperlink()->setUrl( $url ); } return $this; }
[ "public", "function", "setUrl", "(", "$", "url", ")", "{", "// Only set cell value for single cells", "if", "(", "!", "str_contains", "(", "$", "this", "->", "cells", ",", "':'", ")", ")", "{", "$", "this", "->", "sheet", "->", "getCell", "(", "$", "this", "->", "cells", ")", "->", "getHyperlink", "(", ")", "->", "setUrl", "(", "$", "url", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set cell url @param [type] $url @return CellWriter @throws \PhpOffice\PhpSpreadsheet\Exception
[ "Set", "cell", "url" ]
612f06602e701b2cd00d8aa6e662ca6ede345b9a
https://github.com/rodrigopedra/record-processor/blob/612f06602e701b2cd00d8aa6e662ca6ede345b9a/src/RecordProcessor/Helpers/Excel/CellWriter.php#L71-L79
3,081
rodrigopedra/record-processor
src/RecordProcessor/Helpers/Excel/CellWriter.php
CellWriter.setColorStyle
protected function setColorStyle( $styleType, $color, $type = false, $colorType = 'rgb' ) { // Set the styles $styles = is_array( $color ) ? $color : [ 'type' => $type, 'color' => [ $colorType => str_replace( '#', '', $color ) ], ]; return $this->setStyle( $styleType, $styles ); }
php
protected function setColorStyle( $styleType, $color, $type = false, $colorType = 'rgb' ) { // Set the styles $styles = is_array( $color ) ? $color : [ 'type' => $type, 'color' => [ $colorType => str_replace( '#', '', $color ) ], ]; return $this->setStyle( $styleType, $styles ); }
[ "protected", "function", "setColorStyle", "(", "$", "styleType", ",", "$", "color", ",", "$", "type", "=", "false", ",", "$", "colorType", "=", "'rgb'", ")", "{", "// Set the styles", "$", "styles", "=", "is_array", "(", "$", "color", ")", "?", "$", "color", ":", "[", "'type'", "=>", "$", "type", ",", "'color'", "=>", "[", "$", "colorType", "=>", "str_replace", "(", "'#'", ",", "''", ",", "$", "color", ")", "]", ",", "]", ";", "return", "$", "this", "->", "setStyle", "(", "$", "styleType", ",", "$", "styles", ")", ";", "}" ]
Set the color style @param $styleType @param string $color @param boolean $type @param string $colorType @return CellWriter @throws \PhpOffice\PhpSpreadsheet\Exception
[ "Set", "the", "color", "style" ]
612f06602e701b2cd00d8aa6e662ca6ede345b9a
https://github.com/rodrigopedra/record-processor/blob/612f06602e701b2cd00d8aa6e662ca6ede345b9a/src/RecordProcessor/Helpers/Excel/CellWriter.php#L273-L284
3,082
iMoneza/imoneza-php-api
src/iMoneza/Data/DataAbstract.php
DataAbstract.populate
public function populate(array $values = []) { foreach ($values as $key => $value) { $methodName = "set{$key}"; if (method_exists($this, $methodName)) { if (in_array($key, $this->dateTimeKeys)) { $value = new \DateTime($value, new \DateTimeZone('UTC')); } elseif (in_array($key, $this->classKeys) && !is_null($value)) { $populateValue = $value; $className = sprintf('%s\%s', __NAMESPACE__, $key); /** @var self $value */ $value = new $className(); $value->populate($populateValue); } elseif (array_key_exists($key, $this->arrayClassKeys)) { $arrayValues = $value; $value = []; $className = sprintf('%s\%s', __NAMESPACE__, $this->arrayClassKeys[$key]); foreach ($arrayValues as $v) { /** @var self $class */ $class = new $className(); $class->populate($v); $value[] = $class; } } $this->$methodName($value); } } return $this; }
php
public function populate(array $values = []) { foreach ($values as $key => $value) { $methodName = "set{$key}"; if (method_exists($this, $methodName)) { if (in_array($key, $this->dateTimeKeys)) { $value = new \DateTime($value, new \DateTimeZone('UTC')); } elseif (in_array($key, $this->classKeys) && !is_null($value)) { $populateValue = $value; $className = sprintf('%s\%s', __NAMESPACE__, $key); /** @var self $value */ $value = new $className(); $value->populate($populateValue); } elseif (array_key_exists($key, $this->arrayClassKeys)) { $arrayValues = $value; $value = []; $className = sprintf('%s\%s', __NAMESPACE__, $this->arrayClassKeys[$key]); foreach ($arrayValues as $v) { /** @var self $class */ $class = new $className(); $class->populate($v); $value[] = $class; } } $this->$methodName($value); } } return $this; }
[ "public", "function", "populate", "(", "array", "$", "values", "=", "[", "]", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "methodName", "=", "\"set{$key}\"", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "methodName", ")", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "dateTimeKeys", ")", ")", "{", "$", "value", "=", "new", "\\", "DateTime", "(", "$", "value", ",", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "}", "elseif", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "classKeys", ")", "&&", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "populateValue", "=", "$", "value", ";", "$", "className", "=", "sprintf", "(", "'%s\\%s'", ",", "__NAMESPACE__", ",", "$", "key", ")", ";", "/** @var self $value */", "$", "value", "=", "new", "$", "className", "(", ")", ";", "$", "value", "->", "populate", "(", "$", "populateValue", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "arrayClassKeys", ")", ")", "{", "$", "arrayValues", "=", "$", "value", ";", "$", "value", "=", "[", "]", ";", "$", "className", "=", "sprintf", "(", "'%s\\%s'", ",", "__NAMESPACE__", ",", "$", "this", "->", "arrayClassKeys", "[", "$", "key", "]", ")", ";", "foreach", "(", "$", "arrayValues", "as", "$", "v", ")", "{", "/** @var self $class */", "$", "class", "=", "new", "$", "className", "(", ")", ";", "$", "class", "->", "populate", "(", "$", "v", ")", ";", "$", "value", "[", "]", "=", "$", "class", ";", "}", "}", "$", "this", "->", "$", "methodName", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Populate the class @param array $values @return $this
[ "Populate", "the", "class" ]
8347702c88c3cf754d21631a304a2c2d3abac98e
https://github.com/iMoneza/imoneza-php-api/blob/8347702c88c3cf754d21631a304a2c2d3abac98e/src/iMoneza/Data/DataAbstract.php#L36-L67
3,083
face-orm/face
lib/Face/Util/StringUtils.php
StringUtils.subStringBeforeLast
public static function subStringBeforeLast($haystack, $needle, $n = 1) { while ($n>0) { $haystack = substr($haystack, 0, strrpos($haystack, $needle)); $n--; } return $haystack; }
php
public static function subStringBeforeLast($haystack, $needle, $n = 1) { while ($n>0) { $haystack = substr($haystack, 0, strrpos($haystack, $needle)); $n--; } return $haystack; }
[ "public", "static", "function", "subStringBeforeLast", "(", "$", "haystack", ",", "$", "needle", ",", "$", "n", "=", "1", ")", "{", "while", "(", "$", "n", ">", "0", ")", "{", "$", "haystack", "=", "substr", "(", "$", "haystack", ",", "0", ",", "strrpos", "(", "$", "haystack", ",", "$", "needle", ")", ")", ";", "$", "n", "--", ";", "}", "return", "$", "haystack", ";", "}" ]
Get the substring before the last occurence of a character @param $haystack @param $needle @param int $n @return string
[ "Get", "the", "substring", "before", "the", "last", "occurence", "of", "a", "character" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Util/StringUtils.php#L20-L27
3,084
face-orm/face
lib/Face/Util/StringUtils.php
StringUtils.subStringAfterLast
public static function subStringAfterLast($haystack, $needle, $n = 1) { $string = ""; while ($n>0) { $string .= substr($haystack, strrpos($haystack, $needle) + 1); if($n>1){ $string = $needle . $string; } $n--; } return $string; }
php
public static function subStringAfterLast($haystack, $needle, $n = 1) { $string = ""; while ($n>0) { $string .= substr($haystack, strrpos($haystack, $needle) + 1); if($n>1){ $string = $needle . $string; } $n--; } return $string; }
[ "public", "static", "function", "subStringAfterLast", "(", "$", "haystack", ",", "$", "needle", ",", "$", "n", "=", "1", ")", "{", "$", "string", "=", "\"\"", ";", "while", "(", "$", "n", ">", "0", ")", "{", "$", "string", ".=", "substr", "(", "$", "haystack", ",", "strrpos", "(", "$", "haystack", ",", "$", "needle", ")", "+", "1", ")", ";", "if", "(", "$", "n", ">", "1", ")", "{", "$", "string", "=", "$", "needle", ".", "$", "string", ";", "}", "$", "n", "--", ";", "}", "return", "$", "string", ";", "}" ]
Get the substring after the last occurrence of a character @param $haystack @param $needle @param int $n @return string TODO : tests suit
[ "Get", "the", "substring", "after", "the", "last", "occurrence", "of", "a", "character" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Util/StringUtils.php#L37-L48
3,085
Dhii/container-helper-base
src/ContainerUnsetCapableTrait.php
ContainerUnsetCapableTrait._containerUnset
protected function _containerUnset(&$container, $key) { $origKey = $key; $key = $this->_normalizeKey($key); if (is_array($container)) { if (!isset($container[$key])) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } unset($container[$key]); return; } if ($container instanceof stdClass) { if (!isset($container->{$key})) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } unset($container->{$key}); return; } if ($container instanceof ArrayAccess) { try { $hasKey = $container->offsetExists($key); } catch (RootException $e) { throw $this->_createContainerException($this->__('Could not check key "%1$s" on container', [$key]), null, $e, null); } if (!$hasKey) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } try { $container->offsetUnset($key); return; } catch (RootException $e) { throw $this->_createContainerException($this->__('Could not unset key "%1$s" on container', [$key]), null, $e, null); } } throw $this->_createInvalidArgumentException($this->__('Invalid container'), null, null, $container); }
php
protected function _containerUnset(&$container, $key) { $origKey = $key; $key = $this->_normalizeKey($key); if (is_array($container)) { if (!isset($container[$key])) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } unset($container[$key]); return; } if ($container instanceof stdClass) { if (!isset($container->{$key})) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } unset($container->{$key}); return; } if ($container instanceof ArrayAccess) { try { $hasKey = $container->offsetExists($key); } catch (RootException $e) { throw $this->_createContainerException($this->__('Could not check key "%1$s" on container', [$key]), null, $e, null); } if (!$hasKey) { throw $this->_createNotFoundException($this->__('Key "%1$s" not found', [$key]), null, null, null, $key); } try { $container->offsetUnset($key); return; } catch (RootException $e) { throw $this->_createContainerException($this->__('Could not unset key "%1$s" on container', [$key]), null, $e, null); } } throw $this->_createInvalidArgumentException($this->__('Invalid container'), null, null, $container); }
[ "protected", "function", "_containerUnset", "(", "&", "$", "container", ",", "$", "key", ")", "{", "$", "origKey", "=", "$", "key", ";", "$", "key", "=", "$", "this", "->", "_normalizeKey", "(", "$", "key", ")", ";", "if", "(", "is_array", "(", "$", "container", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "container", "[", "$", "key", "]", ")", ")", "{", "throw", "$", "this", "->", "_createNotFoundException", "(", "$", "this", "->", "__", "(", "'Key \"%1$s\" not found'", ",", "[", "$", "key", "]", ")", ",", "null", ",", "null", ",", "null", ",", "$", "key", ")", ";", "}", "unset", "(", "$", "container", "[", "$", "key", "]", ")", ";", "return", ";", "}", "if", "(", "$", "container", "instanceof", "stdClass", ")", "{", "if", "(", "!", "isset", "(", "$", "container", "->", "{", "$", "key", "}", ")", ")", "{", "throw", "$", "this", "->", "_createNotFoundException", "(", "$", "this", "->", "__", "(", "'Key \"%1$s\" not found'", ",", "[", "$", "key", "]", ")", ",", "null", ",", "null", ",", "null", ",", "$", "key", ")", ";", "}", "unset", "(", "$", "container", "->", "{", "$", "key", "}", ")", ";", "return", ";", "}", "if", "(", "$", "container", "instanceof", "ArrayAccess", ")", "{", "try", "{", "$", "hasKey", "=", "$", "container", "->", "offsetExists", "(", "$", "key", ")", ";", "}", "catch", "(", "RootException", "$", "e", ")", "{", "throw", "$", "this", "->", "_createContainerException", "(", "$", "this", "->", "__", "(", "'Could not check key \"%1$s\" on container'", ",", "[", "$", "key", "]", ")", ",", "null", ",", "$", "e", ",", "null", ")", ";", "}", "if", "(", "!", "$", "hasKey", ")", "{", "throw", "$", "this", "->", "_createNotFoundException", "(", "$", "this", "->", "__", "(", "'Key \"%1$s\" not found'", ",", "[", "$", "key", "]", ")", ",", "null", ",", "null", ",", "null", ",", "$", "key", ")", ";", "}", "try", "{", "$", "container", "->", "offsetUnset", "(", "$", "key", ")", ";", "return", ";", "}", "catch", "(", "RootException", "$", "e", ")", "{", "throw", "$", "this", "->", "_createContainerException", "(", "$", "this", "->", "__", "(", "'Could not unset key \"%1$s\" on container'", ",", "[", "$", "key", "]", ")", ",", "null", ",", "$", "e", ",", "null", ")", ";", "}", "}", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Invalid container'", ")", ",", "null", ",", "null", ",", "$", "container", ")", ";", "}" ]
Unsets a value with the specified key on the given container. @since [*next-version*] @param array|ArrayAccess|stdClass $container The writable container to unset the value on. @param string|int|float|bool|Stringable $key The key to unset the value for. @throws InvalidArgumentException If the container is invalid. @throws OutOfRangeException If the key is invalid. @throws NotFoundExceptionInterface If the key is not found. @throws ContainerExceptionInterface If problem accessing the container.
[ "Unsets", "a", "value", "with", "the", "specified", "key", "on", "the", "given", "container", "." ]
ccb2f56971d70cf203baa596cd14fdf91be6bfae
https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerUnsetCapableTrait.php#L35-L81
3,086
soloproyectos-php/sys-file
src/sys/file/SysFile.php
SysFile.concat
public static function concat($file/*, ...*/) { $args = array(); $len = func_num_args(); for ($i = 0; $i < $len; $i++) { $value = func_get_arg($i); $values = is_array($value)? array_values($value) : array($value); $args = array_merge($args, $values); } return rtrim(preg_replace("/\/+/", "/", Text::concat("/", $args)), "/"); }
php
public static function concat($file/*, ...*/) { $args = array(); $len = func_num_args(); for ($i = 0; $i < $len; $i++) { $value = func_get_arg($i); $values = is_array($value)? array_values($value) : array($value); $args = array_merge($args, $values); } return rtrim(preg_replace("/\/+/", "/", Text::concat("/", $args)), "/"); }
[ "public", "static", "function", "concat", "(", "$", "file", "/*, ...*/", ")", "{", "$", "args", "=", "array", "(", ")", ";", "$", "len", "=", "func_num_args", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "value", "=", "func_get_arg", "(", "$", "i", ")", ";", "$", "values", "=", "is_array", "(", "$", "value", ")", "?", "array_values", "(", "$", "value", ")", ":", "array", "(", "$", "value", ")", ";", "$", "args", "=", "array_merge", "(", "$", "args", ",", "$", "values", ")", ";", "}", "return", "rtrim", "(", "preg_replace", "(", "\"/\\/+/\"", ",", "\"/\"", ",", "Text", "::", "concat", "(", "\"/\"", ",", "$", "args", ")", ")", ",", "\"/\"", ")", ";", "}" ]
Concatenates filenames. This function concatenates several filenames into a new one. For example: ```php // the next command prints "dir1/dir2/test.txt" echo SysFile::concat("dir1", "/dir2", "test.txt"); ``` @param string $file One or more files @return string
[ "Concatenates", "filenames", "." ]
706e9ba0dbeda201d58a6fa9ee53d73256cf729f
https://github.com/soloproyectos-php/sys-file/blob/706e9ba0dbeda201d58a6fa9ee53d73256cf729f/src/sys/file/SysFile.php#L41-L53
3,087
soloproyectos-php/sys-file
src/sys/file/SysFile.php
SysFile.getHumanSize
public static function getHumanSize($size, $precision = 1) { $units = array(" bytes", "K", "M", "G", "T", "P", "E", "Z", "Y"); $pow = 1024; $factor = 0; while ($size + 1 > $pow) { $size /= $pow; $factor++; } return round($size, $precision) . $units[$factor]; }
php
public static function getHumanSize($size, $precision = 1) { $units = array(" bytes", "K", "M", "G", "T", "P", "E", "Z", "Y"); $pow = 1024; $factor = 0; while ($size + 1 > $pow) { $size /= $pow; $factor++; } return round($size, $precision) . $units[$factor]; }
[ "public", "static", "function", "getHumanSize", "(", "$", "size", ",", "$", "precision", "=", "1", ")", "{", "$", "units", "=", "array", "(", "\" bytes\"", ",", "\"K\"", ",", "\"M\"", ",", "\"G\"", ",", "\"T\"", ",", "\"P\"", ",", "\"E\"", ",", "\"Z\"", ",", "\"Y\"", ")", ";", "$", "pow", "=", "1024", ";", "$", "factor", "=", "0", ";", "while", "(", "$", "size", "+", "1", ">", "$", "pow", ")", "{", "$", "size", "/=", "$", "pow", ";", "$", "factor", "++", ";", "}", "return", "round", "(", "$", "size", ",", "$", "precision", ")", ".", "$", "units", "[", "$", "factor", "]", ";", "}" ]
Gets a human readable size. This function gets an human readable size. For example: ```php // human readable sizes: echo SysFile::getHumanSize(13); // prints 13 bytes echo SysFile::getHumanSize(1024); // prints 1K echo SysFile::getHumanSize(4562154, 2); // prints 4.35M (2 digits) echo SysFile::getHumanSize(98543246875); // prints 91.8G ``` @param integer $size Size in bytes @param integer $precision Digit precision (default is 1) @return string
[ "Gets", "a", "human", "readable", "size", "." ]
706e9ba0dbeda201d58a6fa9ee53d73256cf729f
https://github.com/soloproyectos-php/sys-file/blob/706e9ba0dbeda201d58a6fa9ee53d73256cf729f/src/sys/file/SysFile.php#L74-L86
3,088
soloproyectos-php/sys-file
src/sys/file/SysFile.php
SysFile.getAvailName
public static function getAvailName($dir, $refname = "", $refext = "") { // fixes arguments $dir = trim($dir); $refname = trim($refname); $refext = ltrim(trim($refext), "."); if (!is_dir($dir)) { throw new SysException("Directory not found: $dir"); } // default refname if (Text::isEmpty($refname)) { $refname = "file"; } // gets name and extension $refname = basename($refname); $pos = strrpos($refname, "."); $name = $refname; $ext = $refext; if ($pos !== false) { $name = substr($refname, 0, $pos); if (Text::isEmpty($refext)) { $ext = substr($refname, $pos + 1); } } // gets an available name for ($i = 0; $i < 100; $i++) { $basename = $i > 0 ? Text::concat(".", $name . "_" . $i, $ext) : Text::concat(".", $name, $ext); $filename = SysFile::concat($dir, $basename); if (!is_file($filename)) { break; } } return $filename; }
php
public static function getAvailName($dir, $refname = "", $refext = "") { // fixes arguments $dir = trim($dir); $refname = trim($refname); $refext = ltrim(trim($refext), "."); if (!is_dir($dir)) { throw new SysException("Directory not found: $dir"); } // default refname if (Text::isEmpty($refname)) { $refname = "file"; } // gets name and extension $refname = basename($refname); $pos = strrpos($refname, "."); $name = $refname; $ext = $refext; if ($pos !== false) { $name = substr($refname, 0, $pos); if (Text::isEmpty($refext)) { $ext = substr($refname, $pos + 1); } } // gets an available name for ($i = 0; $i < 100; $i++) { $basename = $i > 0 ? Text::concat(".", $name . "_" . $i, $ext) : Text::concat(".", $name, $ext); $filename = SysFile::concat($dir, $basename); if (!is_file($filename)) { break; } } return $filename; }
[ "public", "static", "function", "getAvailName", "(", "$", "dir", ",", "$", "refname", "=", "\"\"", ",", "$", "refext", "=", "\"\"", ")", "{", "// fixes arguments", "$", "dir", "=", "trim", "(", "$", "dir", ")", ";", "$", "refname", "=", "trim", "(", "$", "refname", ")", ";", "$", "refext", "=", "ltrim", "(", "trim", "(", "$", "refext", ")", ",", "\".\"", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "throw", "new", "SysException", "(", "\"Directory not found: $dir\"", ")", ";", "}", "// default refname", "if", "(", "Text", "::", "isEmpty", "(", "$", "refname", ")", ")", "{", "$", "refname", "=", "\"file\"", ";", "}", "// gets name and extension", "$", "refname", "=", "basename", "(", "$", "refname", ")", ";", "$", "pos", "=", "strrpos", "(", "$", "refname", ",", "\".\"", ")", ";", "$", "name", "=", "$", "refname", ";", "$", "ext", "=", "$", "refext", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "$", "name", "=", "substr", "(", "$", "refname", ",", "0", ",", "$", "pos", ")", ";", "if", "(", "Text", "::", "isEmpty", "(", "$", "refext", ")", ")", "{", "$", "ext", "=", "substr", "(", "$", "refname", ",", "$", "pos", "+", "1", ")", ";", "}", "}", "// gets an available name", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "100", ";", "$", "i", "++", ")", "{", "$", "basename", "=", "$", "i", ">", "0", "?", "Text", "::", "concat", "(", "\".\"", ",", "$", "name", ".", "\"_\"", ".", "$", "i", ",", "$", "ext", ")", ":", "Text", "::", "concat", "(", "\".\"", ",", "$", "name", ",", "$", "ext", ")", ";", "$", "filename", "=", "SysFile", "::", "concat", "(", "$", "dir", ",", "$", "basename", ")", ";", "if", "(", "!", "is_file", "(", "$", "filename", ")", ")", "{", "break", ";", "}", "}", "return", "$", "filename", ";", "}" ]
Gets an available name under a given directory. This function returns an available name under a given directory. For example, if there's a file named 'test.txt' under de directory 'dir1', the following command returns 'test_1.txt': ```php // prints 'test_1.txt' if the name 'test.txt' is taken: echo SysFile::getAvailName('dir1', 'test1.txt'); ``` @param string $dir Directory @param string $refname Filename used as reference (default is "") @param string $refext Extension used as reference (default is "") @return string
[ "Gets", "an", "available", "name", "under", "a", "given", "directory", "." ]
706e9ba0dbeda201d58a6fa9ee53d73256cf729f
https://github.com/soloproyectos-php/sys-file/blob/706e9ba0dbeda201d58a6fa9ee53d73256cf729f/src/sys/file/SysFile.php#L106-L149
3,089
soloproyectos-php/sys-file
src/sys/file/SysFile.php
SysFile.getInfo
public static function getInfo($path) { $info = pathinfo($path); return array( "dirname" => Arr::get($info, "dirname", ""), "basename" => Arr::get($info, "basename", ""), "extension" => Arr::get($info, "extension", ""), "filename" => Arr::get($info, "filename", "") ); }
php
public static function getInfo($path) { $info = pathinfo($path); return array( "dirname" => Arr::get($info, "dirname", ""), "basename" => Arr::get($info, "basename", ""), "extension" => Arr::get($info, "extension", ""), "filename" => Arr::get($info, "filename", "") ); }
[ "public", "static", "function", "getInfo", "(", "$", "path", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "path", ")", ";", "return", "array", "(", "\"dirname\"", "=>", "Arr", "::", "get", "(", "$", "info", ",", "\"dirname\"", ",", "\"\"", ")", ",", "\"basename\"", "=>", "Arr", "::", "get", "(", "$", "info", ",", "\"basename\"", ",", "\"\"", ")", ",", "\"extension\"", "=>", "Arr", "::", "get", "(", "$", "info", ",", "\"extension\"", ",", "\"\"", ")", ",", "\"filename\"", "=>", "Arr", "::", "get", "(", "$", "info", ",", "\"filename\"", ",", "\"\"", ")", ")", ";", "}" ]
Gets the information of a file path. @param string $path File path @return string[]
[ "Gets", "the", "information", "of", "a", "file", "path", "." ]
706e9ba0dbeda201d58a6fa9ee53d73256cf729f
https://github.com/soloproyectos-php/sys-file/blob/706e9ba0dbeda201d58a6fa9ee53d73256cf729f/src/sys/file/SysFile.php#L158-L167
3,090
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.insertDeveloper
protected function insertDeveloper() { $data = $this->getPatchData(); $create = $data->get( 'gridguyz-core', 'developer', 'Do you want to create a developer user? (y/n)', 'n', array( 'y', 'n', 'yes', 'no', 't', 'f', 'true', 'false', '1', '0' ) ); if ( in_array( strtolower( $create ), array( 'n', 'no', 'f', 'false', '0', '' ) ) ) { return null; } $email = $data->get( 'gridguyz-core', 'developer-email', 'Type the developer\'s email (must be valid email)', null, '/^[A-Z0-9\._%\+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', 3 ); $displayName = $data->get( 'gridguyz-core', 'developer-displayName', 'Type the developer\'s display name', strstr( $email, '@', true ) ); $password = $data->get( 'gridguyz-core', 'developer-password', 'Type the developer\'s password', $this->createPasswordSalt( 6 ), true ); return $this->insertIntoTable( 'user', array( 'email' => $email, 'displayName' => $displayName, 'passwordHash' => $this->createPasswordHash( $password ), 'groupId' => static::DEVELOPER_GROUP, 'state' => 'active', 'confirmed' => 't', 'locale' => 'en', ), true ); }
php
protected function insertDeveloper() { $data = $this->getPatchData(); $create = $data->get( 'gridguyz-core', 'developer', 'Do you want to create a developer user? (y/n)', 'n', array( 'y', 'n', 'yes', 'no', 't', 'f', 'true', 'false', '1', '0' ) ); if ( in_array( strtolower( $create ), array( 'n', 'no', 'f', 'false', '0', '' ) ) ) { return null; } $email = $data->get( 'gridguyz-core', 'developer-email', 'Type the developer\'s email (must be valid email)', null, '/^[A-Z0-9\._%\+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', 3 ); $displayName = $data->get( 'gridguyz-core', 'developer-displayName', 'Type the developer\'s display name', strstr( $email, '@', true ) ); $password = $data->get( 'gridguyz-core', 'developer-password', 'Type the developer\'s password', $this->createPasswordSalt( 6 ), true ); return $this->insertIntoTable( 'user', array( 'email' => $email, 'displayName' => $displayName, 'passwordHash' => $this->createPasswordHash( $password ), 'groupId' => static::DEVELOPER_GROUP, 'state' => 'active', 'confirmed' => 't', 'locale' => 'en', ), true ); }
[ "protected", "function", "insertDeveloper", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getPatchData", "(", ")", ";", "$", "create", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'developer'", ",", "'Do you want to create a developer user? (y/n)'", ",", "'n'", ",", "array", "(", "'y'", ",", "'n'", ",", "'yes'", ",", "'no'", ",", "'t'", ",", "'f'", ",", "'true'", ",", "'false'", ",", "'1'", ",", "'0'", ")", ")", ";", "if", "(", "in_array", "(", "strtolower", "(", "$", "create", ")", ",", "array", "(", "'n'", ",", "'no'", ",", "'f'", ",", "'false'", ",", "'0'", ",", "''", ")", ")", ")", "{", "return", "null", ";", "}", "$", "email", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'developer-email'", ",", "'Type the developer\\'s email (must be valid email)'", ",", "null", ",", "'/^[A-Z0-9\\._%\\+-]+@[A-Z0-9\\.-]+\\.[A-Z]{2,4}$/i'", ",", "3", ")", ";", "$", "displayName", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'developer-displayName'", ",", "'Type the developer\\'s display name'", ",", "strstr", "(", "$", "email", ",", "'@'", ",", "true", ")", ")", ";", "$", "password", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'developer-password'", ",", "'Type the developer\\'s password'", ",", "$", "this", "->", "createPasswordSalt", "(", "6", ")", ",", "true", ")", ";", "return", "$", "this", "->", "insertIntoTable", "(", "'user'", ",", "array", "(", "'email'", "=>", "$", "email", ",", "'displayName'", "=>", "$", "displayName", ",", "'passwordHash'", "=>", "$", "this", "->", "createPasswordHash", "(", "$", "password", ")", ",", "'groupId'", "=>", "static", "::", "DEVELOPER_GROUP", ",", "'state'", "=>", "'active'", ",", "'confirmed'", "=>", "'t'", ",", "'locale'", "=>", "'en'", ",", ")", ",", "true", ")", ";", "}" ]
Insert developer user @return int|null
[ "Insert", "developer", "user" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L197-L251
3,091
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.insertPlatformOwner
protected function insertPlatformOwner() { $data = $this->getPatchData(); $email = $data->get( 'gridguyz-core', 'platformOwner-email', 'Type the platform owner\'s email (must be valid email)', null, '/^[A-Z0-9\._%\+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', 3 ); $displayName = $data->get( 'gridguyz-core', 'platformOwner-displayName', 'Type the platform owner\'s display name', strstr( $email, '@', true ) ); $password = $data->get( 'gridguyz-core', 'platformOwner-password', 'Type the platform owner\'s password', $this->createPasswordSalt( 6 ), true ); return $this->insertIntoTable( 'user', array( 'email' => $email, 'displayName' => $displayName, 'passwordHash' => $this->createPasswordHash( $password ), 'groupId' => static::SITE_OWNER_GROUP, 'state' => 'active', 'confirmed' => 't', 'locale' => 'en', ), true ); }
php
protected function insertPlatformOwner() { $data = $this->getPatchData(); $email = $data->get( 'gridguyz-core', 'platformOwner-email', 'Type the platform owner\'s email (must be valid email)', null, '/^[A-Z0-9\._%\+-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}$/i', 3 ); $displayName = $data->get( 'gridguyz-core', 'platformOwner-displayName', 'Type the platform owner\'s display name', strstr( $email, '@', true ) ); $password = $data->get( 'gridguyz-core', 'platformOwner-password', 'Type the platform owner\'s password', $this->createPasswordSalt( 6 ), true ); return $this->insertIntoTable( 'user', array( 'email' => $email, 'displayName' => $displayName, 'passwordHash' => $this->createPasswordHash( $password ), 'groupId' => static::SITE_OWNER_GROUP, 'state' => 'active', 'confirmed' => 't', 'locale' => 'en', ), true ); }
[ "protected", "function", "insertPlatformOwner", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getPatchData", "(", ")", ";", "$", "email", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'platformOwner-email'", ",", "'Type the platform owner\\'s email (must be valid email)'", ",", "null", ",", "'/^[A-Z0-9\\._%\\+-]+@[A-Z0-9\\.-]+\\.[A-Z]{2,4}$/i'", ",", "3", ")", ";", "$", "displayName", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'platformOwner-displayName'", ",", "'Type the platform owner\\'s display name'", ",", "strstr", "(", "$", "email", ",", "'@'", ",", "true", ")", ")", ";", "$", "password", "=", "$", "data", "->", "get", "(", "'gridguyz-core'", ",", "'platformOwner-password'", ",", "'Type the platform owner\\'s password'", ",", "$", "this", "->", "createPasswordSalt", "(", "6", ")", ",", "true", ")", ";", "return", "$", "this", "->", "insertIntoTable", "(", "'user'", ",", "array", "(", "'email'", "=>", "$", "email", ",", "'displayName'", "=>", "$", "displayName", ",", "'passwordHash'", "=>", "$", "this", "->", "createPasswordHash", "(", "$", "password", ")", ",", "'groupId'", "=>", "static", "::", "SITE_OWNER_GROUP", ",", "'state'", "=>", "'active'", ",", "'confirmed'", "=>", "'t'", ",", "'locale'", "=>", "'en'", ",", ")", ",", "true", ")", ";", "}" ]
Insert platform-owner user @return int
[ "Insert", "platform", "-", "owner", "user" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L258-L298
3,092
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.createPasswordHash
protected function createPasswordHash( $password ) { if ( function_exists( 'password_hash' ) ) { return password_hash( $password, PASSWORD_DEFAULT ); } if ( ! defined( 'CRYPT_BLOWFISH' ) ) { throw new Exception\RuntimeException( sprintf( '%s: CRYPT_BLOWFISH algorithm must be enabled', __METHOD__ ) ); } return crypt( $password, ( version_compare( PHP_VERSION, '5.3.7' ) >= 0 ? '$2y' : '$2a' ) . '$10$' . $this->createPasswordSalt() . '$' ); }
php
protected function createPasswordHash( $password ) { if ( function_exists( 'password_hash' ) ) { return password_hash( $password, PASSWORD_DEFAULT ); } if ( ! defined( 'CRYPT_BLOWFISH' ) ) { throw new Exception\RuntimeException( sprintf( '%s: CRYPT_BLOWFISH algorithm must be enabled', __METHOD__ ) ); } return crypt( $password, ( version_compare( PHP_VERSION, '5.3.7' ) >= 0 ? '$2y' : '$2a' ) . '$10$' . $this->createPasswordSalt() . '$' ); }
[ "protected", "function", "createPasswordHash", "(", "$", "password", ")", "{", "if", "(", "function_exists", "(", "'password_hash'", ")", ")", "{", "return", "password_hash", "(", "$", "password", ",", "PASSWORD_DEFAULT", ")", ";", "}", "if", "(", "!", "defined", "(", "'CRYPT_BLOWFISH'", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'%s: CRYPT_BLOWFISH algorithm must be enabled'", ",", "__METHOD__", ")", ")", ";", "}", "return", "crypt", "(", "$", "password", ",", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.3.7'", ")", ">=", "0", "?", "'$2y'", ":", "'$2a'", ")", ".", "'$10$'", ".", "$", "this", "->", "createPasswordSalt", "(", ")", ".", "'$'", ")", ";", "}" ]
Create password hash @param string $password @return string
[ "Create", "password", "hash" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L306-L326
3,093
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.createPasswordSalt
private function createPasswordSalt( $length = 22 ) { static $chars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; if ( function_exists( 'openssl_random_pseudo_bytes' ) && ( version_compare( PHP_VERSION, '5.3.4' ) >= 0 || strtoupper( substr( PHP_OS, 0, 3 ) ) !== 'WIN' ) ) { $bytes = openssl_random_pseudo_bytes( $length, $usable ); if ( true !== $usable ) { $bytes = null; } } if ( empty( $bytes ) && function_exists( 'mcrypt_create_iv' ) && ( version_compare( PHP_VERSION, '5.3.7' ) >= 0 || strtoupper( substr( PHP_OS, 0, 3 ) ) !== 'WIN' ) ) { $bytes = mcrypt_create_iv( $length, MCRYPT_DEV_URANDOM ); if ( empty( $bytes ) || strlen( $bytes ) < $length ) { $bytes = null; } } if ( empty( $bytes ) ) { $bytes = ''; for ( $i = 0; $i < $length; ++$i ) { $bytes .= chr( mt_rand( 0, 255 ) ); } } $pos = 0; $salt = ''; $clen = strlen( $chars ); for ( $i = 0; $i < $length; ++$i ) { $pos = ( $pos + ord( $bytes[$i] ) ) % $clen; $salt .= $chars[$pos]; } return $salt; }
php
private function createPasswordSalt( $length = 22 ) { static $chars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; if ( function_exists( 'openssl_random_pseudo_bytes' ) && ( version_compare( PHP_VERSION, '5.3.4' ) >= 0 || strtoupper( substr( PHP_OS, 0, 3 ) ) !== 'WIN' ) ) { $bytes = openssl_random_pseudo_bytes( $length, $usable ); if ( true !== $usable ) { $bytes = null; } } if ( empty( $bytes ) && function_exists( 'mcrypt_create_iv' ) && ( version_compare( PHP_VERSION, '5.3.7' ) >= 0 || strtoupper( substr( PHP_OS, 0, 3 ) ) !== 'WIN' ) ) { $bytes = mcrypt_create_iv( $length, MCRYPT_DEV_URANDOM ); if ( empty( $bytes ) || strlen( $bytes ) < $length ) { $bytes = null; } } if ( empty( $bytes ) ) { $bytes = ''; for ( $i = 0; $i < $length; ++$i ) { $bytes .= chr( mt_rand( 0, 255 ) ); } } $pos = 0; $salt = ''; $clen = strlen( $chars ); for ( $i = 0; $i < $length; ++$i ) { $pos = ( $pos + ord( $bytes[$i] ) ) % $clen; $salt .= $chars[$pos]; } return $salt; }
[ "private", "function", "createPasswordSalt", "(", "$", "length", "=", "22", ")", "{", "static", "$", "chars", "=", "'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'", ";", "if", "(", "function_exists", "(", "'openssl_random_pseudo_bytes'", ")", "&&", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.3.4'", ")", ">=", "0", "||", "strtoupper", "(", "substr", "(", "PHP_OS", ",", "0", ",", "3", ")", ")", "!==", "'WIN'", ")", ")", "{", "$", "bytes", "=", "openssl_random_pseudo_bytes", "(", "$", "length", ",", "$", "usable", ")", ";", "if", "(", "true", "!==", "$", "usable", ")", "{", "$", "bytes", "=", "null", ";", "}", "}", "if", "(", "empty", "(", "$", "bytes", ")", "&&", "function_exists", "(", "'mcrypt_create_iv'", ")", "&&", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.3.7'", ")", ">=", "0", "||", "strtoupper", "(", "substr", "(", "PHP_OS", ",", "0", ",", "3", ")", ")", "!==", "'WIN'", ")", ")", "{", "$", "bytes", "=", "mcrypt_create_iv", "(", "$", "length", ",", "MCRYPT_DEV_URANDOM", ")", ";", "if", "(", "empty", "(", "$", "bytes", ")", "||", "strlen", "(", "$", "bytes", ")", "<", "$", "length", ")", "{", "$", "bytes", "=", "null", ";", "}", "}", "if", "(", "empty", "(", "$", "bytes", ")", ")", "{", "$", "bytes", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "++", "$", "i", ")", "{", "$", "bytes", ".=", "chr", "(", "mt_rand", "(", "0", ",", "255", ")", ")", ";", "}", "}", "$", "pos", "=", "0", ";", "$", "salt", "=", "''", ";", "$", "clen", "=", "strlen", "(", "$", "chars", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "++", "$", "i", ")", "{", "$", "pos", "=", "(", "$", "pos", "+", "ord", "(", "$", "bytes", "[", "$", "i", "]", ")", ")", "%", "$", "clen", ";", "$", "salt", ".=", "$", "chars", "[", "$", "pos", "]", ";", "}", "return", "$", "salt", ";", "}" ]
Create password-salt @param int $length @return string
[ "Create", "password", "-", "salt" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L334-L384
3,094
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.insertDefaultMenu
protected function insertDefaultMenu( $content ) { $root = $this->insertIntoTable( 'menu', array( 'type' => 'container', 'left' => 1, 'right' => 4, ), true ); $this->insertIntoTable( 'menu_label', array( 'menuId' => $root, 'locale' => 'en', 'label' => 'Default menu', ) ); $menuContent = $this->insertIntoTable( 'menu', array( 'type' => 'content', 'left' => 2, 'right' => 3, ), true ); $this->insertIntoTable( 'menu_label', array( 'menuId' => $menuContent, 'locale' => 'en', 'label' => 'Home', ) ); $this->insertIntoTable( 'menu_property', array( 'menuId' => $menuContent, 'name' => 'contentId', 'value' => $content, ) ); return $root; }
php
protected function insertDefaultMenu( $content ) { $root = $this->insertIntoTable( 'menu', array( 'type' => 'container', 'left' => 1, 'right' => 4, ), true ); $this->insertIntoTable( 'menu_label', array( 'menuId' => $root, 'locale' => 'en', 'label' => 'Default menu', ) ); $menuContent = $this->insertIntoTable( 'menu', array( 'type' => 'content', 'left' => 2, 'right' => 3, ), true ); $this->insertIntoTable( 'menu_label', array( 'menuId' => $menuContent, 'locale' => 'en', 'label' => 'Home', ) ); $this->insertIntoTable( 'menu_property', array( 'menuId' => $menuContent, 'name' => 'contentId', 'value' => $content, ) ); return $root; }
[ "protected", "function", "insertDefaultMenu", "(", "$", "content", ")", "{", "$", "root", "=", "$", "this", "->", "insertIntoTable", "(", "'menu'", ",", "array", "(", "'type'", "=>", "'container'", ",", "'left'", "=>", "1", ",", "'right'", "=>", "4", ",", ")", ",", "true", ")", ";", "$", "this", "->", "insertIntoTable", "(", "'menu_label'", ",", "array", "(", "'menuId'", "=>", "$", "root", ",", "'locale'", "=>", "'en'", ",", "'label'", "=>", "'Default menu'", ",", ")", ")", ";", "$", "menuContent", "=", "$", "this", "->", "insertIntoTable", "(", "'menu'", ",", "array", "(", "'type'", "=>", "'content'", ",", "'left'", "=>", "2", ",", "'right'", "=>", "3", ",", ")", ",", "true", ")", ";", "$", "this", "->", "insertIntoTable", "(", "'menu_label'", ",", "array", "(", "'menuId'", "=>", "$", "menuContent", ",", "'locale'", "=>", "'en'", ",", "'label'", "=>", "'Home'", ",", ")", ")", ";", "$", "this", "->", "insertIntoTable", "(", "'menu_property'", ",", "array", "(", "'menuId'", "=>", "$", "menuContent", ",", "'name'", "=>", "'contentId'", ",", "'value'", "=>", "$", "content", ",", ")", ")", ";", "return", "$", "root", ";", "}" ]
Insert default menu @param int $content @return int
[ "Insert", "default", "menu" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L465-L515
3,095
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.appendCustomizeGlobalExtra
protected function appendCustomizeGlobalExtra( $globalExtraCss, $schema = null ) { $where = array( 'rootParagraphId' => null ); $table = 'customize_extra'; if ( $schema ) { $table = array( $schema, $table ); } $current = $this->selectFromTable( $table, 'extra', $where ); if ( null === $current ) { $update = $this->updateTable( $table, array( 'extra' => $globalExtraCss, ), $where ); if ( ! $update ) { return (bool) $this->insertIntoTable( $table, array( 'rootParagraphId' => null, 'extra' => $globalExtraCss, ), true ); } return (bool) $update; } return (bool) $this->updateTable( $table, array( 'extra' => $current . "\n\n" . $globalExtraCss, ), $where ); }
php
protected function appendCustomizeGlobalExtra( $globalExtraCss, $schema = null ) { $where = array( 'rootParagraphId' => null ); $table = 'customize_extra'; if ( $schema ) { $table = array( $schema, $table ); } $current = $this->selectFromTable( $table, 'extra', $where ); if ( null === $current ) { $update = $this->updateTable( $table, array( 'extra' => $globalExtraCss, ), $where ); if ( ! $update ) { return (bool) $this->insertIntoTable( $table, array( 'rootParagraphId' => null, 'extra' => $globalExtraCss, ), true ); } return (bool) $update; } return (bool) $this->updateTable( $table, array( 'extra' => $current . "\n\n" . $globalExtraCss, ), $where ); }
[ "protected", "function", "appendCustomizeGlobalExtra", "(", "$", "globalExtraCss", ",", "$", "schema", "=", "null", ")", "{", "$", "where", "=", "array", "(", "'rootParagraphId'", "=>", "null", ")", ";", "$", "table", "=", "'customize_extra'", ";", "if", "(", "$", "schema", ")", "{", "$", "table", "=", "array", "(", "$", "schema", ",", "$", "table", ")", ";", "}", "$", "current", "=", "$", "this", "->", "selectFromTable", "(", "$", "table", ",", "'extra'", ",", "$", "where", ")", ";", "if", "(", "null", "===", "$", "current", ")", "{", "$", "update", "=", "$", "this", "->", "updateTable", "(", "$", "table", ",", "array", "(", "'extra'", "=>", "$", "globalExtraCss", ",", ")", ",", "$", "where", ")", ";", "if", "(", "!", "$", "update", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "insertIntoTable", "(", "$", "table", ",", "array", "(", "'rootParagraphId'", "=>", "null", ",", "'extra'", "=>", "$", "globalExtraCss", ",", ")", ",", "true", ")", ";", "}", "return", "(", "bool", ")", "$", "update", ";", "}", "return", "(", "bool", ")", "$", "this", "->", "updateTable", "(", "$", "table", ",", "array", "(", "'extra'", "=>", "$", "current", ".", "\"\\n\\n\"", ".", "$", "globalExtraCss", ",", ")", ",", "$", "where", ")", ";", "}" ]
Append global extra css to customize @param string $globalExtraCss @param string|null $schema @return bool
[ "Append", "global", "extra", "css", "to", "customize" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L544-L592
3,096
webriq/core
module/Core/src/Grid/Core/Installer/Patch.php
Patch.mergePackagesConfig
protected function mergePackagesConfig() { $this->getInstaller() ->mergeConfigData( 'packages.local', include __DIR__ . '/../../../../config/default.packages.php', function ( & $config ) { if ( ! empty( $config['modules']['Grid\Core']['enabledPackages'] ) ) { foreach ( $config['modules']['Grid\Core']['enabledPackages'] as & $packages ) { if ( ! is_array( $packages ) ) { $packages = array( $packages => (string) $packages ); } $packages = array_unique( array_map( 'strtolower', array_filter( $packages, function ( $package ) { return (bool) preg_match( '#^[a-z0-9_-]+/[a-z0-9_-]+$#i', $package ); } ) ) ); } } return $config; } ); }
php
protected function mergePackagesConfig() { $this->getInstaller() ->mergeConfigData( 'packages.local', include __DIR__ . '/../../../../config/default.packages.php', function ( & $config ) { if ( ! empty( $config['modules']['Grid\Core']['enabledPackages'] ) ) { foreach ( $config['modules']['Grid\Core']['enabledPackages'] as & $packages ) { if ( ! is_array( $packages ) ) { $packages = array( $packages => (string) $packages ); } $packages = array_unique( array_map( 'strtolower', array_filter( $packages, function ( $package ) { return (bool) preg_match( '#^[a-z0-9_-]+/[a-z0-9_-]+$#i', $package ); } ) ) ); } } return $config; } ); }
[ "protected", "function", "mergePackagesConfig", "(", ")", "{", "$", "this", "->", "getInstaller", "(", ")", "->", "mergeConfigData", "(", "'packages.local'", ",", "include", "__DIR__", ".", "'/../../../../config/default.packages.php'", ",", "function", "(", "&", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'modules'", "]", "[", "'Grid\\Core'", "]", "[", "'enabledPackages'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'modules'", "]", "[", "'Grid\\Core'", "]", "[", "'enabledPackages'", "]", "as", "&", "$", "packages", ")", "{", "if", "(", "!", "is_array", "(", "$", "packages", ")", ")", "{", "$", "packages", "=", "array", "(", "$", "packages", "=>", "(", "string", ")", "$", "packages", ")", ";", "}", "$", "packages", "=", "array_unique", "(", "array_map", "(", "'strtolower'", ",", "array_filter", "(", "$", "packages", ",", "function", "(", "$", "package", ")", "{", "return", "(", "bool", ")", "preg_match", "(", "'#^[a-z0-9_-]+/[a-z0-9_-]+$#i'", ",", "$", "package", ")", ";", "}", ")", ")", ")", ";", "}", "}", "return", "$", "config", ";", "}", ")", ";", "}" ]
Merge packages config @return void
[ "Merge", "packages", "config" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Installer/Patch.php#L599-L637
3,097
MarcusFulbright/represent
src/Represent/Builder/PropertyContextBuilder.php
PropertyContextBuilder.propertyContextFromReflection
public function propertyContextFromReflection(\ReflectionProperty $property, $original) { $property->setAccessible(true); $context = new PropertyContext($property->name, $property->getValue($original), $property->class); return $this->parseAnnotations($context, $property, $original); }
php
public function propertyContextFromReflection(\ReflectionProperty $property, $original) { $property->setAccessible(true); $context = new PropertyContext($property->name, $property->getValue($original), $property->class); return $this->parseAnnotations($context, $property, $original); }
[ "public", "function", "propertyContextFromReflection", "(", "\\", "ReflectionProperty", "$", "property", ",", "$", "original", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "context", "=", "new", "PropertyContext", "(", "$", "property", "->", "name", ",", "$", "property", "->", "getValue", "(", "$", "original", ")", ",", "$", "property", "->", "class", ")", ";", "return", "$", "this", "->", "parseAnnotations", "(", "$", "context", ",", "$", "property", ",", "$", "original", ")", ";", "}" ]
Responsible for building property representation from \ReflectionProperties in the form of PropertyContext @param \ReflectionProperty $property @param $original @return PropertyContext
[ "Responsible", "for", "building", "property", "representation", "from", "\\", "ReflectionProperties", "in", "the", "form", "of", "PropertyContext" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/PropertyContextBuilder.php#L28-L34
3,098
MarcusFulbright/represent
src/Represent/Builder/PropertyContextBuilder.php
PropertyContextBuilder.parseAnnotations
private function parseAnnotations(PropertyContext $context, \ReflectionProperty $property, $original) { $annot = $this->propertyHandler->getPropertyAnnotation($property); if ($annot) { $context = $this->handleRepresentProperty($property, $annot, $context, $original); } return $context; }
php
private function parseAnnotations(PropertyContext $context, \ReflectionProperty $property, $original) { $annot = $this->propertyHandler->getPropertyAnnotation($property); if ($annot) { $context = $this->handleRepresentProperty($property, $annot, $context, $original); } return $context; }
[ "private", "function", "parseAnnotations", "(", "PropertyContext", "$", "context", ",", "\\", "ReflectionProperty", "$", "property", ",", "$", "original", ")", "{", "$", "annot", "=", "$", "this", "->", "propertyHandler", "->", "getPropertyAnnotation", "(", "$", "property", ")", ";", "if", "(", "$", "annot", ")", "{", "$", "context", "=", "$", "this", "->", "handleRepresentProperty", "(", "$", "property", ",", "$", "annot", ",", "$", "context", ",", "$", "original", ")", ";", "}", "return", "$", "context", ";", "}" ]
Parses properties for annotations and delegates the handling of those annotations @param PropertyContext $context @param \ReflectionProperty $property @param $original @return PropertyContext
[ "Parses", "properties", "for", "annotations", "and", "delegates", "the", "handling", "of", "those", "annotations" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/PropertyContextBuilder.php#L44-L53
3,099
MarcusFulbright/represent
src/Represent/Builder/PropertyContextBuilder.php
PropertyContextBuilder.handleRepresentProperty
private function handleRepresentProperty(\ReflectionProperty $property, Property $annot, PropertyContext $context, $original) { if ($annot->getName()) { $context->name = $annot->getName(); } if ($annot->getType()) { $context->value = $this->propertyHandler->handleTypeConversion($annot->getType(), $property->getValue($original)); } return $context; }
php
private function handleRepresentProperty(\ReflectionProperty $property, Property $annot, PropertyContext $context, $original) { if ($annot->getName()) { $context->name = $annot->getName(); } if ($annot->getType()) { $context->value = $this->propertyHandler->handleTypeConversion($annot->getType(), $property->getValue($original)); } return $context; }
[ "private", "function", "handleRepresentProperty", "(", "\\", "ReflectionProperty", "$", "property", ",", "Property", "$", "annot", ",", "PropertyContext", "$", "context", ",", "$", "original", ")", "{", "if", "(", "$", "annot", "->", "getName", "(", ")", ")", "{", "$", "context", "->", "name", "=", "$", "annot", "->", "getName", "(", ")", ";", "}", "if", "(", "$", "annot", "->", "getType", "(", ")", ")", "{", "$", "context", "->", "value", "=", "$", "this", "->", "propertyHandler", "->", "handleTypeConversion", "(", "$", "annot", "->", "getType", "(", ")", ",", "$", "property", "->", "getValue", "(", "$", "original", ")", ")", ";", "}", "return", "$", "context", ";", "}" ]
Handles dealing with Represent\Property annotation @param \ReflectionProperty $property @param Property $annot @param \Represent\Context\PropertyContext $context @param $original @return PropertyContext
[ "Handles", "dealing", "with", "Represent", "\\", "Property", "annotation" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/PropertyContextBuilder.php#L63-L74