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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
15,000
chippyash/Math-Type-Calculator
src/Chippyash/Math/Type/Traits/ArbitrateTwoTypes.php
ArbitrateTwoTypes.getTypePairing
private function getTypePairing(NumericTypeInterface $a, NumericTypeInterface $b) { $search = [ 'Chippyash\Type\Number\Rational\\', 'Chippyash\Type\Number\Complex\\', 'Chippyash\Type\Number\\', 'Type' ]; $replace = ['', '', '', '']; $tA = strtolower(str_replace($search, $replace, get_class($a))); $tB = strtolower(str_replace($search, $replace, get_class($b))); return "{$tA}:{$tB}"; }
php
private function getTypePairing(NumericTypeInterface $a, NumericTypeInterface $b) { $search = [ 'Chippyash\Type\Number\Rational\\', 'Chippyash\Type\Number\Complex\\', 'Chippyash\Type\Number\\', 'Type' ]; $replace = ['', '', '', '']; $tA = strtolower(str_replace($search, $replace, get_class($a))); $tB = strtolower(str_replace($search, $replace, get_class($b))); return "{$tA}:{$tB}"; }
[ "private", "function", "getTypePairing", "(", "NumericTypeInterface", "$", "a", ",", "NumericTypeInterface", "$", "b", ")", "{", "$", "search", "=", "[", "'Chippyash\\Type\\Number\\Rational\\\\'", ",", "'Chippyash\\Type\\Number\\Complex\\\\'", ",", "'Chippyash\\Type\\Number\\\\'", ",", "'Type'", "]", ";", "$", "replace", "=", "[", "''", ",", "''", ",", "''", ",", "''", "]", ";", "$", "tA", "=", "strtolower", "(", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "get_class", "(", "$", "a", ")", ")", ")", ";", "$", "tB", "=", "strtolower", "(", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "get_class", "(", "$", "b", ")", ")", ")", ";", "return", "\"{$tA}:{$tB}\"", ";", "}" ]
Work out the type of the number pairs @param NumericTypeInterface $a first operand @param NumericTypeInterface $b second operand @return string
[ "Work", "out", "the", "type", "of", "the", "number", "pairs" ]
2a2fae0ab4d052772d3dd45745efd5a91f88b9e3
https://github.com/chippyash/Math-Type-Calculator/blob/2a2fae0ab4d052772d3dd45745efd5a91f88b9e3/src/Chippyash/Math/Type/Traits/ArbitrateTwoTypes.php#L66-L79
15,001
harp-orm/query
src/Compiler/Insert.php
Insert.render
public static function render(Query\Insert $query) { return Compiler::withDb($query->getDb(), function () use ($query) { $table = $query->getTable(); $select = $query->getSelect(); return Compiler::expression(array( 'INSERT', $query->getType(), Compiler::word('INTO', $table !== null ? Aliased::render($table) : null), Columns::render($query->getColumns()), Compiler::word('VALUES', Values::combine($query->getValues())), Compiler::word('SET', Set::combine($query->getSet())), $select !== null ? Select::render($select) : null, )); }); }
php
public static function render(Query\Insert $query) { return Compiler::withDb($query->getDb(), function () use ($query) { $table = $query->getTable(); $select = $query->getSelect(); return Compiler::expression(array( 'INSERT', $query->getType(), Compiler::word('INTO', $table !== null ? Aliased::render($table) : null), Columns::render($query->getColumns()), Compiler::word('VALUES', Values::combine($query->getValues())), Compiler::word('SET', Set::combine($query->getSet())), $select !== null ? Select::render($select) : null, )); }); }
[ "public", "static", "function", "render", "(", "Query", "\\", "Insert", "$", "query", ")", "{", "return", "Compiler", "::", "withDb", "(", "$", "query", "->", "getDb", "(", ")", ",", "function", "(", ")", "use", "(", "$", "query", ")", "{", "$", "table", "=", "$", "query", "->", "getTable", "(", ")", ";", "$", "select", "=", "$", "query", "->", "getSelect", "(", ")", ";", "return", "Compiler", "::", "expression", "(", "array", "(", "'INSERT'", ",", "$", "query", "->", "getType", "(", ")", ",", "Compiler", "::", "word", "(", "'INTO'", ",", "$", "table", "!==", "null", "?", "Aliased", "::", "render", "(", "$", "table", ")", ":", "null", ")", ",", "Columns", "::", "render", "(", "$", "query", "->", "getColumns", "(", ")", ")", ",", "Compiler", "::", "word", "(", "'VALUES'", ",", "Values", "::", "combine", "(", "$", "query", "->", "getValues", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'SET'", ",", "Set", "::", "combine", "(", "$", "query", "->", "getSet", "(", ")", ")", ")", ",", "$", "select", "!==", "null", "?", "Select", "::", "render", "(", "$", "select", ")", ":", "null", ",", ")", ")", ";", "}", ")", ";", "}" ]
Render a Insert object @param Query\Insert $query @return string
[ "Render", "a", "Insert", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Insert.php#L19-L36
15,002
FrenchFrogs/framework
src/Laravel/Database/Schema/Blueprint.php
Blueprint.binaryUuid
public function binaryUuid($column = 'id', $primary = true) { $column = $this->addColumn('binaryuuid', $column, ['length' => 16]); // gestion de la clé primaire if ($primary) { $column->primary(); } return $column; }
php
public function binaryUuid($column = 'id', $primary = true) { $column = $this->addColumn('binaryuuid', $column, ['length' => 16]); // gestion de la clé primaire if ($primary) { $column->primary(); } return $column; }
[ "public", "function", "binaryUuid", "(", "$", "column", "=", "'id'", ",", "$", "primary", "=", "true", ")", "{", "$", "column", "=", "$", "this", "->", "addColumn", "(", "'binaryuuid'", ",", "$", "column", ",", "[", "'length'", "=>", "16", "]", ")", ";", "// gestion de la clé primaire", "if", "(", "$", "primary", ")", "{", "$", "column", "->", "primary", "(", ")", ";", "}", "return", "$", "column", ";", "}" ]
Ajoute une column de type binary UUID @param string $column @return \Illuminate\Support\Fluent
[ "Ajoute", "une", "column", "de", "type", "binary", "UUID" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Laravel/Database/Schema/Blueprint.php#L19-L29
15,003
FrenchFrogs/framework
src/Laravel/Database/Schema/Blueprint.php
Blueprint.stringId
public function stringId($column = 'id', $size = 32, $primary = true) { $column = $this->string($column, $size); // gestion de la clé primaire if ($primary) { $column->primary(); } return $column; }
php
public function stringId($column = 'id', $size = 32, $primary = true) { $column = $this->string($column, $size); // gestion de la clé primaire if ($primary) { $column->primary(); } return $column; }
[ "public", "function", "stringId", "(", "$", "column", "=", "'id'", ",", "$", "size", "=", "32", ",", "$", "primary", "=", "true", ")", "{", "$", "column", "=", "$", "this", "->", "string", "(", "$", "column", ",", "$", "size", ")", ";", "// gestion de la clé primaire", "if", "(", "$", "primary", ")", "{", "$", "column", "->", "primary", "(", ")", ";", "}", "return", "$", "column", ";", "}" ]
Ajoute une colonne id de type string @param string $column @param int $size @return mixed
[ "Ajoute", "une", "colonne", "id", "de", "type", "string" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Laravel/Database/Schema/Blueprint.php#L39-L49
15,004
Elendev/ElendevRoxyFilemanBundle
FileSystem/LocalFileSystem.php
LocalFileSystem.getDirectoryTreeList
public function getDirectoryTreeList() { $finder = new Finder(); $finder->in($this->rootPath)->directories(); $directories = array(); $rootFinder = new Finder(); $rootFinder->in($this->rootPath)->depth(0); //Add root directory $directories[] = new Directory($this->virtualRootPath, $rootFinder->directories()->count(), $rootFinder->files()->count()); foreach($finder as $dir){ $dirFinder = new Finder(); $dirFinder->in($dir->getPathname())->depth(0); $virtualAbsolutePath = substr($this->fs->makePathRelative($dir->getPathname(), $this->rootPath), 0, -1); //substring to remove last / $directories[] = new Directory($this->virtualRootPath .'/' . $virtualAbsolutePath, $dirFinder->files()->count(), $dirFinder->directories()->count()); } return $directories; }
php
public function getDirectoryTreeList() { $finder = new Finder(); $finder->in($this->rootPath)->directories(); $directories = array(); $rootFinder = new Finder(); $rootFinder->in($this->rootPath)->depth(0); //Add root directory $directories[] = new Directory($this->virtualRootPath, $rootFinder->directories()->count(), $rootFinder->files()->count()); foreach($finder as $dir){ $dirFinder = new Finder(); $dirFinder->in($dir->getPathname())->depth(0); $virtualAbsolutePath = substr($this->fs->makePathRelative($dir->getPathname(), $this->rootPath), 0, -1); //substring to remove last / $directories[] = new Directory($this->virtualRootPath .'/' . $virtualAbsolutePath, $dirFinder->files()->count(), $dirFinder->directories()->count()); } return $directories; }
[ "public", "function", "getDirectoryTreeList", "(", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "in", "(", "$", "this", "->", "rootPath", ")", "->", "directories", "(", ")", ";", "$", "directories", "=", "array", "(", ")", ";", "$", "rootFinder", "=", "new", "Finder", "(", ")", ";", "$", "rootFinder", "->", "in", "(", "$", "this", "->", "rootPath", ")", "->", "depth", "(", "0", ")", ";", "//Add root directory", "$", "directories", "[", "]", "=", "new", "Directory", "(", "$", "this", "->", "virtualRootPath", ",", "$", "rootFinder", "->", "directories", "(", ")", "->", "count", "(", ")", ",", "$", "rootFinder", "->", "files", "(", ")", "->", "count", "(", ")", ")", ";", "foreach", "(", "$", "finder", "as", "$", "dir", ")", "{", "$", "dirFinder", "=", "new", "Finder", "(", ")", ";", "$", "dirFinder", "->", "in", "(", "$", "dir", "->", "getPathname", "(", ")", ")", "->", "depth", "(", "0", ")", ";", "$", "virtualAbsolutePath", "=", "substr", "(", "$", "this", "->", "fs", "->", "makePathRelative", "(", "$", "dir", "->", "getPathname", "(", ")", ",", "$", "this", "->", "rootPath", ")", ",", "0", ",", "-", "1", ")", ";", "//substring to remove last /", "$", "directories", "[", "]", "=", "new", "Directory", "(", "$", "this", "->", "virtualRootPath", ".", "'/'", ".", "$", "virtualAbsolutePath", ",", "$", "dirFinder", "->", "files", "(", ")", "->", "count", "(", ")", ",", "$", "dirFinder", "->", "directories", "(", ")", "->", "count", "(", ")", ")", ";", "}", "return", "$", "directories", ";", "}" ]
Return the directory tree in the form of a list @return DirectoryInterface[]
[ "Return", "the", "directory", "tree", "in", "the", "form", "of", "a", "list" ]
2173ce00e4f1d22960eec70b437a5908f4681dc1
https://github.com/Elendev/ElendevRoxyFilemanBundle/blob/2173ce00e4f1d22960eec70b437a5908f4681dc1/FileSystem/LocalFileSystem.php#L52-L76
15,005
Elendev/ElendevRoxyFilemanBundle
FileSystem/LocalFileSystem.php
LocalFileSystem.getRealPath
private function getRealPath($path) { if(strpos($path, '../') !== false){ throw new AccessDeniedException('Path cannot contain "../" pattern'); } return str_replace($this->virtualRootPath, $this->rootPath, $path); }
php
private function getRealPath($path) { if(strpos($path, '../') !== false){ throw new AccessDeniedException('Path cannot contain "../" pattern'); } return str_replace($this->virtualRootPath, $this->rootPath, $path); }
[ "private", "function", "getRealPath", "(", "$", "path", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'../'", ")", "!==", "false", ")", "{", "throw", "new", "AccessDeniedException", "(", "'Path cannot contain \"../\" pattern'", ")", ";", "}", "return", "str_replace", "(", "$", "this", "->", "virtualRootPath", ",", "$", "this", "->", "rootPath", ",", "$", "path", ")", ";", "}" ]
Return local path from remote query @param $path
[ "Return", "local", "path", "from", "remote", "query" ]
2173ce00e4f1d22960eec70b437a5908f4681dc1
https://github.com/Elendev/ElendevRoxyFilemanBundle/blob/2173ce00e4f1d22960eec70b437a5908f4681dc1/FileSystem/LocalFileSystem.php#L415-L421
15,006
slaff/learnzf2-route-cache
Module.php
Module.routeSave
public function routeSave(MvcEvent $event) { $match = $event->getRouteMatch(); if(!$match) { return; } if($event->getParam('route-cached') || !$event->getParam('route-cacheable')) { return; } $path = $event->getRequest() ->getUri() ->getPath(); // save the route match into the cache. $cache = $event->getApplication()->getServiceManager()->get('var-cache'); $cacheKey = $this->getCacheKey($path); $data = array ( 'name' => $event->getRouteMatch()->getMatchedRouteName(), 'route' => $path, 'defaults' => $event->getRouteMatch()->getParams(), ); $cache->setItem($cacheKey, $data); }
php
public function routeSave(MvcEvent $event) { $match = $event->getRouteMatch(); if(!$match) { return; } if($event->getParam('route-cached') || !$event->getParam('route-cacheable')) { return; } $path = $event->getRequest() ->getUri() ->getPath(); // save the route match into the cache. $cache = $event->getApplication()->getServiceManager()->get('var-cache'); $cacheKey = $this->getCacheKey($path); $data = array ( 'name' => $event->getRouteMatch()->getMatchedRouteName(), 'route' => $path, 'defaults' => $event->getRouteMatch()->getParams(), ); $cache->setItem($cacheKey, $data); }
[ "public", "function", "routeSave", "(", "MvcEvent", "$", "event", ")", "{", "$", "match", "=", "$", "event", "->", "getRouteMatch", "(", ")", ";", "if", "(", "!", "$", "match", ")", "{", "return", ";", "}", "if", "(", "$", "event", "->", "getParam", "(", "'route-cached'", ")", "||", "!", "$", "event", "->", "getParam", "(", "'route-cacheable'", ")", ")", "{", "return", ";", "}", "$", "path", "=", "$", "event", "->", "getRequest", "(", ")", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", "// save the route match into the cache.", "$", "cache", "=", "$", "event", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", "->", "get", "(", "'var-cache'", ")", ";", "$", "cacheKey", "=", "$", "this", "->", "getCacheKey", "(", "$", "path", ")", ";", "$", "data", "=", "array", "(", "'name'", "=>", "$", "event", "->", "getRouteMatch", "(", ")", "->", "getMatchedRouteName", "(", ")", ",", "'route'", "=>", "$", "path", ",", "'defaults'", "=>", "$", "event", "->", "getRouteMatch", "(", ")", "->", "getParams", "(", ")", ",", ")", ";", "$", "cache", "->", "setItem", "(", "$", "cacheKey", ",", "$", "data", ")", ";", "}" ]
Method that tries to save a route match into a cache system @param MvcEvent $event
[ "Method", "that", "tries", "to", "save", "a", "route", "match", "into", "a", "cache", "system" ]
dfbc0b604fca04a917d425bc6c1404aca36963ec
https://github.com/slaff/learnzf2-route-cache/blob/dfbc0b604fca04a917d425bc6c1404aca36963ec/Module.php#L19-L43
15,007
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.find
public function find($id) { return new self($this->_user, self::get($this->_user, $id)); }
php
public function find($id) { return new self($this->_user, self::get($this->_user, $id)); }
[ "public", "function", "find", "(", "$", "id", ")", "{", "return", "new", "self", "(", "$", "this", "->", "_user", ",", "self", "::", "get", "(", "$", "this", "->", "_user", ",", "$", "id", ")", ")", ";", "}" ]
Class method to find a Subscription @param string $id @return DataSift_Pylon
[ "Class", "method", "to", "find", "a", "Subscription" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L128-L131
15,008
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.findAll
public function findAll( $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC ) { $results = self::getAll($this->_user, $page, $per_page, $order_by, $order_dir); if (isset($results['subscriptions'])) { // Cope with pagination $results = $results['subscriptions']; } $retval = array(); foreach ($results as $pylon) { $retval[] = new self($this->_user, $pylon); } return $retval; }
php
public function findAll( $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC ) { $results = self::getAll($this->_user, $page, $per_page, $order_by, $order_dir); if (isset($results['subscriptions'])) { // Cope with pagination $results = $results['subscriptions']; } $retval = array(); foreach ($results as $pylon) { $retval[] = new self($this->_user, $pylon); } return $retval; }
[ "public", "function", "findAll", "(", "$", "page", "=", "1", ",", "$", "per_page", "=", "20", ",", "$", "order_by", "=", "self", "::", "ORDERBY_CREATED_AT", ",", "$", "order_dir", "=", "self", "::", "ORDERDIR_ASC", ")", "{", "$", "results", "=", "self", "::", "getAll", "(", "$", "this", "->", "_user", ",", "$", "page", ",", "$", "per_page", ",", "$", "order_by", ",", "$", "order_dir", ")", ";", "if", "(", "isset", "(", "$", "results", "[", "'subscriptions'", "]", ")", ")", "{", "// Cope with pagination", "$", "results", "=", "$", "results", "[", "'subscriptions'", "]", ";", "}", "$", "retval", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "pylon", ")", "{", "$", "retval", "[", "]", "=", "new", "self", "(", "$", "this", "->", "_user", ",", "$", "pylon", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Class method to find all Subscriptions @return DataSift_Pylon
[ "Class", "method", "to", "find", "all", "Subscriptions" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L139-L158
15,009
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.get
public static function get($user, $id = false) { $params = array(); if ($id) { $params['id'] = $id; } return $user->get('pylon/get', $params); }
php
public static function get($user, $id = false) { $params = array(); if ($id) { $params['id'] = $id; } return $user->get('pylon/get', $params); }
[ "public", "static", "function", "get", "(", "$", "user", ",", "$", "id", "=", "false", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "id", ")", "{", "$", "params", "[", "'id'", "]", "=", "$", "id", ";", "}", "return", "$", "user", "->", "get", "(", "'pylon/get'", ",", "$", "params", ")", ";", "}" ]
Get an existing recordings. @param Datasift_User $user The Datasift user object @param string $id The id of the existing pylon @throws DataSift_Exception_InvalidData @return DataSift_Pylon
[ "Get", "an", "existing", "recordings", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L170-L179
15,010
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.load
private function load($data) { if (empty($data)) { throw new DataSift_Exception_InvalidData('No data found'); } //Assign the instance variables foreach ($data as $key => $value) { $this->{'_' . $key} = $value; } }
php
private function load($data) { if (empty($data)) { throw new DataSift_Exception_InvalidData('No data found'); } //Assign the instance variables foreach ($data as $key => $value) { $this->{'_' . $key} = $value; } }
[ "private", "function", "load", "(", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No data found'", ")", ";", "}", "//Assign the instance variables", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "{", "'_'", ".", "$", "key", "}", "=", "$", "value", ";", "}", "}" ]
Loads an pylon object from the get data @param array $data An array containing the subscription data. @throws DataSift_Exception_InvalidData
[ "Loads", "an", "pylon", "object", "from", "the", "get", "data" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L255-L265
15,011
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.reload
public function reload() { if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to reload pylon without an ID'); } $this->load(self::get($this->_user, $this->_id)); }
php
public function reload() { if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to reload pylon without an ID'); } $this->load(self::get($this->_user, $this->_id)); }
[ "public", "function", "reload", "(", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "_id", ")", "==", "0", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Unable to reload pylon without an ID'", ")", ";", "}", "$", "this", "->", "load", "(", "self", "::", "get", "(", "$", "this", "->", "_user", ",", "$", "this", "->", "_id", ")", ")", ";", "}" ]
Updates the object with fresh results from get @throws DataSift_Exception_InvalidData
[ "Updates", "the", "object", "with", "fresh", "results", "from", "get" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L272-L279
15,012
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.compile
public function compile($csdl = false) { if ($csdl) { $this->_csdl = $csdl; } if (strlen($this->_csdl) == 0) { throw new DataSift_Exception_InvalidData('Cannot compile an empty definition.'); } $res = $this->_user->post('pylon/compile', array('csdl' => $this->_csdl)); $this->_hash = $res['hash']; return $res; }
php
public function compile($csdl = false) { if ($csdl) { $this->_csdl = $csdl; } if (strlen($this->_csdl) == 0) { throw new DataSift_Exception_InvalidData('Cannot compile an empty definition.'); } $res = $this->_user->post('pylon/compile', array('csdl' => $this->_csdl)); $this->_hash = $res['hash']; return $res; }
[ "public", "function", "compile", "(", "$", "csdl", "=", "false", ")", "{", "if", "(", "$", "csdl", ")", "{", "$", "this", "->", "_csdl", "=", "$", "csdl", ";", "}", "if", "(", "strlen", "(", "$", "this", "->", "_csdl", ")", "==", "0", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Cannot compile an empty definition.'", ")", ";", "}", "$", "res", "=", "$", "this", "->", "_user", "->", "post", "(", "'pylon/compile'", ",", "array", "(", "'csdl'", "=>", "$", "this", "->", "_csdl", ")", ")", ";", "$", "this", "->", "_hash", "=", "$", "res", "[", "'hash'", "]", ";", "return", "$", "res", ";", "}" ]
Compiles the CSDL of this object @param string $csdl If a CSDL string is passed to compile it will set the CSDL for the object @return array Response from the compile
[ "Compiles", "the", "CSDL", "of", "this", "object" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L431-L446
15,013
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.start
public function start($hash = false, $name = false) { if ($hash) { $this->_hash = $hash; } if ($name) { $this->_name = $name; } if (! empty($this->_id)) { $this->restart(); } else { $this->create(); } }
php
public function start($hash = false, $name = false) { if ($hash) { $this->_hash = $hash; } if ($name) { $this->_name = $name; } if (! empty($this->_id)) { $this->restart(); } else { $this->create(); } }
[ "public", "function", "start", "(", "$", "hash", "=", "false", ",", "$", "name", "=", "false", ")", "{", "if", "(", "$", "hash", ")", "{", "$", "this", "->", "_hash", "=", "$", "hash", ";", "}", "if", "(", "$", "name", ")", "{", "$", "this", "->", "_name", "=", "$", "name", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_id", ")", ")", "{", "$", "this", "->", "restart", "(", ")", ";", "}", "else", "{", "$", "this", "->", "create", "(", ")", ";", "}", "}" ]
Creates a new recording or restarts an existing one if an ID is present @param string $hash If hash is provided it will be set @param string $name If name is provided it will be set
[ "Creates", "a", "new", "recording", "or", "restarts", "an", "existing", "one", "if", "an", "ID", "is", "present" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L455-L470
15,014
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.restart
public function restart($id = false) { if ($id) { $this->_id = $id; } $this->_user->put('pylon/start', array('id' => $this->_id)); }
php
public function restart($id = false) { if ($id) { $this->_id = $id; } $this->_user->put('pylon/start', array('id' => $this->_id)); }
[ "public", "function", "restart", "(", "$", "id", "=", "false", ")", "{", "if", "(", "$", "id", ")", "{", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "$", "this", "->", "_user", "->", "put", "(", "'pylon/start'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "_id", ")", ")", ";", "}" ]
Restarts the pylon recording @param string $id If ID is provided it will be set
[ "Restarts", "the", "pylon", "recording" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L505-L512
15,015
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.stop
public function stop($id = false) { if ($id) { $this->_id = $id; } if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to reload pylon without an ID'); } $this->_user->post('pylon/stop', array('id' => $this->_id)); }
php
public function stop($id = false) { if ($id) { $this->_id = $id; } if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to reload pylon without an ID'); } $this->_user->post('pylon/stop', array('id' => $this->_id)); }
[ "public", "function", "stop", "(", "$", "id", "=", "false", ")", "{", "if", "(", "$", "id", ")", "{", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "if", "(", "strlen", "(", "$", "this", "->", "_id", ")", "==", "0", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Unable to reload pylon without an ID'", ")", ";", "}", "$", "this", "->", "_user", "->", "post", "(", "'pylon/stop'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "_id", ")", ")", ";", "}" ]
Stops the pylon recording @param string $id If ID is provided it will be set
[ "Stops", "the", "pylon", "recording" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L519-L529
15,016
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.analyze
public function analyze($parameters, $filter = false, $start = false, $end = false, $id = false) { if ($id) { $this->_id = $id; } //If parameters is not an array try and decode it if (! is_array($parameters)) { $parameters = json_decode($parameters); } if (empty($parameters)) { throw new DataSift_Exception_InvalidData('Parameters must be supplied as an array or valid JSON'); } $params = array( 'id' => $this->_id, 'parameters' => $parameters ); //Set optional request parameters if ($filter) { $params['filter'] = $filter; } if ($start) { $params['start'] = $start; } if ($end) { $params['end'] = $end; } return $this->_user->post('pylon/analyze', $params); }
php
public function analyze($parameters, $filter = false, $start = false, $end = false, $id = false) { if ($id) { $this->_id = $id; } //If parameters is not an array try and decode it if (! is_array($parameters)) { $parameters = json_decode($parameters); } if (empty($parameters)) { throw new DataSift_Exception_InvalidData('Parameters must be supplied as an array or valid JSON'); } $params = array( 'id' => $this->_id, 'parameters' => $parameters ); //Set optional request parameters if ($filter) { $params['filter'] = $filter; } if ($start) { $params['start'] = $start; } if ($end) { $params['end'] = $end; } return $this->_user->post('pylon/analyze', $params); }
[ "public", "function", "analyze", "(", "$", "parameters", ",", "$", "filter", "=", "false", ",", "$", "start", "=", "false", ",", "$", "end", "=", "false", ",", "$", "id", "=", "false", ")", "{", "if", "(", "$", "id", ")", "{", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "//If parameters is not an array try and decode it", "if", "(", "!", "is_array", "(", "$", "parameters", ")", ")", "{", "$", "parameters", "=", "json_decode", "(", "$", "parameters", ")", ";", "}", "if", "(", "empty", "(", "$", "parameters", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Parameters must be supplied as an array or valid JSON'", ")", ";", "}", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "_id", ",", "'parameters'", "=>", "$", "parameters", ")", ";", "//Set optional request parameters", "if", "(", "$", "filter", ")", "{", "$", "params", "[", "'filter'", "]", "=", "$", "filter", ";", "}", "if", "(", "$", "start", ")", "{", "$", "params", "[", "'start'", "]", "=", "$", "start", ";", "}", "if", "(", "$", "end", ")", "{", "$", "params", "[", "'end'", "]", "=", "$", "end", ";", "}", "return", "$", "this", "->", "_user", "->", "post", "(", "'pylon/analyze'", ",", "$", "params", ")", ";", "}" ]
Analyze the recording @param array $parameters the parameter array to be used to analyze the data set @param string $filter additional CSDL filter @param int $start the start time of the pylon @param int $end the end time of the pylon @param string $id If id is provided it will be set @return array Response from the compile
[ "Analyze", "the", "recording" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L543-L576
15,017
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.tags
public function tags($id = false) { if ($id) { $this->_id = $id; } if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to get tags without an ID'); } return $this->_user->get('pylon/tags', array('id' => $this->_id)); }
php
public function tags($id = false) { if ($id) { $this->_id = $id; } if (strlen($this->_id) == 0) { throw new DataSift_Exception_InvalidData('Unable to get tags without an ID'); } return $this->_user->get('pylon/tags', array('id' => $this->_id)); }
[ "public", "function", "tags", "(", "$", "id", "=", "false", ")", "{", "if", "(", "$", "id", ")", "{", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "if", "(", "strlen", "(", "$", "this", "->", "_id", ")", "==", "0", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Unable to get tags without an ID'", ")", ";", "}", "return", "$", "this", "->", "_user", "->", "get", "(", "'pylon/tags'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "_id", ")", ")", ";", "}" ]
Analyze the tags in the data set @param string $id If ID is provided it will be set @return array Response from the tags endpoint
[ "Analyze", "the", "tags", "in", "the", "data", "set" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L585-L595
15,018
datasift/datasift-php
lib/DataSift/Pylon.php
DataSift_Pylon.update
public function update($id = false, $hash = false, $name = false) { if ($id) { $this->_id = $id; } if ($hash) { $this->_hash = $hash; } if ($name) { $this->_name = $name; } $params = array( 'id' => $this->_id, 'hash' => $this->_hash, 'name' => $this->_name ); $this->_user->put('pylon/update', $params); }
php
public function update($id = false, $hash = false, $name = false) { if ($id) { $this->_id = $id; } if ($hash) { $this->_hash = $hash; } if ($name) { $this->_name = $name; } $params = array( 'id' => $this->_id, 'hash' => $this->_hash, 'name' => $this->_name ); $this->_user->put('pylon/update', $params); }
[ "public", "function", "update", "(", "$", "id", "=", "false", ",", "$", "hash", "=", "false", ",", "$", "name", "=", "false", ")", "{", "if", "(", "$", "id", ")", "{", "$", "this", "->", "_id", "=", "$", "id", ";", "}", "if", "(", "$", "hash", ")", "{", "$", "this", "->", "_hash", "=", "$", "hash", ";", "}", "if", "(", "$", "name", ")", "{", "$", "this", "->", "_name", "=", "$", "name", ";", "}", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "_id", ",", "'hash'", "=>", "$", "this", "->", "_hash", ",", "'name'", "=>", "$", "this", "->", "_name", ")", ";", "$", "this", "->", "_user", "->", "put", "(", "'pylon/update'", ",", "$", "params", ")", ";", "}" ]
Updates a recording with a new hash and or name @param string $id The id of the existing recording @param string $hash The new hash of the pylon recording @param string $name The new updated name of the recording @throws DataSift_Exception_InvalidData
[ "Updates", "a", "recording", "with", "a", "new", "hash", "and", "or", "name" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Pylon.php#L652-L672
15,019
fuzz-productions/laravel-api-data
src/Transformations/Serialization/ApiDataSerializer.php
ApiDataSerializer.applyRequestQueryParams
public function applyRequestQueryParams(AbstractPaginator $paginator) { // Pass in any additional query variables foreach ( array_except( Request::instance()->query->all(), [ self::PAGINATION_CURRENT_PAGE, self::PAGINATION_PER_PAGE ] ) as $key => $value ) { $paginator->addQuery($key, $value); } // Add our "per page" pagination parameter to the constructed URLs $paginator->addQuery(self::PAGINATION_PER_PAGE, $paginator->perPage()); }
php
public function applyRequestQueryParams(AbstractPaginator $paginator) { // Pass in any additional query variables foreach ( array_except( Request::instance()->query->all(), [ self::PAGINATION_CURRENT_PAGE, self::PAGINATION_PER_PAGE ] ) as $key => $value ) { $paginator->addQuery($key, $value); } // Add our "per page" pagination parameter to the constructed URLs $paginator->addQuery(self::PAGINATION_PER_PAGE, $paginator->perPage()); }
[ "public", "function", "applyRequestQueryParams", "(", "AbstractPaginator", "$", "paginator", ")", "{", "// Pass in any additional query variables", "foreach", "(", "array_except", "(", "Request", "::", "instance", "(", ")", "->", "query", "->", "all", "(", ")", ",", "[", "self", "::", "PAGINATION_CURRENT_PAGE", ",", "self", "::", "PAGINATION_PER_PAGE", "]", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "paginator", "->", "addQuery", "(", "$", "key", ",", "$", "value", ")", ";", "}", "// Add our \"per page\" pagination parameter to the constructed URLs", "$", "paginator", "->", "addQuery", "(", "self", "::", "PAGINATION_PER_PAGE", ",", "$", "paginator", "->", "perPage", "(", ")", ")", ";", "}" ]
Find all the query parameters passed in the request and apply them to the paginator so we can build a useful URL. @param \Illuminate\Pagination\AbstractPaginator $paginator
[ "Find", "all", "the", "query", "parameters", "passed", "in", "the", "request", "and", "apply", "them", "to", "the", "paginator", "so", "we", "can", "build", "a", "useful", "URL", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/Serialization/ApiDataSerializer.php#L95-L110
15,020
opis/storages
config/Database.php
Database.checkCache
protected function checkCache($name) { if (!isset($this->cache[$name])) { try { $config = $this->db ->from($this->table) ->where($this->columns['name'])->eq($name) ->select() ->fetchAssoc() ->first(); if (!$config) { return false; } $this->cache[$name] = new ArrayHelper(unserialize($config[$this->columns['data']])); } catch (PDOException $e) { return false; } } return true; }
php
protected function checkCache($name) { if (!isset($this->cache[$name])) { try { $config = $this->db ->from($this->table) ->where($this->columns['name'])->eq($name) ->select() ->fetchAssoc() ->first(); if (!$config) { return false; } $this->cache[$name] = new ArrayHelper(unserialize($config[$this->columns['data']])); } catch (PDOException $e) { return false; } } return true; }
[ "protected", "function", "checkCache", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "name", "]", ")", ")", "{", "try", "{", "$", "config", "=", "$", "this", "->", "db", "->", "from", "(", "$", "this", "->", "table", ")", "->", "where", "(", "$", "this", "->", "columns", "[", "'name'", "]", ")", "->", "eq", "(", "$", "name", ")", "->", "select", "(", ")", "->", "fetchAssoc", "(", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "config", ")", "{", "return", "false", ";", "}", "$", "this", "->", "cache", "[", "$", "name", "]", "=", "new", "ArrayHelper", "(", "unserialize", "(", "$", "config", "[", "$", "this", "->", "columns", "[", "'data'", "]", "]", ")", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Check if an item was cached @param string $name @return boolean
[ "Check", "if", "an", "item", "was", "cached" ]
548dd631239c7cd75c04d17878b677e646540fde
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/config/Database.php#L71-L92
15,021
opis/storages
config/Database.php
Database.write
public function write($name, $value) { $path = explode('.', $name); $key = array_shift($path); $exists = $this->checkCache($key); if ($path) { if (!$exists) { $this->cache[$key] = new ArrayHelper(); } $this->cache[$key]->set($path, $value); } else { $this->cache[$key] = new ArrayHelper($value); } return $exists ? $this->updateRecord($key) : $this->insertRecord($key); }
php
public function write($name, $value) { $path = explode('.', $name); $key = array_shift($path); $exists = $this->checkCache($key); if ($path) { if (!$exists) { $this->cache[$key] = new ArrayHelper(); } $this->cache[$key]->set($path, $value); } else { $this->cache[$key] = new ArrayHelper($value); } return $exists ? $this->updateRecord($key) : $this->insertRecord($key); }
[ "public", "function", "write", "(", "$", "name", ",", "$", "value", ")", "{", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "key", "=", "array_shift", "(", "$", "path", ")", ";", "$", "exists", "=", "$", "this", "->", "checkCache", "(", "$", "key", ")", ";", "if", "(", "$", "path", ")", "{", "if", "(", "!", "$", "exists", ")", "{", "$", "this", "->", "cache", "[", "$", "key", "]", "=", "new", "ArrayHelper", "(", ")", ";", "}", "$", "this", "->", "cache", "[", "$", "key", "]", "->", "set", "(", "$", "path", ",", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "cache", "[", "$", "key", "]", "=", "new", "ArrayHelper", "(", "$", "value", ")", ";", "}", "return", "$", "exists", "?", "$", "this", "->", "updateRecord", "(", "$", "key", ")", ":", "$", "this", "->", "insertRecord", "(", "$", "key", ")", ";", "}" ]
Write config data @param string $name @param mixed $value @return boolean
[ "Write", "config", "data" ]
548dd631239c7cd75c04d17878b677e646540fde
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/config/Database.php#L163-L180
15,022
opis/storages
config/Database.php
Database.read
public function read($name, $default = null) { $path = explode('.', $name); $key = array_shift($path); if ($this->checkCache($key)) { return $path ? $this->cache[$key]->get($path, $default) : $this->cache[$key]->toArray(); } return $default; }
php
public function read($name, $default = null) { $path = explode('.', $name); $key = array_shift($path); if ($this->checkCache($key)) { return $path ? $this->cache[$key]->get($path, $default) : $this->cache[$key]->toArray(); } return $default; }
[ "public", "function", "read", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "key", "=", "array_shift", "(", "$", "path", ")", ";", "if", "(", "$", "this", "->", "checkCache", "(", "$", "key", ")", ")", "{", "return", "$", "path", "?", "$", "this", "->", "cache", "[", "$", "key", "]", "->", "get", "(", "$", "path", ",", "$", "default", ")", ":", "$", "this", "->", "cache", "[", "$", "key", "]", "->", "toArray", "(", ")", ";", "}", "return", "$", "default", ";", "}" ]
Read config data @param string $name @param mixed|null $default (optional) @return mixed
[ "Read", "config", "data" ]
548dd631239c7cd75c04d17878b677e646540fde
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/config/Database.php#L190-L200
15,023
opis/storages
config/Database.php
Database.has
public function has($name) { $path = explode('.', $name); $key = array_shift($path); if ($this->checkCache($key)) { return $path ? $this->cache[$key]->has($path) : true; } return false; }
php
public function has($name) { $path = explode('.', $name); $key = array_shift($path); if ($this->checkCache($key)) { return $path ? $this->cache[$key]->has($path) : true; } return false; }
[ "public", "function", "has", "(", "$", "name", ")", "{", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "key", "=", "array_shift", "(", "$", "path", ")", ";", "if", "(", "$", "this", "->", "checkCache", "(", "$", "key", ")", ")", "{", "return", "$", "path", "?", "$", "this", "->", "cache", "[", "$", "key", "]", "->", "has", "(", "$", "path", ")", ":", "true", ";", "}", "return", "false", ";", "}" ]
Check if the config exists @param string $name @return boolean
[ "Check", "if", "the", "config", "exists" ]
548dd631239c7cd75c04d17878b677e646540fde
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/config/Database.php#L209-L219
15,024
opis/storages
config/Database.php
Database.delete
public function delete($name) { $path = explode('.', $name); $key = array_shift($path); if ($path) { if ($this->checkCache($key) && $this->cache[$key]->delete($path)) { return $this->updateRecord($key); } return false; } unset($this->cache[$key]); return $this->deleteRecord($key); }
php
public function delete($name) { $path = explode('.', $name); $key = array_shift($path); if ($path) { if ($this->checkCache($key) && $this->cache[$key]->delete($path)) { return $this->updateRecord($key); } return false; } unset($this->cache[$key]); return $this->deleteRecord($key); }
[ "public", "function", "delete", "(", "$", "name", ")", "{", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "key", "=", "array_shift", "(", "$", "path", ")", ";", "if", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "checkCache", "(", "$", "key", ")", "&&", "$", "this", "->", "cache", "[", "$", "key", "]", "->", "delete", "(", "$", "path", ")", ")", "{", "return", "$", "this", "->", "updateRecord", "(", "$", "key", ")", ";", "}", "return", "false", ";", "}", "unset", "(", "$", "this", "->", "cache", "[", "$", "key", "]", ")", ";", "return", "$", "this", "->", "deleteRecord", "(", "$", "key", ")", ";", "}" ]
Delete a config @param string $name @return boolean
[ "Delete", "a", "config" ]
548dd631239c7cd75c04d17878b677e646540fde
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/config/Database.php#L228-L243
15,025
comelyio/comely
src/Comely/IO/Events/Event/Trigger.php
Trigger.params
public function params(...$params): self { $this->params = $params; array_push($this->params, $this->event); return $this; }
php
public function params(...$params): self { $this->params = $params; array_push($this->params, $this->event); return $this; }
[ "public", "function", "params", "(", "...", "$", "params", ")", ":", "self", "{", "$", "this", "->", "params", "=", "$", "params", ";", "array_push", "(", "$", "this", "->", "params", ",", "$", "this", "->", "event", ")", ";", "return", "$", "this", ";", "}" ]
All arguments passed to this method will be forwarded to callback functions of all listeners @param array ...$params @return Trigger
[ "All", "arguments", "passed", "to", "this", "method", "will", "be", "forwarded", "to", "callback", "functions", "of", "all", "listeners" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Events/Event/Trigger.php#L50-L55
15,026
kabirbaidhya/AwesomeCache
src/Cache.php
Cache.cachedData
public function cachedData() { if (!$this->isCached()) { return null; } $contents = file_get_contents($this->file); $serializationEnabled = static::config('serialize'); $data = $serializationEnabled ? unserialize($contents) : $contents; return $data; }
php
public function cachedData() { if (!$this->isCached()) { return null; } $contents = file_get_contents($this->file); $serializationEnabled = static::config('serialize'); $data = $serializationEnabled ? unserialize($contents) : $contents; return $data; }
[ "public", "function", "cachedData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isCached", "(", ")", ")", "{", "return", "null", ";", "}", "$", "contents", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "$", "serializationEnabled", "=", "static", "::", "config", "(", "'serialize'", ")", ";", "$", "data", "=", "$", "serializationEnabled", "?", "unserialize", "(", "$", "contents", ")", ":", "$", "contents", ";", "return", "$", "data", ";", "}" ]
Retrieves the cached data that is refered by this object @return mixed
[ "Retrieves", "the", "cached", "data", "that", "is", "refered", "by", "this", "object" ]
ecf6293f3bcb3855133b1a8962c53170af1ebc32
https://github.com/kabirbaidhya/AwesomeCache/blob/ecf6293f3bcb3855133b1a8962c53170af1ebc32/src/Cache.php#L80-L93
15,027
kabirbaidhya/AwesomeCache
src/Cache.php
Cache.clearAll
public static function clearAll() { $dir = new \DirectoryIterator(static::config('directory')); foreach ($dir as $fileinfo) { if ($fileinfo->isFile()) { $cacheKey = $fileinfo->getFilename(); static::clear($cacheKey); } } }
php
public static function clearAll() { $dir = new \DirectoryIterator(static::config('directory')); foreach ($dir as $fileinfo) { if ($fileinfo->isFile()) { $cacheKey = $fileinfo->getFilename(); static::clear($cacheKey); } } }
[ "public", "static", "function", "clearAll", "(", ")", "{", "$", "dir", "=", "new", "\\", "DirectoryIterator", "(", "static", "::", "config", "(", "'directory'", ")", ")", ";", "foreach", "(", "$", "dir", "as", "$", "fileinfo", ")", "{", "if", "(", "$", "fileinfo", "->", "isFile", "(", ")", ")", "{", "$", "cacheKey", "=", "$", "fileinfo", "->", "getFilename", "(", ")", ";", "static", "::", "clear", "(", "$", "cacheKey", ")", ";", "}", "}", "}" ]
Clear all the cache data stored in the cache directory @return void
[ "Clear", "all", "the", "cache", "data", "stored", "in", "the", "cache", "directory" ]
ecf6293f3bcb3855133b1a8962c53170af1ebc32
https://github.com/kabirbaidhya/AwesomeCache/blob/ecf6293f3bcb3855133b1a8962c53170af1ebc32/src/Cache.php#L185-L196
15,028
kabirbaidhya/AwesomeCache
src/Cache.php
Cache.countAll
public static function countAll() { $count = 0; $dir = new \DirectoryIterator(static::config('directory')); foreach ($dir as $fileinfo) { if ($fileinfo->isFile()) { $count++; } } return $count; }
php
public static function countAll() { $count = 0; $dir = new \DirectoryIterator(static::config('directory')); foreach ($dir as $fileinfo) { if ($fileinfo->isFile()) { $count++; } } return $count; }
[ "public", "static", "function", "countAll", "(", ")", "{", "$", "count", "=", "0", ";", "$", "dir", "=", "new", "\\", "DirectoryIterator", "(", "static", "::", "config", "(", "'directory'", ")", ")", ";", "foreach", "(", "$", "dir", "as", "$", "fileinfo", ")", "{", "if", "(", "$", "fileinfo", "->", "isFile", "(", ")", ")", "{", "$", "count", "++", ";", "}", "}", "return", "$", "count", ";", "}" ]
Returns the total number of unique cached data @return int
[ "Returns", "the", "total", "number", "of", "unique", "cached", "data" ]
ecf6293f3bcb3855133b1a8962c53170af1ebc32
https://github.com/kabirbaidhya/AwesomeCache/blob/ecf6293f3bcb3855133b1a8962c53170af1ebc32/src/Cache.php#L202-L215
15,029
lodev09/php-util
src/Util.php
Util.slugify
public static function slugify($text, $lowercase = true, $skip_chars = '') { // replace non letter or digits by - $text = preg_replace('~[^\\pL\d'.$skip_chars.']+~u', '-', $text); // trim $text = trim($text, '-'); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // lowercase if ($lowercase) $text = strtolower($text); // remove unwanted characters $text = preg_replace('~[^-\w'.$skip_chars.']+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; }
php
public static function slugify($text, $lowercase = true, $skip_chars = '') { // replace non letter or digits by - $text = preg_replace('~[^\\pL\d'.$skip_chars.']+~u', '-', $text); // trim $text = trim($text, '-'); // transliterate $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); // lowercase if ($lowercase) $text = strtolower($text); // remove unwanted characters $text = preg_replace('~[^-\w'.$skip_chars.']+~', '', $text); if (empty($text)) { return 'n-a'; } return $text; }
[ "public", "static", "function", "slugify", "(", "$", "text", ",", "$", "lowercase", "=", "true", ",", "$", "skip_chars", "=", "''", ")", "{", "// replace non letter or digits by -\r", "$", "text", "=", "preg_replace", "(", "'~[^\\\\pL\\d'", ".", "$", "skip_chars", ".", "']+~u'", ",", "'-'", ",", "$", "text", ")", ";", "// trim\r", "$", "text", "=", "trim", "(", "$", "text", ",", "'-'", ")", ";", "// transliterate\r", "$", "text", "=", "iconv", "(", "'utf-8'", ",", "'us-ascii//TRANSLIT'", ",", "$", "text", ")", ";", "// lowercase\r", "if", "(", "$", "lowercase", ")", "$", "text", "=", "strtolower", "(", "$", "text", ")", ";", "// remove unwanted characters\r", "$", "text", "=", "preg_replace", "(", "'~[^-\\w'", ".", "$", "skip_chars", ".", "']+~'", ",", "''", ",", "$", "text", ")", ";", "if", "(", "empty", "(", "$", "text", ")", ")", "{", "return", "'n-a'", ";", "}", "return", "$", "text", ";", "}" ]
Convert a string to friendly SEO string @param string $text input @return string output
[ "Convert", "a", "string", "to", "friendly", "SEO", "string" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L344-L362
15,030
lodev09/php-util
src/Util.php
Util.set_values
public static function set_values($defaults, $values, $default_key = "") { if ($default_key != "") { if (!is_array($values)) { if (isset($defaults[$default_key])) $defaults[$default_key] = $values; return $defaults; } } if ($values) { foreach ($values as $key => $value) { if (array_key_exists($key, $defaults)) $defaults[$key] = $value; } } return $defaults; }
php
public static function set_values($defaults, $values, $default_key = "") { if ($default_key != "") { if (!is_array($values)) { if (isset($defaults[$default_key])) $defaults[$default_key] = $values; return $defaults; } } if ($values) { foreach ($values as $key => $value) { if (array_key_exists($key, $defaults)) $defaults[$key] = $value; } } return $defaults; }
[ "public", "static", "function", "set_values", "(", "$", "defaults", ",", "$", "values", ",", "$", "default_key", "=", "\"\"", ")", "{", "if", "(", "$", "default_key", "!=", "\"\"", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "if", "(", "isset", "(", "$", "defaults", "[", "$", "default_key", "]", ")", ")", "$", "defaults", "[", "$", "default_key", "]", "=", "$", "values", ";", "return", "$", "defaults", ";", "}", "}", "if", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "defaults", ")", ")", "$", "defaults", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "defaults", ";", "}" ]
Set values from default properties of an array @param array $defaults The defualt array structure @param array $values The input array @param string $default_key Default key if input is a string or something @return array Returns the right array
[ "Set", "values", "from", "default", "properties", "of", "an", "array" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L370-L385
15,031
lodev09/php-util
src/Util.php
Util.read_csv
public static function read_csv($filename, $with_header = true, $headers = null, $delimiter = ',') { $data = []; $index = 0; $header_count = $headers ? count($headers) : 0; $handle = @fopen($filename, "r") or false; if ($handle !== FALSE) { while (($row = fgetcsv($handle, 0, $delimiter)) !== FALSE) { if ($index == 0 && $with_header) { if (!$headers) $headers = $row; $header_count = count($headers); } else { if ($headers) { $column_count = count($row); if ($header_count > $column_count) { $row = array_merge($row, array_fill_keys(range($column_count, $header_count - 1), null)); } else if ($header_count < $column_count) { $extracted = array_splice($row, $header_count); $row[$header_count - 1] = $row[$header_count - 1].'|'.implode('|', $extracted); trigger_error('read_csv: row '.$index.' column mismatch. headers: '.$header_count.', columns: '.$column_count); } $data[] = array_combine($headers, $row); } else { $data[] = $row; } } $index++; } fclose($handle); } return $data; }
php
public static function read_csv($filename, $with_header = true, $headers = null, $delimiter = ',') { $data = []; $index = 0; $header_count = $headers ? count($headers) : 0; $handle = @fopen($filename, "r") or false; if ($handle !== FALSE) { while (($row = fgetcsv($handle, 0, $delimiter)) !== FALSE) { if ($index == 0 && $with_header) { if (!$headers) $headers = $row; $header_count = count($headers); } else { if ($headers) { $column_count = count($row); if ($header_count > $column_count) { $row = array_merge($row, array_fill_keys(range($column_count, $header_count - 1), null)); } else if ($header_count < $column_count) { $extracted = array_splice($row, $header_count); $row[$header_count - 1] = $row[$header_count - 1].'|'.implode('|', $extracted); trigger_error('read_csv: row '.$index.' column mismatch. headers: '.$header_count.', columns: '.$column_count); } $data[] = array_combine($headers, $row); } else { $data[] = $row; } } $index++; } fclose($handle); } return $data; }
[ "public", "static", "function", "read_csv", "(", "$", "filename", ",", "$", "with_header", "=", "true", ",", "$", "headers", "=", "null", ",", "$", "delimiter", "=", "','", ")", "{", "$", "data", "=", "[", "]", ";", "$", "index", "=", "0", ";", "$", "header_count", "=", "$", "headers", "?", "count", "(", "$", "headers", ")", ":", "0", ";", "$", "handle", "=", "@", "fopen", "(", "$", "filename", ",", "\"r\"", ")", "or", "false", ";", "if", "(", "$", "handle", "!==", "FALSE", ")", "{", "while", "(", "(", "$", "row", "=", "fgetcsv", "(", "$", "handle", ",", "0", ",", "$", "delimiter", ")", ")", "!==", "FALSE", ")", "{", "if", "(", "$", "index", "==", "0", "&&", "$", "with_header", ")", "{", "if", "(", "!", "$", "headers", ")", "$", "headers", "=", "$", "row", ";", "$", "header_count", "=", "count", "(", "$", "headers", ")", ";", "}", "else", "{", "if", "(", "$", "headers", ")", "{", "$", "column_count", "=", "count", "(", "$", "row", ")", ";", "if", "(", "$", "header_count", ">", "$", "column_count", ")", "{", "$", "row", "=", "array_merge", "(", "$", "row", ",", "array_fill_keys", "(", "range", "(", "$", "column_count", ",", "$", "header_count", "-", "1", ")", ",", "null", ")", ")", ";", "}", "else", "if", "(", "$", "header_count", "<", "$", "column_count", ")", "{", "$", "extracted", "=", "array_splice", "(", "$", "row", ",", "$", "header_count", ")", ";", "$", "row", "[", "$", "header_count", "-", "1", "]", "=", "$", "row", "[", "$", "header_count", "-", "1", "]", ".", "'|'", ".", "implode", "(", "'|'", ",", "$", "extracted", ")", ";", "trigger_error", "(", "'read_csv: row '", ".", "$", "index", ".", "' column mismatch. headers: '", ".", "$", "header_count", ".", "', columns: '", ".", "$", "column_count", ")", ";", "}", "$", "data", "[", "]", "=", "array_combine", "(", "$", "headers", ",", "$", "row", ")", ";", "}", "else", "{", "$", "data", "[", "]", "=", "$", "row", ";", "}", "}", "$", "index", "++", ";", "}", "fclose", "(", "$", "handle", ")", ";", "}", "return", "$", "data", ";", "}" ]
Read CSV from URL or File @param string $filename Filename @param string $headers Delimiter @return array [description]
[ "Read", "CSV", "from", "URL", "or", "File" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L392-L427
15,032
lodev09/php-util
src/Util.php
Util.parse_email
public static function parse_email($str, $separator = ",") { $str = trim(preg_replace('/\s+/', ' ', $str)); $all = []; $emails = preg_split('/(".*?"\s*<.+?>)\s*' . $separator . '*|' . $separator . '+/', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($emails as $email) { $name = ""; $email = trim($email); $email_info = new stdClass; if (preg_match('/(.*?)<(.*)>/', $email, $regs)) { $email_info->name = trim(trim($regs[1]) , '"'); $email_info->email = trim($regs[2]); } else { $email_info->name = $email; $email_info->email = $email; } if (strpos($email_info->email, $separator) !== false) { $addtl_emails = parse_email($email_info->email, $separator); foreach ($addtl_emails as $addtl_email_info) { if ($addtl_email_info->name == "" || $addtl_email_info->name == $addtl_email_info->email) $addtl_email_info->name = $email_info->name; $all[] = $addtl_email_info; } } else { if (filter_var($email_info->email, FILTER_VALIDATE_EMAIL)) $all[] = $email_info; } } return $all; }
php
public static function parse_email($str, $separator = ",") { $str = trim(preg_replace('/\s+/', ' ', $str)); $all = []; $emails = preg_split('/(".*?"\s*<.+?>)\s*' . $separator . '*|' . $separator . '+/', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); foreach ($emails as $email) { $name = ""; $email = trim($email); $email_info = new stdClass; if (preg_match('/(.*?)<(.*)>/', $email, $regs)) { $email_info->name = trim(trim($regs[1]) , '"'); $email_info->email = trim($regs[2]); } else { $email_info->name = $email; $email_info->email = $email; } if (strpos($email_info->email, $separator) !== false) { $addtl_emails = parse_email($email_info->email, $separator); foreach ($addtl_emails as $addtl_email_info) { if ($addtl_email_info->name == "" || $addtl_email_info->name == $addtl_email_info->email) $addtl_email_info->name = $email_info->name; $all[] = $addtl_email_info; } } else { if (filter_var($email_info->email, FILTER_VALIDATE_EMAIL)) $all[] = $email_info; } } return $all; }
[ "public", "static", "function", "parse_email", "(", "$", "str", ",", "$", "separator", "=", "\",\"", ")", "{", "$", "str", "=", "trim", "(", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", "str", ")", ")", ";", "$", "all", "=", "[", "]", ";", "$", "emails", "=", "preg_split", "(", "'/(\".*?\"\\s*<.+?>)\\s*'", ".", "$", "separator", ".", "'*|'", ".", "$", "separator", ".", "'+/'", ",", "$", "str", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ")", ";", "foreach", "(", "$", "emails", "as", "$", "email", ")", "{", "$", "name", "=", "\"\"", ";", "$", "email", "=", "trim", "(", "$", "email", ")", ";", "$", "email_info", "=", "new", "stdClass", ";", "if", "(", "preg_match", "(", "'/(.*?)<(.*)>/'", ",", "$", "email", ",", "$", "regs", ")", ")", "{", "$", "email_info", "->", "name", "=", "trim", "(", "trim", "(", "$", "regs", "[", "1", "]", ")", ",", "'\"'", ")", ";", "$", "email_info", "->", "email", "=", "trim", "(", "$", "regs", "[", "2", "]", ")", ";", "}", "else", "{", "$", "email_info", "->", "name", "=", "$", "email", ";", "$", "email_info", "->", "email", "=", "$", "email", ";", "}", "if", "(", "strpos", "(", "$", "email_info", "->", "email", ",", "$", "separator", ")", "!==", "false", ")", "{", "$", "addtl_emails", "=", "parse_email", "(", "$", "email_info", "->", "email", ",", "$", "separator", ")", ";", "foreach", "(", "$", "addtl_emails", "as", "$", "addtl_email_info", ")", "{", "if", "(", "$", "addtl_email_info", "->", "name", "==", "\"\"", "||", "$", "addtl_email_info", "->", "name", "==", "$", "addtl_email_info", "->", "email", ")", "$", "addtl_email_info", "->", "name", "=", "$", "email_info", "->", "name", ";", "$", "all", "[", "]", "=", "$", "addtl_email_info", ";", "}", "}", "else", "{", "if", "(", "filter_var", "(", "$", "email_info", "->", "email", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "$", "all", "[", "]", "=", "$", "email_info", ";", "}", "}", "return", "$", "all", ";", "}" ]
Parse email address string @param string $str string input @param string $separator separator, default "," @return array array
[ "Parse", "email", "address", "string" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L434-L463
15,033
lodev09/php-util
src/Util.php
Util.get_session_info
public static function get_session_info() { $browser_info = get_browser_info(); $result = new stdClass; $result->ip = get_client_ip(); $result->browser_info = (object)$browser_info; return $result; }
php
public static function get_session_info() { $browser_info = get_browser_info(); $result = new stdClass; $result->ip = get_client_ip(); $result->browser_info = (object)$browser_info; return $result; }
[ "public", "static", "function", "get_session_info", "(", ")", "{", "$", "browser_info", "=", "get_browser_info", "(", ")", ";", "$", "result", "=", "new", "stdClass", ";", "$", "result", "->", "ip", "=", "get_client_ip", "(", ")", ";", "$", "result", "->", "browser_info", "=", "(", "object", ")", "$", "browser_info", ";", "return", "$", "result", ";", "}" ]
Store client session info to an object @return stdClass returns the object containing details of the session
[ "Store", "client", "session", "info", "to", "an", "object" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L468-L475
15,034
lodev09/php-util
src/Util.php
Util.get_client_ip
public static function get_client_ip() { $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if (getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if (getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if (getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if (getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if (getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; return $ipaddress; }
php
public static function get_client_ip() { $ipaddress = ''; if (getenv('HTTP_CLIENT_IP')) $ipaddress = getenv('HTTP_CLIENT_IP'); else if (getenv('HTTP_X_FORWARDED_FOR')) $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); else if (getenv('HTTP_X_FORWARDED')) $ipaddress = getenv('HTTP_X_FORWARDED'); else if (getenv('HTTP_FORWARDED_FOR')) $ipaddress = getenv('HTTP_FORWARDED_FOR'); else if (getenv('HTTP_FORWARDED')) $ipaddress = getenv('HTTP_FORWARDED'); else if (getenv('REMOTE_ADDR')) $ipaddress = getenv('REMOTE_ADDR'); else $ipaddress = 'UNKNOWN'; return $ipaddress; }
[ "public", "static", "function", "get_client_ip", "(", ")", "{", "$", "ipaddress", "=", "''", ";", "if", "(", "getenv", "(", "'HTTP_CLIENT_IP'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'HTTP_CLIENT_IP'", ")", ";", "else", "if", "(", "getenv", "(", "'HTTP_X_FORWARDED_FOR'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'HTTP_X_FORWARDED_FOR'", ")", ";", "else", "if", "(", "getenv", "(", "'HTTP_X_FORWARDED'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'HTTP_X_FORWARDED'", ")", ";", "else", "if", "(", "getenv", "(", "'HTTP_FORWARDED_FOR'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'HTTP_FORWARDED_FOR'", ")", ";", "else", "if", "(", "getenv", "(", "'HTTP_FORWARDED'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'HTTP_FORWARDED'", ")", ";", "else", "if", "(", "getenv", "(", "'REMOTE_ADDR'", ")", ")", "$", "ipaddress", "=", "getenv", "(", "'REMOTE_ADDR'", ")", ";", "else", "$", "ipaddress", "=", "'UNKNOWN'", ";", "return", "$", "ipaddress", ";", "}" ]
Get the client's IP Address @return string IP address string
[ "Get", "the", "client", "s", "IP", "Address" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L516-L526
15,035
lodev09/php-util
src/Util.php
Util.get_browser_info
public static function get_browser_info() { $u_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'UNKNOWN'; $bname = 'Unknown'; $platform = 'Unknown'; $ub = 'Unknown'; $version = ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; } // Next get the name of the useragent yes seperately and for good reason if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif (preg_match('/Firefox/i', $u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif (preg_match('/Chrome/i', $u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif (preg_match('/Safari/i', $u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif (preg_match('/Opera/i', $u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif (preg_match('/Netscape/i', $u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } // finally get the correct version number $known = [ 'Version', $ub, 'other' ]; $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $u_agent, $matches)) { // we have no matching number just continue } else { // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($u_agent, "Version") < strripos($u_agent, $ub)) { $version = $matches['version'][0]; } else { $version = $matches['version'][1]; } } else { $version = $matches['version'][0]; } } // check if we have a number if ($version == null || $version == "") { $version = "?"; } return [ 'user_agent' => $u_agent, 'name' => $bname, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern ]; }
php
public static function get_browser_info() { $u_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'UNKNOWN'; $bname = 'Unknown'; $platform = 'Unknown'; $ub = 'Unknown'; $version = ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; } // Next get the name of the useragent yes seperately and for good reason if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif (preg_match('/Firefox/i', $u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif (preg_match('/Chrome/i', $u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif (preg_match('/Safari/i', $u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif (preg_match('/Opera/i', $u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif (preg_match('/Netscape/i', $u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } // finally get the correct version number $known = [ 'Version', $ub, 'other' ]; $pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $u_agent, $matches)) { // we have no matching number just continue } else { // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($u_agent, "Version") < strripos($u_agent, $ub)) { $version = $matches['version'][0]; } else { $version = $matches['version'][1]; } } else { $version = $matches['version'][0]; } } // check if we have a number if ($version == null || $version == "") { $version = "?"; } return [ 'user_agent' => $u_agent, 'name' => $bname, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern ]; }
[ "public", "static", "function", "get_browser_info", "(", ")", "{", "$", "u_agent", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "'UNKNOWN'", ";", "$", "bname", "=", "'Unknown'", ";", "$", "platform", "=", "'Unknown'", ";", "$", "ub", "=", "'Unknown'", ";", "$", "version", "=", "\"\"", ";", "//First get the platform?\r", "if", "(", "preg_match", "(", "'/linux/i'", ",", "$", "u_agent", ")", ")", "{", "$", "platform", "=", "'linux'", ";", "}", "elseif", "(", "preg_match", "(", "'/macintosh|mac os x/i'", ",", "$", "u_agent", ")", ")", "{", "$", "platform", "=", "'mac'", ";", "}", "elseif", "(", "preg_match", "(", "'/windows|win32/i'", ",", "$", "u_agent", ")", ")", "{", "$", "platform", "=", "'windows'", ";", "}", "// Next get the name of the useragent yes seperately and for good reason\r", "if", "(", "preg_match", "(", "'/MSIE/i'", ",", "$", "u_agent", ")", "&&", "!", "preg_match", "(", "'/Opera/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Internet Explorer'", ";", "$", "ub", "=", "\"MSIE\"", ";", "}", "elseif", "(", "preg_match", "(", "'/Firefox/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Mozilla Firefox'", ";", "$", "ub", "=", "\"Firefox\"", ";", "}", "elseif", "(", "preg_match", "(", "'/Chrome/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Google Chrome'", ";", "$", "ub", "=", "\"Chrome\"", ";", "}", "elseif", "(", "preg_match", "(", "'/Safari/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Apple Safari'", ";", "$", "ub", "=", "\"Safari\"", ";", "}", "elseif", "(", "preg_match", "(", "'/Opera/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Opera'", ";", "$", "ub", "=", "\"Opera\"", ";", "}", "elseif", "(", "preg_match", "(", "'/Netscape/i'", ",", "$", "u_agent", ")", ")", "{", "$", "bname", "=", "'Netscape'", ";", "$", "ub", "=", "\"Netscape\"", ";", "}", "// finally get the correct version number\r", "$", "known", "=", "[", "'Version'", ",", "$", "ub", ",", "'other'", "]", ";", "$", "pattern", "=", "'#(?<browser>'", ".", "join", "(", "'|'", ",", "$", "known", ")", ".", "')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'", ";", "if", "(", "!", "preg_match_all", "(", "$", "pattern", ",", "$", "u_agent", ",", "$", "matches", ")", ")", "{", "// we have no matching number just continue\r", "}", "else", "{", "// see how many we have\r", "$", "i", "=", "count", "(", "$", "matches", "[", "'browser'", "]", ")", ";", "if", "(", "$", "i", "!=", "1", ")", "{", "//we will have two since we are not using 'other' argument yet\r", "//see if version is before or after the name\r", "if", "(", "strripos", "(", "$", "u_agent", ",", "\"Version\"", ")", "<", "strripos", "(", "$", "u_agent", ",", "$", "ub", ")", ")", "{", "$", "version", "=", "$", "matches", "[", "'version'", "]", "[", "0", "]", ";", "}", "else", "{", "$", "version", "=", "$", "matches", "[", "'version'", "]", "[", "1", "]", ";", "}", "}", "else", "{", "$", "version", "=", "$", "matches", "[", "'version'", "]", "[", "0", "]", ";", "}", "}", "// check if we have a number\r", "if", "(", "$", "version", "==", "null", "||", "$", "version", "==", "\"\"", ")", "{", "$", "version", "=", "\"?\"", ";", "}", "return", "[", "'user_agent'", "=>", "$", "u_agent", ",", "'name'", "=>", "$", "bname", ",", "'version'", "=>", "$", "version", ",", "'platform'", "=>", "$", "platform", ",", "'pattern'", "=>", "$", "pattern", "]", ";", "}" ]
Get your browser's info @return stdClass returns the object containing the info of your browser
[ "Get", "your", "browser", "s", "info" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L531-L602
15,036
lodev09/php-util
src/Util.php
Util.encrypt
public static function encrypt($data, $key, $iv) { $output = false; $encrypt_method = "AES-256-CBC"; // hash $key = hash_hmac('sha256', $data, $iv); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr($iv, 0, 16); $output = openssl_encrypt($data, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); return $output; }
php
public static function encrypt($data, $key, $iv) { $output = false; $encrypt_method = "AES-256-CBC"; // hash $key = hash_hmac('sha256', $data, $iv); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr($iv, 0, 16); $output = openssl_encrypt($data, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); return $output; }
[ "public", "static", "function", "encrypt", "(", "$", "data", ",", "$", "key", ",", "$", "iv", ")", "{", "$", "output", "=", "false", ";", "$", "encrypt_method", "=", "\"AES-256-CBC\"", ";", "// hash\r", "$", "key", "=", "hash_hmac", "(", "'sha256'", ",", "$", "data", ",", "$", "iv", ")", ";", "// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning\r", "$", "iv", "=", "substr", "(", "$", "iv", ",", "0", ",", "16", ")", ";", "$", "output", "=", "openssl_encrypt", "(", "$", "data", ",", "$", "encrypt_method", ",", "$", "key", ",", "0", ",", "$", "iv", ")", ";", "$", "output", "=", "base64_encode", "(", "$", "output", ")", ";", "return", "$", "output", ";", "}" ]
Returns an base64 encoded encrypted string
[ "Returns", "an", "base64", "encoded", "encrypted", "string" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L607-L619
15,037
lodev09/php-util
src/Util.php
Util.decrypt
public static function decrypt($data, $key, $iv) { $output = false; $encrypt_method = "AES-256-CBC"; // hash $key = hash_hmac('sha256', $data, $iv); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr($iv, 0, 16); $output = openssl_decrypt(base64_decode($data), $encrypt_method, $key, 0, $iv); return $output; }
php
public static function decrypt($data, $key, $iv) { $output = false; $encrypt_method = "AES-256-CBC"; // hash $key = hash_hmac('sha256', $data, $iv); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr($iv, 0, 16); $output = openssl_decrypt(base64_decode($data), $encrypt_method, $key, 0, $iv); return $output; }
[ "public", "static", "function", "decrypt", "(", "$", "data", ",", "$", "key", ",", "$", "iv", ")", "{", "$", "output", "=", "false", ";", "$", "encrypt_method", "=", "\"AES-256-CBC\"", ";", "// hash\r", "$", "key", "=", "hash_hmac", "(", "'sha256'", ",", "$", "data", ",", "$", "iv", ")", ";", "// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning\r", "$", "iv", "=", "substr", "(", "$", "iv", ",", "0", ",", "16", ")", ";", "$", "output", "=", "openssl_decrypt", "(", "base64_decode", "(", "$", "data", ")", ",", "$", "encrypt_method", ",", "$", "key", ",", "0", ",", "$", "iv", ")", ";", "return", "$", "output", ";", "}" ]
Returns decrypted original string
[ "Returns", "decrypted", "original", "string" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L624-L635
15,038
lodev09/php-util
src/Util.php
Util.to_array
public static function to_array($object) { if (is_array($object)) return $object; if (!is_object($object) && !is_array($object)) return $object; if (is_object($object)) $object = get_object_vars($object); return array_map([ __CLASS__, 'to_array' ], $object); }
php
public static function to_array($object) { if (is_array($object)) return $object; if (!is_object($object) && !is_array($object)) return $object; if (is_object($object)) $object = get_object_vars($object); return array_map([ __CLASS__, 'to_array' ], $object); }
[ "public", "static", "function", "to_array", "(", "$", "object", ")", "{", "if", "(", "is_array", "(", "$", "object", ")", ")", "return", "$", "object", ";", "if", "(", "!", "is_object", "(", "$", "object", ")", "&&", "!", "is_array", "(", "$", "object", ")", ")", "return", "$", "object", ";", "if", "(", "is_object", "(", "$", "object", ")", ")", "$", "object", "=", "get_object_vars", "(", "$", "object", ")", ";", "return", "array_map", "(", "[", "__CLASS__", ",", "'to_array'", "]", ",", "$", "object", ")", ";", "}" ]
Convert an object to an array @param object $object The object to convert @reeturn array
[ "Convert", "an", "object", "to", "an", "array" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L865-L874
15,039
lodev09/php-util
src/Util.php
Util.zip
public static function zip($files = [], $destination = '', $overwrite = false) { // if the zip file already exists and overwrite is false, return false if (file_exists($destination) && !$overwrite) { return false; } $valid_files = []; $files = is_array($files) ? $files : [$files]; // if files were passed in... if ($files) { // cycle through each file foreach ($files as $filename => $file) { // make sure the file exists if (file_exists($file)) { if (is_int($filename)) $filename = basename($file); $valid_files[$filename] = $file; } } } // if we have good files... if (count($valid_files)) { // create the archive $zip = new \ZipArchive(); if ($zip->open($destination, \ZipArchive::OVERWRITE | \ZipArchive::CREATE) !== true) { return false; } // add the files foreach ($valid_files as $filename => $file) { $zip->addFile($file, $filename); } // close the zip -- done! $zip->close(); // check to make sure the file exists return file_exists($destination); } else { return false; } }
php
public static function zip($files = [], $destination = '', $overwrite = false) { // if the zip file already exists and overwrite is false, return false if (file_exists($destination) && !$overwrite) { return false; } $valid_files = []; $files = is_array($files) ? $files : [$files]; // if files were passed in... if ($files) { // cycle through each file foreach ($files as $filename => $file) { // make sure the file exists if (file_exists($file)) { if (is_int($filename)) $filename = basename($file); $valid_files[$filename] = $file; } } } // if we have good files... if (count($valid_files)) { // create the archive $zip = new \ZipArchive(); if ($zip->open($destination, \ZipArchive::OVERWRITE | \ZipArchive::CREATE) !== true) { return false; } // add the files foreach ($valid_files as $filename => $file) { $zip->addFile($file, $filename); } // close the zip -- done! $zip->close(); // check to make sure the file exists return file_exists($destination); } else { return false; } }
[ "public", "static", "function", "zip", "(", "$", "files", "=", "[", "]", ",", "$", "destination", "=", "''", ",", "$", "overwrite", "=", "false", ")", "{", "// if the zip file already exists and overwrite is false, return false\r", "if", "(", "file_exists", "(", "$", "destination", ")", "&&", "!", "$", "overwrite", ")", "{", "return", "false", ";", "}", "$", "valid_files", "=", "[", "]", ";", "$", "files", "=", "is_array", "(", "$", "files", ")", "?", "$", "files", ":", "[", "$", "files", "]", ";", "// if files were passed in...\r", "if", "(", "$", "files", ")", "{", "// cycle through each file\r", "foreach", "(", "$", "files", "as", "$", "filename", "=>", "$", "file", ")", "{", "// make sure the file exists\r", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "is_int", "(", "$", "filename", ")", ")", "$", "filename", "=", "basename", "(", "$", "file", ")", ";", "$", "valid_files", "[", "$", "filename", "]", "=", "$", "file", ";", "}", "}", "}", "// if we have good files...\r", "if", "(", "count", "(", "$", "valid_files", ")", ")", "{", "// create the archive\r", "$", "zip", "=", "new", "\\", "ZipArchive", "(", ")", ";", "if", "(", "$", "zip", "->", "open", "(", "$", "destination", ",", "\\", "ZipArchive", "::", "OVERWRITE", "|", "\\", "ZipArchive", "::", "CREATE", ")", "!==", "true", ")", "{", "return", "false", ";", "}", "// add the files\r", "foreach", "(", "$", "valid_files", "as", "$", "filename", "=>", "$", "file", ")", "{", "$", "zip", "->", "addFile", "(", "$", "file", ",", "$", "filename", ")", ";", "}", "// close the zip -- done!\r", "$", "zip", "->", "close", "(", ")", ";", "// check to make sure the file exists\r", "return", "file_exists", "(", "$", "destination", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Create a compressed zip file @param array $files files (filename => file_location) @param string $destination destination of the zip file @param boolean $overwrite overwrite if zip file exists @return [type] true if success, otherwise false
[ "Create", "a", "compressed", "zip", "file" ]
8f3adb0b1bbc1c9f71cab126fdf8110414e65515
https://github.com/lodev09/php-util/blob/8f3adb0b1bbc1c9f71cab126fdf8110414e65515/src/Util.php#L1024-L1064
15,040
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Base.php
Base.init
public function init() { $this->version = $this->read(true); if(!$this->login()) return false; return true; }
php
public function init() { $this->version = $this->read(true); if(!$this->login()) return false; return true; }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "version", "=", "$", "this", "->", "read", "(", "true", ")", ";", "if", "(", "!", "$", "this", "->", "login", "(", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Initializes Connection and Log's In @return bool
[ "Initializes", "Connection", "and", "Log", "s", "In" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Base.php#L65-L72
15,041
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Base.php
Base.connect
public function connect(&$cn = 1, &$cs = "Unknown error") { $fp = fsockopen($this->ip, $this->port, $cn, $cs, 3) or die("Could not connect. " . date("Y-m-d H:i:s") . PHP_EOL); if (!$fp) { return false; } else { self::$socket = $fp; return true; } }
php
public function connect(&$cn = 1, &$cs = "Unknown error") { $fp = fsockopen($this->ip, $this->port, $cn, $cs, 3) or die("Could not connect. " . date("Y-m-d H:i:s") . PHP_EOL); if (!$fp) { return false; } else { self::$socket = $fp; return true; } }
[ "public", "function", "connect", "(", "&", "$", "cn", "=", "1", ",", "&", "$", "cs", "=", "\"Unknown error\"", ")", "{", "$", "fp", "=", "fsockopen", "(", "$", "this", "->", "ip", ",", "$", "this", "->", "port", ",", "$", "cn", ",", "$", "cs", ",", "3", ")", "or", "die", "(", "\"Could not connect. \"", ".", "date", "(", "\"Y-m-d H:i:s\"", ")", ".", "PHP_EOL", ")", ";", "if", "(", "!", "$", "fp", ")", "{", "return", "false", ";", "}", "else", "{", "self", "::", "$", "socket", "=", "$", "fp", ";", "return", "true", ";", "}", "}" ]
Connect with server @param int &$cn number of error @param string &$cs detailed error message @access public @return int
[ "Connect", "with", "server" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Base.php#L83-L93
15,042
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Base.php
Base.login
protected function login() { return $this->query('login '.md5(substr($this->read(true), 17) . $this->pwd)) == 'Authentication successful, rcon ready.'; }
php
protected function login() { return $this->query('login '.md5(substr($this->read(true), 17) . $this->pwd)) == 'Authentication successful, rcon ready.'; }
[ "protected", "function", "login", "(", ")", "{", "return", "$", "this", "->", "query", "(", "'login '", ".", "md5", "(", "substr", "(", "$", "this", "->", "read", "(", "true", ")", ",", "17", ")", ".", "$", "this", "->", "pwd", ")", ")", "==", "'Authentication successful, rcon ready.'", ";", "}" ]
Tries to Login @access protected @return bool
[ "Tries", "to", "Login" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Base.php#L101-L104
15,043
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Base.php
Base.query
public static function query($line, $bare = false) { self::write($line, $bare); if(strpos($result = self::read($bare), 'rcon: unknown command:') === 0) return false; return $result; }
php
public static function query($line, $bare = false) { self::write($line, $bare); if(strpos($result = self::read($bare), 'rcon: unknown command:') === 0) return false; return $result; }
[ "public", "static", "function", "query", "(", "$", "line", ",", "$", "bare", "=", "false", ")", "{", "self", "::", "write", "(", "$", "line", ",", "$", "bare", ")", ";", "if", "(", "strpos", "(", "$", "result", "=", "self", "::", "read", "(", "$", "bare", ")", ",", "'rcon: unknown command:'", ")", "===", "0", ")", "return", "false", ";", "return", "$", "result", ";", "}" ]
Executes a Query on the Server @param string $line @param bool $bare @return string
[ "Executes", "a", "Query", "on", "the", "Server" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Base.php#L114-L121
15,044
piqus/bfp4f-rcon
src/T4G/BFP4F/Rcon/Base.php
Base.read
protected static function read($bare = false) { $delim = $bare ? "\n" : "\x04"; for($buffer = '';($char = fgetc(self::$socket)) != $delim;$buffer .= $char); return trim($buffer); }
php
protected static function read($bare = false) { $delim = $bare ? "\n" : "\x04"; for($buffer = '';($char = fgetc(self::$socket)) != $delim;$buffer .= $char); return trim($buffer); }
[ "protected", "static", "function", "read", "(", "$", "bare", "=", "false", ")", "{", "$", "delim", "=", "$", "bare", "?", "\"\\n\"", ":", "\"\\x04\"", ";", "for", "(", "$", "buffer", "=", "''", ";", "(", "$", "char", "=", "fgetc", "(", "self", "::", "$", "socket", ")", ")", "!=", "$", "delim", ";", "$", "buffer", ".=", "$", "char", ")", ";", "return", "trim", "(", "$", "buffer", ")", ";", "}" ]
Reads the Buffer @param bool $bare @return string
[ "Reads", "the", "Buffer" ]
8e94587bc93c686e5a025a54645aed7c701811e6
https://github.com/piqus/bfp4f-rcon/blob/8e94587bc93c686e5a025a54645aed7c701811e6/src/T4G/BFP4F/Rcon/Base.php#L143-L150
15,045
dreamfactorysoftware/df-azure
src/Resources/DocumentDbTable.php
DocumentDbTable.cleanOrderBy
private function cleanOrderBy($table, $orderBy) { if (!empty($orderBy)) { $orderByArray = explode(',', $orderBy); foreach ($orderByArray as $k => $order) { $orderByArray[$k] = $table . '.' . $order; } $orderBy = implode(',', $orderByArray); } return $orderBy; }
php
private function cleanOrderBy($table, $orderBy) { if (!empty($orderBy)) { $orderByArray = explode(',', $orderBy); foreach ($orderByArray as $k => $order) { $orderByArray[$k] = $table . '.' . $order; } $orderBy = implode(',', $orderByArray); } return $orderBy; }
[ "private", "function", "cleanOrderBy", "(", "$", "table", ",", "$", "orderBy", ")", "{", "if", "(", "!", "empty", "(", "$", "orderBy", ")", ")", "{", "$", "orderByArray", "=", "explode", "(", "','", ",", "$", "orderBy", ")", ";", "foreach", "(", "$", "orderByArray", "as", "$", "k", "=>", "$", "order", ")", "{", "$", "orderByArray", "[", "$", "k", "]", "=", "$", "table", ".", "'.'", ".", "$", "order", ";", "}", "$", "orderBy", "=", "implode", "(", "','", ",", "$", "orderByArray", ")", ";", "}", "return", "$", "orderBy", ";", "}" ]
Cleans order by clause @param $table @param $orderBy @return string
[ "Cleans", "order", "by", "clause" ]
48dff2796dc544344c0c7badaaa6917f1bcd623f
https://github.com/dreamfactorysoftware/df-azure/blob/48dff2796dc544344c0c7badaaa6917f1bcd623f/src/Resources/DocumentDbTable.php#L501-L512
15,046
dreamfactorysoftware/df-azure
src/Resources/DocumentDbTable.php
DocumentDbTable.mergeRecords
protected function mergeRecords(array $records) { foreach ($records as $key => $record) { if (null === $id = array_get($record, static::ID_FIELD)) { throw new InternalServerErrorException('No ' . static::ID_FIELD . ' field found in supplied record(s). Cannot merge record(s) for PATCH operation.'); } $rs = $this->getConnection()->getDocument($this->transactionTable, $id); $record = array_merge($rs, $record); $records[$key] = $record; } return $records; }
php
protected function mergeRecords(array $records) { foreach ($records as $key => $record) { if (null === $id = array_get($record, static::ID_FIELD)) { throw new InternalServerErrorException('No ' . static::ID_FIELD . ' field found in supplied record(s). Cannot merge record(s) for PATCH operation.'); } $rs = $this->getConnection()->getDocument($this->transactionTable, $id); $record = array_merge($rs, $record); $records[$key] = $record; } return $records; }
[ "protected", "function", "mergeRecords", "(", "array", "$", "records", ")", "{", "foreach", "(", "$", "records", "as", "$", "key", "=>", "$", "record", ")", "{", "if", "(", "null", "===", "$", "id", "=", "array_get", "(", "$", "record", ",", "static", "::", "ID_FIELD", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No '", ".", "static", "::", "ID_FIELD", ".", "' field found in supplied record(s). Cannot merge record(s) for PATCH operation.'", ")", ";", "}", "$", "rs", "=", "$", "this", "->", "getConnection", "(", ")", "->", "getDocument", "(", "$", "this", "->", "transactionTable", ",", "$", "id", ")", ";", "$", "record", "=", "array_merge", "(", "$", "rs", ",", "$", "record", ")", ";", "$", "records", "[", "$", "key", "]", "=", "$", "record", ";", "}", "return", "$", "records", ";", "}" ]
Merges new record with existing record to perform PATCH operation @param array $records @return array @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Merges", "new", "record", "with", "existing", "record", "to", "perform", "PATCH", "operation" ]
48dff2796dc544344c0c7badaaa6917f1bcd623f
https://github.com/dreamfactorysoftware/df-azure/blob/48dff2796dc544344c0c7badaaa6917f1bcd623f/src/Resources/DocumentDbTable.php#L791-L806
15,047
awesomite/chariot
src/Reflections/Objects.php
Objects.getProperty
public static function getProperty($object, string $propertyName) { $reflection = new \ReflectionObject($object); $property = $reflection->getProperty($propertyName); $property->setAccessible(true); return $property->getValue($object); }
php
public static function getProperty($object, string $propertyName) { $reflection = new \ReflectionObject($object); $property = $reflection->getProperty($propertyName); $property->setAccessible(true); return $property->getValue($object); }
[ "public", "static", "function", "getProperty", "(", "$", "object", ",", "string", "$", "propertyName", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionObject", "(", "$", "object", ")", ";", "$", "property", "=", "$", "reflection", "->", "getProperty", "(", "$", "propertyName", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "}" ]
Reads also private and protected properties @param $object @param string $propertyName @return mixed
[ "Reads", "also", "private", "and", "protected", "properties" ]
3229e38537b857be1d352308ba340dc530b12afb
https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Reflections/Objects.php#L25-L32
15,048
nick-jones/globby
lib/Globby/Tokenizer/Glob.php
Glob.parse
public function parse($pattern) { $lexer = $this->createLexer(); try { $result = $lexer->lex($pattern); } catch (LexingException $e) { $message = sprintf('Lexing failed with error: %s', $e->getMessage()); throw new TokenizeException($message, 0, $e); } // If the lexer still has state, then it reached the end of the pattern prematurely. An example of when this // can happen is unclosed character groupings (e.g. "foo[a-z") - lack of closing bracket will mean the lexer // does not pop out of the IN_GROUP state. if ($lexer->hasPushedStates()) { throw new TokenizeException('Premature end of pattern'); } return $result; }
php
public function parse($pattern) { $lexer = $this->createLexer(); try { $result = $lexer->lex($pattern); } catch (LexingException $e) { $message = sprintf('Lexing failed with error: %s', $e->getMessage()); throw new TokenizeException($message, 0, $e); } // If the lexer still has state, then it reached the end of the pattern prematurely. An example of when this // can happen is unclosed character groupings (e.g. "foo[a-z") - lack of closing bracket will mean the lexer // does not pop out of the IN_GROUP state. if ($lexer->hasPushedStates()) { throw new TokenizeException('Premature end of pattern'); } return $result; }
[ "public", "function", "parse", "(", "$", "pattern", ")", "{", "$", "lexer", "=", "$", "this", "->", "createLexer", "(", ")", ";", "try", "{", "$", "result", "=", "$", "lexer", "->", "lex", "(", "$", "pattern", ")", ";", "}", "catch", "(", "LexingException", "$", "e", ")", "{", "$", "message", "=", "sprintf", "(", "'Lexing failed with error: %s'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "throw", "new", "TokenizeException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "}", "// If the lexer still has state, then it reached the end of the pattern prematurely. An example of when this", "// can happen is unclosed character groupings (e.g. \"foo[a-z\") - lack of closing bracket will mean the lexer", "// does not pop out of the IN_GROUP state.", "if", "(", "$", "lexer", "->", "hasPushedStates", "(", ")", ")", "{", "throw", "new", "TokenizeException", "(", "'Premature end of pattern'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Parses the pattern to produce an array of token identifiers. @param string $pattern @return array @throws TokenizeException
[ "Parses", "the", "pattern", "to", "produce", "an", "array", "of", "token", "identifiers", "." ]
5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4
https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Tokenizer/Glob.php#L46-L65
15,049
nick-jones/globby
lib/Globby/Tokenizer/Glob.php
Glob.createInitialDefinition
protected function createInitialDefinition() { return [ /* * Match against non-special characters. To explain the components of this: * * [^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)* * - This matches non-special (\*[?) characters. If it matches one, it'll permit it to be an escape * (i.e. \) if a character exists after it (which may be "special"). This then returns to the previous * matching pattern, repeating the same rules until a non-escaped "special" character is hit. * * (?:\\\\.[^\\\\*\[?]*)+ * - This immediately looks for escape characters, as the previous component of this regex requires for the * initial character to be non-special. This then returns to the standard rules the previous regex. */ '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self::T_WORD, // Simple match of "*" '\*' => self::T_WILDCARD_MULTI, // Simple match of "?" '\?' => self::T_WILDCARD_SINGLE, /* * Matches against [. This also optionally matches "!" or "^" as the first character to provide negation * context. The positive lookahead provides a means to check for "]" as the first character. This is a * slightly nasty hack to deal with a rule that "]" can be permitted as a standard character in a character, * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure * it's captured by adding a capturing group inside (regex lookarounds do not capture). */ '\[([!^]?)(?=(\])?)' => function (Stateful $lexer, $matches) { // Determine the state to enter (depending on whether the lookahead succeeded, i.e. "]" is the first // character of the grouping) $state = isset($matches[2]) ? 'IN_GROUP_SPECIAL_FIRST' : 'IN_GROUP'; $lexer->pushState($state); // Negated grouping if the first character is "!" return $matches[1] !== '' ? self::T_GROUP_BEGIN_NEGATED : self::T_GROUP_BEGIN; } ]; }
php
protected function createInitialDefinition() { return [ /* * Match against non-special characters. To explain the components of this: * * [^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)* * - This matches non-special (\*[?) characters. If it matches one, it'll permit it to be an escape * (i.e. \) if a character exists after it (which may be "special"). This then returns to the previous * matching pattern, repeating the same rules until a non-escaped "special" character is hit. * * (?:\\\\.[^\\\\*\[?]*)+ * - This immediately looks for escape characters, as the previous component of this regex requires for the * initial character to be non-special. This then returns to the standard rules the previous regex. */ '[^\\\\*\[?]+(?:\\\\.[^\\\\*\[?]*)*|(?:\\\\.[^\\\\*\[?]*)+' => self::T_WORD, // Simple match of "*" '\*' => self::T_WILDCARD_MULTI, // Simple match of "?" '\?' => self::T_WILDCARD_SINGLE, /* * Matches against [. This also optionally matches "!" or "^" as the first character to provide negation * context. The positive lookahead provides a means to check for "]" as the first character. This is a * slightly nasty hack to deal with a rule that "]" can be permitted as a standard character in a character, * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure * it's captured by adding a capturing group inside (regex lookarounds do not capture). */ '\[([!^]?)(?=(\])?)' => function (Stateful $lexer, $matches) { // Determine the state to enter (depending on whether the lookahead succeeded, i.e. "]" is the first // character of the grouping) $state = isset($matches[2]) ? 'IN_GROUP_SPECIAL_FIRST' : 'IN_GROUP'; $lexer->pushState($state); // Negated grouping if the first character is "!" return $matches[1] !== '' ? self::T_GROUP_BEGIN_NEGATED : self::T_GROUP_BEGIN; } ]; }
[ "protected", "function", "createInitialDefinition", "(", ")", "{", "return", "[", "/*\n * Match against non-special characters. To explain the components of this:\n *\n * [^\\\\\\\\*\\[?]+(?:\\\\\\\\.[^\\\\\\\\*\\[?]*)*\n * - This matches non-special (\\*[?) characters. If it matches one, it'll permit it to be an escape\n * (i.e. \\) if a character exists after it (which may be \"special\"). This then returns to the previous\n * matching pattern, repeating the same rules until a non-escaped \"special\" character is hit.\n *\n * (?:\\\\\\\\.[^\\\\\\\\*\\[?]*)+\n * - This immediately looks for escape characters, as the previous component of this regex requires for the\n * initial character to be non-special. This then returns to the standard rules the previous regex.\n */", "'[^\\\\\\\\*\\[?]+(?:\\\\\\\\.[^\\\\\\\\*\\[?]*)*|(?:\\\\\\\\.[^\\\\\\\\*\\[?]*)+'", "=>", "self", "::", "T_WORD", ",", "// Simple match of \"*\"", "'\\*'", "=>", "self", "::", "T_WILDCARD_MULTI", ",", "// Simple match of \"?\"", "'\\?'", "=>", "self", "::", "T_WILDCARD_SINGLE", ",", "/*\n * Matches against [. This also optionally matches \"!\" or \"^\" as the first character to provide negation\n * context. The positive lookahead provides a means to check for \"]\" as the first character. This is a\n * slightly nasty hack to deal with a rule that \"]\" can be permitted as a standard character in a character,\n * grouping so long as it's the first character. Once we move into the IN_GROUP state we have no such\n * context, so it must be checked at this level. To achieve this we lookahead for the character, and ensure\n * it's captured by adding a capturing group inside (regex lookarounds do not capture).\n */", "'\\[([!^]?)(?=(\\])?)'", "=>", "function", "(", "Stateful", "$", "lexer", ",", "$", "matches", ")", "{", "// Determine the state to enter (depending on whether the lookahead succeeded, i.e. \"]\" is the first", "// character of the grouping)", "$", "state", "=", "isset", "(", "$", "matches", "[", "2", "]", ")", "?", "'IN_GROUP_SPECIAL_FIRST'", ":", "'IN_GROUP'", ";", "$", "lexer", "->", "pushState", "(", "$", "state", ")", ";", "// Negated grouping if the first character is \"!\"", "return", "$", "matches", "[", "1", "]", "!==", "''", "?", "self", "::", "T_GROUP_BEGIN_NEGATED", ":", "self", "::", "T_GROUP_BEGIN", ";", "}", "]", ";", "}" ]
Initial state. This is the default state when the lexer enters the pattern. @return array
[ "Initial", "state", ".", "This", "is", "the", "default", "state", "when", "the", "lexer", "enters", "the", "pattern", "." ]
5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4
https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Tokenizer/Glob.php#L98-L141
15,050
nick-jones/globby
lib/Globby/Tokenizer/Glob.php
Glob.createInGroupDefinition
protected function createInGroupDefinition() { return [ // Close of a grouping. Note that we avoid trouble with the "valid" inclusion of this character at the first // position by consuming it in the IN_GROUP_SPECIAL_FIRST state. Therefore, any further occurrences are // indeed valid closing of the current character grouping. '\]' => function (Stateful $lexer) { $lexer->popState(); return self::T_GROUP_END; }, // A range is CHAR1-CHAR2, where CHAR2 is not the closing of a group ("-" is permitted as the first or // last character of a character grouping. '.-[^\]]' => self::T_GROUP_RANGE, '\[:[a-z]+:\]' => self::T_GROUP_CHARACTER_CLASS, '.' => self::T_GROUP_CHARACTER ]; }
php
protected function createInGroupDefinition() { return [ // Close of a grouping. Note that we avoid trouble with the "valid" inclusion of this character at the first // position by consuming it in the IN_GROUP_SPECIAL_FIRST state. Therefore, any further occurrences are // indeed valid closing of the current character grouping. '\]' => function (Stateful $lexer) { $lexer->popState(); return self::T_GROUP_END; }, // A range is CHAR1-CHAR2, where CHAR2 is not the closing of a group ("-" is permitted as the first or // last character of a character grouping. '.-[^\]]' => self::T_GROUP_RANGE, '\[:[a-z]+:\]' => self::T_GROUP_CHARACTER_CLASS, '.' => self::T_GROUP_CHARACTER ]; }
[ "protected", "function", "createInGroupDefinition", "(", ")", "{", "return", "[", "// Close of a grouping. Note that we avoid trouble with the \"valid\" inclusion of this character at the first", "// position by consuming it in the IN_GROUP_SPECIAL_FIRST state. Therefore, any further occurrences are", "// indeed valid closing of the current character grouping.", "'\\]'", "=>", "function", "(", "Stateful", "$", "lexer", ")", "{", "$", "lexer", "->", "popState", "(", ")", ";", "return", "self", "::", "T_GROUP_END", ";", "}", ",", "// A range is CHAR1-CHAR2, where CHAR2 is not the closing of a group (\"-\" is permitted as the first or", "// last character of a character grouping.", "'.-[^\\]]'", "=>", "self", "::", "T_GROUP_RANGE", ",", "'\\[:[a-z]+:\\]'", "=>", "self", "::", "T_GROUP_CHARACTER_CLASS", ",", "'.'", "=>", "self", "::", "T_GROUP_CHARACTER", "]", ";", "}" ]
In group state. This looks for standard characters, ranges, and POSIX character classes. @return array
[ "In", "group", "state", ".", "This", "looks", "for", "standard", "characters", "ranges", "and", "POSIX", "character", "classes", "." ]
5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4
https://github.com/nick-jones/globby/blob/5bfc56fbeb0ff84d71f7144c10cc9215a34d9ea4/lib/Globby/Tokenizer/Glob.php#L148-L164
15,051
JoffreyPoreeCoding/MongoDB-ODM
src/Tools/EventManager.php
EventManager.execute
public function execute($eventName, $object) { if (isset($this->events[$eventName]) && is_array(($this->events[$eventName]))) { foreach ($this->events[$eventName] as $method) { call_user_func([$object, $method]); } } }
php
public function execute($eventName, $object) { if (isset($this->events[$eventName]) && is_array(($this->events[$eventName]))) { foreach ($this->events[$eventName] as $method) { call_user_func([$object, $method]); } } }
[ "public", "function", "execute", "(", "$", "eventName", ",", "$", "object", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", "&&", "is_array", "(", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "events", "[", "$", "eventName", "]", "as", "$", "method", ")", "{", "call_user_func", "(", "[", "$", "object", ",", "$", "method", "]", ")", ";", "}", "}", "}" ]
Execute an event @param string $eventName Name of event @param mixed $object Object on wich object will be executed @return void
[ "Execute", "an", "event" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/EventManager.php#L48-L55
15,052
werx/forms
src/Input.php
Input.filter
protected function filter(&$value) { if (is_scalar($value)) { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } elseif (is_array($value)){ array_walk_recursive($value, [$this, 'filter']); } elseif (is_object($value)) { foreach (get_object_vars($value) as $k => $v) { $value->$k = $this->filter($value); } } return $value; }
php
protected function filter(&$value) { if (is_scalar($value)) { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } elseif (is_array($value)){ array_walk_recursive($value, [$this, 'filter']); } elseif (is_object($value)) { foreach (get_object_vars($value) as $k => $v) { $value->$k = $this->filter($value); } } return $value; }
[ "protected", "function", "filter", "(", "&", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "htmlspecialchars", "(", "$", "value", ",", "ENT_QUOTES", "|", "ENT_SUBSTITUTE", ",", "'UTF-8'", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "array_walk_recursive", "(", "$", "value", ",", "[", "$", "this", ",", "'filter'", "]", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "foreach", "(", "get_object_vars", "(", "$", "value", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "value", "->", "$", "k", "=", "$", "this", "->", "filter", "(", "$", "value", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Filters a variable reference for XSS. @param $value @return string
[ "Filters", "a", "variable", "reference", "for", "XSS", "." ]
e057e4890bd13541da72b3cb2d22c2c84435c16a
https://github.com/werx/forms/blob/e057e4890bd13541da72b3cb2d22c2c84435c16a/src/Input.php#L47-L60
15,053
drunomics/service-utils
src/file/FileUsage/FileUsageTrait.php
FileUsageTrait.getFileUsage
public function getFileUsage() { if (empty($this->fileUsage)) { $this->fileUsage = \Drupal::service('file.usage'); } return $this->fileUsage; }
php
public function getFileUsage() { if (empty($this->fileUsage)) { $this->fileUsage = \Drupal::service('file.usage'); } return $this->fileUsage; }
[ "public", "function", "getFileUsage", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fileUsage", ")", ")", "{", "$", "this", "->", "fileUsage", "=", "\\", "Drupal", "::", "service", "(", "'file.usage'", ")", ";", "}", "return", "$", "this", "->", "fileUsage", ";", "}" ]
Gets file usage service. @return \Drupal\file\FileUsage\FileUsageInterface File usage service.
[ "Gets", "file", "usage", "service", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/file/FileUsage/FileUsageTrait.php#L38-L43
15,054
gregorybesson/PlaygroundCore
src/Service/Ffmpeg.php
Ffmpeg.createImagesFromVideos
public function createImagesFromVideos($source, $target = 'step-%03d.jpg') { try { $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); $this->serviceLocator->get('playgroundcore_phpvideotoolkit') ->addPreInputCommand('-y') ->addCommand('-i', $source) ->setOutputPath($target) ->execute(); } catch (FfmpegProcessOutputException $e) { throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); } catch (\PHPVideoToolkit\Exception $e) { throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); } return $target; }
php
public function createImagesFromVideos($source, $target = 'step-%03d.jpg') { try { $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); $this->serviceLocator->get('playgroundcore_phpvideotoolkit') ->addPreInputCommand('-y') ->addCommand('-i', $source) ->setOutputPath($target) ->execute(); } catch (FfmpegProcessOutputException $e) { throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); } catch (\PHPVideoToolkit\Exception $e) { throw new \PHPVideoToolkit\InvalidArgumentException('Error when merging videos'); } return $target; }
[ "public", "function", "createImagesFromVideos", "(", "$", "source", ",", "$", "target", "=", "'step-%03d.jpg'", ")", "{", "try", "{", "$", "this", "->", "serviceLocator", "->", "setShared", "(", "'playgroundcore_phpvideotoolkit'", ",", "false", ")", ";", "$", "this", "->", "serviceLocator", "->", "get", "(", "'playgroundcore_phpvideotoolkit'", ")", "->", "addPreInputCommand", "(", "'-y'", ")", "->", "addCommand", "(", "'-i'", ",", "$", "source", ")", "->", "setOutputPath", "(", "$", "target", ")", "->", "execute", "(", ")", ";", "}", "catch", "(", "FfmpegProcessOutputException", "$", "e", ")", "{", "throw", "new", "\\", "PHPVideoToolkit", "\\", "InvalidArgumentException", "(", "'Error when merging videos'", ")", ";", "}", "catch", "(", "\\", "PHPVideoToolkit", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "PHPVideoToolkit", "\\", "InvalidArgumentException", "(", "'Error when merging videos'", ")", ";", "}", "return", "$", "target", ";", "}" ]
This method create images from a video. ffmpeg -i input.mov output_%03d.png
[ "This", "method", "create", "images", "from", "a", "video", ".", "ffmpeg", "-", "i", "input", ".", "mov", "output_%03d", ".", "png" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Ffmpeg.php#L45-L62
15,055
gregorybesson/PlaygroundCore
src/Service/Ffmpeg.php
Ffmpeg.convertToMp3
public function convertToMp3($source, $target) { $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); $this->serviceLocator->get('playgroundcore_phpvideotoolkit') ->addPreInputCommand('-y') ->addCommand('-i', $source) ->addCommand('-vn') ->addCommand('-ar', '44100') ->addCommand('-ac', '2') ->addCommand('-ab', '192') ->addCommand('-f', 'mp3') ->setOutputPath($target) ->execute(); return $target; }
php
public function convertToMp3($source, $target) { $this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); $this->serviceLocator->get('playgroundcore_phpvideotoolkit') ->addPreInputCommand('-y') ->addCommand('-i', $source) ->addCommand('-vn') ->addCommand('-ar', '44100') ->addCommand('-ac', '2') ->addCommand('-ab', '192') ->addCommand('-f', 'mp3') ->setOutputPath($target) ->execute(); return $target; }
[ "public", "function", "convertToMp3", "(", "$", "source", ",", "$", "target", ")", "{", "$", "this", "->", "serviceLocator", "->", "setShared", "(", "'playgroundcore_phpvideotoolkit'", ",", "false", ")", ";", "$", "this", "->", "serviceLocator", "->", "get", "(", "'playgroundcore_phpvideotoolkit'", ")", "->", "addPreInputCommand", "(", "'-y'", ")", "->", "addCommand", "(", "'-i'", ",", "$", "source", ")", "->", "addCommand", "(", "'-vn'", ")", "->", "addCommand", "(", "'-ar'", ",", "'44100'", ")", "->", "addCommand", "(", "'-ac'", ",", "'2'", ")", "->", "addCommand", "(", "'-ab'", ",", "'192'", ")", "->", "addCommand", "(", "'-f'", ",", "'mp3'", ")", "->", "setOutputPath", "(", "$", "target", ")", "->", "execute", "(", ")", ";", "return", "$", "target", ";", "}" ]
ffmpeg -i sound.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 out.mp3
[ "ffmpeg", "-", "i", "sound", ".", "avi", "-", "vn", "-", "ar", "44100", "-", "ac", "2", "-", "ab", "192", "-", "f", "mp3", "out", ".", "mp3" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Ffmpeg.php#L229-L245
15,056
phramework/jsonapi
src/Model/Cache.php
Cache.invalidateCache
protected static function invalidateCache($id) { $type = static::getType(); $id = (string)$id; static::initializeCache($type); $collection = self::$cache->{$type}; unset($collection->{$id}); }
php
protected static function invalidateCache($id) { $type = static::getType(); $id = (string)$id; static::initializeCache($type); $collection = self::$cache->{$type}; unset($collection->{$id}); }
[ "protected", "static", "function", "invalidateCache", "(", "$", "id", ")", "{", "$", "type", "=", "static", "::", "getType", "(", ")", ";", "$", "id", "=", "(", "string", ")", "$", "id", ";", "static", "::", "initializeCache", "(", "$", "type", ")", ";", "$", "collection", "=", "self", "::", "$", "cache", "->", "{", "$", "type", "}", ";", "unset", "(", "$", "collection", "->", "{", "$", "id", "}", ")", ";", "}" ]
Remove resource from cache, used by `PUT`, `PATCH` and `DELETE` methods when changing an object @param string $id
[ "Remove", "resource", "from", "cache", "used", "by", "PUT", "PATCH", "and", "DELETE", "methods", "when", "changing", "an", "object" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Cache.php#L115-L126
15,057
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.id
public function id(): string { if (null !== $this->id) { return $this->id; } if ($this->headers->contain('HTTP_X_REQUEST_ID')) { $this->id = $this->readHeader('HTTP_X_REQUEST_ID') ->ifMatches('~^([a-zA-Z0-9+/=-]{20,200})$~'); } if (null === $this->id) { $this->id = substr(str_shuffle(md5(microtime())), 0, 25); } return $this->id; }
php
public function id(): string { if (null !== $this->id) { return $this->id; } if ($this->headers->contain('HTTP_X_REQUEST_ID')) { $this->id = $this->readHeader('HTTP_X_REQUEST_ID') ->ifMatches('~^([a-zA-Z0-9+/=-]{20,200})$~'); } if (null === $this->id) { $this->id = substr(str_shuffle(md5(microtime())), 0, 25); } return $this->id; }
[ "public", "function", "id", "(", ")", ":", "string", "{", "if", "(", "null", "!==", "$", "this", "->", "id", ")", "{", "return", "$", "this", "->", "id", ";", "}", "if", "(", "$", "this", "->", "headers", "->", "contain", "(", "'HTTP_X_REQUEST_ID'", ")", ")", "{", "$", "this", "->", "id", "=", "$", "this", "->", "readHeader", "(", "'HTTP_X_REQUEST_ID'", ")", "->", "ifMatches", "(", "'~^([a-zA-Z0-9+/=-]{20,200})$~'", ")", ";", "}", "if", "(", "null", "===", "$", "this", "->", "id", ")", "{", "$", "this", "->", "id", "=", "substr", "(", "str_shuffle", "(", "md5", "(", "microtime", "(", ")", ")", ")", ",", "0", ",", "25", ")", ";", "}", "return", "$", "this", "->", "id", ";", "}" ]
returns id of the request The id of the request may come from an optional X-Request-ID header. The value must be between 20 and 200 characters, and consist of ASCII letters, digits, or the characters +, /, =, and -. Invalid or missing ids will be ignored and replaced with generated ones. @return string @since 4.2.0 @see https://devcenter.heroku.com/articles/http-request-id
[ "returns", "id", "of", "the", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L110-L126
15,058
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.protocolVersion
public function protocolVersion() { if (!$this->headers->contain('SERVER_PROTOCOL')) { return new HttpVersion(1, 0); } try { return HttpVersion::fromString($this->headers->value('SERVER_PROTOCOL')->value()); } catch (\InvalidArgumentException $ex) { return null; } }
php
public function protocolVersion() { if (!$this->headers->contain('SERVER_PROTOCOL')) { return new HttpVersion(1, 0); } try { return HttpVersion::fromString($this->headers->value('SERVER_PROTOCOL')->value()); } catch (\InvalidArgumentException $ex) { return null; } }
[ "public", "function", "protocolVersion", "(", ")", "{", "if", "(", "!", "$", "this", "->", "headers", "->", "contain", "(", "'SERVER_PROTOCOL'", ")", ")", "{", "return", "new", "HttpVersion", "(", "1", ",", "0", ")", ";", "}", "try", "{", "return", "HttpVersion", "::", "fromString", "(", "$", "this", "->", "headers", "->", "value", "(", "'SERVER_PROTOCOL'", ")", "->", "value", "(", ")", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "ex", ")", "{", "return", "null", ";", "}", "}" ]
returns HTTP protocol version of request If no SERVER_PROTOCOL is present it is assumed that the protocol version is HTTP/1.0. In case the SERVER_PROTOCOL does not denote a valid HTTP version according to http://tools.ietf.org/html/rfc7230#section-2.6 the return value will be null. @return \stubbles\peer\http\HttpVersion @since 2.0.2
[ "returns", "HTTP", "protocol", "version", "of", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L159-L170
15,059
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.originatingIpAddress
public function originatingIpAddress() { try { if ($this->headers->contain('HTTP_X_FORWARDED_FOR')) { $remoteAddresses = explode(',', $this->headers->value('HTTP_X_FORWARDED_FOR')->value()); return new IpAddress(trim($remoteAddresses[0])); } if ($this->headers->contain('REMOTE_ADDR')) { return new IpAddress($this->headers->value('REMOTE_ADDR')->value()); } } catch (\InvalidArgumentException $iae) { // treat as if no ip address available } return null; }
php
public function originatingIpAddress() { try { if ($this->headers->contain('HTTP_X_FORWARDED_FOR')) { $remoteAddresses = explode(',', $this->headers->value('HTTP_X_FORWARDED_FOR')->value()); return new IpAddress(trim($remoteAddresses[0])); } if ($this->headers->contain('REMOTE_ADDR')) { return new IpAddress($this->headers->value('REMOTE_ADDR')->value()); } } catch (\InvalidArgumentException $iae) { // treat as if no ip address available } return null; }
[ "public", "function", "originatingIpAddress", "(", ")", "{", "try", "{", "if", "(", "$", "this", "->", "headers", "->", "contain", "(", "'HTTP_X_FORWARDED_FOR'", ")", ")", "{", "$", "remoteAddresses", "=", "explode", "(", "','", ",", "$", "this", "->", "headers", "->", "value", "(", "'HTTP_X_FORWARDED_FOR'", ")", "->", "value", "(", ")", ")", ";", "return", "new", "IpAddress", "(", "trim", "(", "$", "remoteAddresses", "[", "0", "]", ")", ")", ";", "}", "if", "(", "$", "this", "->", "headers", "->", "contain", "(", "'REMOTE_ADDR'", ")", ")", "{", "return", "new", "IpAddress", "(", "$", "this", "->", "headers", "->", "value", "(", "'REMOTE_ADDR'", ")", "->", "value", "(", ")", ")", ";", "}", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "iae", ")", "{", "// treat as if no ip address available", "}", "return", "null", ";", "}" ]
returns the ip address which issued the request originally The originating IP address is the IP address of the client which issued the request. In case the request was routed via several proxies it will still return the real client IP, and not the IP address of the last proxy in the chain. Please note that the method relies on the values of REMOTE_ADDR provided by PHP and the X-Forwarded-For header. If none of these is present the return value will be null. Additionally, if the value of these headers does not contain a syntactically correct IP address, the return value will be null. Also, the return value might not neccessarily be an existing IP address nor the real IP address of the client, as it may be spoofed. @return \stubbles\peer\IpAddress @since 3.0.0
[ "returns", "the", "ip", "address", "which", "issued", "the", "request", "originally" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L192-L208
15,060
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.userAgent
public function userAgent(array $botSignatures = []): UserAgent { return new UserAgent( $this->headers->value('HTTP_USER_AGENT')->value(), $this->cookies->count() > 0, $botSignatures ); }
php
public function userAgent(array $botSignatures = []): UserAgent { return new UserAgent( $this->headers->value('HTTP_USER_AGENT')->value(), $this->cookies->count() > 0, $botSignatures ); }
[ "public", "function", "userAgent", "(", "array", "$", "botSignatures", "=", "[", "]", ")", ":", "UserAgent", "{", "return", "new", "UserAgent", "(", "$", "this", "->", "headers", "->", "value", "(", "'HTTP_USER_AGENT'", ")", "->", "value", "(", ")", ",", "$", "this", "->", "cookies", "->", "count", "(", ")", ">", "0", ",", "$", "botSignatures", ")", ";", "}" ]
returns the user agent which issued the request Please be aware that user agents can fake their appearance. The bot recognition will recognize Googlebot, Bing (including former msnbot), Yahoo! Slurp, Pingdom and Yandex by default. Additional signatures can be passed, they must contain a regular expression which matches the user agent of a bot. @param string[] $botSignatures optional additional list of bot user agent signatures @return \stubbles\webapp\request\UserAgent @since 4.1.0
[ "returns", "the", "user", "agent", "which", "issued", "the", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L224-L231
15,061
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.uri
public function uri(): HttpUri { $host = (string) $this->headers->value('HTTP_HOST')->value(); return HttpUri::fromParts( $this->headers->contain('HTTPS') ? Http::SCHEME_SSL : Http::SCHEME, $host, strstr($host, ':') === false ? $this->headers->value('SERVER_PORT')->value() : null, (string) $this->headers->value('REQUEST_URI')->value() // already contains query string ); }
php
public function uri(): HttpUri { $host = (string) $this->headers->value('HTTP_HOST')->value(); return HttpUri::fromParts( $this->headers->contain('HTTPS') ? Http::SCHEME_SSL : Http::SCHEME, $host, strstr($host, ':') === false ? $this->headers->value('SERVER_PORT')->value() : null, (string) $this->headers->value('REQUEST_URI')->value() // already contains query string ); }
[ "public", "function", "uri", "(", ")", ":", "HttpUri", "{", "$", "host", "=", "(", "string", ")", "$", "this", "->", "headers", "->", "value", "(", "'HTTP_HOST'", ")", "->", "value", "(", ")", ";", "return", "HttpUri", "::", "fromParts", "(", "$", "this", "->", "headers", "->", "contain", "(", "'HTTPS'", ")", "?", "Http", "::", "SCHEME_SSL", ":", "Http", "::", "SCHEME", ",", "$", "host", ",", "strstr", "(", "$", "host", ",", "':'", ")", "===", "false", "?", "$", "this", "->", "headers", "->", "value", "(", "'SERVER_PORT'", ")", "->", "value", "(", ")", ":", "null", ",", "(", "string", ")", "$", "this", "->", "headers", "->", "value", "(", "'REQUEST_URI'", ")", "->", "value", "(", ")", "// already contains query string", ")", ";", "}" ]
returns the uri of the request In case the composed uri for this request does not denote a valid HTTP uri a stubbles\peer\MalformedUriException is thrown. If you came this far but the request is for an invalid HTTP uri something is completely wrong, most likely the request tries to find out if you have a security issue because the request uri data is not checked properly. It is advisable to respond with a 400 Bad Request in such cases. @return \stubbles\peer\http\HttpUri
[ "returns", "the", "uri", "of", "the", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L245-L254
15,062
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.hasRedirectHeader
public function hasRedirectHeader(string $headerName): bool { return $this->hasHeader('REDIRECT_' . $headerName) || $this->hasHeader($headerName); }
php
public function hasRedirectHeader(string $headerName): bool { return $this->hasHeader('REDIRECT_' . $headerName) || $this->hasHeader($headerName); }
[ "public", "function", "hasRedirectHeader", "(", "string", "$", "headerName", ")", ":", "bool", "{", "return", "$", "this", "->", "hasHeader", "(", "'REDIRECT_'", ".", "$", "headerName", ")", "||", "$", "this", "->", "hasHeader", "(", "$", "headerName", ")", ";", "}" ]
checks whether a request header or it's redirect equivalent is set A redirect header is one that starts with REDIRECT_ and has most likely a different value after a redirection happened than the original header. The method will try to use the header REDIRECT_$headerName first, but falls back to $headerName when REDIRECT_$headerName is not present. @param string $headerName @return bool @since 3.1.1
[ "checks", "whether", "a", "request", "header", "or", "it", "s", "redirect", "equivalent", "is", "set" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L291-L294
15,063
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.validateRedirectHeader
public function validateRedirectHeader(string $headerName): ValueValidator { if ($this->headers->contain('REDIRECT_' . $headerName)) { return $this->validateHeader('REDIRECT_' . $headerName); } return $this->validateHeader($headerName); }
php
public function validateRedirectHeader(string $headerName): ValueValidator { if ($this->headers->contain('REDIRECT_' . $headerName)) { return $this->validateHeader('REDIRECT_' . $headerName); } return $this->validateHeader($headerName); }
[ "public", "function", "validateRedirectHeader", "(", "string", "$", "headerName", ")", ":", "ValueValidator", "{", "if", "(", "$", "this", "->", "headers", "->", "contain", "(", "'REDIRECT_'", ".", "$", "headerName", ")", ")", "{", "return", "$", "this", "->", "validateHeader", "(", "'REDIRECT_'", ".", "$", "headerName", ")", ";", "}", "return", "$", "this", "->", "validateHeader", "(", "$", "headerName", ")", ";", "}" ]
checks whether a request value from redirect headers is valid or not A redirect header is one that starts with REDIRECT_ and has most likely a different value after a redirection happened than the original header. The method will try to use the header REDIRECT_$headerName first, but falls back to $headerName when REDIRECT_$headerName is not present. @param string $headerName name of header @return \stubbles\input\ValueValidator @since 3.1.0
[ "checks", "whether", "a", "request", "value", "from", "redirect", "headers", "is", "valid", "or", "not" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L331-L338
15,064
stubbles/stubbles-webapp-core
src/main/php/request/WebRequest.php
WebRequest.readCookie
public function readCookie(string $cookieName): ValueReader { return new ValueReader( $this->cookies->errors(), $cookieName, $this->cookies->value($cookieName) ); }
php
public function readCookie(string $cookieName): ValueReader { return new ValueReader( $this->cookies->errors(), $cookieName, $this->cookies->value($cookieName) ); }
[ "public", "function", "readCookie", "(", "string", "$", "cookieName", ")", ":", "ValueReader", "{", "return", "new", "ValueReader", "(", "$", "this", "->", "cookies", "->", "errors", "(", ")", ",", "$", "cookieName", ",", "$", "this", "->", "cookies", "->", "value", "(", "$", "cookieName", ")", ")", ";", "}" ]
returns request value from cookies for filtering or validation @param string $cookieName name of cookie @return \stubbles\input\ValueReader @since 1.3.0
[ "returns", "request", "value", "from", "cookies", "for", "filtering", "or", "validation" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/WebRequest.php#L430-L437
15,065
sulu/SuluPricingBundle
Pricing/ItemPriceCalculator.php
ItemPriceCalculator.calculateItemTotalNetPrice
public function calculateItemTotalNetPrice($item, $currency = null, $useProductsPrice = true, $isGrossPrice = false) { $priceValue = $this->calculateItemNetPrice($item, $currency, $useProductsPrice, $isGrossPrice); if ($priceValue === null) { $priceValue = 0; } if ($item->getPrice() && $item->getPrice() !== $priceValue) { $item->setPriceChange($item->getPrice(), $priceValue); } $itemPrice = $priceValue * $item->getCalcQuantity(); // Calculate items discount. $discount = ($itemPrice / 100) * $item->getCalcDiscount(); // Calculate total item price. $totalPrice = $itemPrice - $discount; return $totalPrice; }
php
public function calculateItemTotalNetPrice($item, $currency = null, $useProductsPrice = true, $isGrossPrice = false) { $priceValue = $this->calculateItemNetPrice($item, $currency, $useProductsPrice, $isGrossPrice); if ($priceValue === null) { $priceValue = 0; } if ($item->getPrice() && $item->getPrice() !== $priceValue) { $item->setPriceChange($item->getPrice(), $priceValue); } $itemPrice = $priceValue * $item->getCalcQuantity(); // Calculate items discount. $discount = ($itemPrice / 100) * $item->getCalcDiscount(); // Calculate total item price. $totalPrice = $itemPrice - $discount; return $totalPrice; }
[ "public", "function", "calculateItemTotalNetPrice", "(", "$", "item", ",", "$", "currency", "=", "null", ",", "$", "useProductsPrice", "=", "true", ",", "$", "isGrossPrice", "=", "false", ")", "{", "$", "priceValue", "=", "$", "this", "->", "calculateItemNetPrice", "(", "$", "item", ",", "$", "currency", ",", "$", "useProductsPrice", ",", "$", "isGrossPrice", ")", ";", "if", "(", "$", "priceValue", "===", "null", ")", "{", "$", "priceValue", "=", "0", ";", "}", "if", "(", "$", "item", "->", "getPrice", "(", ")", "&&", "$", "item", "->", "getPrice", "(", ")", "!==", "$", "priceValue", ")", "{", "$", "item", "->", "setPriceChange", "(", "$", "item", "->", "getPrice", "(", ")", ",", "$", "priceValue", ")", ";", "}", "$", "itemPrice", "=", "$", "priceValue", "*", "$", "item", "->", "getCalcQuantity", "(", ")", ";", "// Calculate items discount.", "$", "discount", "=", "(", "$", "itemPrice", "/", "100", ")", "*", "$", "item", "->", "getCalcDiscount", "(", ")", ";", "// Calculate total item price.", "$", "totalPrice", "=", "$", "itemPrice", "-", "$", "discount", ";", "return", "$", "totalPrice", ";", "}" ]
Calculates the overall total price of an item. @param CalculableBulkPriceItemInterface $item @param string|null $currency @param bool|null $useProductsPrice @param bool|null $isGrossPrice @return float
[ "Calculates", "the", "overall", "total", "price", "of", "an", "item", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Pricing/ItemPriceCalculator.php#L64-L85
15,066
sulu/SuluPricingBundle
Pricing/ItemPriceCalculator.php
ItemPriceCalculator.calculateItemNetPrice
public function calculateItemNetPrice($item, $currency = null, $useProductsPrice = null, $isGrossPrice = false) { $currency = $this->getCurrency($currency); if ($useProductsPrice === null) { $useProductsPrice = $item->getUseProductsPrice(); } // Validate item $this->validateItem($item); $priceValue = $item->getPrice(); if ($useProductsPrice && ($item->getCalcProduct() || $item->getAddon())) { $priceValue = $this->getValidProductNetPriceForItem($item, $currency); } elseif ($isGrossPrice) { // Handle gross prices. $tax = $item->getTax(); if ($tax > 0) { $priceValue = ($priceValue / (100 + $tax)) * 100; } } return $priceValue; }
php
public function calculateItemNetPrice($item, $currency = null, $useProductsPrice = null, $isGrossPrice = false) { $currency = $this->getCurrency($currency); if ($useProductsPrice === null) { $useProductsPrice = $item->getUseProductsPrice(); } // Validate item $this->validateItem($item); $priceValue = $item->getPrice(); if ($useProductsPrice && ($item->getCalcProduct() || $item->getAddon())) { $priceValue = $this->getValidProductNetPriceForItem($item, $currency); } elseif ($isGrossPrice) { // Handle gross prices. $tax = $item->getTax(); if ($tax > 0) { $priceValue = ($priceValue / (100 + $tax)) * 100; } } return $priceValue; }
[ "public", "function", "calculateItemNetPrice", "(", "$", "item", ",", "$", "currency", "=", "null", ",", "$", "useProductsPrice", "=", "null", ",", "$", "isGrossPrice", "=", "false", ")", "{", "$", "currency", "=", "$", "this", "->", "getCurrency", "(", "$", "currency", ")", ";", "if", "(", "$", "useProductsPrice", "===", "null", ")", "{", "$", "useProductsPrice", "=", "$", "item", "->", "getUseProductsPrice", "(", ")", ";", "}", "// Validate item", "$", "this", "->", "validateItem", "(", "$", "item", ")", ";", "$", "priceValue", "=", "$", "item", "->", "getPrice", "(", ")", ";", "if", "(", "$", "useProductsPrice", "&&", "(", "$", "item", "->", "getCalcProduct", "(", ")", "||", "$", "item", "->", "getAddon", "(", ")", ")", ")", "{", "$", "priceValue", "=", "$", "this", "->", "getValidProductNetPriceForItem", "(", "$", "item", ",", "$", "currency", ")", ";", "}", "elseif", "(", "$", "isGrossPrice", ")", "{", "// Handle gross prices.", "$", "tax", "=", "$", "item", "->", "getTax", "(", ")", ";", "if", "(", "$", "tax", ">", "0", ")", "{", "$", "priceValue", "=", "(", "$", "priceValue", "/", "(", "100", "+", "$", "tax", ")", ")", "*", "100", ";", "}", "}", "return", "$", "priceValue", ";", "}" ]
Returns price of a single item based on it's quantity. @param CalculableBulkPriceItemInterface $item @param null|string $currency @param null|bool $useProductsPrice @param bool|null $isGrossPrice @throws PriceCalculationException @return float
[ "Returns", "price", "of", "a", "single", "item", "based", "on", "it", "s", "quantity", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Pricing/ItemPriceCalculator.php#L99-L123
15,067
sulu/SuluPricingBundle
Pricing/ItemPriceCalculator.php
ItemPriceCalculator.formatPrice
public function formatPrice($price, $currency, $locale = null) { return $this->priceManager->getFormattedPrice($price, $currency, $locale); }
php
public function formatPrice($price, $currency, $locale = null) { return $this->priceManager->getFormattedPrice($price, $currency, $locale); }
[ "public", "function", "formatPrice", "(", "$", "price", ",", "$", "currency", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "priceManager", "->", "getFormattedPrice", "(", "$", "price", ",", "$", "currency", ",", "$", "locale", ")", ";", "}" ]
Format price. @param float $price @param string $currency @param string $locale @return string
[ "Format", "price", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Pricing/ItemPriceCalculator.php#L134-L137
15,068
sulu/SuluPricingBundle
Pricing/ItemPriceCalculator.php
ItemPriceCalculator.getValidProductNetPriceForItem
private function getValidProductNetPriceForItem(CalculableBulkPriceItemInterface $item, $currency) { $product = $item->getCalcProduct(); $areGrossPrices = false; // Get addon price. $addon = $item->getAddon(); if ($addon) { $addonPrice = $this->priceManager->getAddonPriceForCurrency($item->getAddon(), $currency); if ($addonPrice) { $priceValue = $addonPrice->getPrice(); } else { $priceValue = $this->getPriceOfProduct($addon->getAddon(), $item->getCalcQuantity(), $currency); } $areGrossPrices = $addon->getAddon()->getAreGrossPrices(); } elseif ($product) { $priceValue = $this->getPriceOfProduct($item->getCalcProduct(), $item->getCalcQuantity(), $currency); $areGrossPrices = $product->getAreGrossPrices(); if ($product->getParent()) { $areGrossPrices = $product->getParent()->getAreGrossPrices(); } } // If no price is set - return 0. if (empty($priceValue)) { return 0; } // Check if product price is gross price and return net price instead. if ($areGrossPrices) { $tax = $item->getTax(); if ($tax > 0) { $priceValue = ($priceValue / (100 + $tax)) * 100; } } return $priceValue; }
php
private function getValidProductNetPriceForItem(CalculableBulkPriceItemInterface $item, $currency) { $product = $item->getCalcProduct(); $areGrossPrices = false; // Get addon price. $addon = $item->getAddon(); if ($addon) { $addonPrice = $this->priceManager->getAddonPriceForCurrency($item->getAddon(), $currency); if ($addonPrice) { $priceValue = $addonPrice->getPrice(); } else { $priceValue = $this->getPriceOfProduct($addon->getAddon(), $item->getCalcQuantity(), $currency); } $areGrossPrices = $addon->getAddon()->getAreGrossPrices(); } elseif ($product) { $priceValue = $this->getPriceOfProduct($item->getCalcProduct(), $item->getCalcQuantity(), $currency); $areGrossPrices = $product->getAreGrossPrices(); if ($product->getParent()) { $areGrossPrices = $product->getParent()->getAreGrossPrices(); } } // If no price is set - return 0. if (empty($priceValue)) { return 0; } // Check if product price is gross price and return net price instead. if ($areGrossPrices) { $tax = $item->getTax(); if ($tax > 0) { $priceValue = ($priceValue / (100 + $tax)) * 100; } } return $priceValue; }
[ "private", "function", "getValidProductNetPriceForItem", "(", "CalculableBulkPriceItemInterface", "$", "item", ",", "$", "currency", ")", "{", "$", "product", "=", "$", "item", "->", "getCalcProduct", "(", ")", ";", "$", "areGrossPrices", "=", "false", ";", "// Get addon price.", "$", "addon", "=", "$", "item", "->", "getAddon", "(", ")", ";", "if", "(", "$", "addon", ")", "{", "$", "addonPrice", "=", "$", "this", "->", "priceManager", "->", "getAddonPriceForCurrency", "(", "$", "item", "->", "getAddon", "(", ")", ",", "$", "currency", ")", ";", "if", "(", "$", "addonPrice", ")", "{", "$", "priceValue", "=", "$", "addonPrice", "->", "getPrice", "(", ")", ";", "}", "else", "{", "$", "priceValue", "=", "$", "this", "->", "getPriceOfProduct", "(", "$", "addon", "->", "getAddon", "(", ")", ",", "$", "item", "->", "getCalcQuantity", "(", ")", ",", "$", "currency", ")", ";", "}", "$", "areGrossPrices", "=", "$", "addon", "->", "getAddon", "(", ")", "->", "getAreGrossPrices", "(", ")", ";", "}", "elseif", "(", "$", "product", ")", "{", "$", "priceValue", "=", "$", "this", "->", "getPriceOfProduct", "(", "$", "item", "->", "getCalcProduct", "(", ")", ",", "$", "item", "->", "getCalcQuantity", "(", ")", ",", "$", "currency", ")", ";", "$", "areGrossPrices", "=", "$", "product", "->", "getAreGrossPrices", "(", ")", ";", "if", "(", "$", "product", "->", "getParent", "(", ")", ")", "{", "$", "areGrossPrices", "=", "$", "product", "->", "getParent", "(", ")", "->", "getAreGrossPrices", "(", ")", ";", "}", "}", "// If no price is set - return 0.", "if", "(", "empty", "(", "$", "priceValue", ")", ")", "{", "return", "0", ";", "}", "// Check if product price is gross price and return net price instead.", "if", "(", "$", "areGrossPrices", ")", "{", "$", "tax", "=", "$", "item", "->", "getTax", "(", ")", ";", "if", "(", "$", "tax", ">", "0", ")", "{", "$", "priceValue", "=", "(", "$", "priceValue", "/", "(", "100", "+", "$", "tax", ")", ")", "*", "100", ";", "}", "}", "return", "$", "priceValue", ";", "}" ]
Returns the valid product net price for item. @param CalculableBulkPriceItemInterface $item @param string $currency @return int
[ "Returns", "the", "valid", "product", "net", "price", "for", "item", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Pricing/ItemPriceCalculator.php#L193-L231
15,069
sulu/SuluPricingBundle
Pricing/ItemPriceCalculator.php
ItemPriceCalculator.retrieveProductTypeIdByKey
private function retrieveProductTypeIdByKey($key) { if (!isset($this->productTypesMap[$key])) { return null; } return intval($this->productTypesMap[$key]); }
php
private function retrieveProductTypeIdByKey($key) { if (!isset($this->productTypesMap[$key])) { return null; } return intval($this->productTypesMap[$key]); }
[ "private", "function", "retrieveProductTypeIdByKey", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "productTypesMap", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "return", "intval", "(", "$", "this", "->", "productTypesMap", "[", "$", "key", "]", ")", ";", "}" ]
Returns product type id by key. @param string $key @return int
[ "Returns", "product", "type", "id", "by", "key", "." ]
cd65f823c7c72992d0e423ee758a61f951f1d7d9
https://github.com/sulu/SuluPricingBundle/blob/cd65f823c7c72992d0e423ee758a61f951f1d7d9/Pricing/ItemPriceCalculator.php#L287-L294
15,070
datasift/datasift-php
lib/DataSift/Account/Identity/Token.php
DataSift_Account_Identity_Token.getAll
public function getAll($identity, $page = 1, $perPage = 25) { $params = array( 'page' => $page, 'per_page' => $perPage ); return $this->_user->get('account/identity/' . $identity . '/token', $params); }
php
public function getAll($identity, $page = 1, $perPage = 25) { $params = array( 'page' => $page, 'per_page' => $perPage ); return $this->_user->get('account/identity/' . $identity . '/token', $params); }
[ "public", "function", "getAll", "(", "$", "identity", ",", "$", "page", "=", "1", ",", "$", "perPage", "=", "25", ")", "{", "$", "params", "=", "array", "(", "'page'", "=>", "$", "page", ",", "'per_page'", "=>", "$", "perPage", ")", ";", "return", "$", "this", "->", "_user", "->", "get", "(", "'account/identity/'", ".", "$", "identity", ".", "'/token'", ",", "$", "params", ")", ";", "}" ]
Get all the tokens for an identity @param string $identity @param integer $page @param integer $perPage @return mixed
[ "Get", "all", "the", "tokens", "for", "an", "identity" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Account/Identity/Token.php#L50-L58
15,071
datasift/datasift-php
lib/DataSift/Account/Identity/Token.php
DataSift_Account_Identity_Token.create
public function create($identity, $service, $token) { $params = array( 'service' => $service, 'token' => $token, ); return $this->_user->post('account/identity/' . $identity . '/token', $params); }
php
public function create($identity, $service, $token) { $params = array( 'service' => $service, 'token' => $token, ); return $this->_user->post('account/identity/' . $identity . '/token', $params); }
[ "public", "function", "create", "(", "$", "identity", ",", "$", "service", ",", "$", "token", ")", "{", "$", "params", "=", "array", "(", "'service'", "=>", "$", "service", ",", "'token'", "=>", "$", "token", ",", ")", ";", "return", "$", "this", "->", "_user", "->", "post", "(", "'account/identity/'", ".", "$", "identity", ".", "'/token'", ",", "$", "params", ")", ";", "}" ]
Creates a token for a service @param string $identity @param string $service @param string $token @param string $expiresAt @return mixed
[ "Creates", "a", "token", "for", "a", "service" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Account/Identity/Token.php#L70-L79
15,072
datasift/datasift-php
lib/DataSift/Account/Identity/Token.php
DataSift_Account_Identity_Token.update
public function update($identity, $service, $token) { $params = array( 'token' => $token, ); return $this->_user->put('account/identity/' . $identity . '/token/' . $service, $params); }
php
public function update($identity, $service, $token) { $params = array( 'token' => $token, ); return $this->_user->put('account/identity/' . $identity . '/token/' . $service, $params); }
[ "public", "function", "update", "(", "$", "identity", ",", "$", "service", ",", "$", "token", ")", "{", "$", "params", "=", "array", "(", "'token'", "=>", "$", "token", ",", ")", ";", "return", "$", "this", "->", "_user", "->", "put", "(", "'account/identity/'", ".", "$", "identity", ".", "'/token/'", ".", "$", "service", ",", "$", "params", ")", ";", "}" ]
Updates the token for a service @param string $identity @param string $service @param string $expiresAt @return mixed
[ "Updates", "the", "token", "for", "a", "service" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Account/Identity/Token.php#L90-L98
15,073
datasift/datasift-php
lib/DataSift/Account/Identity/Token.php
DataSift_Account_Identity_Token.delete
public function delete($identity, $service) { $successCode = array(DataSift_ApiClient::HTTP_NO_CONTENT); return $this->_user->delete('account/identity/' . $identity . '/token/' . $service); }
php
public function delete($identity, $service) { $successCode = array(DataSift_ApiClient::HTTP_NO_CONTENT); return $this->_user->delete('account/identity/' . $identity . '/token/' . $service); }
[ "public", "function", "delete", "(", "$", "identity", ",", "$", "service", ")", "{", "$", "successCode", "=", "array", "(", "DataSift_ApiClient", "::", "HTTP_NO_CONTENT", ")", ";", "return", "$", "this", "->", "_user", "->", "delete", "(", "'account/identity/'", ".", "$", "identity", ".", "'/token/'", ".", "$", "service", ")", ";", "}" ]
Deletes a token for a service @param string $identity @param string $service @return mixed
[ "Deletes", "a", "token", "for", "a", "service" ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Account/Identity/Token.php#L108-L113
15,074
activecollab/databasestructure
src/Field/Scalar/EnumField.php
EnumField.&
public function &possibilities(...$possibilities) { if ($this->getDefaultValue() !== null && !in_array($this->getDefaultValue(), $possibilities)) { throw new InvalidArgumentException('Default value ' . var_export($this->getDefaultValue(), true) . ' needs to be in the list of possibilities'); } $this->possibilities = $possibilities; return $this; }
php
public function &possibilities(...$possibilities) { if ($this->getDefaultValue() !== null && !in_array($this->getDefaultValue(), $possibilities)) { throw new InvalidArgumentException('Default value ' . var_export($this->getDefaultValue(), true) . ' needs to be in the list of possibilities'); } $this->possibilities = $possibilities; return $this; }
[ "public", "function", "&", "possibilities", "(", "...", "$", "possibilities", ")", "{", "if", "(", "$", "this", "->", "getDefaultValue", "(", ")", "!==", "null", "&&", "!", "in_array", "(", "$", "this", "->", "getDefaultValue", "(", ")", ",", "$", "possibilities", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Default value '", ".", "var_export", "(", "$", "this", "->", "getDefaultValue", "(", ")", ",", "true", ")", ".", "' needs to be in the list of possibilities'", ")", ";", "}", "$", "this", "->", "possibilities", "=", "$", "possibilities", ";", "return", "$", "this", ";", "}" ]
Set a list of possible values. @param string[] $possibilities @return $this
[ "Set", "a", "list", "of", "possible", "values", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Scalar/EnumField.php#L37-L46
15,075
kderyabin/logger
src/Utils/Date.php
Date.getDateTime
public static function getDateTime() { $dt = \DateTime::createFromFormat('U.u', microtime(true)); $dt->setTimezone(new \DateTimeZone(date('e'))); return $dt; }
php
public static function getDateTime() { $dt = \DateTime::createFromFormat('U.u', microtime(true)); $dt->setTimezone(new \DateTimeZone(date('e'))); return $dt; }
[ "public", "static", "function", "getDateTime", "(", ")", "{", "$", "dt", "=", "\\", "DateTime", "::", "createFromFormat", "(", "'U.u'", ",", "microtime", "(", "true", ")", ")", ";", "$", "dt", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "date", "(", "'e'", ")", ")", ")", ";", "return", "$", "dt", ";", "}" ]
Returns DateTime object. @return \DateTime
[ "Returns", "DateTime", "object", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/Utils/Date.php#L22-L28
15,076
activecollab/databasestructure
src/Association/HasAndBelongsToManyAssociation.php
HasAndBelongsToManyAssociation.getConnectionTableName
public function getConnectionTableName() { $type_names = [$this->getSourceTypeName(), $this->getTargetTypeName()]; sort($type_names); return implode('_', $type_names); }
php
public function getConnectionTableName() { $type_names = [$this->getSourceTypeName(), $this->getTargetTypeName()]; sort($type_names); return implode('_', $type_names); }
[ "public", "function", "getConnectionTableName", "(", ")", "{", "$", "type_names", "=", "[", "$", "this", "->", "getSourceTypeName", "(", ")", ",", "$", "this", "->", "getTargetTypeName", "(", ")", "]", ";", "sort", "(", "$", "type_names", ")", ";", "return", "implode", "(", "'_'", ",", "$", "type_names", ")", ";", "}" ]
Return connection table name. @return string
[ "Return", "connection", "table", "name", "." ]
4b2353c4422186bcfce63b3212da3e70e63eb5df
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Association/HasAndBelongsToManyAssociation.php#L68-L74
15,077
crossjoin/Css
src/Crossjoin/Css/Helper/Url.php
Url.extractUrl
public static function extractUrl($url) { if (is_string($url)) { // Extract the URL from a given CSS URL value|string // // Examples: // - "http://www.example.com" // - 'http://www.example.com' // - url("http://www.example.com") // - url( 'http://www.example.com' ) // - url(http://www.example.com) // - url( http://www.example.com ) // - url("http://www.example.com?escape=\"escape\"") // // "Parentheses, whitespace characters, single quotes (') and double quotes (") appearing in a URL must be // escaped with a backslash so that the resulting value is a valid URL token" $url = Placeholder::replaceStringPlaceholders($url); $url = preg_replace('/^url\(|\)$/', '', $url); $url = str_replace(["\\(", "\\)", "\\ ", "\\'", "\\\""], ["(", ")", " ", "'", "\""], $url); $url = preg_replace('/^(["\'])(.*)\g{1}$/', '\\2', $url); $url = urldecode($url); return $url; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($url). "' for argument 'url' given." ); } }
php
public static function extractUrl($url) { if (is_string($url)) { // Extract the URL from a given CSS URL value|string // // Examples: // - "http://www.example.com" // - 'http://www.example.com' // - url("http://www.example.com") // - url( 'http://www.example.com' ) // - url(http://www.example.com) // - url( http://www.example.com ) // - url("http://www.example.com?escape=\"escape\"") // // "Parentheses, whitespace characters, single quotes (') and double quotes (") appearing in a URL must be // escaped with a backslash so that the resulting value is a valid URL token" $url = Placeholder::replaceStringPlaceholders($url); $url = preg_replace('/^url\(|\)$/', '', $url); $url = str_replace(["\\(", "\\)", "\\ ", "\\'", "\\\""], ["(", ")", " ", "'", "\""], $url); $url = preg_replace('/^(["\'])(.*)\g{1}$/', '\\2', $url); $url = urldecode($url); return $url; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($url). "' for argument 'url' given." ); } }
[ "public", "static", "function", "extractUrl", "(", "$", "url", ")", "{", "if", "(", "is_string", "(", "$", "url", ")", ")", "{", "// Extract the URL from a given CSS URL value|string", "//", "// Examples:", "// - \"http://www.example.com\"", "// - 'http://www.example.com'", "// - url(\"http://www.example.com\")", "// - url( 'http://www.example.com' )", "// - url(http://www.example.com)", "// - url( http://www.example.com )", "// - url(\"http://www.example.com?escape=\\\"escape\\\"\")", "//", "// \"Parentheses, whitespace characters, single quotes (') and double quotes (\") appearing in a URL must be", "// escaped with a backslash so that the resulting value is a valid URL token\"", "$", "url", "=", "Placeholder", "::", "replaceStringPlaceholders", "(", "$", "url", ")", ";", "$", "url", "=", "preg_replace", "(", "'/^url\\(|\\)$/'", ",", "''", ",", "$", "url", ")", ";", "$", "url", "=", "str_replace", "(", "[", "\"\\\\(\"", ",", "\"\\\\)\"", ",", "\"\\\\ \"", ",", "\"\\\\'\"", ",", "\"\\\\\\\"\"", "]", ",", "[", "\"(\"", ",", "\")\"", ",", "\" \"", ",", "\"'\"", ",", "\"\\\"\"", "]", ",", "$", "url", ")", ";", "$", "url", "=", "preg_replace", "(", "'/^([\"\\'])(.*)\\g{1}$/'", ",", "'\\\\2'", ",", "$", "url", ")", ";", "$", "url", "=", "urldecode", "(", "$", "url", ")", ";", "return", "$", "url", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "url", ")", ".", "\"' for argument 'url' given.\"", ")", ";", "}", "}" ]
Extracts the URL from a CSS URL value. @param string $url @return string
[ "Extracts", "the", "URL", "from", "a", "CSS", "URL", "value", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Helper/Url.php#L12-L40
15,078
withfatpanda/illuminate-wordpress
src/WordPress/Http/Arg.php
Arg.range
function range($min = null, $max = null) { $this->min($min); $this->max($max); return $this; }
php
function range($min = null, $max = null) { $this->min($min); $this->max($max); return $this; }
[ "function", "range", "(", "$", "min", "=", "null", ",", "$", "max", "=", "null", ")", "{", "$", "this", "->", "min", "(", "$", "min", ")", ";", "$", "this", "->", "max", "(", "$", "max", ")", ";", "return", "$", "this", ";", "}" ]
Set the minimum and maximum @param numeric minimum @param numeric maximum @return Arg
[ "Set", "the", "minimum", "and", "maximum" ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Http/Arg.php#L154-L159
15,079
withfatpanda/illuminate-wordpress
src/WordPress/Http/Arg.php
Arg.exclusiveRange
function exclusiveRange($min = null, $max = null) { $this->exclusiveMin($min); $this->exclusiveMax($max); return $this; }
php
function exclusiveRange($min = null, $max = null) { $this->exclusiveMin($min); $this->exclusiveMax($max); return $this; }
[ "function", "exclusiveRange", "(", "$", "min", "=", "null", ",", "$", "max", "=", "null", ")", "{", "$", "this", "->", "exclusiveMin", "(", "$", "min", ")", ";", "$", "this", "->", "exclusiveMax", "(", "$", "max", ")", ";", "return", "$", "this", ";", "}" ]
Set the exclusive minimum and maximum @param numeric minimum @param numeric maximum @return Arg
[ "Set", "the", "exclusive", "minimum", "and", "maximum" ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Http/Arg.php#L167-L172
15,080
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/TagCollection.php
TagCollection.add
public function add($tag) { if (!$tag instanceof TagInterface) { throw new \InvalidArgumentException('This tag is not allowed'); } if ($this->isUniqueTag($tag->getName())) { $this->removeByName($tag->getName()); } return parent::add($tag); }
php
public function add($tag) { if (!$tag instanceof TagInterface) { throw new \InvalidArgumentException('This tag is not allowed'); } if ($this->isUniqueTag($tag->getName())) { $this->removeByName($tag->getName()); } return parent::add($tag); }
[ "public", "function", "add", "(", "$", "tag", ")", "{", "if", "(", "!", "$", "tag", "instanceof", "TagInterface", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'This tag is not allowed'", ")", ";", "}", "if", "(", "$", "this", "->", "isUniqueTag", "(", "$", "tag", "->", "getName", "(", ")", ")", ")", "{", "$", "this", "->", "removeByName", "(", "$", "tag", "->", "getName", "(", ")", ")", ";", "}", "return", "parent", "::", "add", "(", "$", "tag", ")", ";", "}" ]
Adds a new Tag on Dockblock. @param TagInterface $tag @throws \InvalidArgumentException @return bool
[ "Adds", "a", "new", "Tag", "on", "Dockblock", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/TagCollection.php#L40-L50
15,081
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/TagCollection.php
TagCollection.sortAsc
public function sortAsc() { $cmp = function (TagInterface $a, TagInterface $b) { if ($a->getName() == $b->getName()) { return 0; } return ($a->getName() < $b->getName()) ? -1 : 1; }; usort($this->elements, $cmp); }
php
public function sortAsc() { $cmp = function (TagInterface $a, TagInterface $b) { if ($a->getName() == $b->getName()) { return 0; } return ($a->getName() < $b->getName()) ? -1 : 1; }; usort($this->elements, $cmp); }
[ "public", "function", "sortAsc", "(", ")", "{", "$", "cmp", "=", "function", "(", "TagInterface", "$", "a", ",", "TagInterface", "$", "b", ")", "{", "if", "(", "$", "a", "->", "getName", "(", ")", "==", "$", "b", "->", "getName", "(", ")", ")", "{", "return", "0", ";", "}", "return", "(", "$", "a", "->", "getName", "(", ")", "<", "$", "b", "->", "getName", "(", ")", ")", "?", "-", "1", ":", "1", ";", "}", ";", "usort", "(", "$", "this", "->", "elements", ",", "$", "cmp", ")", ";", "}" ]
Sort the list by elements. @return void
[ "Sort", "the", "list", "by", "elements", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/TagCollection.php#L121-L131
15,082
acasademont/wurfl
WURFL/Configuration/XmlConfig.php
WURFL_Configuration_XmlConfig.initialize
protected function initialize() { $xmlConfig = simplexml_load_file($this->configFilePath); $this->wurflFile = $this->wurflFile($xmlConfig->xpath('/wurfl-config/wurfl/main-file')); $this->wurflPatches = $this->wurflPatches($xmlConfig->xpath('/wurfl-config/wurfl/patches/patch')); $this->allowReload = $this->allowReload($xmlConfig->xpath('/wurfl-config/allow-reload')); $this->capabilityFilter = $this->capabilityFilter($xmlConfig->xpath('/wurfl-config/capability-filter/capability')); $this->persistence = $this->persistence($xmlConfig->xpath('/wurfl-config/persistence')); $this->cache = $this->persistence($xmlConfig->xpath('/wurfl-config/cache')); $this->logDir = $this->logDir($xmlConfig->xpath('/wurfl-config/logDir')); $this->matchMode = $this->matchMode($xmlConfig->xpath('/wurfl-config/match-mode')); }
php
protected function initialize() { $xmlConfig = simplexml_load_file($this->configFilePath); $this->wurflFile = $this->wurflFile($xmlConfig->xpath('/wurfl-config/wurfl/main-file')); $this->wurflPatches = $this->wurflPatches($xmlConfig->xpath('/wurfl-config/wurfl/patches/patch')); $this->allowReload = $this->allowReload($xmlConfig->xpath('/wurfl-config/allow-reload')); $this->capabilityFilter = $this->capabilityFilter($xmlConfig->xpath('/wurfl-config/capability-filter/capability')); $this->persistence = $this->persistence($xmlConfig->xpath('/wurfl-config/persistence')); $this->cache = $this->persistence($xmlConfig->xpath('/wurfl-config/cache')); $this->logDir = $this->logDir($xmlConfig->xpath('/wurfl-config/logDir')); $this->matchMode = $this->matchMode($xmlConfig->xpath('/wurfl-config/match-mode')); }
[ "protected", "function", "initialize", "(", ")", "{", "$", "xmlConfig", "=", "simplexml_load_file", "(", "$", "this", "->", "configFilePath", ")", ";", "$", "this", "->", "wurflFile", "=", "$", "this", "->", "wurflFile", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/wurfl/main-file'", ")", ")", ";", "$", "this", "->", "wurflPatches", "=", "$", "this", "->", "wurflPatches", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/wurfl/patches/patch'", ")", ")", ";", "$", "this", "->", "allowReload", "=", "$", "this", "->", "allowReload", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/allow-reload'", ")", ")", ";", "$", "this", "->", "capabilityFilter", "=", "$", "this", "->", "capabilityFilter", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/capability-filter/capability'", ")", ")", ";", "$", "this", "->", "persistence", "=", "$", "this", "->", "persistence", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/persistence'", ")", ")", ";", "$", "this", "->", "cache", "=", "$", "this", "->", "persistence", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/cache'", ")", ")", ";", "$", "this", "->", "logDir", "=", "$", "this", "->", "logDir", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/logDir'", ")", ")", ";", "$", "this", "->", "matchMode", "=", "$", "this", "->", "matchMode", "(", "$", "xmlConfig", "->", "xpath", "(", "'/wurfl-config/match-mode'", ")", ")", ";", "}" ]
Initialize XML Configuration
[ "Initialize", "XML", "Configuration" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/XmlConfig.php#L27-L38
15,083
acasademont/wurfl
WURFL/Configuration/XmlConfig.php
WURFL_Configuration_XmlConfig.wurflPatches
private function wurflPatches($patchElements) { $patches = array(); if ($patchElements) { foreach ($patchElements as $patchElement) { $patches[] = parent::getFullPath((string)$patchElement); } } return $patches; }
php
private function wurflPatches($patchElements) { $patches = array(); if ($patchElements) { foreach ($patchElements as $patchElement) { $patches[] = parent::getFullPath((string)$patchElement); } } return $patches; }
[ "private", "function", "wurflPatches", "(", "$", "patchElements", ")", "{", "$", "patches", "=", "array", "(", ")", ";", "if", "(", "$", "patchElements", ")", "{", "foreach", "(", "$", "patchElements", "as", "$", "patchElement", ")", "{", "$", "patches", "[", "]", "=", "parent", "::", "getFullPath", "(", "(", "string", ")", "$", "patchElement", ")", ";", "}", "}", "return", "$", "patches", ";", "}" ]
Returns an array of full path WURFL patches @param array $patchElements array of SimpleXMLElement objects @return array WURFL Patches
[ "Returns", "an", "array", "of", "full", "path", "WURFL", "patches" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/XmlConfig.php#L55-L64
15,084
acasademont/wurfl
WURFL/Configuration/XmlConfig.php
WURFL_Configuration_XmlConfig.capabilityFilter
private function capabilityFilter($capabilityFilter) { $filter = array(); if ($capabilityFilter) { foreach ($capabilityFilter as $filterElement) { $filter[] = (string)$filterElement; } } return $filter; }
php
private function capabilityFilter($capabilityFilter) { $filter = array(); if ($capabilityFilter) { foreach ($capabilityFilter as $filterElement) { $filter[] = (string)$filterElement; } } return $filter; }
[ "private", "function", "capabilityFilter", "(", "$", "capabilityFilter", ")", "{", "$", "filter", "=", "array", "(", ")", ";", "if", "(", "$", "capabilityFilter", ")", "{", "foreach", "(", "$", "capabilityFilter", "as", "$", "filterElement", ")", "{", "$", "filter", "[", "]", "=", "(", "string", ")", "$", "filterElement", ";", "}", "}", "return", "$", "filter", ";", "}" ]
Returns an array of WURFL Capabilities @param array $capabilityFilter array of SimpleXMLElement objects @return array WURFL Capabilities
[ "Returns", "an", "array", "of", "WURFL", "Capabilities" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/XmlConfig.php#L71-L80
15,085
acasademont/wurfl
WURFL/Configuration/XmlConfig.php
WURFL_Configuration_XmlConfig.matchMode
private function matchMode($modeElement) { if (!empty($modeElement)) { $mode = $modeElement[0]; if (!$mode) { return $this->matchMode; } if (!self::validMatchMode($mode)) { throw new WURFL_WURFLException('Invalid Match Mode: '.$mode); } $this->matchMode = $mode; } return $this->matchMode; }
php
private function matchMode($modeElement) { if (!empty($modeElement)) { $mode = $modeElement[0]; if (!$mode) { return $this->matchMode; } if (!self::validMatchMode($mode)) { throw new WURFL_WURFLException('Invalid Match Mode: '.$mode); } $this->matchMode = $mode; } return $this->matchMode; }
[ "private", "function", "matchMode", "(", "$", "modeElement", ")", "{", "if", "(", "!", "empty", "(", "$", "modeElement", ")", ")", "{", "$", "mode", "=", "$", "modeElement", "[", "0", "]", ";", "if", "(", "!", "$", "mode", ")", "{", "return", "$", "this", "->", "matchMode", ";", "}", "if", "(", "!", "self", "::", "validMatchMode", "(", "$", "mode", ")", ")", "{", "throw", "new", "WURFL_WURFLException", "(", "'Invalid Match Mode: '", ".", "$", "mode", ")", ";", "}", "$", "this", "->", "matchMode", "=", "$", "mode", ";", "}", "return", "$", "this", "->", "matchMode", ";", "}" ]
Returns the mode of operation if set, otherwise null @param array $modeElement array of SimpleXMLElement objects @return boolean
[ "Returns", "the", "mode", "of", "operation", "if", "set", "otherwise", "null" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/XmlConfig.php#L100-L113
15,086
acasademont/wurfl
WURFL/Configuration/XmlConfig.php
WURFL_Configuration_XmlConfig.persistence
private function persistence($persistenceElement) { $persistence = array(); if ($persistenceElement) { $persistence['provider'] = (string)$persistenceElement[0]->provider; $persistence['params'] = $this->_toArray((string)$persistenceElement[0]->params); } return $persistence; }
php
private function persistence($persistenceElement) { $persistence = array(); if ($persistenceElement) { $persistence['provider'] = (string)$persistenceElement[0]->provider; $persistence['params'] = $this->_toArray((string)$persistenceElement[0]->params); } return $persistence; }
[ "private", "function", "persistence", "(", "$", "persistenceElement", ")", "{", "$", "persistence", "=", "array", "(", ")", ";", "if", "(", "$", "persistenceElement", ")", "{", "$", "persistence", "[", "'provider'", "]", "=", "(", "string", ")", "$", "persistenceElement", "[", "0", "]", "->", "provider", ";", "$", "persistence", "[", "'params'", "]", "=", "$", "this", "->", "_toArray", "(", "(", "string", ")", "$", "persistenceElement", "[", "0", "]", "->", "params", ")", ";", "}", "return", "$", "persistence", ";", "}" ]
Returns persistence provider info from XML config @param array $persistenceElement array of SimpleXMLElement objects @return array Persistence info
[ "Returns", "persistence", "provider", "info", "from", "XML", "config" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Configuration/XmlConfig.php#L133-L141
15,087
toxor88/yii2-widget-switchery
Switchery.php
Switchery.registerPlugin
protected function registerPlugin() { if (!isset($this->options['id'])) { $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId(); } else { $this->setId($this->options['id']); } $clientOptions = []; $this->clientOptions = ArrayHelper::merge($clientOptions, $this->clientOptions); if ($this->hasModel()) { $this->querySelector = '#' . $this->options['id']; } elseif (empty($this->querySelector)) { $this->querySelector = ArrayHelper::remove($this->clientOptions, 'querySelector', '#' . $this->options['id']); } }
php
protected function registerPlugin() { if (!isset($this->options['id'])) { $this->options['id'] = $this->hasModel() ? Html::getInputId($this->model, $this->attribute) : $this->getId(); } else { $this->setId($this->options['id']); } $clientOptions = []; $this->clientOptions = ArrayHelper::merge($clientOptions, $this->clientOptions); if ($this->hasModel()) { $this->querySelector = '#' . $this->options['id']; } elseif (empty($this->querySelector)) { $this->querySelector = ArrayHelper::remove($this->clientOptions, 'querySelector', '#' . $this->options['id']); } }
[ "protected", "function", "registerPlugin", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'id'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'id'", "]", "=", "$", "this", "->", "hasModel", "(", ")", "?", "Html", "::", "getInputId", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ")", ":", "$", "this", "->", "getId", "(", ")", ";", "}", "else", "{", "$", "this", "->", "setId", "(", "$", "this", "->", "options", "[", "'id'", "]", ")", ";", "}", "$", "clientOptions", "=", "[", "]", ";", "$", "this", "->", "clientOptions", "=", "ArrayHelper", "::", "merge", "(", "$", "clientOptions", ",", "$", "this", "->", "clientOptions", ")", ";", "if", "(", "$", "this", "->", "hasModel", "(", ")", ")", "{", "$", "this", "->", "querySelector", "=", "'#'", ".", "$", "this", "->", "options", "[", "'id'", "]", ";", "}", "elseif", "(", "empty", "(", "$", "this", "->", "querySelector", ")", ")", "{", "$", "this", "->", "querySelector", "=", "ArrayHelper", "::", "remove", "(", "$", "this", "->", "clientOptions", ",", "'querySelector'", ",", "'#'", ".", "$", "this", "->", "options", "[", "'id'", "]", ")", ";", "}", "}" ]
Registers switchery plugin
[ "Registers", "switchery", "plugin" ]
ddee54d4d486a514d3b02a249f2cc3833b020d0c
https://github.com/toxor88/yii2-widget-switchery/blob/ddee54d4d486a514d3b02a249f2cc3833b020d0c/Switchery.php#L98-L114
15,088
drunomics/service-utils
src/user/SharedTempStoreFactoryTrait.php
SharedTempStoreFactoryTrait.getSharedTempStoreFactory
public function getSharedTempStoreFactory() { if (empty($this->sharedTempStoreFactory)) { $this->sharedTempStoreFactory = \Drupal::service('user.shared_tempstore'); } return $this->sharedTempStoreFactory; }
php
public function getSharedTempStoreFactory() { if (empty($this->sharedTempStoreFactory)) { $this->sharedTempStoreFactory = \Drupal::service('user.shared_tempstore'); } return $this->sharedTempStoreFactory; }
[ "public", "function", "getSharedTempStoreFactory", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "sharedTempStoreFactory", ")", ")", "{", "$", "this", "->", "sharedTempStoreFactory", "=", "\\", "Drupal", "::", "service", "(", "'user.shared_tempstore'", ")", ";", "}", "return", "$", "this", "->", "sharedTempStoreFactory", ";", "}" ]
Gets shared tempstore factory. @return \Drupal\user\SharedTempStoreFactory Shared tempstore factory.
[ "Gets", "shared", "tempstore", "factory", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/user/SharedTempStoreFactoryTrait.php#L38-L43
15,089
graphp/plaintext
src/File.php
File.getLines
protected function getLines() { $ret = file($this->fileName); if ($ret === false) { throw new Exception('Unable to read file'); } $lines = array(); foreach ($ret as $line) { $lines[] = rtrim($line); } return $lines; }
php
protected function getLines() { $ret = file($this->fileName); if ($ret === false) { throw new Exception('Unable to read file'); } $lines = array(); foreach ($ret as $line) { $lines[] = rtrim($line); } return $lines; }
[ "protected", "function", "getLines", "(", ")", "{", "$", "ret", "=", "file", "(", "$", "this", "->", "fileName", ")", ";", "if", "(", "$", "ret", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Unable to read file'", ")", ";", "}", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "ret", "as", "$", "line", ")", "{", "$", "lines", "[", "]", "=", "rtrim", "(", "$", "line", ")", ";", "}", "return", "$", "lines", ";", "}" ]
get an array of all lines in this file @return string[] @throws InvalidArgumentException if file can not be read
[ "get", "an", "array", "of", "all", "lines", "in", "this", "file" ]
77cfdc71558f7d04860afc73b4b5e70eded21f00
https://github.com/graphp/plaintext/blob/77cfdc71558f7d04860afc73b4b5e70eded21f00/src/File.php#L24-L36
15,090
phramework/jsonapi
src/Model.php
Model.collection
public static function collection($records = [], Fields $fields = null, $flags = Resource::PARSE_DEFAULT) { return Resource::parseFromRecords( $records, static::class, $fields, $flags ); }
php
public static function collection($records = [], Fields $fields = null, $flags = Resource::PARSE_DEFAULT) { return Resource::parseFromRecords( $records, static::class, $fields, $flags ); }
[ "public", "static", "function", "collection", "(", "$", "records", "=", "[", "]", ",", "Fields", "$", "fields", "=", "null", ",", "$", "flags", "=", "Resource", "::", "PARSE_DEFAULT", ")", "{", "return", "Resource", "::", "parseFromRecords", "(", "$", "records", ",", "static", "::", "class", ",", "$", "fields", ",", "$", "flags", ")", ";", "}" ]
Prepare a collection of resources @param array[]|object[] $records Multiple records fetched from database [Optional] Write resource and relationship links, defaults is false @param Fields|null $fields @param int $flags @return Resource[] @uses Resource::parseFromRecords @example ```php Model::collection([ [ 'id' => '10', 'title' => 'Hello world' ] ]); ```
[ "Prepare", "a", "collection", "of", "resources" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model.php#L96-L104
15,091
phramework/jsonapi
src/Model.php
Model.resource
public static function resource($record, Fields $fields = null, $flags = Resource::PARSE_DEFAULT) { return Resource::parseFromRecord( $record, static::class, $fields, $flags ); }
php
public static function resource($record, Fields $fields = null, $flags = Resource::PARSE_DEFAULT) { return Resource::parseFromRecord( $record, static::class, $fields, $flags ); }
[ "public", "static", "function", "resource", "(", "$", "record", ",", "Fields", "$", "fields", "=", "null", ",", "$", "flags", "=", "Resource", "::", "PARSE_DEFAULT", ")", "{", "return", "Resource", "::", "parseFromRecord", "(", "$", "record", ",", "static", "::", "class", ",", "$", "fields", ",", "$", "flags", ")", ";", "}" ]
Prepare an individual resource @param array|object $record A single record fetched from database @param Fields|null $fields @param int $flags @return Resource|null @throws \Exception @uses Resource::parseFromRecord @example ```php Model::resource( [ 'id' => '10', 'title' => 'Hello world' ], null, Resource::PARSE_DEFAULT | Resource::PARSE_RELATIONSHIP_DATA ); ```
[ "Prepare", "an", "individual", "resource" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model.php#L126-L134
15,092
phramework/jsonapi
src/Model.php
Model.post
public static function post( $attributes, $return = \Phramework\Database\Operations\Create::RETURN_ID ) { return \Phramework\Database\Operations\Create::create( $attributes, static::getTable(), static::getSchema(), $return ); }
php
public static function post( $attributes, $return = \Phramework\Database\Operations\Create::RETURN_ID ) { return \Phramework\Database\Operations\Create::create( $attributes, static::getTable(), static::getSchema(), $return ); }
[ "public", "static", "function", "post", "(", "$", "attributes", ",", "$", "return", "=", "\\", "Phramework", "\\", "Database", "\\", "Operations", "\\", "Create", "::", "RETURN_ID", ")", "{", "return", "\\", "Phramework", "\\", "Database", "\\", "Operations", "\\", "Create", "::", "create", "(", "$", "attributes", ",", "static", "::", "getTable", "(", ")", ",", "static", "::", "getSchema", "(", ")", ",", "$", "return", ")", ";", "}" ]
Create a record in database @param array $attributes @param \Phramework\Database\Operations\Create::RETURN_ID $return Return type, default is RETURN_ID @return mixed @todo disable post ?
[ "Create", "a", "record", "in", "database" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model.php#L144-L154
15,093
phramework/jsonapi
src/Model.php
Model.patch
public static function patch($id, $attributes) { static::invalidateCache($id); return \Phramework\Database\Operations\Update::update( $id, (array) $attributes, ( static::getSchema() === null ? static::getTable() : [ 'table' => static::getTable(), 'schema' => static::getSchema() ] ), static::getIdAttribute() ); }
php
public static function patch($id, $attributes) { static::invalidateCache($id); return \Phramework\Database\Operations\Update::update( $id, (array) $attributes, ( static::getSchema() === null ? static::getTable() : [ 'table' => static::getTable(), 'schema' => static::getSchema() ] ), static::getIdAttribute() ); }
[ "public", "static", "function", "patch", "(", "$", "id", ",", "$", "attributes", ")", "{", "static", "::", "invalidateCache", "(", "$", "id", ")", ";", "return", "\\", "Phramework", "\\", "Database", "\\", "Operations", "\\", "Update", "::", "update", "(", "$", "id", ",", "(", "array", ")", "$", "attributes", ",", "(", "static", "::", "getSchema", "(", ")", "===", "null", "?", "static", "::", "getTable", "(", ")", ":", "[", "'table'", "=>", "static", "::", "getTable", "(", ")", ",", "'schema'", "=>", "static", "::", "getSchema", "(", ")", "]", ")", ",", "static", "::", "getIdAttribute", "(", ")", ")", ";", "}" ]
Update selected attributes of a database record @param mixed $id id attribute's value @param object $attributes Key-value array with fields to update @return int Number of updated rows @todo add query limit
[ "Update", "selected", "attributes", "of", "a", "database", "record" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model.php#L163-L180
15,094
phramework/jsonapi
src/Model.php
Model.delete
public static function delete($id, $additionalAttributes = null) { static::invalidateCache($id); return \Phramework\Database\Operations\Delete::delete( $id, ( $additionalAttributes !== null ? (array) $additionalAttributes : [] ), ( static::getSchema() === null ? static::getTable() : [ 'table' => static::getTable(), 'schema' => static::getSchema() ] ), static::getIdAttribute() ); }
php
public static function delete($id, $additionalAttributes = null) { static::invalidateCache($id); return \Phramework\Database\Operations\Delete::delete( $id, ( $additionalAttributes !== null ? (array) $additionalAttributes : [] ), ( static::getSchema() === null ? static::getTable() : [ 'table' => static::getTable(), 'schema' => static::getSchema() ] ), static::getIdAttribute() ); }
[ "public", "static", "function", "delete", "(", "$", "id", ",", "$", "additionalAttributes", "=", "null", ")", "{", "static", "::", "invalidateCache", "(", "$", "id", ")", ";", "return", "\\", "Phramework", "\\", "Database", "\\", "Operations", "\\", "Delete", "::", "delete", "(", "$", "id", ",", "(", "$", "additionalAttributes", "!==", "null", "?", "(", "array", ")", "$", "additionalAttributes", ":", "[", "]", ")", ",", "(", "static", "::", "getSchema", "(", ")", "===", "null", "?", "static", "::", "getTable", "(", ")", ":", "[", "'table'", "=>", "static", "::", "getTable", "(", ")", ",", "'schema'", "=>", "static", "::", "getSchema", "(", ")", "]", ")", ",", "static", "::", "getIdAttribute", "(", ")", ")", ";", "}" ]
Delete a database record @param mixed $id id attribute's value @param object $additionalAttributes Object with additional fields to use in WHERE clause @return boolean Returns true on success, false on failure
[ "Delete", "a", "database", "record" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model.php#L189-L210
15,095
WebDevTmas/date-repetition
src/DateRepetition/DateRepetitionInterpeter.php
DateRepetitionInterpeter.convertDateRepetitionToString
public static function convertDateRepetitionToString(DateRepetition $dateRepetition) { $dateString = ''; if($dateRepetition instanceof HourlyDateRepetition) { $prefix = 'hourly'; $timeString = ' at minute ' . $dateRepetition->getMinute(); } if($dateRepetition instanceof DailyDateRepetition) { $prefix = 'daily'; $timeString = ' at ' . $dateRepetition->getHour() . ':' . $dateRepetition->getMinute(); } if($dateRepetition instanceof WeeklyDateRepetition) { $prefix = 'weekly'; $dateString = ' on ' . $dateRepetition->getDay(); } return $prefix . $dateString . $timeString; }
php
public static function convertDateRepetitionToString(DateRepetition $dateRepetition) { $dateString = ''; if($dateRepetition instanceof HourlyDateRepetition) { $prefix = 'hourly'; $timeString = ' at minute ' . $dateRepetition->getMinute(); } if($dateRepetition instanceof DailyDateRepetition) { $prefix = 'daily'; $timeString = ' at ' . $dateRepetition->getHour() . ':' . $dateRepetition->getMinute(); } if($dateRepetition instanceof WeeklyDateRepetition) { $prefix = 'weekly'; $dateString = ' on ' . $dateRepetition->getDay(); } return $prefix . $dateString . $timeString; }
[ "public", "static", "function", "convertDateRepetitionToString", "(", "DateRepetition", "$", "dateRepetition", ")", "{", "$", "dateString", "=", "''", ";", "if", "(", "$", "dateRepetition", "instanceof", "HourlyDateRepetition", ")", "{", "$", "prefix", "=", "'hourly'", ";", "$", "timeString", "=", "' at minute '", ".", "$", "dateRepetition", "->", "getMinute", "(", ")", ";", "}", "if", "(", "$", "dateRepetition", "instanceof", "DailyDateRepetition", ")", "{", "$", "prefix", "=", "'daily'", ";", "$", "timeString", "=", "' at '", ".", "$", "dateRepetition", "->", "getHour", "(", ")", ".", "':'", ".", "$", "dateRepetition", "->", "getMinute", "(", ")", ";", "}", "if", "(", "$", "dateRepetition", "instanceof", "WeeklyDateRepetition", ")", "{", "$", "prefix", "=", "'weekly'", ";", "$", "dateString", "=", "' on '", ".", "$", "dateRepetition", "->", "getDay", "(", ")", ";", "}", "return", "$", "prefix", ".", "$", "dateString", ".", "$", "timeString", ";", "}" ]
converts DateRepetition to a string accepted by 'newDateRepetitionFromString' @param DateRepetition @return string
[ "converts", "DateRepetition", "to", "a", "string", "accepted", "by", "newDateRepetitionFromString" ]
3ebd59f4ab3aab4b7497ebd767a57fad08277c6d
https://github.com/WebDevTmas/date-repetition/blob/3ebd59f4ab3aab4b7497ebd767a57fad08277c6d/src/DateRepetition/DateRepetitionInterpeter.php#L55-L73
15,096
ericpoe/haystack
src/HString.php
HString.toHArray
public function toHArray($delim = '', $limit = null) { if (empty($this->str)) { return new HArray(); } $arr = new StringToArray($this->str, $delim); return new HArray($arr->stringToArray($limit)); }
php
public function toHArray($delim = '', $limit = null) { if (empty($this->str)) { return new HArray(); } $arr = new StringToArray($this->str, $delim); return new HArray($arr->stringToArray($limit)); }
[ "public", "function", "toHArray", "(", "$", "delim", "=", "''", ",", "$", "limit", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "str", ")", ")", "{", "return", "new", "HArray", "(", ")", ";", "}", "$", "arr", "=", "new", "StringToArray", "(", "$", "this", "->", "str", ",", "$", "delim", ")", ";", "return", "new", "HArray", "(", "$", "arr", "->", "stringToArray", "(", "$", "limit", ")", ")", ";", "}" ]
Alias to PHP function `explode` @param string $delim @param null|int $limit @return HArray @throws \InvalidArgumentException
[ "Alias", "to", "PHP", "function", "explode" ]
92c9ec4698fd013c1465efa6d49bc844a5869be0
https://github.com/ericpoe/haystack/blob/92c9ec4698fd013c1465efa6d49bc844a5869be0/src/HString.php#L273-L281
15,097
activecollab/databasemigrations
src/Command/Create.php
Create.getMigrationFileContents
private function getMigrationFileContents($class_name) { $namespace = $this->getNamespace(); $contents = [ '<?php', '', ]; if ($header_comment = $this->getHeaderComment()) { $contents[] = '/*'; $contents = array_merge($contents, array_map(function ($line) { if ($line) { return ' * ' . $line; } else { return ' *'; } }, explode("\n", $header_comment))); $contents[] = ' */'; $contents[] = ''; } if ($namespace) { $contents[] = 'namespace ' . $namespace . ';'; $contents[] = ''; } $contents[] = 'use ActiveCollab\DatabaseMigrations\Migration\Migration;'; $contents[] = ''; if ($namespace) { $contents[] = '/**'; $contents[] = ' * @package ' . $namespace; $contents[] = ' */'; } $contents[] = 'class ' . $class_name . ' extends Migration'; $contents[] = '{'; $contents[] = ' /**'; $contents[] = ' * {@inheritdoc}'; $contents[] = ' */'; $contents[] = ' public function up()'; $contents[] = ' {'; $contents[] = ' }'; $contents[] = '}'; $contents[] = ''; return implode("\n", $contents); }
php
private function getMigrationFileContents($class_name) { $namespace = $this->getNamespace(); $contents = [ '<?php', '', ]; if ($header_comment = $this->getHeaderComment()) { $contents[] = '/*'; $contents = array_merge($contents, array_map(function ($line) { if ($line) { return ' * ' . $line; } else { return ' *'; } }, explode("\n", $header_comment))); $contents[] = ' */'; $contents[] = ''; } if ($namespace) { $contents[] = 'namespace ' . $namespace . ';'; $contents[] = ''; } $contents[] = 'use ActiveCollab\DatabaseMigrations\Migration\Migration;'; $contents[] = ''; if ($namespace) { $contents[] = '/**'; $contents[] = ' * @package ' . $namespace; $contents[] = ' */'; } $contents[] = 'class ' . $class_name . ' extends Migration'; $contents[] = '{'; $contents[] = ' /**'; $contents[] = ' * {@inheritdoc}'; $contents[] = ' */'; $contents[] = ' public function up()'; $contents[] = ' {'; $contents[] = ' }'; $contents[] = '}'; $contents[] = ''; return implode("\n", $contents); }
[ "private", "function", "getMigrationFileContents", "(", "$", "class_name", ")", "{", "$", "namespace", "=", "$", "this", "->", "getNamespace", "(", ")", ";", "$", "contents", "=", "[", "'<?php'", ",", "''", ",", "]", ";", "if", "(", "$", "header_comment", "=", "$", "this", "->", "getHeaderComment", "(", ")", ")", "{", "$", "contents", "[", "]", "=", "'/*'", ";", "$", "contents", "=", "array_merge", "(", "$", "contents", ",", "array_map", "(", "function", "(", "$", "line", ")", "{", "if", "(", "$", "line", ")", "{", "return", "' * '", ".", "$", "line", ";", "}", "else", "{", "return", "' *'", ";", "}", "}", ",", "explode", "(", "\"\\n\"", ",", "$", "header_comment", ")", ")", ")", ";", "$", "contents", "[", "]", "=", "' */'", ";", "$", "contents", "[", "]", "=", "''", ";", "}", "if", "(", "$", "namespace", ")", "{", "$", "contents", "[", "]", "=", "'namespace '", ".", "$", "namespace", ".", "';'", ";", "$", "contents", "[", "]", "=", "''", ";", "}", "$", "contents", "[", "]", "=", "'use ActiveCollab\\DatabaseMigrations\\Migration\\Migration;'", ";", "$", "contents", "[", "]", "=", "''", ";", "if", "(", "$", "namespace", ")", "{", "$", "contents", "[", "]", "=", "'/**'", ";", "$", "contents", "[", "]", "=", "' * @package '", ".", "$", "namespace", ";", "$", "contents", "[", "]", "=", "' */'", ";", "}", "$", "contents", "[", "]", "=", "'class '", ".", "$", "class_name", ".", "' extends Migration'", ";", "$", "contents", "[", "]", "=", "'{'", ";", "$", "contents", "[", "]", "=", "' /**'", ";", "$", "contents", "[", "]", "=", "' * {@inheritdoc}'", ";", "$", "contents", "[", "]", "=", "' */'", ";", "$", "contents", "[", "]", "=", "' public function up()'", ";", "$", "contents", "[", "]", "=", "' {'", ";", "$", "contents", "[", "]", "=", "' }'", ";", "$", "contents", "[", "]", "=", "'}'", ";", "$", "contents", "[", "]", "=", "''", ";", "return", "implode", "(", "\"\\n\"", ",", "$", "contents", ")", ";", "}" ]
Generate migration class contents. @param string $class_name @return string
[ "Generate", "migration", "class", "contents", "." ]
ef91d5b5f74d79b4a75695393eb25c7c47dad093
https://github.com/activecollab/databasemigrations/blob/ef91d5b5f74d79b4a75695393eb25c7c47dad093/src/Command/Create.php#L77-L125
15,098
kiwiz/ecl
src/Command/Elasticsearch.php
Elasticsearch.setSettings
public function setSettings(array $settings) { $this->settings = $settings; $hosts = \ECL\Util::get($settings, 'hosts', []); $index_hosts = \ECL\Util::get($settings, 'index_hosts', []); $ssl_cert = \ECL\Util::get($settings, 'ssl_cert', null); $ssl_client_key = \ECL\Util::get($settings, 'ssl_client_key', null); $ssl_client_cert = \ECL\Util::get($settings, 'ssl_client_cert', null); if(count($index_hosts) == 0) { $index_hosts = $hosts; } $cb = \Elasticsearch\ClientBuilder::create(); if(count($hosts)) { $cb->setHosts($hosts); } $icb = \Elasticsearch\ClientBuilder::create(); if(count($index_hosts)) { $icb->setHosts($index_hosts); } if($ssl_cert !== null) { $cb->setSSLVerification($ssl_cert); $icb->setSSLVerification($ssl_cert); } if($ssl_client_key !== null && $ssl_client_cert !== null) { $cb->setSSLKey($ssl_client_key); $cb->setSSLCert($ssl_client_cert); $icb->setSSLKey($ssl_client_key); $icb->setSSLCert($ssl_client_cert); } $this->client = $cb->build(); $this->index_client = $icb->build(); }
php
public function setSettings(array $settings) { $this->settings = $settings; $hosts = \ECL\Util::get($settings, 'hosts', []); $index_hosts = \ECL\Util::get($settings, 'index_hosts', []); $ssl_cert = \ECL\Util::get($settings, 'ssl_cert', null); $ssl_client_key = \ECL\Util::get($settings, 'ssl_client_key', null); $ssl_client_cert = \ECL\Util::get($settings, 'ssl_client_cert', null); if(count($index_hosts) == 0) { $index_hosts = $hosts; } $cb = \Elasticsearch\ClientBuilder::create(); if(count($hosts)) { $cb->setHosts($hosts); } $icb = \Elasticsearch\ClientBuilder::create(); if(count($index_hosts)) { $icb->setHosts($index_hosts); } if($ssl_cert !== null) { $cb->setSSLVerification($ssl_cert); $icb->setSSLVerification($ssl_cert); } if($ssl_client_key !== null && $ssl_client_cert !== null) { $cb->setSSLKey($ssl_client_key); $cb->setSSLCert($ssl_client_cert); $icb->setSSLKey($ssl_client_key); $icb->setSSLCert($ssl_client_cert); } $this->client = $cb->build(); $this->index_client = $icb->build(); }
[ "public", "function", "setSettings", "(", "array", "$", "settings", ")", "{", "$", "this", "->", "settings", "=", "$", "settings", ";", "$", "hosts", "=", "\\", "ECL", "\\", "Util", "::", "get", "(", "$", "settings", ",", "'hosts'", ",", "[", "]", ")", ";", "$", "index_hosts", "=", "\\", "ECL", "\\", "Util", "::", "get", "(", "$", "settings", ",", "'index_hosts'", ",", "[", "]", ")", ";", "$", "ssl_cert", "=", "\\", "ECL", "\\", "Util", "::", "get", "(", "$", "settings", ",", "'ssl_cert'", ",", "null", ")", ";", "$", "ssl_client_key", "=", "\\", "ECL", "\\", "Util", "::", "get", "(", "$", "settings", ",", "'ssl_client_key'", ",", "null", ")", ";", "$", "ssl_client_cert", "=", "\\", "ECL", "\\", "Util", "::", "get", "(", "$", "settings", ",", "'ssl_client_cert'", ",", "null", ")", ";", "if", "(", "count", "(", "$", "index_hosts", ")", "==", "0", ")", "{", "$", "index_hosts", "=", "$", "hosts", ";", "}", "$", "cb", "=", "\\", "Elasticsearch", "\\", "ClientBuilder", "::", "create", "(", ")", ";", "if", "(", "count", "(", "$", "hosts", ")", ")", "{", "$", "cb", "->", "setHosts", "(", "$", "hosts", ")", ";", "}", "$", "icb", "=", "\\", "Elasticsearch", "\\", "ClientBuilder", "::", "create", "(", ")", ";", "if", "(", "count", "(", "$", "index_hosts", ")", ")", "{", "$", "icb", "->", "setHosts", "(", "$", "index_hosts", ")", ";", "}", "if", "(", "$", "ssl_cert", "!==", "null", ")", "{", "$", "cb", "->", "setSSLVerification", "(", "$", "ssl_cert", ")", ";", "$", "icb", "->", "setSSLVerification", "(", "$", "ssl_cert", ")", ";", "}", "if", "(", "$", "ssl_client_key", "!==", "null", "&&", "$", "ssl_client_cert", "!==", "null", ")", "{", "$", "cb", "->", "setSSLKey", "(", "$", "ssl_client_key", ")", ";", "$", "cb", "->", "setSSLCert", "(", "$", "ssl_client_cert", ")", ";", "$", "icb", "->", "setSSLKey", "(", "$", "ssl_client_key", ")", ";", "$", "icb", "->", "setSSLCert", "(", "$", "ssl_client_cert", ")", ";", "}", "$", "this", "->", "client", "=", "$", "cb", "->", "build", "(", ")", ";", "$", "this", "->", "index_client", "=", "$", "icb", "->", "build", "(", ")", ";", "}" ]
Set the current list of settings. @param array $settings List of settings to apply.
[ "Set", "the", "current", "list", "of", "settings", "." ]
6536dd2a4c1905a08cf718bdbef56a22f0e9b488
https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Command/Elasticsearch.php#L51-L87
15,099
kiwiz/ecl
src/Command/Elasticsearch.php
Elasticsearch.constructQueryBody
private function constructQueryBody(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, $fields=null, $sort=null, $size=null, $date_field=null, $from=null, $to=null) { $query_body = [ 'size' => 100, 'query' => [ 'bool' => [ 'filter' => $this->constructFilter( $table, $filters, $date_field, $from, $to ) ] ] ]; // Optionally set result set size. if(!is_null($size)) { $query_body['size'] = $size; } // Optionally set aggregations if(!is_null($agg)) { $query_body['aggs'] = $agg->constructQuery($table); // When executing an agg, we don't care about the actual hits. $query_body['size'] = 0; } // Optionally set list of fields to return. if(!is_null($fields)) { $query_body['_source'] = ['include' => $fields]; } // Optionally set sort order. if(!is_null($sort)) { $query_body['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $sort); } return $query_body; }
php
private function constructQueryBody(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, $fields=null, $sort=null, $size=null, $date_field=null, $from=null, $to=null) { $query_body = [ 'size' => 100, 'query' => [ 'bool' => [ 'filter' => $this->constructFilter( $table, $filters, $date_field, $from, $to ) ] ] ]; // Optionally set result set size. if(!is_null($size)) { $query_body['size'] = $size; } // Optionally set aggregations if(!is_null($agg)) { $query_body['aggs'] = $agg->constructQuery($table); // When executing an agg, we don't care about the actual hits. $query_body['size'] = 0; } // Optionally set list of fields to return. if(!is_null($fields)) { $query_body['_source'] = ['include' => $fields]; } // Optionally set sort order. if(!is_null($sort)) { $query_body['sort'] = array_map(function($x) { return [$x[0] => ['order' => $x[1] ? 'asc':'desc']]; }, $sort); } return $query_body; }
[ "private", "function", "constructQueryBody", "(", "\\", "ECL", "\\", "SymbolTable", "$", "table", ",", "array", "$", "filters", ",", "\\", "ECL", "\\", "Command", "\\", "Elasticsearch", "\\", "Agg", "$", "agg", "=", "null", ",", "$", "fields", "=", "null", ",", "$", "sort", "=", "null", ",", "$", "size", "=", "null", ",", "$", "date_field", "=", "null", ",", "$", "from", "=", "null", ",", "$", "to", "=", "null", ")", "{", "$", "query_body", "=", "[", "'size'", "=>", "100", ",", "'query'", "=>", "[", "'bool'", "=>", "[", "'filter'", "=>", "$", "this", "->", "constructFilter", "(", "$", "table", ",", "$", "filters", ",", "$", "date_field", ",", "$", "from", ",", "$", "to", ")", "]", "]", "]", ";", "// Optionally set result set size.", "if", "(", "!", "is_null", "(", "$", "size", ")", ")", "{", "$", "query_body", "[", "'size'", "]", "=", "$", "size", ";", "}", "// Optionally set aggregations", "if", "(", "!", "is_null", "(", "$", "agg", ")", ")", "{", "$", "query_body", "[", "'aggs'", "]", "=", "$", "agg", "->", "constructQuery", "(", "$", "table", ")", ";", "// When executing an agg, we don't care about the actual hits.", "$", "query_body", "[", "'size'", "]", "=", "0", ";", "}", "// Optionally set list of fields to return.", "if", "(", "!", "is_null", "(", "$", "fields", ")", ")", "{", "$", "query_body", "[", "'_source'", "]", "=", "[", "'include'", "=>", "$", "fields", "]", ";", "}", "// Optionally set sort order.", "if", "(", "!", "is_null", "(", "$", "sort", ")", ")", "{", "$", "query_body", "[", "'sort'", "]", "=", "array_map", "(", "function", "(", "$", "x", ")", "{", "return", "[", "$", "x", "[", "0", "]", "=>", "[", "'order'", "=>", "$", "x", "[", "1", "]", "?", "'asc'", ":", "'desc'", "]", "]", ";", "}", ",", "$", "sort", ")", ";", "}", "return", "$", "query_body", ";", "}" ]
Construct the query body.
[ "Construct", "the", "query", "body", "." ]
6536dd2a4c1905a08cf718bdbef56a22f0e9b488
https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/Command/Elasticsearch.php#L177-L212