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
24,100
sciactive/nymph-server
src/Drivers/DriverTrait.php
DriverTrait.pushCache
protected function pushCache(&$entity, $className) { if (!isset($entity->guid)) { return; } // Increment the entity access count. if (!isset($this->entityCount[$entity->guid])) { $this->entityCount[$entity->guid] = 0; } $this->entityCount[$entity->guid]++; // Check the threshold. if ($this->entityCount[$entity->guid] < $this->config['cache_threshold']) { return; } // Cache the entity. if ((array) $this->entityCache[$entity->guid] === $this->entityCache[$entity->guid]) { $this->entityCache[$entity->guid][$className] = clone $entity; } else { while ($this->config['cache_limit'] && count($this->entityCache) >= $this->config['cache_limit']) { // Find which entity has been accessed the least. asort($this->entityCount); foreach ($this->entityCount as $key => $val) { if (isset($this->entityCache[$key])) { break; } } // Remove it. if (isset($this->entityCache[$key])) { unset($this->entityCache[$key]); } } $this->entityCache[$entity->guid] = [$className => (clone $entity)]; } $this->entityCache[$entity->guid][$className]->clearCache(); }
php
protected function pushCache(&$entity, $className) { if (!isset($entity->guid)) { return; } // Increment the entity access count. if (!isset($this->entityCount[$entity->guid])) { $this->entityCount[$entity->guid] = 0; } $this->entityCount[$entity->guid]++; // Check the threshold. if ($this->entityCount[$entity->guid] < $this->config['cache_threshold']) { return; } // Cache the entity. if ((array) $this->entityCache[$entity->guid] === $this->entityCache[$entity->guid]) { $this->entityCache[$entity->guid][$className] = clone $entity; } else { while ($this->config['cache_limit'] && count($this->entityCache) >= $this->config['cache_limit']) { // Find which entity has been accessed the least. asort($this->entityCount); foreach ($this->entityCount as $key => $val) { if (isset($this->entityCache[$key])) { break; } } // Remove it. if (isset($this->entityCache[$key])) { unset($this->entityCache[$key]); } } $this->entityCache[$entity->guid] = [$className => (clone $entity)]; } $this->entityCache[$entity->guid][$className]->clearCache(); }
[ "protected", "function", "pushCache", "(", "&", "$", "entity", ",", "$", "className", ")", "{", "if", "(", "!", "isset", "(", "$", "entity", "->", "guid", ")", ")", "{", "return", ";", "}", "// Increment the entity access count.", "if", "(", "!", "isset", "(", "$", "this", "->", "entityCount", "[", "$", "entity", "->", "guid", "]", ")", ")", "{", "$", "this", "->", "entityCount", "[", "$", "entity", "->", "guid", "]", "=", "0", ";", "}", "$", "this", "->", "entityCount", "[", "$", "entity", "->", "guid", "]", "++", ";", "// Check the threshold.", "if", "(", "$", "this", "->", "entityCount", "[", "$", "entity", "->", "guid", "]", "<", "$", "this", "->", "config", "[", "'cache_threshold'", "]", ")", "{", "return", ";", "}", "// Cache the entity.", "if", "(", "(", "array", ")", "$", "this", "->", "entityCache", "[", "$", "entity", "->", "guid", "]", "===", "$", "this", "->", "entityCache", "[", "$", "entity", "->", "guid", "]", ")", "{", "$", "this", "->", "entityCache", "[", "$", "entity", "->", "guid", "]", "[", "$", "className", "]", "=", "clone", "$", "entity", ";", "}", "else", "{", "while", "(", "$", "this", "->", "config", "[", "'cache_limit'", "]", "&&", "count", "(", "$", "this", "->", "entityCache", ")", ">=", "$", "this", "->", "config", "[", "'cache_limit'", "]", ")", "{", "// Find which entity has been accessed the least.", "asort", "(", "$", "this", "->", "entityCount", ")", ";", "foreach", "(", "$", "this", "->", "entityCount", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "entityCache", "[", "$", "key", "]", ")", ")", "{", "break", ";", "}", "}", "// Remove it.", "if", "(", "isset", "(", "$", "this", "->", "entityCache", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "entityCache", "[", "$", "key", "]", ")", ";", "}", "}", "$", "this", "->", "entityCache", "[", "$", "entity", "->", "guid", "]", "=", "[", "$", "className", "=>", "(", "clone", "$", "entity", ")", "]", ";", "}", "$", "this", "->", "entityCache", "[", "$", "entity", "->", "guid", "]", "[", "$", "className", "]", "->", "clearCache", "(", ")", ";", "}" ]
Push an entity onto the cache. @param Entity &$entity The entity to push onto the cache. @param string $className The class of the entity. @access protected
[ "Push", "an", "entity", "onto", "the", "cache", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L858-L893
24,101
sciactive/nymph-server
src/Drivers/DriverTrait.php
DriverTrait.sortProperty
protected function sortProperty($a, $b) { $property = $this->sortProperty; $parent = $this->sortParent; if (isset($parent) && (isset($a->$parent->$property) || isset($b->$parent->$property))) { if (!$this->sortCaseSensitive && is_string($a->$parent->$property) && is_string($b->$parent->$property)) { $aprop = strtoupper($a->$parent->$property); $bprop = strtoupper($b->$parent->$property); if ($aprop > $bprop) { return 1; } if ($aprop < $bprop) { return -1; } } else { if ($a->$parent->$property > $b->$parent->$property) { return 1; } if ($a->$parent->$property < $b->$parent->$property) { return -1; } } } // If they have the same parent, order them by their own property. if (!$this->sortCaseSensitive && is_string($a->$property) && is_string($b->$property)) { $aprop = strtoupper($a->$property); $bprop = strtoupper($b->$property); if ($aprop > $bprop) { return 1; } if ($aprop < $bprop) { return -1; } } else { if ($a->$property > $b->$property) { return 1; } if ($a->$property < $b->$property) { return -1; } } return 0; }
php
protected function sortProperty($a, $b) { $property = $this->sortProperty; $parent = $this->sortParent; if (isset($parent) && (isset($a->$parent->$property) || isset($b->$parent->$property))) { if (!$this->sortCaseSensitive && is_string($a->$parent->$property) && is_string($b->$parent->$property)) { $aprop = strtoupper($a->$parent->$property); $bprop = strtoupper($b->$parent->$property); if ($aprop > $bprop) { return 1; } if ($aprop < $bprop) { return -1; } } else { if ($a->$parent->$property > $b->$parent->$property) { return 1; } if ($a->$parent->$property < $b->$parent->$property) { return -1; } } } // If they have the same parent, order them by their own property. if (!$this->sortCaseSensitive && is_string($a->$property) && is_string($b->$property)) { $aprop = strtoupper($a->$property); $bprop = strtoupper($b->$property); if ($aprop > $bprop) { return 1; } if ($aprop < $bprop) { return -1; } } else { if ($a->$property > $b->$property) { return 1; } if ($a->$property < $b->$property) { return -1; } } return 0; }
[ "protected", "function", "sortProperty", "(", "$", "a", ",", "$", "b", ")", "{", "$", "property", "=", "$", "this", "->", "sortProperty", ";", "$", "parent", "=", "$", "this", "->", "sortParent", ";", "if", "(", "isset", "(", "$", "parent", ")", "&&", "(", "isset", "(", "$", "a", "->", "$", "parent", "->", "$", "property", ")", "||", "isset", "(", "$", "b", "->", "$", "parent", "->", "$", "property", ")", ")", ")", "{", "if", "(", "!", "$", "this", "->", "sortCaseSensitive", "&&", "is_string", "(", "$", "a", "->", "$", "parent", "->", "$", "property", ")", "&&", "is_string", "(", "$", "b", "->", "$", "parent", "->", "$", "property", ")", ")", "{", "$", "aprop", "=", "strtoupper", "(", "$", "a", "->", "$", "parent", "->", "$", "property", ")", ";", "$", "bprop", "=", "strtoupper", "(", "$", "b", "->", "$", "parent", "->", "$", "property", ")", ";", "if", "(", "$", "aprop", ">", "$", "bprop", ")", "{", "return", "1", ";", "}", "if", "(", "$", "aprop", "<", "$", "bprop", ")", "{", "return", "-", "1", ";", "}", "}", "else", "{", "if", "(", "$", "a", "->", "$", "parent", "->", "$", "property", ">", "$", "b", "->", "$", "parent", "->", "$", "property", ")", "{", "return", "1", ";", "}", "if", "(", "$", "a", "->", "$", "parent", "->", "$", "property", "<", "$", "b", "->", "$", "parent", "->", "$", "property", ")", "{", "return", "-", "1", ";", "}", "}", "}", "// If they have the same parent, order them by their own property.", "if", "(", "!", "$", "this", "->", "sortCaseSensitive", "&&", "is_string", "(", "$", "a", "->", "$", "property", ")", "&&", "is_string", "(", "$", "b", "->", "$", "property", ")", ")", "{", "$", "aprop", "=", "strtoupper", "(", "$", "a", "->", "$", "property", ")", ";", "$", "bprop", "=", "strtoupper", "(", "$", "b", "->", "$", "property", ")", ";", "if", "(", "$", "aprop", ">", "$", "bprop", ")", "{", "return", "1", ";", "}", "if", "(", "$", "aprop", "<", "$", "bprop", ")", "{", "return", "-", "1", ";", "}", "}", "else", "{", "if", "(", "$", "a", "->", "$", "property", ">", "$", "b", "->", "$", "property", ")", "{", "return", "1", ";", "}", "if", "(", "$", "a", "->", "$", "property", "<", "$", "b", "->", "$", "property", ")", "{", "return", "-", "1", ";", "}", "}", "return", "0", ";", "}" ]
Determine the sort order between two entities. @param Entity $a Entity A. @param Entity $b Entity B. @return int Sort order. @access protected
[ "Determine", "the", "sort", "order", "between", "two", "entities", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L1014-L1060
24,102
wilgucki/php-csv
src/Reader.php
Reader.open
public function open($file, $mode = 'r+') { if (!file_exists($file)) { throw new FileException('CSV file does not exist'); } parent::open($file, $mode); return $this; }
php
public function open($file, $mode = 'r+') { if (!file_exists($file)) { throw new FileException('CSV file does not exist'); } parent::open($file, $mode); return $this; }
[ "public", "function", "open", "(", "$", "file", ",", "$", "mode", "=", "'r+'", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "FileException", "(", "'CSV file does not exist'", ")", ";", "}", "parent", "::", "open", "(", "$", "file", ",", "$", "mode", ")", ";", "return", "$", "this", ";", "}" ]
Open CSV file for reading @param string $file File name with path to open @param string $mode @link http://php.net/manual/en/function.fopen.php @return $this @throws FileException
[ "Open", "CSV", "file", "for", "reading" ]
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L27-L35
24,103
wilgucki/php-csv
src/Reader.php
Reader.getHeader
public function getHeader() { $this->withHeader = true; if (ftell($this->handle) == 0) { $this->header = $this->read(); } return $this->header; }
php
public function getHeader() { $this->withHeader = true; if (ftell($this->handle) == 0) { $this->header = $this->read(); } return $this->header; }
[ "public", "function", "getHeader", "(", ")", "{", "$", "this", "->", "withHeader", "=", "true", ";", "if", "(", "ftell", "(", "$", "this", "->", "handle", ")", "==", "0", ")", "{", "$", "this", "->", "header", "=", "$", "this", "->", "read", "(", ")", ";", "}", "return", "$", "this", "->", "header", ";", "}" ]
Get CSV header. Usually it's the first line in file. @return array
[ "Get", "CSV", "header", ".", "Usually", "it", "s", "the", "first", "line", "in", "file", "." ]
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L42-L49
24,104
wilgucki/php-csv
src/Reader.php
Reader.readLine
public function readLine() { $out = $this->read(); if ($this->withHeader && is_array($out)) { $out = array_combine($this->header, $out); } return $out; }
php
public function readLine() { $out = $this->read(); if ($this->withHeader && is_array($out)) { $out = array_combine($this->header, $out); } return $out; }
[ "public", "function", "readLine", "(", ")", "{", "$", "out", "=", "$", "this", "->", "read", "(", ")", ";", "if", "(", "$", "this", "->", "withHeader", "&&", "is_array", "(", "$", "out", ")", ")", "{", "$", "out", "=", "array_combine", "(", "$", "this", "->", "header", ",", "$", "out", ")", ";", "}", "return", "$", "out", ";", "}" ]
Read current line from CSV file @return array
[ "Read", "current", "line", "from", "CSV", "file" ]
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L56-L63
24,105
wilgucki/php-csv
src/Reader.php
Reader.read
private function read() { $out = fgetcsv($this->handle, null, $this->delimiter, $this->enclosure); if (!is_array($out)) { return $out; } if ($this->encodingFrom !== null && $this->encodingTo !== null) { foreach ($out as $k => $v) { $out[$k] = iconv($this->encodingFrom, $this->encodingTo, $v); } } return $out; }
php
private function read() { $out = fgetcsv($this->handle, null, $this->delimiter, $this->enclosure); if (!is_array($out)) { return $out; } if ($this->encodingFrom !== null && $this->encodingTo !== null) { foreach ($out as $k => $v) { $out[$k] = iconv($this->encodingFrom, $this->encodingTo, $v); } } return $out; }
[ "private", "function", "read", "(", ")", "{", "$", "out", "=", "fgetcsv", "(", "$", "this", "->", "handle", ",", "null", ",", "$", "this", "->", "delimiter", ",", "$", "this", "->", "enclosure", ")", ";", "if", "(", "!", "is_array", "(", "$", "out", ")", ")", "{", "return", "$", "out", ";", "}", "if", "(", "$", "this", "->", "encodingFrom", "!==", "null", "&&", "$", "this", "->", "encodingTo", "!==", "null", ")", "{", "foreach", "(", "$", "out", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "out", "[", "$", "k", "]", "=", "iconv", "(", "$", "this", "->", "encodingFrom", ",", "$", "this", "->", "encodingTo", ",", "$", "v", ")", ";", "}", "}", "return", "$", "out", ";", "}" ]
Wrapper for fgetcsv function @return array|null|false
[ "Wrapper", "for", "fgetcsv", "function" ]
a6759ecc2ee42348f989dce0688f6c9dd02b1b96
https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L84-L99
24,106
DevGroup-ru/yii2-measure
src/actions/ListAction.php
ListAction.run
public function run() { $model = new Measure; return $this->controller->render( 'index', [ 'dataProvider' => $model->search(\Yii::$app->request->get()), 'model' => $model, ] ); }
php
public function run() { $model = new Measure; return $this->controller->render( 'index', [ 'dataProvider' => $model->search(\Yii::$app->request->get()), 'model' => $model, ] ); }
[ "public", "function", "run", "(", ")", "{", "$", "model", "=", "new", "Measure", ";", "return", "$", "this", "->", "controller", "->", "render", "(", "'index'", ",", "[", "'dataProvider'", "=>", "$", "model", "->", "search", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", ")", ")", ",", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}" ]
Lists all Measure models. @return mixed
[ "Lists", "all", "Measure", "models", "." ]
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/actions/ListAction.php#L18-L28
24,107
tttptd/laravel-responder
src/ResourceFactory.php
ResourceFactory.make
public function make($data = null) { if (is_null($data)) { return new NullResource(); } elseif (is_array($data)) { return static::makeFromArray($data); } $method = static::getMakeMethod($data); return static::$method($data); }
php
public function make($data = null) { if (is_null($data)) { return new NullResource(); } elseif (is_array($data)) { return static::makeFromArray($data); } $method = static::getMakeMethod($data); return static::$method($data); }
[ "public", "function", "make", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "return", "new", "NullResource", "(", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "static", "::", "makeFromArray", "(", "$", "data", ")", ";", "}", "$", "method", "=", "static", "::", "getMakeMethod", "(", "$", "data", ")", ";", "return", "static", "::", "$", "method", "(", "$", "data", ")", ";", "}" ]
Build a resource instance from the given data. @param mixed|null $data @return \League\Fractal\Resource\ResourceInterface
[ "Build", "a", "resource", "instance", "from", "the", "given", "data", "." ]
0e4a32701f0de755c1f1af458045829e1bd6caf6
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResourceFactory.php#L49-L60
24,108
tttptd/laravel-responder
src/ResourceFactory.php
ResourceFactory.makeFromPaginator
protected function makeFromPaginator(Paginator $paginator):ResourceInterface { $resource = static::makeFromCollection($paginator->getCollection()); if ($resource instanceof CollectionResource) { $queryParams = array_diff_key(app('request')->all(), array_flip(['page'])); $paginator->appends($queryParams); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); } return $resource; }
php
protected function makeFromPaginator(Paginator $paginator):ResourceInterface { $resource = static::makeFromCollection($paginator->getCollection()); if ($resource instanceof CollectionResource) { $queryParams = array_diff_key(app('request')->all(), array_flip(['page'])); $paginator->appends($queryParams); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); } return $resource; }
[ "protected", "function", "makeFromPaginator", "(", "Paginator", "$", "paginator", ")", ":", "ResourceInterface", "{", "$", "resource", "=", "static", "::", "makeFromCollection", "(", "$", "paginator", "->", "getCollection", "(", ")", ")", ";", "if", "(", "$", "resource", "instanceof", "CollectionResource", ")", "{", "$", "queryParams", "=", "array_diff_key", "(", "app", "(", "'request'", ")", "->", "all", "(", ")", ",", "array_flip", "(", "[", "'page'", "]", ")", ")", ";", "$", "paginator", "->", "appends", "(", "$", "queryParams", ")", ";", "$", "resource", "->", "setPaginator", "(", "new", "IlluminatePaginatorAdapter", "(", "$", "paginator", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Make resource from an Eloquent paginator. @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator @return \League\Fractal\Resource\ResourceInterface
[ "Make", "resource", "from", "an", "Eloquent", "paginator", "." ]
0e4a32701f0de755c1f1af458045829e1bd6caf6
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResourceFactory.php#L130-L142
24,109
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Adapter/FileTransfer.php
FileTransfer.download
public function download($ftkey, $size, $passthru = FALSE) { $this->init($ftkey); if($passthru) { return $this->passthru($size); } $buff = new Str(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for($seek = 0;$seek < $size;) { $rest = $size-$seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek+$pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if(strlen($buff) != $size) { throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)"); } return $buff; }
php
public function download($ftkey, $size, $passthru = FALSE) { $this->init($ftkey); if($passthru) { return $this->passthru($size); } $buff = new Str(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for($seek = 0;$seek < $size;) { $rest = $size-$seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek+$pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if(strlen($buff) != $size) { throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)"); } return $buff; }
[ "public", "function", "download", "(", "$", "ftkey", ",", "$", "size", ",", "$", "passthru", "=", "FALSE", ")", "{", "$", "this", "->", "init", "(", "$", "ftkey", ")", ";", "if", "(", "$", "passthru", ")", "{", "return", "$", "this", "->", "passthru", "(", "$", "size", ")", ";", "}", "$", "buff", "=", "new", "Str", "(", "\"\"", ")", ";", "$", "size", "=", "intval", "(", "$", "size", ")", ";", "$", "pack", "=", "4096", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadStarted\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "for", "(", "$", "seek", "=", "0", ";", "$", "seek", "<", "$", "size", ";", ")", "{", "$", "rest", "=", "$", "size", "-", "$", "seek", ";", "$", "pack", "=", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ";", "$", "data", "=", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ")", ";", "$", "seek", "=", "$", "seek", "+", "$", "pack", ";", "$", "buff", "->", "append", "(", "$", "data", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadProgress\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "}", "$", "this", "->", "getProfiler", "(", ")", "->", "stop", "(", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadFinished\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "if", "(", "strlen", "(", "$", "buff", ")", "!=", "$", "size", ")", "{", "throw", "new", "Exception", "(", "\"incomplete file download (\"", ".", "count", "(", "$", "buff", ")", ".", "\" of \"", ".", "$", "size", ".", "\" bytes)\"", ")", ";", "}", "return", "$", "buff", ";", "}" ]
Returns the content of a downloaded file as a Str object. @param string $ftkey @param integer $size @param boolean $passthru @throws Exception @return Str
[ "Returns", "the", "content", "of", "a", "downloaded", "file", "as", "a", "Str", "object", "." ]
39a56eca608da6b56b6aa386a7b5b31dc576c41a
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Adapter/FileTransfer.php#L142-L179
24,110
ekuiter/feature-php
FeaturePhp/ProductLine/Settings.php
Settings.processDirectoryEntry
private function processDirectoryEntry($artifactDirectory, $entry) { $entity = fphp\Helper\Path::join($artifactDirectory, $entry); // directory containing artifact file if (is_dir($entity) && !fphp\Helper\Path::isDot($entry) && in_array($this->get("artifactFile"), scandir($entity))) { $feature = $this->get("model")->getFeature($entry, true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile( fphp\Helper\Path::join($entity, $this->get("artifactFile"))) )); } else if (is_dir($entity) && !fphp\Helper\Path::isDot($entry)) // recursively search subdirectory foreach (scandir($entity) as $entry) $this->processDirectoryEntry($entity, $entry); else if (is_file($entity)) // artifact file try { $feature = $this->get("model")->getFeature(pathinfo($entity)["filename"], true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile($entity) )); } catch (fphp\Model\ModelException $e) {} }
php
private function processDirectoryEntry($artifactDirectory, $entry) { $entity = fphp\Helper\Path::join($artifactDirectory, $entry); // directory containing artifact file if (is_dir($entity) && !fphp\Helper\Path::isDot($entry) && in_array($this->get("artifactFile"), scandir($entity))) { $feature = $this->get("model")->getFeature($entry, true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile( fphp\Helper\Path::join($entity, $this->get("artifactFile"))) )); } else if (is_dir($entity) && !fphp\Helper\Path::isDot($entry)) // recursively search subdirectory foreach (scandir($entity) as $entry) $this->processDirectoryEntry($entity, $entry); else if (is_file($entity)) // artifact file try { $feature = $this->get("model")->getFeature(pathinfo($entity)["filename"], true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile($entity) )); } catch (fphp\Model\ModelException $e) {} }
[ "private", "function", "processDirectoryEntry", "(", "$", "artifactDirectory", ",", "$", "entry", ")", "{", "$", "entity", "=", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "artifactDirectory", ",", "$", "entry", ")", ";", "// directory containing artifact file", "if", "(", "is_dir", "(", "$", "entity", ")", "&&", "!", "fphp", "\\", "Helper", "\\", "Path", "::", "isDot", "(", "$", "entry", ")", "&&", "in_array", "(", "$", "this", "->", "get", "(", "\"artifactFile\"", ")", ",", "scandir", "(", "$", "entity", ")", ")", ")", "{", "$", "feature", "=", "$", "this", "->", "get", "(", "\"model\"", ")", "->", "getFeature", "(", "$", "entry", ",", "true", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "feature", "->", "getName", "(", ")", ",", "$", "this", "->", "get", "(", "\"artifacts\"", ")", ")", ")", "throw", "new", "fphp", "\\", "SettingsException", "(", "\"there are multiple settings for \\\"{$feature->getName()}\\\"\"", ")", ";", "$", "this", "->", "set", "(", "\"artifacts\"", ",", "$", "feature", "->", "getName", "(", ")", ",", "new", "fphp", "\\", "Artifact", "\\", "Artifact", "(", "$", "feature", ",", "fphp", "\\", "Artifact", "\\", "Settings", "::", "fromFile", "(", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "entity", ",", "$", "this", "->", "get", "(", "\"artifactFile\"", ")", ")", ")", ")", ")", ";", "}", "else", "if", "(", "is_dir", "(", "$", "entity", ")", "&&", "!", "fphp", "\\", "Helper", "\\", "Path", "::", "isDot", "(", "$", "entry", ")", ")", "// recursively search subdirectory", "foreach", "(", "scandir", "(", "$", "entity", ")", "as", "$", "entry", ")", "$", "this", "->", "processDirectoryEntry", "(", "$", "entity", ",", "$", "entry", ")", ";", "else", "if", "(", "is_file", "(", "$", "entity", ")", ")", "// artifact file", "try", "{", "$", "feature", "=", "$", "this", "->", "get", "(", "\"model\"", ")", "->", "getFeature", "(", "pathinfo", "(", "$", "entity", ")", "[", "\"filename\"", "]", ",", "true", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "feature", "->", "getName", "(", ")", ",", "$", "this", "->", "get", "(", "\"artifacts\"", ")", ")", ")", "throw", "new", "fphp", "\\", "SettingsException", "(", "\"there are multiple settings for \\\"{$feature->getName()}\\\"\"", ")", ";", "$", "this", "->", "set", "(", "\"artifacts\"", ",", "$", "feature", "->", "getName", "(", ")", ",", "new", "fphp", "\\", "Artifact", "\\", "Artifact", "(", "$", "feature", ",", "fphp", "\\", "Artifact", "\\", "Settings", "::", "fromFile", "(", "$", "entity", ")", ")", ")", ";", "}", "catch", "(", "fphp", "\\", "Model", "\\", "ModelException", "$", "e", ")", "{", "}", "}" ]
recursively search the artifact directory, allowing the user to group features
[ "recursively", "search", "the", "artifact", "directory", "allowing", "the", "user", "to", "group", "features" ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Settings.php#L99-L125
24,111
zhouyl/mellivora
Mellivora/Database/Eloquent/Concerns/HasEvents.php
HasEvents.observe
public static function observe($class) { $className = is_string($class) ? $class : get_class($class); // When registering a model observer, we will spin through the possible events // and determine if this observer has that method. If it does, we will hook // it into the model's event system, making it convenient to watch these. foreach (static::$observables as $event) { if (method_exists($class, $event)) { static::registerModelEvent($event, $className . '@' . $event); } } }
php
public static function observe($class) { $className = is_string($class) ? $class : get_class($class); // When registering a model observer, we will spin through the possible events // and determine if this observer has that method. If it does, we will hook // it into the model's event system, making it convenient to watch these. foreach (static::$observables as $event) { if (method_exists($class, $event)) { static::registerModelEvent($event, $className . '@' . $event); } } }
[ "public", "static", "function", "observe", "(", "$", "class", ")", "{", "$", "className", "=", "is_string", "(", "$", "class", ")", "?", "$", "class", ":", "get_class", "(", "$", "class", ")", ";", "// When registering a model observer, we will spin through the possible events", "// and determine if this observer has that method. If it does, we will hook", "// it into the model's event system, making it convenient to watch these.", "foreach", "(", "static", "::", "$", "observables", "as", "$", "event", ")", "{", "if", "(", "method_exists", "(", "$", "class", ",", "$", "event", ")", ")", "{", "static", "::", "registerModelEvent", "(", "$", "event", ",", "$", "className", ".", "'@'", ".", "$", "event", ")", ";", "}", "}", "}" ]
Register an observer with the Model. @param object|string $class @return void
[ "Register", "an", "observer", "with", "the", "Model", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Concerns/HasEvents.php#L37-L49
24,112
nabab/bbn
src/bbn/mvc/controller.php
controller.say_dir
public function say_dir() { if ( $this->path ){ $p = dirname($this->path); if ( $p === '.' ){ return ''; } if ( ($prepath = $this->get_prepath()) && (strpos($p, $prepath) === 0) ){ return substr($p, \strlen($prepath)); } return $p; } return false; }
php
public function say_dir() { if ( $this->path ){ $p = dirname($this->path); if ( $p === '.' ){ return ''; } if ( ($prepath = $this->get_prepath()) && (strpos($p, $prepath) === 0) ){ return substr($p, \strlen($prepath)); } return $p; } return false; }
[ "public", "function", "say_dir", "(", ")", "{", "if", "(", "$", "this", "->", "path", ")", "{", "$", "p", "=", "dirname", "(", "$", "this", "->", "path", ")", ";", "if", "(", "$", "p", "===", "'.'", ")", "{", "return", "''", ";", "}", "if", "(", "(", "$", "prepath", "=", "$", "this", "->", "get_prepath", "(", ")", ")", "&&", "(", "strpos", "(", "$", "p", ",", "$", "prepath", ")", "===", "0", ")", ")", "{", "return", "substr", "(", "$", "p", ",", "\\", "strlen", "(", "$", "prepath", ")", ")", ";", "}", "return", "$", "p", ";", "}", "return", "false", ";", "}" ]
Returns the current controller's file's name. @return string
[ "Returns", "the", "current", "controller", "s", "file", "s", "name", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L264-L280
24,113
nabab/bbn
src/bbn/mvc/controller.php
controller.render
public function render($view, $model=''){ if ( empty($model) && $this->has_data() ){ $model = $this->data; } if ( \is_string($view) ){ return \is_array($model) ? bbn\tpl::render($view, $model) : $view; } die(bbn\x::hdump("Problem with the template", $view, $this->path, $this->mode)); }
php
public function render($view, $model=''){ if ( empty($model) && $this->has_data() ){ $model = $this->data; } if ( \is_string($view) ){ return \is_array($model) ? bbn\tpl::render($view, $model) : $view; } die(bbn\x::hdump("Problem with the template", $view, $this->path, $this->mode)); }
[ "public", "function", "render", "(", "$", "view", ",", "$", "model", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "model", ")", "&&", "$", "this", "->", "has_data", "(", ")", ")", "{", "$", "model", "=", "$", "this", "->", "data", ";", "}", "if", "(", "\\", "is_string", "(", "$", "view", ")", ")", "{", "return", "\\", "is_array", "(", "$", "model", ")", "?", "bbn", "\\", "tpl", "::", "render", "(", "$", "view", ",", "$", "model", ")", ":", "$", "view", ";", "}", "die", "(", "bbn", "\\", "x", "::", "hdump", "(", "\"Problem with the template\"", ",", "$", "view", ",", "$", "this", "->", "path", ",", "$", "this", "->", "mode", ")", ")", ";", "}" ]
This directly renders content with arbitrary values using the existing Mustache engine. @param string $view The view to be rendered @param array $model The data model to fill the view with @return void
[ "This", "directly", "renders", "content", "with", "arbitrary", "values", "using", "the", "existing", "Mustache", "engine", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L296-L304
24,114
nabab/bbn
src/bbn/mvc/controller.php
controller.incl
public function incl($file_name){ if ( $this->exists() ){ $d = dirname($this->file).'/'; if ( substr($file_name, -4) !== '.php' ){ $file_name .= '.php'; } if ( (strpos($file_name, '..') === false) && file_exists($d.$file_name) ){ $bbn_path = $d.$file_name; $ctrl =& $this; unset($d, $file_name); include($bbn_path); } } return $this; }
php
public function incl($file_name){ if ( $this->exists() ){ $d = dirname($this->file).'/'; if ( substr($file_name, -4) !== '.php' ){ $file_name .= '.php'; } if ( (strpos($file_name, '..') === false) && file_exists($d.$file_name) ){ $bbn_path = $d.$file_name; $ctrl =& $this; unset($d, $file_name); include($bbn_path); } } return $this; }
[ "public", "function", "incl", "(", "$", "file_name", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "d", "=", "dirname", "(", "$", "this", "->", "file", ")", ".", "'/'", ";", "if", "(", "substr", "(", "$", "file_name", ",", "-", "4", ")", "!==", "'.php'", ")", "{", "$", "file_name", ".=", "'.php'", ";", "}", "if", "(", "(", "strpos", "(", "$", "file_name", ",", "'..'", ")", "===", "false", ")", "&&", "file_exists", "(", "$", "d", ".", "$", "file_name", ")", ")", "{", "$", "bbn_path", "=", "$", "d", ".", "$", "file_name", ";", "$", "ctrl", "=", "&", "$", "this", ";", "unset", "(", "$", "d", ",", "$", "file_name", ")", ";", "include", "(", "$", "bbn_path", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
This will include a file from within the controller's path. Chainable @param string $file_name If .php is ommited it will be added @return $this
[ "This", "will", "include", "a", "file", "from", "within", "the", "controller", "s", "path", ".", "Chainable" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L337-L351
24,115
nabab/bbn
src/bbn/mvc/controller.php
controller.add_script
public function add_script($script){ if ( \is_object($this->obj) ){ if ( !isset($this->obj->script) ){ $this->obj->script = ''; } $this->obj->script .= $script; } return $this; }
php
public function add_script($script){ if ( \is_object($this->obj) ){ if ( !isset($this->obj->script) ){ $this->obj->script = ''; } $this->obj->script .= $script; } return $this; }
[ "public", "function", "add_script", "(", "$", "script", ")", "{", "if", "(", "\\", "is_object", "(", "$", "this", "->", "obj", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "obj", "->", "script", ")", ")", "{", "$", "this", "->", "obj", "->", "script", "=", "''", ";", "}", "$", "this", "->", "obj", "->", "script", ".=", "$", "script", ";", "}", "return", "$", "this", ";", "}" ]
This will add the given string to the script property, and create it if needed. Chainable @param string $script The javascript chain to add @return $this
[ "This", "will", "add", "the", "given", "string", "to", "the", "script", "property", "and", "create", "it", "if", "needed", ".", "Chainable" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L359-L367
24,116
nabab/bbn
src/bbn/mvc/controller.php
controller.get_content
public function get_content($file_name){ if ( $this->check_path($file_name) && \defined('BBN_DATA_PATH') && is_file(BBN_DATA_PATH.$file_name) ){ return file_get_contents(BBN_DATA_PATH.$file_name); } return false; }
php
public function get_content($file_name){ if ( $this->check_path($file_name) && \defined('BBN_DATA_PATH') && is_file(BBN_DATA_PATH.$file_name) ){ return file_get_contents(BBN_DATA_PATH.$file_name); } return false; }
[ "public", "function", "get_content", "(", "$", "file_name", ")", "{", "if", "(", "$", "this", "->", "check_path", "(", "$", "file_name", ")", "&&", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", "&&", "is_file", "(", "BBN_DATA_PATH", ".", "$", "file_name", ")", ")", "{", "return", "file_get_contents", "(", "BBN_DATA_PATH", ".", "$", "file_name", ")", ";", "}", "return", "false", ";", "}" ]
This will get a the content of a file located within the data path @param string $file_name @return string|false
[ "This", "will", "get", "a", "the", "content", "of", "a", "file", "located", "within", "the", "data", "path" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L840-L848
24,117
nabab/bbn
src/bbn/mvc/controller.php
controller.delete_cached_model
public function delete_cached_model(){ $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } return $this->mvc->delete_cached_model($path, $data, $this); }
php
public function delete_cached_model(){ $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } return $this->mvc->delete_cached_model($path, $data, $this); }
[ "public", "function", "delete_cached_model", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", "&&", "\\", "strlen", "(", "$", "a", ")", ")", "{", "$", "path", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_array", "(", "$", "a", ")", ")", "{", "$", "data", "=", "$", "a", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "}", "else", "if", "(", "strpos", "(", "$", "path", ",", "'./'", ")", "===", "0", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "return", "$", "this", "->", "mvc", "->", "delete_cached_model", "(", "$", "path", ",", "$", "data", ",", "$", "this", ")", ";", "}" ]
This will delete the cached model. There is no order for the arguments. @params string path to the model @params array data to send to the model
[ "This", "will", "delete", "the", "cached", "model", ".", "There", "is", "no", "order", "for", "the", "arguments", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L984-L1005
24,118
nabab/bbn
src/bbn/mvc/controller.php
controller.has_data
public function has_data($data=null) { if ( \is_null($data) ){ $data = $this->data; } return ( \is_array($data) && (\count($data) > 0) ) ? 1 : false; }
php
public function has_data($data=null) { if ( \is_null($data) ){ $data = $this->data; } return ( \is_array($data) && (\count($data) > 0) ) ? 1 : false; }
[ "public", "function", "has_data", "(", "$", "data", "=", "null", ")", "{", "if", "(", "\\", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "return", "(", "\\", "is_array", "(", "$", "data", ")", "&&", "(", "\\", "count", "(", "$", "data", ")", ">", "0", ")", ")", "?", "1", ":", "false", ";", "}" ]
Checks if data exists @return bool
[ "Checks", "if", "data", "exists" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L1086-L1092
24,119
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/UrlDomain.php
UrlDomain.urlGetDomainUrlAndClasifyParamsAndDomainParams
protected function urlGetDomainUrlAndClasifyParamsAndDomainParams (array & $params, array & $domainParamsDefault, & $targetDomainRoute) { // remove domain module params and complete URL address base part by module domain $domainParams = array_intersect_key($params, $domainParamsDefault); $params = array_diff_key($params, $domainParamsDefault); $defaultDomainParams = array_merge([], $this->GetDefaultParams() ?: []); list($domainUrlBaseSection,) = $targetDomainRoute->Url( $this->request, $domainParams, $defaultDomainParams, '', TRUE ); return $domainUrlBaseSection; }
php
protected function urlGetDomainUrlAndClasifyParamsAndDomainParams (array & $params, array & $domainParamsDefault, & $targetDomainRoute) { // remove domain module params and complete URL address base part by module domain $domainParams = array_intersect_key($params, $domainParamsDefault); $params = array_diff_key($params, $domainParamsDefault); $defaultDomainParams = array_merge([], $this->GetDefaultParams() ?: []); list($domainUrlBaseSection,) = $targetDomainRoute->Url( $this->request, $domainParams, $defaultDomainParams, '', TRUE ); return $domainUrlBaseSection; }
[ "protected", "function", "urlGetDomainUrlAndClasifyParamsAndDomainParams", "(", "array", "&", "$", "params", ",", "array", "&", "$", "domainParamsDefault", ",", "&", "$", "targetDomainRoute", ")", "{", "// remove domain module params and complete URL address base part by module domain", "$", "domainParams", "=", "array_intersect_key", "(", "$", "params", ",", "$", "domainParamsDefault", ")", ";", "$", "params", "=", "array_diff_key", "(", "$", "params", ",", "$", "domainParamsDefault", ")", ";", "$", "defaultDomainParams", "=", "array_merge", "(", "[", "]", ",", "$", "this", "->", "GetDefaultParams", "(", ")", "?", ":", "[", "]", ")", ";", "list", "(", "$", "domainUrlBaseSection", ",", ")", "=", "$", "targetDomainRoute", "->", "Url", "(", "$", "this", "->", "request", ",", "$", "domainParams", ",", "$", "defaultDomainParams", ",", "''", ",", "TRUE", ")", ";", "return", "$", "domainUrlBaseSection", ";", "}" ]
Complete domain URL part by given module domain route and classify params necessary to complete URL by module route reverse string and unset those params from params array reference. Params array will be changed. Return URL base part by module domain route. @param array $params @param array $domainParamsDefault @param \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute $targetDomainRoute @return string
[ "Complete", "domain", "URL", "part", "by", "given", "module", "domain", "route", "and", "classify", "params", "necessary", "to", "complete", "URL", "by", "module", "route", "reverse", "string", "and", "unset", "those", "params", "from", "params", "array", "reference", ".", "Params", "array", "will", "be", "changed", ".", "Return", "URL", "base", "part", "by", "module", "domain", "route", "." ]
7695784a451db86cca6a43c98d076803cd0a50a7
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/UrlDomain.php#L68-L77
24,120
LeaseCloud/leasecloud-php-sdk
src/ApiRequestor.php
ApiRequestor.httpClient
private function httpClient() { if (!self::$httpClient) { self::$httpClient = HttpClient\CurlClient::instance(); } return self::$httpClient; }
php
private function httpClient() { if (!self::$httpClient) { self::$httpClient = HttpClient\CurlClient::instance(); } return self::$httpClient; }
[ "private", "function", "httpClient", "(", ")", "{", "if", "(", "!", "self", "::", "$", "httpClient", ")", "{", "self", "::", "$", "httpClient", "=", "HttpClient", "\\", "CurlClient", "::", "instance", "(", ")", ";", "}", "return", "self", "::", "$", "httpClient", ";", "}" ]
If needed create, and return a http client @return HttpClient\CurlClient
[ "If", "needed", "create", "and", "return", "a", "http", "client" ]
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/ApiRequestor.php#L84-L90
24,121
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.isVariableRequired
public function isVariableRequired( $field ) { switch ( $field ) { case 'email': $user = eZUser::currentUser(); if( !$user->isAnonymous() ) { return false; } return true; case 'recaptcha': // if the user bypasses captcha, don't validate field $bypassCaptcha = ezcomPermission::hasAccessToSecurity( 'AntiSpam' , 'bypass_captcha' ); if( $bypassCaptcha['result'] ) { return false; } return true; default: return parent::isVariableRequired( $field ); } }
php
public function isVariableRequired( $field ) { switch ( $field ) { case 'email': $user = eZUser::currentUser(); if( !$user->isAnonymous() ) { return false; } return true; case 'recaptcha': // if the user bypasses captcha, don't validate field $bypassCaptcha = ezcomPermission::hasAccessToSecurity( 'AntiSpam' , 'bypass_captcha' ); if( $bypassCaptcha['result'] ) { return false; } return true; default: return parent::isVariableRequired( $field ); } }
[ "public", "function", "isVariableRequired", "(", "$", "field", ")", "{", "switch", "(", "$", "field", ")", "{", "case", "'email'", ":", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "case", "'recaptcha'", ":", "// if the user bypasses captcha, don't validate field", "$", "bypassCaptcha", "=", "ezcomPermission", "::", "hasAccessToSecurity", "(", "'AntiSpam'", ",", "'bypass_captcha'", ")", ";", "if", "(", "$", "bypassCaptcha", "[", "'result'", "]", ")", "{", "return", "false", ";", "}", "return", "true", ";", "default", ":", "return", "parent", "::", "isVariableRequired", "(", "$", "field", ")", ";", "}", "}" ]
isVariableRequire in adding comment. When adding comment, for logined user the email is not required @see extension/ezcomments/classes/ezcomFormTool#isVariableRequired($field)
[ "isVariableRequire", "in", "adding", "comment", ".", "When", "adding", "comment", "for", "logined", "user", "the", "email", "is", "not", "required" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L24-L46
24,122
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.validateField
protected function validateField( $field, $value ) { switch ( $field ) { case 'website': return ezcomUtility::validateURLString( $value ); case 'email': // just validate anonymous's input email $user = eZUser::currentUser(); if( $user->isAnonymous() ) { $result = eZMail::validate( $value ); if ( !$result ) { return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' ); } } return true; case 'recaptcha': require_once 'recaptchalib.php'; $ini = eZINI::instance( 'ezcomments.ini' ); $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' ); $http = eZHTTPTool::instance(); if( $http->hasPostVariable( 'recaptcha_challenge_field' ) && $http->hasPostVariable( 'recaptcha_response_field' ) ) { $ip = $_SERVER["REMOTE_ADDR"]; $challengeField = $http->postVariable( 'recaptcha_challenge_field' ); $responseField = $http->postVariable( 'recaptcha_response_field' ); $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField ); if( !$capchaResponse->is_valid ) { return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' ); } } else { return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' ); } return true; default: return true; } }
php
protected function validateField( $field, $value ) { switch ( $field ) { case 'website': return ezcomUtility::validateURLString( $value ); case 'email': // just validate anonymous's input email $user = eZUser::currentUser(); if( $user->isAnonymous() ) { $result = eZMail::validate( $value ); if ( !$result ) { return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' ); } } return true; case 'recaptcha': require_once 'recaptchalib.php'; $ini = eZINI::instance( 'ezcomments.ini' ); $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' ); $http = eZHTTPTool::instance(); if( $http->hasPostVariable( 'recaptcha_challenge_field' ) && $http->hasPostVariable( 'recaptcha_response_field' ) ) { $ip = $_SERVER["REMOTE_ADDR"]; $challengeField = $http->postVariable( 'recaptcha_challenge_field' ); $responseField = $http->postVariable( 'recaptcha_response_field' ); $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField ); if( !$capchaResponse->is_valid ) { return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' ); } } else { return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' ); } return true; default: return true; } }
[ "protected", "function", "validateField", "(", "$", "field", ",", "$", "value", ")", "{", "switch", "(", "$", "field", ")", "{", "case", "'website'", ":", "return", "ezcomUtility", "::", "validateURLString", "(", "$", "value", ")", ";", "case", "'email'", ":", "// just validate anonymous's input email", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "if", "(", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "$", "result", "=", "eZMail", "::", "validate", "(", "$", "value", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'Not a valid email address.'", ")", ";", "}", "}", "return", "true", ";", "case", "'recaptcha'", ":", "require_once", "'recaptchalib.php'", ";", "$", "ini", "=", "eZINI", "::", "instance", "(", "'ezcomments.ini'", ")", ";", "$", "privateKey", "=", "$", "ini", "->", "variable", "(", "'RecaptchaSetting'", ",", "'PrivateKey'", ")", ";", "$", "http", "=", "eZHTTPTool", "::", "instance", "(", ")", ";", "if", "(", "$", "http", "->", "hasPostVariable", "(", "'recaptcha_challenge_field'", ")", "&&", "$", "http", "->", "hasPostVariable", "(", "'recaptcha_response_field'", ")", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "\"REMOTE_ADDR\"", "]", ";", "$", "challengeField", "=", "$", "http", "->", "postVariable", "(", "'recaptcha_challenge_field'", ")", ";", "$", "responseField", "=", "$", "http", "->", "postVariable", "(", "'recaptcha_response_field'", ")", ";", "$", "capchaResponse", "=", "recaptcha_check_answer", "(", "$", "privateKey", ",", "$", "ip", ",", "$", "challengeField", ",", "$", "responseField", ")", ";", "if", "(", "!", "$", "capchaResponse", "->", "is_valid", ")", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'The words you input are incorrect.'", ")", ";", "}", "}", "else", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'Captcha parameter error.'", ")", ";", "}", "return", "true", ";", "default", ":", "return", "true", ";", "}", "}" ]
Implement the validatation in adding comment @see extension/ezcomments/classes/ezcomFormTool#validateField($field)
[ "Implement", "the", "validatation", "in", "adding", "comment" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L52-L95
24,123
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.setFieldValue
protected function setFieldValue( $field, $fieldPostName ) { $user = eZUser::currentUser(); switch ( $field ) { case 'email': if( !$user->isAnonymous() ) { $this->fieldValues[$field] = $user->attribute( 'email' ); } else { parent::setFieldValue( $field, $fieldPostName ); } break; case 'notificationField': $http = eZHTTPTool::instance(); $notification = false; if( $http->hasPostVariable( $fieldPostName ) && $http->postVariable( $fieldPostName ) == '1') { $notification = true; } $this->fieldValues[$field] = $notification; break; default: parent::setFieldValue( $field, $fieldPostName ); break; } }
php
protected function setFieldValue( $field, $fieldPostName ) { $user = eZUser::currentUser(); switch ( $field ) { case 'email': if( !$user->isAnonymous() ) { $this->fieldValues[$field] = $user->attribute( 'email' ); } else { parent::setFieldValue( $field, $fieldPostName ); } break; case 'notificationField': $http = eZHTTPTool::instance(); $notification = false; if( $http->hasPostVariable( $fieldPostName ) && $http->postVariable( $fieldPostName ) == '1') { $notification = true; } $this->fieldValues[$field] = $notification; break; default: parent::setFieldValue( $field, $fieldPostName ); break; } }
[ "protected", "function", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", "{", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "switch", "(", "$", "field", ")", "{", "case", "'email'", ":", "if", "(", "!", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "$", "this", "->", "fieldValues", "[", "$", "field", "]", "=", "$", "user", "->", "attribute", "(", "'email'", ")", ";", "}", "else", "{", "parent", "::", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", ";", "}", "break", ";", "case", "'notificationField'", ":", "$", "http", "=", "eZHTTPTool", "::", "instance", "(", ")", ";", "$", "notification", "=", "false", ";", "if", "(", "$", "http", "->", "hasPostVariable", "(", "$", "fieldPostName", ")", "&&", "$", "http", "->", "postVariable", "(", "$", "fieldPostName", ")", "==", "'1'", ")", "{", "$", "notification", "=", "true", ";", "}", "$", "this", "->", "fieldValues", "[", "$", "field", "]", "=", "$", "notification", ";", "break", ";", "default", ":", "parent", "::", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", ";", "break", ";", "}", "}" ]
Implement the setFieldValue in adding comment @see extension/ezcomments/classes/ezcomFormTool#setFieldValue($fieldPostName)
[ "Implement", "the", "setFieldValue", "in", "adding", "comment" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L101-L129
24,124
digipolisgent/robo-digipolis-package-drupal8
src/Utility/ThemeFinder.php
ThemeFinder.getThemePaths
protected function getThemePaths($themes) { $dirsFromConfig = array_filter( [ $this->getConfig()->get('digipolis.root.project', false), $this->getConfig()->get('digipolis.root.web', false), ] ); $dirs = empty($this->dirs) ? $dirsFromConfig : $this->dirs; if (empty($dirs)) { $dirs = [getcwd()]; } $finder = clone $this->finder; $finder->in($dirs)->files(); foreach ($themes as $themeName) { // Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'. $finder->path('/themes\/(custom\/)?[^\/]*\/' . preg_quote($themeName, '/') . '\.info\.yml/'); } $processed = []; $paths = []; foreach ($finder as $infoFile) { $path = dirname($infoFile->getRealPath()); // The web dir can be a subdir of the project root (in most cases // really). Make sure we don't compile the same theme twice. if (isset($processed[$path])) { continue; } $processed[$path] = true; $theme = $infoFile->getBasename('.info.yml'); $paths[$theme] = $path; } return $paths; }
php
protected function getThemePaths($themes) { $dirsFromConfig = array_filter( [ $this->getConfig()->get('digipolis.root.project', false), $this->getConfig()->get('digipolis.root.web', false), ] ); $dirs = empty($this->dirs) ? $dirsFromConfig : $this->dirs; if (empty($dirs)) { $dirs = [getcwd()]; } $finder = clone $this->finder; $finder->in($dirs)->files(); foreach ($themes as $themeName) { // Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'. $finder->path('/themes\/(custom\/)?[^\/]*\/' . preg_quote($themeName, '/') . '\.info\.yml/'); } $processed = []; $paths = []; foreach ($finder as $infoFile) { $path = dirname($infoFile->getRealPath()); // The web dir can be a subdir of the project root (in most cases // really). Make sure we don't compile the same theme twice. if (isset($processed[$path])) { continue; } $processed[$path] = true; $theme = $infoFile->getBasename('.info.yml'); $paths[$theme] = $path; } return $paths; }
[ "protected", "function", "getThemePaths", "(", "$", "themes", ")", "{", "$", "dirsFromConfig", "=", "array_filter", "(", "[", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.project'", ",", "false", ")", ",", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.web'", ",", "false", ")", ",", "]", ")", ";", "$", "dirs", "=", "empty", "(", "$", "this", "->", "dirs", ")", "?", "$", "dirsFromConfig", ":", "$", "this", "->", "dirs", ";", "if", "(", "empty", "(", "$", "dirs", ")", ")", "{", "$", "dirs", "=", "[", "getcwd", "(", ")", "]", ";", "}", "$", "finder", "=", "clone", "$", "this", "->", "finder", ";", "$", "finder", "->", "in", "(", "$", "dirs", ")", "->", "files", "(", ")", ";", "foreach", "(", "$", "themes", "as", "$", "themeName", ")", "{", "// Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'.", "$", "finder", "->", "path", "(", "'/themes\\/(custom\\/)?[^\\/]*\\/'", ".", "preg_quote", "(", "$", "themeName", ",", "'/'", ")", ".", "'\\.info\\.yml/'", ")", ";", "}", "$", "processed", "=", "[", "]", ";", "$", "paths", "=", "[", "]", ";", "foreach", "(", "$", "finder", "as", "$", "infoFile", ")", "{", "$", "path", "=", "dirname", "(", "$", "infoFile", "->", "getRealPath", "(", ")", ")", ";", "// The web dir can be a subdir of the project root (in most cases", "// really). Make sure we don't compile the same theme twice.", "if", "(", "isset", "(", "$", "processed", "[", "$", "path", "]", ")", ")", "{", "continue", ";", "}", "$", "processed", "[", "$", "path", "]", "=", "true", ";", "$", "theme", "=", "$", "infoFile", "->", "getBasename", "(", "'.info.yml'", ")", ";", "$", "paths", "[", "$", "theme", "]", "=", "$", "path", ";", "}", "return", "$", "paths", ";", "}" ]
Get the theme paths. @param array $themes An array of theme names. @return array The theme paths keyed by theme name.
[ "Get", "the", "theme", "paths", "." ]
dc03ae0f68d56a027291e9574ff7aa433c27690a
https://github.com/digipolisgent/robo-digipolis-package-drupal8/blob/dc03ae0f68d56a027291e9574ff7aa433c27690a/src/Utility/ThemeFinder.php#L17-L52
24,125
sgmendez/json
src/Json.php
Json.decodeFile
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0) { set_error_handler( create_function( '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ); try { $jsonData = file_get_contents($file); } catch (Exception $e) { throw new RuntimeException(sprintf($e->getMessage())); } restore_error_handler(); if(false === $jsonData) { throw new RuntimeException(sprintf('Unable to get file %s', $file)); } return $this->decode($jsonData, $assoc, $depth, $options); }
php
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0) { set_error_handler( create_function( '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ); try { $jsonData = file_get_contents($file); } catch (Exception $e) { throw new RuntimeException(sprintf($e->getMessage())); } restore_error_handler(); if(false === $jsonData) { throw new RuntimeException(sprintf('Unable to get file %s', $file)); } return $this->decode($jsonData, $assoc, $depth, $options); }
[ "public", "function", "decodeFile", "(", "$", "file", ",", "$", "assoc", "=", "true", ",", "$", "depth", "=", "512", ",", "$", "options", "=", "0", ")", "{", "set_error_handler", "(", "create_function", "(", "'$severity, $message, $file, $line'", ",", "'throw new ErrorException($message, $severity, $severity, $file, $line);'", ")", ")", ";", "try", "{", "$", "jsonData", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "restore_error_handler", "(", ")", ";", "if", "(", "false", "===", "$", "jsonData", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Unable to get file %s'", ",", "$", "file", ")", ")", ";", "}", "return", "$", "this", "->", "decode", "(", "$", "jsonData", ",", "$", "assoc", ",", "$", "depth", ",", "$", "options", ")", ";", "}" ]
Decode JSON data encoded in file @param string $file @param boolean $assoc @param integer $depth @param integer $options @return mixed @throws RuntimeException
[ "Decode", "JSON", "data", "encoded", "in", "file" ]
5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L86-L111
24,126
sgmendez/json
src/Json.php
Json.checkJsonError
protected function checkJsonError() { if(!function_exists('json_last_error')) { throw new BadFunctionCallException('json_last_error() function not exits'); } $jsonError = json_last_error(); if($jsonError !== JSON_ERROR_NONE) { $this->jsonErrorException($jsonError); } return true; }
php
protected function checkJsonError() { if(!function_exists('json_last_error')) { throw new BadFunctionCallException('json_last_error() function not exits'); } $jsonError = json_last_error(); if($jsonError !== JSON_ERROR_NONE) { $this->jsonErrorException($jsonError); } return true; }
[ "protected", "function", "checkJsonError", "(", ")", "{", "if", "(", "!", "function_exists", "(", "'json_last_error'", ")", ")", "{", "throw", "new", "BadFunctionCallException", "(", "'json_last_error() function not exits'", ")", ";", "}", "$", "jsonError", "=", "json_last_error", "(", ")", ";", "if", "(", "$", "jsonError", "!==", "JSON_ERROR_NONE", ")", "{", "$", "this", "->", "jsonErrorException", "(", "$", "jsonError", ")", ";", "}", "return", "true", ";", "}" ]
Check exists error for last execution json funtion @return boolean @throws BadFunctionCallException
[ "Check", "exists", "error", "for", "last", "execution", "json", "funtion" ]
5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L157-L171
24,127
sgmendez/json
src/Json.php
Json.decodeCheckVersion
private function decodeCheckVersion($dataValid, $assocValid, $depthValid, $optionsValid) { //In 5.4 add options param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_decode($dataValid, $assocValid, $depthValid, $optionsValid); } return json_decode($dataValid, $assocValid, $depthValid); }
php
private function decodeCheckVersion($dataValid, $assocValid, $depthValid, $optionsValid) { //In 5.4 add options param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_decode($dataValid, $assocValid, $depthValid, $optionsValid); } return json_decode($dataValid, $assocValid, $depthValid); }
[ "private", "function", "decodeCheckVersion", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ",", "$", "optionsValid", ")", "{", "//In 5.4 add options param", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4.0'", ")", ">=", "0", ")", "{", "return", "json_decode", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ",", "$", "optionsValid", ")", ";", "}", "return", "json_decode", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ")", ";", "}" ]
Options param add 5.4 @param $dataValid @param $assocValid @param $depthValid @param $optionsValid @return mixed
[ "Options", "param", "add", "5", ".", "4" ]
5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L314-L323
24,128
sgmendez/json
src/Json.php
Json.encodeCheckVersion
private function encodeCheckVersion($dataValid, $optionsValid, $depthValid) { //In 5.4 add depth param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_encode($dataValid, $optionsValid, $depthValid); } return json_encode($dataValid, $optionsValid); }
php
private function encodeCheckVersion($dataValid, $optionsValid, $depthValid) { //In 5.4 add depth param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_encode($dataValid, $optionsValid, $depthValid); } return json_encode($dataValid, $optionsValid); }
[ "private", "function", "encodeCheckVersion", "(", "$", "dataValid", ",", "$", "optionsValid", ",", "$", "depthValid", ")", "{", "//In 5.4 add depth param", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4.0'", ")", ">=", "0", ")", "{", "return", "json_encode", "(", "$", "dataValid", ",", "$", "optionsValid", ",", "$", "depthValid", ")", ";", "}", "return", "json_encode", "(", "$", "dataValid", ",", "$", "optionsValid", ")", ";", "}" ]
Depth param add 5.4 @param $dataValid @param $optionsValid @param $depthValid @return string
[ "Depth", "param", "add", "5", ".", "4" ]
5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L333-L342
24,129
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerCampagneWorkerService
protected function registerCampagneWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\CampagneInterface', function() { return new \designpond\newsletter\Newsletter\Worker\CampagneWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface') ); }); }
php
protected function registerCampagneWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\CampagneInterface', function() { return new \designpond\newsletter\Newsletter\Worker\CampagneWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface') ); }); }
[ "protected", "function", "registerCampagneWorkerService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\CampagneInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "CampagneWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterContentInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterCampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Campagne worker
[ "Newsletter", "Campagne", "worker" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L190-L201
24,130
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerImportService
protected function registerImportService(){ $this->app->singleton('designpond\newsletter\Newsletter\Worker\ImportWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\ImportWorker( \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('Maatwebsite\Excel\Excel'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Worker\CampagneInterface'), \App::make('designpond\newsletter\Newsletter\Service\UploadInterface') ); }); }
php
protected function registerImportService(){ $this->app->singleton('designpond\newsletter\Newsletter\Worker\ImportWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\ImportWorker( \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('Maatwebsite\Excel\Excel'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Worker\CampagneInterface'), \App::make('designpond\newsletter\Newsletter\Service\UploadInterface') ); }); }
[ "protected", "function", "registerImportService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'designpond\\newsletter\\Newsletter\\Worker\\ImportWorkerInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "ImportWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetServiceInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'Maatwebsite\\Excel\\Excel'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterCampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\CampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Service\\UploadInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Import worker
[ "Newsletter", "Import", "worker" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L231-L245
24,131
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerSubscribeWorkerService
protected function registerSubscribeWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\SubscriptionWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\SubscriptionWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface') ); }); }
php
protected function registerSubscribeWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\SubscriptionWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\SubscriptionWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface') ); }); }
[ "protected", "function", "registerSubscribeWorkerService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\SubscriptionWorkerInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "SubscriptionWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetServiceInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter subscriber service
[ "Newsletter", "subscriber", "service" ]
0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L294-L304
24,132
oroinc/OroLayoutComponent
Templating/Helper/LayoutHelper.php
LayoutHelper.parentBlockWidget
public function parentBlockWidget(BlockView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables, true); }
php
public function parentBlockWidget(BlockView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables, true); }
[ "public", "function", "parentBlockWidget", "(", "BlockView", "$", "view", ",", "array", "$", "variables", "=", "[", "]", ")", "{", "return", "$", "this", "->", "renderer", "->", "searchAndRenderBlock", "(", "$", "view", ",", "'widget'", ",", "$", "variables", ",", "true", ")", ";", "}" ]
Renders the parent block widget defined in other resources on all levels of block prefix hierarchy @param BlockView $view @param array $variables @return string
[ "Renders", "the", "parent", "block", "widget", "defined", "in", "other", "resources", "on", "all", "levels", "of", "block", "prefix", "hierarchy" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Templating/Helper/LayoutHelper.php#L98-L101
24,133
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.formatLog
public function formatLog(array $logMessage) { extract($logMessage); $level = strtoupper($level); $message = $this->applyContext($message, $context); $timestamp = date($this->dateTimeFormat, $timestamp); $exception = $this->getExceptionTrace($context); $log = str_replace(self::FORMAT_TIMESTAMP, $timestamp, $this->logFormat); $log = str_replace(self::FORMAT_LEVEL, $level, $log); $log = str_replace(self::FORMAT_MESSAGE, $message, $log); $log = str_replace(self::FORMAT_EXCEPTION, $exception, $log); return $log; }
php
public function formatLog(array $logMessage) { extract($logMessage); $level = strtoupper($level); $message = $this->applyContext($message, $context); $timestamp = date($this->dateTimeFormat, $timestamp); $exception = $this->getExceptionTrace($context); $log = str_replace(self::FORMAT_TIMESTAMP, $timestamp, $this->logFormat); $log = str_replace(self::FORMAT_LEVEL, $level, $log); $log = str_replace(self::FORMAT_MESSAGE, $message, $log); $log = str_replace(self::FORMAT_EXCEPTION, $exception, $log); return $log; }
[ "public", "function", "formatLog", "(", "array", "$", "logMessage", ")", "{", "extract", "(", "$", "logMessage", ")", ";", "$", "level", "=", "strtoupper", "(", "$", "level", ")", ";", "$", "message", "=", "$", "this", "->", "applyContext", "(", "$", "message", ",", "$", "context", ")", ";", "$", "timestamp", "=", "date", "(", "$", "this", "->", "dateTimeFormat", ",", "$", "timestamp", ")", ";", "$", "exception", "=", "$", "this", "->", "getExceptionTrace", "(", "$", "context", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_TIMESTAMP", ",", "$", "timestamp", ",", "$", "this", "->", "logFormat", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_LEVEL", ",", "$", "level", ",", "$", "log", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_MESSAGE", ",", "$", "message", ",", "$", "log", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_EXCEPTION", ",", "$", "exception", ",", "$", "log", ")", ";", "return", "$", "log", ";", "}" ]
Format log message @param array $logMessage An array with key `timestamp`, 'level', 'message', and 'context' @return string
[ "Format", "log", "message" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L64-L78
24,134
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.applyContext
protected function applyContext($message, array $context = array()) { foreach ($context as $key => $value) { $key = trim($key, "{}"); if ($key != 'exception') { $message = $this->replaceContext($message, $key, $value); } } return $message; }
php
protected function applyContext($message, array $context = array()) { foreach ($context as $key => $value) { $key = trim($key, "{}"); if ($key != 'exception') { $message = $this->replaceContext($message, $key, $value); } } return $message; }
[ "protected", "function", "applyContext", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "trim", "(", "$", "key", ",", "\"{}\"", ")", ";", "if", "(", "$", "key", "!=", "'exception'", ")", "{", "$", "message", "=", "$", "this", "->", "replaceContext", "(", "$", "message", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", "$", "message", ";", "}" ]
Apply context into log message. @param string $message @param array $context [optional] @return string
[ "Apply", "context", "into", "log", "message", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L88-L98
24,135
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.replaceContext
protected function replaceContext($message, string $key, $context) { $strContext = ''; if (is_object($context)) { if (method_exists($context, '__toString')) { $strContext = call_user_func([$context, '__toString']); } else { $strContext = var_export($context, true); } } else { $strContext = $context; } return str_replace('{'.$key.'}', $strContext, $message); }
php
protected function replaceContext($message, string $key, $context) { $strContext = ''; if (is_object($context)) { if (method_exists($context, '__toString')) { $strContext = call_user_func([$context, '__toString']); } else { $strContext = var_export($context, true); } } else { $strContext = $context; } return str_replace('{'.$key.'}', $strContext, $message); }
[ "protected", "function", "replaceContext", "(", "$", "message", ",", "string", "$", "key", ",", "$", "context", ")", "{", "$", "strContext", "=", "''", ";", "if", "(", "is_object", "(", "$", "context", ")", ")", "{", "if", "(", "method_exists", "(", "$", "context", ",", "'__toString'", ")", ")", "{", "$", "strContext", "=", "call_user_func", "(", "[", "$", "context", ",", "'__toString'", "]", ")", ";", "}", "else", "{", "$", "strContext", "=", "var_export", "(", "$", "context", ",", "true", ")", ";", "}", "}", "else", "{", "$", "strContext", "=", "$", "context", ";", "}", "return", "str_replace", "(", "'{'", ".", "$", "key", ".", "'}'", ",", "$", "strContext", ",", "$", "message", ")", ";", "}" ]
Replace context pattern in the message with related context. @param string $message Log message @param string $key Context pattern to be replaced @param mixed $context Related context to replace $key @return string $message with pattern '{$key}' replaced by $context
[ "Replace", "context", "pattern", "in", "the", "message", "with", "related", "context", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L109-L123
24,136
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.getExceptionTrace
protected function getExceptionTrace(array $context) { if (array_key_exists('exception', $context)) { if ($context['exception'] instanceof \Exception) { $strException = $context['exception']->getTraceAsString(); return $strException; } } return ''; }
php
protected function getExceptionTrace(array $context) { if (array_key_exists('exception', $context)) { if ($context['exception'] instanceof \Exception) { $strException = $context['exception']->getTraceAsString(); return $strException; } } return ''; }
[ "protected", "function", "getExceptionTrace", "(", "array", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "'exception'", ",", "$", "context", ")", ")", "{", "if", "(", "$", "context", "[", "'exception'", "]", "instanceof", "\\", "Exception", ")", "{", "$", "strException", "=", "$", "context", "[", "'exception'", "]", "->", "getTraceAsString", "(", ")", ";", "return", "$", "strException", ";", "}", "}", "return", "''", ";", "}" ]
Get Exception trace if found in the context. @param array $context
[ "Get", "Exception", "trace", "if", "found", "in", "the", "context", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L130-L141
24,137
scherersoftware/cake-monitor
src/Lib/MonitorHandler.php
MonitorHandler.handleChecks
public function handleChecks() { $errors = []; foreach ($this->_config['checks'] as $name => $check) { if (empty($check)) { continue; } $result = $check['callback'](); if ($result !== true) { $errors[] = $name . ': <br>' . $check['error'] . ' - ' . $result; } } if (!empty($errors)) { $this->response->statusCode(500); echo date('Y-m-d H:i:s') . ': ' . $this->_config['projectName'] . ' - ' . $this->_config['serverDescription'] . ' - Status Code: ' . $this->response->statusCode() . '<br><br> '; foreach ($errors as $error) { echo $error . '<br><br>'; } die; } $this->_config['onSuccess'](); die; }
php
public function handleChecks() { $errors = []; foreach ($this->_config['checks'] as $name => $check) { if (empty($check)) { continue; } $result = $check['callback'](); if ($result !== true) { $errors[] = $name . ': <br>' . $check['error'] . ' - ' . $result; } } if (!empty($errors)) { $this->response->statusCode(500); echo date('Y-m-d H:i:s') . ': ' . $this->_config['projectName'] . ' - ' . $this->_config['serverDescription'] . ' - Status Code: ' . $this->response->statusCode() . '<br><br> '; foreach ($errors as $error) { echo $error . '<br><br>'; } die; } $this->_config['onSuccess'](); die; }
[ "public", "function", "handleChecks", "(", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_config", "[", "'checks'", "]", "as", "$", "name", "=>", "$", "check", ")", "{", "if", "(", "empty", "(", "$", "check", ")", ")", "{", "continue", ";", "}", "$", "result", "=", "$", "check", "[", "'callback'", "]", "(", ")", ";", "if", "(", "$", "result", "!==", "true", ")", "{", "$", "errors", "[", "]", "=", "$", "name", ".", "': <br>'", ".", "$", "check", "[", "'error'", "]", ".", "' - '", ".", "$", "result", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "{", "$", "this", "->", "response", "->", "statusCode", "(", "500", ")", ";", "echo", "date", "(", "'Y-m-d H:i:s'", ")", ".", "': '", ".", "$", "this", "->", "_config", "[", "'projectName'", "]", ".", "' - '", ".", "$", "this", "->", "_config", "[", "'serverDescription'", "]", ".", "' - Status Code: '", ".", "$", "this", "->", "response", "->", "statusCode", "(", ")", ".", "'<br><br> '", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "echo", "$", "error", ".", "'<br><br>'", ";", "}", "die", ";", "}", "$", "this", "->", "_config", "[", "'onSuccess'", "]", "(", ")", ";", "die", ";", "}" ]
Handle all defined checks @return void
[ "Handle", "all", "defined", "checks" ]
dbe07a1aac41b3db15e631d9e59cf26214bf6938
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Lib/MonitorHandler.php#L88-L112
24,138
bariew/yii2-i18n-cms-module
models/MessageSearch.php
MessageSearch.search
public function search($params) { $query = Message::find(); $query->joinWith('source'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes['sourceMessage'] = [ 'asc' => ['source.message' => SORT_ASC], 'desc' => ['source.message' => SORT_DESC], ]; $dataProvider->getSort()->attributes['sourceCategory'] = [ 'asc' => ['source.category' => SORT_ASC], 'desc' => ['source.category' => SORT_DESC], ]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); if ($this->translation) { $t = addslashes($this->translation); $query->where("translation like '%{$t}%'"); } if ($this->translationUpdate === 'is null') { $query->where('translation is null'); } if ($this->translationUpdate === 'is not null') { $query->where('translation is not null'); } if ($this->translation) { $query->andWhere(['like', 'translation', '%' . $this->translation .'%', false]); } if ($this->sourceMessage) { $query->andFilterWhere(['like', 'source.message', $this->sourceMessage]); } if ($this->language) { $query->andWhere(['language' => $this->language]); } if ($this->sourceCategory) { $query->andFilterWhere(['like', 'source.category', $this->sourceCategory]); } return $dataProvider; }
php
public function search($params) { $query = Message::find(); $query->joinWith('source'); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->getSort()->attributes['sourceMessage'] = [ 'asc' => ['source.message' => SORT_ASC], 'desc' => ['source.message' => SORT_DESC], ]; $dataProvider->getSort()->attributes['sourceCategory'] = [ 'asc' => ['source.category' => SORT_ASC], 'desc' => ['source.category' => SORT_DESC], ]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); if ($this->translation) { $t = addslashes($this->translation); $query->where("translation like '%{$t}%'"); } if ($this->translationUpdate === 'is null') { $query->where('translation is null'); } if ($this->translationUpdate === 'is not null') { $query->where('translation is not null'); } if ($this->translation) { $query->andWhere(['like', 'translation', '%' . $this->translation .'%', false]); } if ($this->sourceMessage) { $query->andFilterWhere(['like', 'source.message', $this->sourceMessage]); } if ($this->language) { $query->andWhere(['language' => $this->language]); } if ($this->sourceCategory) { $query->andFilterWhere(['like', 'source.category', $this->sourceCategory]); } return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "query", "=", "Message", "::", "find", "(", ")", ";", "$", "query", "->", "joinWith", "(", "'source'", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", "]", ")", ";", "$", "dataProvider", "->", "getSort", "(", ")", "->", "attributes", "[", "'sourceMessage'", "]", "=", "[", "'asc'", "=>", "[", "'source.message'", "=>", "SORT_ASC", "]", ",", "'desc'", "=>", "[", "'source.message'", "=>", "SORT_DESC", "]", ",", "]", ";", "$", "dataProvider", "->", "getSort", "(", ")", "->", "attributes", "[", "'sourceCategory'", "]", "=", "[", "'asc'", "=>", "[", "'source.category'", "=>", "SORT_ASC", "]", ",", "'desc'", "=>", "[", "'source.category'", "=>", "SORT_DESC", "]", ",", "]", ";", "if", "(", "!", "(", "$", "this", "->", "load", "(", "$", "params", ")", "&&", "$", "this", "->", "validate", "(", ")", ")", ")", "{", "return", "$", "dataProvider", ";", "}", "$", "query", "->", "andFilterWhere", "(", "[", "'id'", "=>", "$", "this", "->", "id", "]", ")", ";", "if", "(", "$", "this", "->", "translation", ")", "{", "$", "t", "=", "addslashes", "(", "$", "this", "->", "translation", ")", ";", "$", "query", "->", "where", "(", "\"translation like '%{$t}%'\"", ")", ";", "}", "if", "(", "$", "this", "->", "translationUpdate", "===", "'is null'", ")", "{", "$", "query", "->", "where", "(", "'translation is null'", ")", ";", "}", "if", "(", "$", "this", "->", "translationUpdate", "===", "'is not null'", ")", "{", "$", "query", "->", "where", "(", "'translation is not null'", ")", ";", "}", "if", "(", "$", "this", "->", "translation", ")", "{", "$", "query", "->", "andWhere", "(", "[", "'like'", ",", "'translation'", ",", "'%'", ".", "$", "this", "->", "translation", ".", "'%'", ",", "false", "]", ")", ";", "}", "if", "(", "$", "this", "->", "sourceMessage", ")", "{", "$", "query", "->", "andFilterWhere", "(", "[", "'like'", ",", "'source.message'", ",", "$", "this", "->", "sourceMessage", "]", ")", ";", "}", "if", "(", "$", "this", "->", "language", ")", "{", "$", "query", "->", "andWhere", "(", "[", "'language'", "=>", "$", "this", "->", "language", "]", ")", ";", "}", "if", "(", "$", "this", "->", "sourceCategory", ")", "{", "$", "query", "->", "andFilterWhere", "(", "[", "'like'", ",", "'source.category'", ",", "$", "this", "->", "sourceCategory", "]", ")", ";", "}", "return", "$", "dataProvider", ";", "}" ]
Default index search method @param $params @return ActiveDataProvider
[ "Default", "index", "search", "method" ]
18d2394565cdd8b5070a287a739c9007705ef18a
https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/models/MessageSearch.php#L44-L91
24,139
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/Debug.php
Debug.execute
public function execute(ProjectDescriptor $project) { $this->analyzer->analyze($project); $this->log->debug((string) $this->analyzer); }
php
public function execute(ProjectDescriptor $project) { $this->analyzer->analyze($project); $this->log->debug((string) $this->analyzer); }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "this", "->", "analyzer", "->", "analyze", "(", "$", "project", ")", ";", "$", "this", "->", "log", "->", "debug", "(", "(", "string", ")", "$", "this", "->", "analyzer", ")", ";", "}" ]
Analyzes the given project and returns the results to the logger. @param ProjectDescriptor $project @return void
[ "Analyzes", "the", "given", "project", "and", "returns", "the", "results", "to", "the", "logger", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/Debug.php#L62-L66
24,140
thienhungho/yii2-product-management
src/modules/ProductManage/controllers/ProductTypeController.php
ProductTypeController.findModel
protected function findModel($id) { if (($model = ProductType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
php
protected function findModel($id) { if (($model = ProductType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "ProductType", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "t", "(", "'app'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the ProductType model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return ProductType the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "ProductType", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
72e1237bba123faf671e44491bd93077b50adde9
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductTypeController.php#L230-L237
24,141
artscorestudio/document-bundle
DependencyInjection/Configuration.php
Configuration.addPageParameterNode
protected function addPageParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('page'); $node ->treatTrueLike(array( 'versionable' => false, 'signable' => false, 'form' => array( 'type' => "ASF\DocumentBundle\Form\Type\PageType", 'name' => 'page_type' ) )) ->treatFalseLike(array( 'versionable' => false, 'signable' => false, 'form' => array( 'type' => "ASF\DocumentBundle\Form\Type\PageType", 'name' => 'page_type' ) )) ->addDefaultsIfNotSet() ->children() ->booleanNode('versionable') ->defaultFalse() ->end() ->booleanNode('signable') ->defaultFalse() ->end() ->arrayNode('form') ->addDefaultsIfNotSet() ->children() ->scalarNode('type') ->defaultValue('ASF\DocumentBundle\Form\Type\PageType') ->end() ->scalarNode('name') ->defaultValue('page_type') ->end() ->arrayNode('validation_groups') ->prototype('scalar')->end() ->defaultValue(array("Default")) ->end() ->end() ->end() ->end() ; return $node; }
php
protected function addPageParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('page'); $node ->treatTrueLike(array( 'versionable' => false, 'signable' => false, 'form' => array( 'type' => "ASF\DocumentBundle\Form\Type\PageType", 'name' => 'page_type' ) )) ->treatFalseLike(array( 'versionable' => false, 'signable' => false, 'form' => array( 'type' => "ASF\DocumentBundle\Form\Type\PageType", 'name' => 'page_type' ) )) ->addDefaultsIfNotSet() ->children() ->booleanNode('versionable') ->defaultFalse() ->end() ->booleanNode('signable') ->defaultFalse() ->end() ->arrayNode('form') ->addDefaultsIfNotSet() ->children() ->scalarNode('type') ->defaultValue('ASF\DocumentBundle\Form\Type\PageType') ->end() ->scalarNode('name') ->defaultValue('page_type') ->end() ->arrayNode('validation_groups') ->prototype('scalar')->end() ->defaultValue(array("Default")) ->end() ->end() ->end() ->end() ; return $node; }
[ "protected", "function", "addPageParameterNode", "(", ")", "{", "$", "builder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "node", "=", "$", "builder", "->", "root", "(", "'page'", ")", ";", "$", "node", "->", "treatTrueLike", "(", "array", "(", "'versionable'", "=>", "false", ",", "'signable'", "=>", "false", ",", "'form'", "=>", "array", "(", "'type'", "=>", "\"ASF\\DocumentBundle\\Form\\Type\\PageType\"", ",", "'name'", "=>", "'page_type'", ")", ")", ")", "->", "treatFalseLike", "(", "array", "(", "'versionable'", "=>", "false", ",", "'signable'", "=>", "false", ",", "'form'", "=>", "array", "(", "'type'", "=>", "\"ASF\\DocumentBundle\\Form\\Type\\PageType\"", ",", "'name'", "=>", "'page_type'", ")", ")", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "booleanNode", "(", "'versionable'", ")", "->", "defaultFalse", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'signable'", ")", "->", "defaultFalse", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'form'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'type'", ")", "->", "defaultValue", "(", "'ASF\\DocumentBundle\\Form\\Type\\PageType'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'name'", ")", "->", "defaultValue", "(", "'page_type'", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'validation_groups'", ")", "->", "prototype", "(", "'scalar'", ")", "->", "end", "(", ")", "->", "defaultValue", "(", "array", "(", "\"Default\"", ")", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "node", ";", "}" ]
Add Page Entity Configuration
[ "Add", "Page", "Entity", "Configuration" ]
3aceab0f75de8f7dd0fad0d0db83d7940bf565c8
https://github.com/artscorestudio/document-bundle/blob/3aceab0f75de8f7dd0fad0d0db83d7940bf565c8/DependencyInjection/Configuration.php#L49-L98
24,142
thelia-modules/CustomerGroup
Model/Base/CustomerCustomerGroupQuery.php
CustomerCustomerGroupQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \CustomerGroup\Model\CustomerCustomerGroupQuery) { return $criteria; } $query = new \CustomerGroup\Model\CustomerCustomerGroupQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \CustomerGroup\Model\CustomerCustomerGroupQuery) { return $criteria; } $query = new \CustomerGroup\Model\CustomerCustomerGroupQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerCustomerGroupQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerCustomerGroupQuery", "(", ")", ";", "if", "(", "null", "!==", "$", "modelAlias", ")", "{", "$", "query", "->", "setModelAlias", "(", "$", "modelAlias", ")", ";", "}", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new ChildCustomerCustomerGroupQuery object. @param string $modelAlias The alias of a model in the query @param Criteria $criteria Optional Criteria to build the query from @return ChildCustomerCustomerGroupQuery
[ "Returns", "a", "new", "ChildCustomerCustomerGroupQuery", "object", "." ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroupQuery.php#L76-L90
24,143
thelia-modules/CustomerGroup
Model/Base/CustomerCustomerGroupQuery.php
CustomerCustomerGroupQuery.filterByCustomerGroupId
public function filterByCustomerGroupId($customerGroupId = null, $comparison = null) { if (is_array($customerGroupId)) { $useMinMax = false; if (isset($customerGroupId['min'])) { $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerGroupId['max'])) { $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId, $comparison); }
php
public function filterByCustomerGroupId($customerGroupId = null, $comparison = null) { if (is_array($customerGroupId)) { $useMinMax = false; if (isset($customerGroupId['min'])) { $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($customerGroupId['max'])) { $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $customerGroupId, $comparison); }
[ "public", "function", "filterByCustomerGroupId", "(", "$", "customerGroupId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "customerGroupId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "customerGroupId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_GROUP_ID", ",", "$", "customerGroupId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "customerGroupId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_GROUP_ID", ",", "$", "customerGroupId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_GROUP_ID", ",", "$", "customerGroupId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the customer_group_id column Example usage: <code> $query->filterByCustomerGroupId(1234); // WHERE customer_group_id = 1234 $query->filterByCustomerGroupId(array(12, 34)); // WHERE customer_group_id IN (12, 34) $query->filterByCustomerGroupId(array('min' => 12)); // WHERE customer_group_id > 12 </code> @see filterByCustomerGroup() @param mixed $customerGroupId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerCustomerGroupQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "customer_group_id", "column" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroupQuery.php#L303-L324
24,144
thelia-modules/CustomerGroup
Model/Base/CustomerCustomerGroupQuery.php
CustomerCustomerGroupQuery.filterByCustomer
public function filterByCustomer($customer, $comparison = null) { if ($customer instanceof \Thelia\Model\Customer) { return $this ->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_ID, $customer->getId(), $comparison); } elseif ($customer instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); } }
php
public function filterByCustomer($customer, $comparison = null) { if ($customer instanceof \Thelia\Model\Customer) { return $this ->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_ID, $customer->getId(), $comparison); } elseif ($customer instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(CustomerCustomerGroupTableMap::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomer() only accepts arguments of type \Thelia\Model\Customer or Collection'); } }
[ "public", "function", "filterByCustomer", "(", "$", "customer", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "customer", "instanceof", "\\", "Thelia", "\\", "Model", "\\", "Customer", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_ID", ",", "$", "customer", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "customer", "instanceof", "ObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_ID", ",", "$", "customer", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByCustomer() only accepts arguments of type \\Thelia\\Model\\Customer or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \Thelia\Model\Customer object @param \Thelia\Model\Customer|ObjectCollection $customer The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerCustomerGroupQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Thelia", "\\", "Model", "\\", "Customer", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroupQuery.php#L334-L349
24,145
thelia-modules/CustomerGroup
Model/Base/CustomerCustomerGroupQuery.php
CustomerCustomerGroupQuery.useCustomerQuery
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCustomer($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); }
php
public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCustomer($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); }
[ "public", "function", "useCustomerQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinCustomer", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'Customer'", ",", "'\\Thelia\\Model\\CustomerQuery'", ")", ";", "}" ]
Use the Customer relation Customer object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query
[ "Use", "the", "Customer", "relation", "Customer", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroupQuery.php#L394-L399
24,146
mustardandrew/muan-laravel-acl
src/Commands/User/ViewCommand.php
ViewCommand.show
protected function show($user, string $modelName) { $method = "{$modelName}s"; $methodTitle = ucfirst($method); if (! $user->$method) { $this->warn("User not use Has{$methodTitle}Trait!"); return; } echo "{$methodTitle}:", PHP_EOL; $data = $this->prepareData($user->$method->toArray()); if ($user->$method->count()) { $this->table(['ID', ucfirst($modelName), 'Created At', 'Updated At'], $data); } else { $this->warn("Not found any {$method}!"); } }
php
protected function show($user, string $modelName) { $method = "{$modelName}s"; $methodTitle = ucfirst($method); if (! $user->$method) { $this->warn("User not use Has{$methodTitle}Trait!"); return; } echo "{$methodTitle}:", PHP_EOL; $data = $this->prepareData($user->$method->toArray()); if ($user->$method->count()) { $this->table(['ID', ucfirst($modelName), 'Created At', 'Updated At'], $data); } else { $this->warn("Not found any {$method}!"); } }
[ "protected", "function", "show", "(", "$", "user", ",", "string", "$", "modelName", ")", "{", "$", "method", "=", "\"{$modelName}s\"", ";", "$", "methodTitle", "=", "ucfirst", "(", "$", "method", ")", ";", "if", "(", "!", "$", "user", "->", "$", "method", ")", "{", "$", "this", "->", "warn", "(", "\"User not use Has{$methodTitle}Trait!\"", ")", ";", "return", ";", "}", "echo", "\"{$methodTitle}:\"", ",", "PHP_EOL", ";", "$", "data", "=", "$", "this", "->", "prepareData", "(", "$", "user", "->", "$", "method", "->", "toArray", "(", ")", ")", ";", "if", "(", "$", "user", "->", "$", "method", "->", "count", "(", ")", ")", "{", "$", "this", "->", "table", "(", "[", "'ID'", ",", "ucfirst", "(", "$", "modelName", ")", ",", "'Created At'", ",", "'Updated At'", "]", ",", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "warn", "(", "\"Not found any {$method}!\"", ")", ";", "}", "}" ]
Show roles or permissions @param $user @param string $modelName
[ "Show", "roles", "or", "permissions" ]
b5f23340b5536babb98d9fd0d727a7a3371c97d5
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/User/ViewCommand.php#L65-L84
24,147
pixxet/flysystem-webdav
src/WebDAVAdapter.php
WebDAVAdapter.nativeCopy
function nativeCopy($path, $newPath) { if (!$this->createDir(Util::dirname($newPath), new Config())) { return false; } $location = $this->applyPathPrefix($this->encodePath($path)); $newLocation = $this->applyPathPrefix($this->encodePath($newPath)); try { $destination = $this->client->getAbsoluteUrl($newLocation); $response = $this->client->request('COPY', '/' . ltrim($location, '/'), null, [ 'Destination' => $destination, ]); if ($response['statusCode'] >= 200 && $response['statusCode'] < 300) { return true; } } catch (NotFound $e) { // Would have returned false here, but would be redundant } return false; }
php
function nativeCopy($path, $newPath) { if (!$this->createDir(Util::dirname($newPath), new Config())) { return false; } $location = $this->applyPathPrefix($this->encodePath($path)); $newLocation = $this->applyPathPrefix($this->encodePath($newPath)); try { $destination = $this->client->getAbsoluteUrl($newLocation); $response = $this->client->request('COPY', '/' . ltrim($location, '/'), null, [ 'Destination' => $destination, ]); if ($response['statusCode'] >= 200 && $response['statusCode'] < 300) { return true; } } catch (NotFound $e) { // Would have returned false here, but would be redundant } return false; }
[ "function", "nativeCopy", "(", "$", "path", ",", "$", "newPath", ")", "{", "if", "(", "!", "$", "this", "->", "createDir", "(", "Util", "::", "dirname", "(", "$", "newPath", ")", ",", "new", "Config", "(", ")", ")", ")", "{", "return", "false", ";", "}", "$", "location", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "this", "->", "encodePath", "(", "$", "path", ")", ")", ";", "$", "newLocation", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "this", "->", "encodePath", "(", "$", "newPath", ")", ")", ";", "try", "{", "$", "destination", "=", "$", "this", "->", "client", "->", "getAbsoluteUrl", "(", "$", "newLocation", ")", ";", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'COPY'", ",", "'/'", ".", "ltrim", "(", "$", "location", ",", "'/'", ")", ",", "null", ",", "[", "'Destination'", "=>", "$", "destination", ",", "]", ")", ";", "if", "(", "$", "response", "[", "'statusCode'", "]", ">=", "200", "&&", "$", "response", "[", "'statusCode'", "]", "<", "300", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "NotFound", "$", "e", ")", "{", "// Would have returned false here, but would be redundant", "}", "return", "false", ";", "}" ]
Copy a file through WebDav COPY method. @param string $path @param string $newPath @return bool
[ "Copy", "a", "file", "through", "WebDav", "COPY", "method", "." ]
1ce6d63f9565171ccb5f4741d43906e50441516a
https://github.com/pixxet/flysystem-webdav/blob/1ce6d63f9565171ccb5f4741d43906e50441516a/src/WebDAVAdapter.php#L338-L361
24,148
pixxet/flysystem-webdav
src/WebDAVAdapter.php
WebDAVAdapter.normalizeObject
function normalizeObject(array $object, $path) { if (!isset($object['{DAV:}getcontentlength']) or $object['{DAV:}getcontentlength'] == "") { return ['type' => 'dir', 'path' => trim($path, '/')]; } $result = Util::map($object, static::$resultMap); if (isset($object['{DAV:}getlastmodified'])) { $result['timestamp'] = strtotime($object['{DAV:}getlastmodified']); } $result['type'] = 'file'; $result['path'] = trim($path, '/'); return $result; }
php
function normalizeObject(array $object, $path) { if (!isset($object['{DAV:}getcontentlength']) or $object['{DAV:}getcontentlength'] == "") { return ['type' => 'dir', 'path' => trim($path, '/')]; } $result = Util::map($object, static::$resultMap); if (isset($object['{DAV:}getlastmodified'])) { $result['timestamp'] = strtotime($object['{DAV:}getlastmodified']); } $result['type'] = 'file'; $result['path'] = trim($path, '/'); return $result; }
[ "function", "normalizeObject", "(", "array", "$", "object", ",", "$", "path", ")", "{", "if", "(", "!", "isset", "(", "$", "object", "[", "'{DAV:}getcontentlength'", "]", ")", "or", "$", "object", "[", "'{DAV:}getcontentlength'", "]", "==", "\"\"", ")", "{", "return", "[", "'type'", "=>", "'dir'", ",", "'path'", "=>", "trim", "(", "$", "path", ",", "'/'", ")", "]", ";", "}", "$", "result", "=", "Util", "::", "map", "(", "$", "object", ",", "static", "::", "$", "resultMap", ")", ";", "if", "(", "isset", "(", "$", "object", "[", "'{DAV:}getlastmodified'", "]", ")", ")", "{", "$", "result", "[", "'timestamp'", "]", "=", "strtotime", "(", "$", "object", "[", "'{DAV:}getlastmodified'", "]", ")", ";", "}", "$", "result", "[", "'type'", "]", "=", "'file'", ";", "$", "result", "[", "'path'", "]", "=", "trim", "(", "$", "path", ",", "'/'", ")", ";", "return", "$", "result", ";", "}" ]
Normalise a WebDAV repsonse object. @param array $object @param string $path @return array
[ "Normalise", "a", "WebDAV", "repsonse", "object", "." ]
1ce6d63f9565171ccb5f4741d43906e50441516a
https://github.com/pixxet/flysystem-webdav/blob/1ce6d63f9565171ccb5f4741d43906e50441516a/src/WebDAVAdapter.php#L371-L387
24,149
pixxet/flysystem-webdav
src/WebDAVAdapter.php
WebDAVAdapter.removePathPrefix
function removePathPrefix($path) { if (strpos($path, $this->getPathPrefix()) === false) { return basename($path); } return parent::removePathPrefix($path); }
php
function removePathPrefix($path) { if (strpos($path, $this->getPathPrefix()) === false) { return basename($path); } return parent::removePathPrefix($path); }
[ "function", "removePathPrefix", "(", "$", "path", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "$", "this", "->", "getPathPrefix", "(", ")", ")", "===", "false", ")", "{", "return", "basename", "(", "$", "path", ")", ";", "}", "return", "parent", "::", "removePathPrefix", "(", "$", "path", ")", ";", "}" ]
Remove a path prefix. @param string $path @return string path without the prefix
[ "Remove", "a", "path", "prefix", "." ]
1ce6d63f9565171ccb5f4741d43906e50441516a
https://github.com/pixxet/flysystem-webdav/blob/1ce6d63f9565171ccb5f4741d43906e50441516a/src/WebDAVAdapter.php#L396-L403
24,150
thienhungho/yii2-product-management
src/modules/ProductManage/controllers/TermOfProductTypeController.php
TermOfProductTypeController.findModel
protected function findModel($id) { if (($model = TermOfProductType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
php
protected function findModel($id) { if (($model = TermOfProductType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "TermOfProductType", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "t", "(", "'app'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the TermOfProductType model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return TermOfProductType the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "TermOfProductType", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
72e1237bba123faf671e44491bd93077b50adde9
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/TermOfProductTypeController.php#L207-L214
24,151
surebert/surebert-framework
src/sb/CURL/Client.php
Client.post
public function post($url, $data = [], $headers = [], $curl_opts = []) { return $this->load($url, $data, $headers, $curl_opts); }
php
public function post($url, $data = [], $headers = [], $curl_opts = []) { return $this->load($url, $data, $headers, $curl_opts); }
[ "public", "function", "post", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "headers", "=", "[", "]", ",", "$", "curl_opts", "=", "[", "]", ")", "{", "return", "$", "this", "->", "load", "(", "$", "url", ",", "$", "data", ",", "$", "headers", ",", "$", "curl_opts", ")", ";", "}" ]
GETs data from the server @param string $url The URL to grab @param array $data The data to pass @param array $headers additional HTTP options @param array $curl_opts additional CURL options @return string @throws \Exception
[ "GETs", "data", "from", "the", "server" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/CURL/Client.php#L119-L121
24,152
surebert/surebert-framework
src/sb/CURL/Client.php
Client.put
public function put($url, $data = [], $headers = [], $curl_opts = []) { $curl_opts[CURLOPT_CUSTOMREQUEST] = 'PUT'; return $this->load($url, $data, $headers, $curl_opts); }
php
public function put($url, $data = [], $headers = [], $curl_opts = []) { $curl_opts[CURLOPT_CUSTOMREQUEST] = 'PUT'; return $this->load($url, $data, $headers, $curl_opts); }
[ "public", "function", "put", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "headers", "=", "[", "]", ",", "$", "curl_opts", "=", "[", "]", ")", "{", "$", "curl_opts", "[", "CURLOPT_CUSTOMREQUEST", "]", "=", "'PUT'", ";", "return", "$", "this", "->", "load", "(", "$", "url", ",", "$", "data", ",", "$", "headers", ",", "$", "curl_opts", ")", ";", "}" ]
PUTs data to the server @param string $url The URL to grab @param array $data The data to pass @param array $headers additional HTTP options @param array $curl_opts additional CURL options @return string @throws \Exception
[ "PUTs", "data", "to", "the", "server" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/CURL/Client.php#L132-L135
24,153
surebert/surebert-framework
src/sb/CURL/Client.php
Client.delete
public function delete($url, $data = [], $headers = [], $curl_opts = []) { $curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; return $this->load($url, $data, $headers, $curl_opts); }
php
public function delete($url, $data = [], $headers = [], $curl_opts = []) { $curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; return $this->load($url, $data, $headers, $curl_opts); }
[ "public", "function", "delete", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "headers", "=", "[", "]", ",", "$", "curl_opts", "=", "[", "]", ")", "{", "$", "curl_opts", "[", "CURLOPT_CUSTOMREQUEST", "]", "=", "'DELETE'", ";", "return", "$", "this", "->", "load", "(", "$", "url", ",", "$", "data", ",", "$", "headers", ",", "$", "curl_opts", ")", ";", "}" ]
DELETEs data from the server @param string $url The URL to grab @param array $data The data to pass @param array $headers additional HTTP options @param array $curl_opts additional CURL options @return string @throws \Exception
[ "DELETEs", "data", "from", "the", "server" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/CURL/Client.php#L146-L149
24,154
madkom/regex
src/Splitter.php
Splitter.split
public function split(string $subject, int $limit = -1, int $flags = 0) : array { $result = preg_split($this->pattern->getPattern() . $this->modifier, $subject, $limit, $flags); if (($errno = preg_last_error()) !== PREG_NO_ERROR) { $message = array_flip(get_defined_constants(true)['pcre'])[$errno]; switch ($errno) { case PREG_INTERNAL_ERROR: throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BACKTRACK_LIMIT_ERROR: throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_RECURSION_LIMIT_ERROR: throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BAD_UTF8_ERROR: throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BAD_UTF8_OFFSET_ERROR: throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_JIT_STACKLIMIT_ERROR: throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); } } return $result; }
php
public function split(string $subject, int $limit = -1, int $flags = 0) : array { $result = preg_split($this->pattern->getPattern() . $this->modifier, $subject, $limit, $flags); if (($errno = preg_last_error()) !== PREG_NO_ERROR) { $message = array_flip(get_defined_constants(true)['pcre'])[$errno]; switch ($errno) { case PREG_INTERNAL_ERROR: throw new InternalException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BACKTRACK_LIMIT_ERROR: throw new BacktrackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_RECURSION_LIMIT_ERROR: throw new RecursionLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BAD_UTF8_ERROR: throw new BadUtf8Exception("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_BAD_UTF8_OFFSET_ERROR: throw new BadUtf8OffsetException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); case PREG_JIT_STACKLIMIT_ERROR: throw new JitStackLimitException("{$message} using pattern: {$this->pattern->getPattern()}", $errno); } } return $result; }
[ "public", "function", "split", "(", "string", "$", "subject", ",", "int", "$", "limit", "=", "-", "1", ",", "int", "$", "flags", "=", "0", ")", ":", "array", "{", "$", "result", "=", "preg_split", "(", "$", "this", "->", "pattern", "->", "getPattern", "(", ")", ".", "$", "this", "->", "modifier", ",", "$", "subject", ",", "$", "limit", ",", "$", "flags", ")", ";", "if", "(", "(", "$", "errno", "=", "preg_last_error", "(", ")", ")", "!==", "PREG_NO_ERROR", ")", "{", "$", "message", "=", "array_flip", "(", "get_defined_constants", "(", "true", ")", "[", "'pcre'", "]", ")", "[", "$", "errno", "]", ";", "switch", "(", "$", "errno", ")", "{", "case", "PREG_INTERNAL_ERROR", ":", "throw", "new", "InternalException", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "case", "PREG_BACKTRACK_LIMIT_ERROR", ":", "throw", "new", "BacktrackLimitException", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "case", "PREG_RECURSION_LIMIT_ERROR", ":", "throw", "new", "RecursionLimitException", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "case", "PREG_BAD_UTF8_ERROR", ":", "throw", "new", "BadUtf8Exception", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "case", "PREG_BAD_UTF8_OFFSET_ERROR", ":", "throw", "new", "BadUtf8OffsetException", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "case", "PREG_JIT_STACKLIMIT_ERROR", ":", "throw", "new", "JitStackLimitException", "(", "\"{$message} using pattern: {$this->pattern->getPattern()}\"", ",", "$", "errno", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Retrieves subject split with Pattern @param string $subject @param int $limit @param int $flags @return array @throws BacktrackLimitException @throws BadUtf8Exception @throws BadUtf8OffsetException @throws InternalException @throws JitStackLimitException @throws RecursionLimitException
[ "Retrieves", "subject", "split", "with", "Pattern" ]
798c1124805b130b1110ee6e8dcc9a88d8aaffa8
https://github.com/madkom/regex/blob/798c1124805b130b1110ee6e8dcc9a88d8aaffa8/src/Splitter.php#L57-L80
24,155
namics/twig-nitro-library
src/Twig/TokenParser/ComponentTokenParser.php
ComponentTokenParser.parseArguments
protected function parseArguments() { $stream = $this->parser->getStream(); $data = null; $only = false; if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; } if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { $only = true; $stream->next(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; } $data = $this->parser->getExpressionParser()->parseExpression(); if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { $only = true; $stream->next(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; }
php
protected function parseArguments() { $stream = $this->parser->getStream(); $data = null; $only = false; if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; } if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { $only = true; $stream->next(); $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; } $data = $this->parser->getExpressionParser()->parseExpression(); if ($stream->test(Twig_Token::NAME_TYPE, 'only')) { $only = true; $stream->next(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); return [$data, $only]; }
[ "protected", "function", "parseArguments", "(", ")", "{", "$", "stream", "=", "$", "this", "->", "parser", "->", "getStream", "(", ")", ";", "$", "data", "=", "null", ";", "$", "only", "=", "false", ";", "if", "(", "$", "stream", "->", "test", "(", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ")", "{", "$", "stream", "->", "expect", "(", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ";", "return", "[", "$", "data", ",", "$", "only", "]", ";", "}", "if", "(", "$", "stream", "->", "test", "(", "Twig_Token", "::", "NAME_TYPE", ",", "'only'", ")", ")", "{", "$", "only", "=", "true", ";", "$", "stream", "->", "next", "(", ")", ";", "$", "stream", "->", "expect", "(", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ";", "return", "[", "$", "data", ",", "$", "only", "]", ";", "}", "$", "data", "=", "$", "this", "->", "parser", "->", "getExpressionParser", "(", ")", "->", "parseExpression", "(", ")", ";", "if", "(", "$", "stream", "->", "test", "(", "Twig_Token", "::", "NAME_TYPE", ",", "'only'", ")", ")", "{", "$", "only", "=", "true", ";", "$", "stream", "->", "next", "(", ")", ";", "}", "$", "stream", "->", "expect", "(", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ";", "return", "[", "$", "data", ",", "$", "only", "]", ";", "}" ]
Tokenizes the component stream. @return array
[ "Tokenizes", "the", "component", "stream", "." ]
f4631b50876b7cdc79f3cca4d3465c8c9a2e87de
https://github.com/namics/twig-nitro-library/blob/f4631b50876b7cdc79f3cca4d3465c8c9a2e87de/src/Twig/TokenParser/ComponentTokenParser.php#L56-L87
24,156
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.getSubscribedEvents
public function getSubscribedEvents() { $events = []; foreach ($this->providers as $command => $provider) { $events['command.' . $command] = 'handleCommand'; $events['command.' . $command . '.help'] = 'handleCommandHelp'; } return $events; }
php
public function getSubscribedEvents() { $events = []; foreach ($this->providers as $command => $provider) { $events['command.' . $command] = 'handleCommand'; $events['command.' . $command . '.help'] = 'handleCommandHelp'; } return $events; }
[ "public", "function", "getSubscribedEvents", "(", ")", "{", "$", "events", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "providers", "as", "$", "command", "=>", "$", "provider", ")", "{", "$", "events", "[", "'command.'", ".", "$", "command", "]", "=", "'handleCommand'", ";", "$", "events", "[", "'command.'", ".", "$", "command", ".", "'.help'", "]", "=", "'handleCommandHelp'", ";", "}", "return", "$", "events", ";", "}" ]
Return an array of commands and associated methods @return array
[ "Return", "an", "array", "of", "commands", "and", "associated", "methods" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L62-L71
24,157
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.handleCommandHelp
public function handleCommandHelp(Event $event, Queue $queue) { $params = $event->getCustomParams(); $provider = $this->getProvider( ($event->getCustomCommand() === "help") ? $params[0] : $event->getCustomCommand() ); if ($provider) { $this->sendIrcResponse($event, $queue, $provider->getHelpLines()); } }
php
public function handleCommandHelp(Event $event, Queue $queue) { $params = $event->getCustomParams(); $provider = $this->getProvider( ($event->getCustomCommand() === "help") ? $params[0] : $event->getCustomCommand() ); if ($provider) { $this->sendIrcResponse($event, $queue, $provider->getHelpLines()); } }
[ "public", "function", "handleCommandHelp", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ")", "{", "$", "params", "=", "$", "event", "->", "getCustomParams", "(", ")", ";", "$", "provider", "=", "$", "this", "->", "getProvider", "(", "(", "$", "event", "->", "getCustomCommand", "(", ")", "===", "\"help\"", ")", "?", "$", "params", "[", "0", "]", ":", "$", "event", "->", "getCustomCommand", "(", ")", ")", ";", "if", "(", "$", "provider", ")", "{", "$", "this", "->", "sendIrcResponse", "(", "$", "event", ",", "$", "queue", ",", "$", "provider", "->", "getHelpLines", "(", ")", ")", ";", "}", "}" ]
Main plugin handler for help requests @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Main", "plugin", "handler", "for", "help", "requests" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L98-L109
24,158
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.getProvider
public function getProvider($command) { $providerExists = (isset($this->providers[$command]) && class_exists($this->providers[$command])); return ($providerExists) ? new $this->providers[$command] : false; }
php
public function getProvider($command) { $providerExists = (isset($this->providers[$command]) && class_exists($this->providers[$command])); return ($providerExists) ? new $this->providers[$command] : false; }
[ "public", "function", "getProvider", "(", "$", "command", ")", "{", "$", "providerExists", "=", "(", "isset", "(", "$", "this", "->", "providers", "[", "$", "command", "]", ")", "&&", "class_exists", "(", "$", "this", "->", "providers", "[", "$", "command", "]", ")", ")", ";", "return", "(", "$", "providerExists", ")", "?", "new", "$", "this", "->", "providers", "[", "$", "command", "]", ":", "false", ";", "}" ]
Get a single provider class by command @param string $command @return mixed
[ "Get", "a", "single", "provider", "class", "by", "command" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L118-L122
24,159
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.getApiRequest
protected function getApiRequest(Event $event, Queue $queue, GoogleProviderInterface $provider) { $self = $this; return new HttpRequest([ 'url' => $provider->getApiRequestUrl($event), 'resolveCallback' => function (Response $response) use ($self, $event, $queue, $provider) { $self->sendIrcResponse($event, $queue, $provider->getSuccessLines($event, $response->getBody())); }, 'rejectCallback' => function ($error) use ($self, $event, $queue, $provider) { $self->sendIrcResponse($event, $queue, $provider->getRejectLines($event, $error)); } ]); }
php
protected function getApiRequest(Event $event, Queue $queue, GoogleProviderInterface $provider) { $self = $this; return new HttpRequest([ 'url' => $provider->getApiRequestUrl($event), 'resolveCallback' => function (Response $response) use ($self, $event, $queue, $provider) { $self->sendIrcResponse($event, $queue, $provider->getSuccessLines($event, $response->getBody())); }, 'rejectCallback' => function ($error) use ($self, $event, $queue, $provider) { $self->sendIrcResponse($event, $queue, $provider->getRejectLines($event, $error)); } ]); }
[ "protected", "function", "getApiRequest", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ",", "GoogleProviderInterface", "$", "provider", ")", "{", "$", "self", "=", "$", "this", ";", "return", "new", "HttpRequest", "(", "[", "'url'", "=>", "$", "provider", "->", "getApiRequestUrl", "(", "$", "event", ")", ",", "'resolveCallback'", "=>", "function", "(", "Response", "$", "response", ")", "use", "(", "$", "self", ",", "$", "event", ",", "$", "queue", ",", "$", "provider", ")", "{", "$", "self", "->", "sendIrcResponse", "(", "$", "event", ",", "$", "queue", ",", "$", "provider", "->", "getSuccessLines", "(", "$", "event", ",", "$", "response", "->", "getBody", "(", ")", ")", ")", ";", "}", ",", "'rejectCallback'", "=>", "function", "(", "$", "error", ")", "use", "(", "$", "self", ",", "$", "event", ",", "$", "queue", ",", "$", "provider", ")", "{", "$", "self", "->", "sendIrcResponse", "(", "$", "event", ",", "$", "queue", ",", "$", "provider", "->", "getRejectLines", "(", "$", "event", ",", "$", "error", ")", ")", ";", "}", "]", ")", ";", "}" ]
Set up the API request and set the callbacks @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue @param \Chrismou\Phergie\Plugin\Google\Provider\GoogleProviderInterface $provider @return \Phergie\Plugin\Http\Request
[ "Set", "up", "the", "API", "request", "and", "set", "the", "callbacks" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L133-L146
24,160
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.sendIrcResponse
protected function sendIrcResponse(Event $event, Queue $queue, array $ircResponse) { foreach ($ircResponse as $ircResponseLine) { $this->sendIrcResponseLine($event, $queue, $ircResponseLine); } }
php
protected function sendIrcResponse(Event $event, Queue $queue, array $ircResponse) { foreach ($ircResponse as $ircResponseLine) { $this->sendIrcResponseLine($event, $queue, $ircResponseLine); } }
[ "protected", "function", "sendIrcResponse", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ",", "array", "$", "ircResponse", ")", "{", "foreach", "(", "$", "ircResponse", "as", "$", "ircResponseLine", ")", "{", "$", "this", "->", "sendIrcResponseLine", "(", "$", "event", ",", "$", "queue", ",", "$", "ircResponseLine", ")", ";", "}", "}" ]
Send an array of response lines back to IRC @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue @param array $ircResponse
[ "Send", "an", "array", "of", "response", "lines", "back", "to", "IRC" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L156-L161
24,161
chrismou/phergie-irc-plugin-react-google
src/Plugin.php
Plugin.sendIrcResponseLine
protected function sendIrcResponseLine(Event $event, Queue $queue, $ircResponseLine) { $queue->ircPrivmsg($event->getSource(), $ircResponseLine); }
php
protected function sendIrcResponseLine(Event $event, Queue $queue, $ircResponseLine) { $queue->ircPrivmsg($event->getSource(), $ircResponseLine); }
[ "protected", "function", "sendIrcResponseLine", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ",", "$", "ircResponseLine", ")", "{", "$", "queue", "->", "ircPrivmsg", "(", "$", "event", "->", "getSource", "(", ")", ",", "$", "ircResponseLine", ")", ";", "}" ]
Send a single response line back to IRC @param \Phergie\Irc\Plugin\React\Command\CommandEvent $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue @param string $ircResponseLine
[ "Send", "a", "single", "response", "line", "back", "to", "IRC" ]
4492bf1e25826a9cf7187afee0ec35deddefaf6f
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Plugin.php#L171-L174
24,162
codezero-be/curl
src/ResponseInfo.php
ResponseInfo.fetchInfo
private function fetchInfo($key) { return array_key_exists($key, $this->info) ? $this->info[$key] : null; }
php
private function fetchInfo($key) { return array_key_exists($key, $this->info) ? $this->info[$key] : null; }
[ "private", "function", "fetchInfo", "(", "$", "key", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "info", ")", "?", "$", "this", "->", "info", "[", "$", "key", "]", ":", "null", ";", "}" ]
Search the information array for the specified key and return the value @param string $key @return mixed
[ "Search", "the", "information", "array", "for", "the", "specified", "key", "and", "return", "the", "value" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/ResponseInfo.php#L144-L149
24,163
RhubarbPHP/Module.RestApi
src/UrlHandlers/RestResourceHandler.php
RestResourceHandler.getRestResource
protected function getRestResource() { $parentResource = $this->getParentResource(); if ($parentResource !== null) { $childResource = $parentResource->getChildResource($this->matchingUrl); if ($childResource) { $childResource->setUrlHandler($this); return $childResource; } } $className = $this->apiResourceClassName; /** @var RestResource $resource */ $resource = new $className($this->getParentResource()); $resource->setUrlHandler($this); return $resource; }
php
protected function getRestResource() { $parentResource = $this->getParentResource(); if ($parentResource !== null) { $childResource = $parentResource->getChildResource($this->matchingUrl); if ($childResource) { $childResource->setUrlHandler($this); return $childResource; } } $className = $this->apiResourceClassName; /** @var RestResource $resource */ $resource = new $className($this->getParentResource()); $resource->setUrlHandler($this); return $resource; }
[ "protected", "function", "getRestResource", "(", ")", "{", "$", "parentResource", "=", "$", "this", "->", "getParentResource", "(", ")", ";", "if", "(", "$", "parentResource", "!==", "null", ")", "{", "$", "childResource", "=", "$", "parentResource", "->", "getChildResource", "(", "$", "this", "->", "matchingUrl", ")", ";", "if", "(", "$", "childResource", ")", "{", "$", "childResource", "->", "setUrlHandler", "(", "$", "this", ")", ";", "return", "$", "childResource", ";", "}", "}", "$", "className", "=", "$", "this", "->", "apiResourceClassName", ";", "/** @var RestResource $resource */", "$", "resource", "=", "new", "$", "className", "(", "$", "this", "->", "getParentResource", "(", ")", ")", ";", "$", "resource", "->", "setUrlHandler", "(", "$", "this", ")", ";", "return", "$", "resource", ";", "}" ]
Gets the RestResource object @return RestResource
[ "Gets", "the", "RestResource", "object" ]
825d2b920caed13811971c5eb2784a94417787bd
https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/UrlHandlers/RestResourceHandler.php#L71-L89
24,164
NuclearCMS/Hierarchy
src/Bags/NodeTypeBag.php
NodeTypeBag.addNodeType
public function addNodeType(NodeTypeContract $nodeType) { if ( ! $this->hasNodeType($nodeType->getKey())) { $this->put($nodeType->getKey(), $nodeType); } }
php
public function addNodeType(NodeTypeContract $nodeType) { if ( ! $this->hasNodeType($nodeType->getKey())) { $this->put($nodeType->getKey(), $nodeType); } }
[ "public", "function", "addNodeType", "(", "NodeTypeContract", "$", "nodeType", ")", "{", "if", "(", "!", "$", "this", "->", "hasNodeType", "(", "$", "nodeType", "->", "getKey", "(", ")", ")", ")", "{", "$", "this", "->", "put", "(", "$", "nodeType", "->", "getKey", "(", ")", ",", "$", "nodeType", ")", ";", "}", "}" ]
Adds a node type to the bag @param NodeTypeContract $nodeType
[ "Adds", "a", "node", "type", "to", "the", "bag" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Bags/NodeTypeBag.php#L17-L23
24,165
nabab/bbn
src/bbn/appui/cron.php
cron.get_cron
public function get_cron($id): ?array { if ( $this->check() && ($data = $this->db->rselect($this->table, [], ['id' => $id])) ){ $data['cfg'] = json_decode($data['cfg'], 1); return $data; } return null; }
php
public function get_cron($id): ?array { if ( $this->check() && ($data = $this->db->rselect($this->table, [], ['id' => $id])) ){ $data['cfg'] = json_decode($data['cfg'], 1); return $data; } return null; }
[ "public", "function", "get_cron", "(", "$", "id", ")", ":", "?", "array", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "(", "$", "data", "=", "$", "this", "->", "db", "->", "rselect", "(", "$", "this", "->", "table", ",", "[", "]", ",", "[", "'id'", "=>", "$", "id", "]", ")", ")", ")", "{", "$", "data", "[", "'cfg'", "]", "=", "json_decode", "(", "$", "data", "[", "'cfg'", "]", ",", "1", ")", ";", "return", "$", "data", ";", "}", "return", "null", ";", "}" ]
Returns the full row as an indexed array for the given CRON ID. @param $id @return null|array
[ "Returns", "the", "full", "row", "as", "an", "indexed", "array", "for", "the", "given", "CRON", "ID", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/cron.php#L498-L505
24,166
nabab/bbn
src/bbn/appui/cron.php
cron.start
public function start($id_cron): bool { $res = false; if ( $this->check() && ($cron = $this->get_cron($id_cron)) ){ bbn\appui\history::disable(); $start = date('Y-m-d H:i:s'); if ( $this->db->update($this->table, [ 'prev' => $start, 'next' => date('Y-m-d H:i:s', $this->get_next_date($cron['cfg']['frequency'])) ], [ 'id' => $id_cron ]) ){ $res = true; } bbn\appui\history::enable(); } return $res; }
php
public function start($id_cron): bool { $res = false; if ( $this->check() && ($cron = $this->get_cron($id_cron)) ){ bbn\appui\history::disable(); $start = date('Y-m-d H:i:s'); if ( $this->db->update($this->table, [ 'prev' => $start, 'next' => date('Y-m-d H:i:s', $this->get_next_date($cron['cfg']['frequency'])) ], [ 'id' => $id_cron ]) ){ $res = true; } bbn\appui\history::enable(); } return $res; }
[ "public", "function", "start", "(", "$", "id_cron", ")", ":", "bool", "{", "$", "res", "=", "false", ";", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "(", "$", "cron", "=", "$", "this", "->", "get_cron", "(", "$", "id_cron", ")", ")", ")", "{", "bbn", "\\", "appui", "\\", "history", "::", "disable", "(", ")", ";", "$", "start", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "if", "(", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "table", ",", "[", "'prev'", "=>", "$", "start", ",", "'next'", "=>", "date", "(", "'Y-m-d H:i:s'", ",", "$", "this", "->", "get_next_date", "(", "$", "cron", "[", "'cfg'", "]", "[", "'frequency'", "]", ")", ")", "]", ",", "[", "'id'", "=>", "$", "id_cron", "]", ")", ")", "{", "$", "res", "=", "true", ";", "}", "bbn", "\\", "appui", "\\", "history", "::", "enable", "(", ")", ";", "}", "return", "$", "res", ";", "}" ]
Writes in the given CRON row the next start time, the current as previous, and the new running status. @param $id_cron @return bool
[ "Writes", "in", "the", "given", "CRON", "row", "the", "next", "start", "time", "the", "current", "as", "previous", "and", "the", "new", "running", "status", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/cron.php#L512-L529
24,167
nabab/bbn
src/bbn/appui/cron.php
cron.finish
public function finish($id, $res = ''){ if ( ($article = $this->get_article($id)) && ($cron = $this->get_cron($article['id_cron'])) ){ bbn\appui\history::disable(); $time = $this->timer->has_started('cron_'.$article['id_cron']) ? $this->timer->stop('cron_'.$article['id_cron']): 0; if ( !empty($res) ){ bbn\x::hdump($id, $res); $this->db->update($this->jtable, [ 'finish' => date('Y-m-d H:i:s'), 'duration' => $time, 'res' => $res ], [ 'id' => $id ]); } else{ $this->db->delete($this->jtable, ['id' => $id]); $prev = $this->db->rselect($this->jtable, ['res', 'id'], ['id_cron' => $article['id_cron']], ['finish' => 'DESC']); if ( $prev['res'] === 'error' ){ $this->db->update($this->jtable, ['res' => 'Restarted after error'], ['id' => $prev['id']]); } } bbn\appui\history::enable(); return $time; } return false; }
php
public function finish($id, $res = ''){ if ( ($article = $this->get_article($id)) && ($cron = $this->get_cron($article['id_cron'])) ){ bbn\appui\history::disable(); $time = $this->timer->has_started('cron_'.$article['id_cron']) ? $this->timer->stop('cron_'.$article['id_cron']): 0; if ( !empty($res) ){ bbn\x::hdump($id, $res); $this->db->update($this->jtable, [ 'finish' => date('Y-m-d H:i:s'), 'duration' => $time, 'res' => $res ], [ 'id' => $id ]); } else{ $this->db->delete($this->jtable, ['id' => $id]); $prev = $this->db->rselect($this->jtable, ['res', 'id'], ['id_cron' => $article['id_cron']], ['finish' => 'DESC']); if ( $prev['res'] === 'error' ){ $this->db->update($this->jtable, ['res' => 'Restarted after error'], ['id' => $prev['id']]); } } bbn\appui\history::enable(); return $time; } return false; }
[ "public", "function", "finish", "(", "$", "id", ",", "$", "res", "=", "''", ")", "{", "if", "(", "(", "$", "article", "=", "$", "this", "->", "get_article", "(", "$", "id", ")", ")", "&&", "(", "$", "cron", "=", "$", "this", "->", "get_cron", "(", "$", "article", "[", "'id_cron'", "]", ")", ")", ")", "{", "bbn", "\\", "appui", "\\", "history", "::", "disable", "(", ")", ";", "$", "time", "=", "$", "this", "->", "timer", "->", "has_started", "(", "'cron_'", ".", "$", "article", "[", "'id_cron'", "]", ")", "?", "$", "this", "->", "timer", "->", "stop", "(", "'cron_'", ".", "$", "article", "[", "'id_cron'", "]", ")", ":", "0", ";", "if", "(", "!", "empty", "(", "$", "res", ")", ")", "{", "bbn", "\\", "x", "::", "hdump", "(", "$", "id", ",", "$", "res", ")", ";", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "jtable", ",", "[", "'finish'", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "'duration'", "=>", "$", "time", ",", "'res'", "=>", "$", "res", "]", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "}", "else", "{", "$", "this", "->", "db", "->", "delete", "(", "$", "this", "->", "jtable", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "$", "prev", "=", "$", "this", "->", "db", "->", "rselect", "(", "$", "this", "->", "jtable", ",", "[", "'res'", ",", "'id'", "]", ",", "[", "'id_cron'", "=>", "$", "article", "[", "'id_cron'", "]", "]", ",", "[", "'finish'", "=>", "'DESC'", "]", ")", ";", "if", "(", "$", "prev", "[", "'res'", "]", "===", "'error'", ")", "{", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "jtable", ",", "[", "'res'", "=>", "'Restarted after error'", "]", ",", "[", "'id'", "=>", "$", "prev", "[", "'id'", "]", "]", ")", ";", "}", "}", "bbn", "\\", "appui", "\\", "history", "::", "enable", "(", ")", ";", "return", "$", "time", ";", "}", "return", "false", ";", "}" ]
Writes in the given CRON row the duration and the new finished status. @param $id @param string $res @return bool|int
[ "Writes", "in", "the", "given", "CRON", "row", "the", "duration", "and", "the", "new", "finished", "status", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/cron.php#L537-L563
24,168
nabab/bbn
src/bbn/appui/cron.php
cron.get_next
public function get_next($id_cron = null): ?array { if ( $this->check() && ($data = $this->db->get_row(" SELECT * FROM {$this->table} WHERE `active` = 1 AND `next` < NOW()". ( bbn\str::is_uid($id_cron) ? " AND `id` = '$id_cron'" : '' )." ORDER BY `priority` ASC, `next` ASC LIMIT 1")) ){ // Dans cfg: timeout, et soit: latency, minute, hour, day of month, day of week, date $data['cfg'] = json_decode($data['cfg'], 1); return $data; } }
php
public function get_next($id_cron = null): ?array { if ( $this->check() && ($data = $this->db->get_row(" SELECT * FROM {$this->table} WHERE `active` = 1 AND `next` < NOW()". ( bbn\str::is_uid($id_cron) ? " AND `id` = '$id_cron'" : '' )." ORDER BY `priority` ASC, `next` ASC LIMIT 1")) ){ // Dans cfg: timeout, et soit: latency, minute, hour, day of month, day of week, date $data['cfg'] = json_decode($data['cfg'], 1); return $data; } }
[ "public", "function", "get_next", "(", "$", "id_cron", "=", "null", ")", ":", "?", "array", "{", "if", "(", "$", "this", "->", "check", "(", ")", "&&", "(", "$", "data", "=", "$", "this", "->", "db", "->", "get_row", "(", "\"\n SELECT *\n FROM {$this->table}\n WHERE `active` = 1\n AND `next` < NOW()\"", ".", "(", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id_cron", ")", "?", "\" AND `id` = '$id_cron'\"", ":", "''", ")", ".", "\"\n ORDER BY `priority` ASC, `next` ASC\n LIMIT 1\"", ")", ")", ")", "{", "// Dans cfg: timeout, et soit: latency, minute, hour, day of month, day of week, date", "$", "data", "[", "'cfg'", "]", "=", "json_decode", "(", "$", "data", "[", "'cfg'", "]", ",", "1", ")", ";", "return", "$", "data", ";", "}", "}" ]
Returns the whole row for the next CRON to be executed from now if there is any. @param null $id_cron @return null|array
[ "Returns", "the", "whole", "row", "for", "the", "next", "CRON", "to", "be", "executed", "from", "now", "if", "there", "is", "any", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/cron.php#L621-L635
24,169
maxmirazh33/yii2-uploadable-file
src/Behavior.php
Behavior.beforeValidate
public function beforeValidate() { /* @var $model ActiveRecord */ $model = $this->owner; foreach ($this->attributes as $attr => $options) { $this->ensureAttributes($attr, $options); if ($file = UploadedFile::getInstance($model, $attr)) { $model->{$attr} = $file; } } }
php
public function beforeValidate() { /* @var $model ActiveRecord */ $model = $this->owner; foreach ($this->attributes as $attr => $options) { $this->ensureAttributes($attr, $options); if ($file = UploadedFile::getInstance($model, $attr)) { $model->{$attr} = $file; } } }
[ "public", "function", "beforeValidate", "(", ")", "{", "/* @var $model ActiveRecord */", "$", "model", "=", "$", "this", "->", "owner", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "options", ")", "{", "$", "this", "->", "ensureAttributes", "(", "$", "attr", ",", "$", "options", ")", ";", "if", "(", "$", "file", "=", "UploadedFile", "::", "getInstance", "(", "$", "model", ",", "$", "attr", ")", ")", "{", "$", "model", "->", "{", "$", "attr", "}", "=", "$", "file", ";", "}", "}", "}" ]
function for EVENT_BEFORE_VALIDATE
[ "function", "for", "EVENT_BEFORE_VALIDATE" ]
7993d091b2969cb8ac9ff95254dc311967bd90ce
https://github.com/maxmirazh33/yii2-uploadable-file/blob/7993d091b2969cb8ac9ff95254dc311967bd90ce/src/Behavior.php#L70-L80
24,170
maxmirazh33/yii2-uploadable-file
src/Behavior.php
Behavior.checkAttrExists
private function checkAttrExists($attribute) { foreach ($this->attributes as $attr => $options) { $this->ensureAttributes($attr, $options); if ($attr == $attribute) { return; } } throw new InvalidParamException(); }
php
private function checkAttrExists($attribute) { foreach ($this->attributes as $attr => $options) { $this->ensureAttributes($attr, $options); if ($attr == $attribute) { return; } } throw new InvalidParamException(); }
[ "private", "function", "checkAttrExists", "(", "$", "attribute", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "options", ")", "{", "$", "this", "->", "ensureAttributes", "(", "$", "attr", ",", "$", "options", ")", ";", "if", "(", "$", "attr", "==", "$", "attribute", ")", "{", "return", ";", "}", "}", "throw", "new", "InvalidParamException", "(", ")", ";", "}" ]
Check isset attribute or not @param string $attribute name of attribute @throws InvalidParamException
[ "Check", "isset", "attribute", "or", "not" ]
7993d091b2969cb8ac9ff95254dc311967bd90ce
https://github.com/maxmirazh33/yii2-uploadable-file/blob/7993d091b2969cb8ac9ff95254dc311967bd90ce/src/Behavior.php#L214-L223
24,171
ezsystems/ezcomments-ls-extension
classes/ezcomcomment.php
ezcomComment.definition
public static function definition() { static $def = array( 'fields' => array( 'id' => array( 'name' => 'ID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'language_id' => array( 'name' => 'LanguageID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'created' => array( 'name' => 'Created', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'modified' => array( 'name' => 'Modified', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'user_id' => array( 'name' => 'UserID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'session_key' => array( 'name' => 'SessionKey', 'datatype' => 'string', 'default' => '', 'required' => true ), 'ip' => array( 'name' => 'IPAddress', 'datatype' => 'string', 'default' => '', 'required' => true ), 'contentobject_id' => array( 'name' => 'ContentObjectID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'parent_comment_id' => array( 'name' => 'ParentCommentID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'name' => array( 'name' => 'Name', 'datatype' => 'string', 'default' => '', 'required' => true ), 'email' => array( 'name' => 'EMail', 'datatype' => 'string', 'default' => '', 'required' => true ), 'url' => array( 'name' => 'URL', 'datatype' => 'string', 'default' => '', 'required' => true ), 'text' => array( 'name' => 'Text', 'datatype' => 'string', 'default' => '', 'required' => true ), 'status' => array( 'name' => 'Status', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'title' => array( 'name' => 'Title', 'datatype' => 'string', 'default' => '', 'required' => true ) ), 'keys' => array( 'id' ), 'function_attributes' => array( 'contentobject' => 'contentObject' ), 'increment_key' => 'id', 'class_name' => 'ezcomComment', 'name' => 'ezcomment' ); return $def; }
php
public static function definition() { static $def = array( 'fields' => array( 'id' => array( 'name' => 'ID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'language_id' => array( 'name' => 'LanguageID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'created' => array( 'name' => 'Created', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'modified' => array( 'name' => 'Modified', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'user_id' => array( 'name' => 'UserID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'session_key' => array( 'name' => 'SessionKey', 'datatype' => 'string', 'default' => '', 'required' => true ), 'ip' => array( 'name' => 'IPAddress', 'datatype' => 'string', 'default' => '', 'required' => true ), 'contentobject_id' => array( 'name' => 'ContentObjectID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'parent_comment_id' => array( 'name' => 'ParentCommentID', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'name' => array( 'name' => 'Name', 'datatype' => 'string', 'default' => '', 'required' => true ), 'email' => array( 'name' => 'EMail', 'datatype' => 'string', 'default' => '', 'required' => true ), 'url' => array( 'name' => 'URL', 'datatype' => 'string', 'default' => '', 'required' => true ), 'text' => array( 'name' => 'Text', 'datatype' => 'string', 'default' => '', 'required' => true ), 'status' => array( 'name' => 'Status', 'datatype' => 'integer', 'default' => 0, 'required' => true ), 'title' => array( 'name' => 'Title', 'datatype' => 'string', 'default' => '', 'required' => true ) ), 'keys' => array( 'id' ), 'function_attributes' => array( 'contentobject' => 'contentObject' ), 'increment_key' => 'id', 'class_name' => 'ezcomComment', 'name' => 'ezcomment' ); return $def; }
[ "public", "static", "function", "definition", "(", ")", "{", "static", "$", "def", "=", "array", "(", "'fields'", "=>", "array", "(", "'id'", "=>", "array", "(", "'name'", "=>", "'ID'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'language_id'", "=>", "array", "(", "'name'", "=>", "'LanguageID'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'created'", "=>", "array", "(", "'name'", "=>", "'Created'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'modified'", "=>", "array", "(", "'name'", "=>", "'Modified'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'user_id'", "=>", "array", "(", "'name'", "=>", "'UserID'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'session_key'", "=>", "array", "(", "'name'", "=>", "'SessionKey'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'ip'", "=>", "array", "(", "'name'", "=>", "'IPAddress'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'contentobject_id'", "=>", "array", "(", "'name'", "=>", "'ContentObjectID'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'parent_comment_id'", "=>", "array", "(", "'name'", "=>", "'ParentCommentID'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'name'", "=>", "array", "(", "'name'", "=>", "'Name'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'email'", "=>", "array", "(", "'name'", "=>", "'EMail'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'url'", "=>", "array", "(", "'name'", "=>", "'URL'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'text'", "=>", "array", "(", "'name'", "=>", "'Text'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ",", "'status'", "=>", "array", "(", "'name'", "=>", "'Status'", ",", "'datatype'", "=>", "'integer'", ",", "'default'", "=>", "0", ",", "'required'", "=>", "true", ")", ",", "'title'", "=>", "array", "(", "'name'", "=>", "'Title'", ",", "'datatype'", "=>", "'string'", ",", "'default'", "=>", "''", ",", "'required'", "=>", "true", ")", ")", ",", "'keys'", "=>", "array", "(", "'id'", ")", ",", "'function_attributes'", "=>", "array", "(", "'contentobject'", "=>", "'contentObject'", ")", ",", "'increment_key'", "=>", "'id'", ",", "'class_name'", "=>", "'ezcomComment'", ",", "'name'", "=>", "'ezcomment'", ")", ";", "return", "$", "def", ";", "}" ]
Fields definition. @static @return array
[ "Fields", "definition", "." ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcomment.php#L32-L101
24,172
ezsystems/ezcomments-ls-extension
classes/ezcomcomment.php
ezcomComment.fetchByEmail
static function fetchByEmail( $email, $sorts = null, $offset = null, $length = null, $status = false ) { $cond = array(); $cond['email'] = $email; if ( $status !== false ) { $cond['status'] = $status; } $limit = null; if ( !is_null( $offset ) ) { $limit = array(); $limit = array( 'offset' => $offset, 'length' => $length ); } $return = eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); return $return; }
php
static function fetchByEmail( $email, $sorts = null, $offset = null, $length = null, $status = false ) { $cond = array(); $cond['email'] = $email; if ( $status !== false ) { $cond['status'] = $status; } $limit = null; if ( !is_null( $offset ) ) { $limit = array(); $limit = array( 'offset' => $offset, 'length' => $length ); } $return = eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); return $return; }
[ "static", "function", "fetchByEmail", "(", "$", "email", ",", "$", "sorts", "=", "null", ",", "$", "offset", "=", "null", ",", "$", "length", "=", "null", ",", "$", "status", "=", "false", ")", "{", "$", "cond", "=", "array", "(", ")", ";", "$", "cond", "[", "'email'", "]", "=", "$", "email", ";", "if", "(", "$", "status", "!==", "false", ")", "{", "$", "cond", "[", "'status'", "]", "=", "$", "status", ";", "}", "$", "limit", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "offset", ")", ")", "{", "$", "limit", "=", "array", "(", ")", ";", "$", "limit", "=", "array", "(", "'offset'", "=>", "$", "offset", ",", "'length'", "=>", "$", "length", ")", ";", "}", "$", "return", "=", "eZPersistentObject", "::", "fetchObjectList", "(", "self", "::", "definition", "(", ")", ",", "null", ",", "$", "cond", ",", "$", "sorts", ",", "$", "limit", ")", ";", "return", "$", "return", ";", "}" ]
fetch comment by email @param string $email email address @param array $sorts sort array @param integer $offset offset @param integer $length length @param integer $status status of comment @return ezcomComment|null
[ "fetch", "comment", "by", "email" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcomment.php#L150-L166
24,173
ezsystems/ezcomments-ls-extension
classes/ezcomcomment.php
ezcomComment.fetchByContentObjectID
static function fetchByContentObjectID( $contentObjectID, $languageID, $status = null, $sorts = null, $offset = null, $length = null ) { $cond = array(); $cond['contentobject_id'] = $contentObjectID; if ( $languageID !== false ) { $cond['language_id'] = $languageID; } if( !is_null( $status ) ) { $cond['status'] = $status; } if ( is_null( $offset ) || is_null( $length ) ) { return null; } else { $limit = array( 'offset' => $offset, 'length' => $length); $return = eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); return $return; } }
php
static function fetchByContentObjectID( $contentObjectID, $languageID, $status = null, $sorts = null, $offset = null, $length = null ) { $cond = array(); $cond['contentobject_id'] = $contentObjectID; if ( $languageID !== false ) { $cond['language_id'] = $languageID; } if( !is_null( $status ) ) { $cond['status'] = $status; } if ( is_null( $offset ) || is_null( $length ) ) { return null; } else { $limit = array( 'offset' => $offset, 'length' => $length); $return = eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); return $return; } }
[ "static", "function", "fetchByContentObjectID", "(", "$", "contentObjectID", ",", "$", "languageID", ",", "$", "status", "=", "null", ",", "$", "sorts", "=", "null", ",", "$", "offset", "=", "null", ",", "$", "length", "=", "null", ")", "{", "$", "cond", "=", "array", "(", ")", ";", "$", "cond", "[", "'contentobject_id'", "]", "=", "$", "contentObjectID", ";", "if", "(", "$", "languageID", "!==", "false", ")", "{", "$", "cond", "[", "'language_id'", "]", "=", "$", "languageID", ";", "}", "if", "(", "!", "is_null", "(", "$", "status", ")", ")", "{", "$", "cond", "[", "'status'", "]", "=", "$", "status", ";", "}", "if", "(", "is_null", "(", "$", "offset", ")", "||", "is_null", "(", "$", "length", ")", ")", "{", "return", "null", ";", "}", "else", "{", "$", "limit", "=", "array", "(", "'offset'", "=>", "$", "offset", ",", "'length'", "=>", "$", "length", ")", ";", "$", "return", "=", "eZPersistentObject", "::", "fetchObjectList", "(", "self", "::", "definition", "(", ")", ",", "null", ",", "$", "cond", ",", "$", "sorts", ",", "$", "limit", ")", ";", "return", "$", "return", ";", "}", "}" ]
fetch comment list by contentobject id @param string $contentObjectID @param string $languageID @param integer $status @param array $sorts @param integer $offset @param integer $length @return array comment list
[ "fetch", "comment", "list", "by", "contentobject", "id" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcomment.php#L178-L200
24,174
ezsystems/ezcomments-ls-extension
classes/ezcomcomment.php
ezcomComment.countByContent
static function countByContent( $contentObjectID = false, $languageID = false, $status = null ) { $cond = array(); if ( $contentObjectID !== false ) { $cond['contentobject_id'] = $contentObjectID; } if ( $languageID !== false ) { $cond['language_id'] = $languageID; } if ( !is_null( $status ) ) { $cond['status'] = $status; } return eZPersistentObject::count( self::definition(), $cond ); }
php
static function countByContent( $contentObjectID = false, $languageID = false, $status = null ) { $cond = array(); if ( $contentObjectID !== false ) { $cond['contentobject_id'] = $contentObjectID; } if ( $languageID !== false ) { $cond['language_id'] = $languageID; } if ( !is_null( $status ) ) { $cond['status'] = $status; } return eZPersistentObject::count( self::definition(), $cond ); }
[ "static", "function", "countByContent", "(", "$", "contentObjectID", "=", "false", ",", "$", "languageID", "=", "false", ",", "$", "status", "=", "null", ")", "{", "$", "cond", "=", "array", "(", ")", ";", "if", "(", "$", "contentObjectID", "!==", "false", ")", "{", "$", "cond", "[", "'contentobject_id'", "]", "=", "$", "contentObjectID", ";", "}", "if", "(", "$", "languageID", "!==", "false", ")", "{", "$", "cond", "[", "'language_id'", "]", "=", "$", "languageID", ";", "}", "if", "(", "!", "is_null", "(", "$", "status", ")", ")", "{", "$", "cond", "[", "'status'", "]", "=", "$", "status", ";", "}", "return", "eZPersistentObject", "::", "count", "(", "self", "::", "definition", "(", ")", ",", "$", "cond", ")", ";", "}" ]
Count the comments by content object id @param integer $contentObjectID @param integer $languageID @param integer $status @return count of comments
[ "Count", "the", "comments", "by", "content", "object", "id" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcomment.php#L268-L284
24,175
ezsystems/ezcomments-ls-extension
classes/ezcomcomment.php
ezcomComment.countContentObjectByEmail
static function countContentObjectByEmail( $email, $status = false ) { $statusString = ""; if ( $status !== false ) { $statusString = " AND status = $status"; } $sql = "SELECT COUNT(*) as row_count FROM " . "( SELECT DISTINCT contentobject_id, language_id ". " FROM ezcomment " . " WHERE email='$email'" . "$statusString" . ") as contentobject"; $db = eZDB::instance(); $result = $db->arrayQuery( $sql ); return $result[0]['row_count']; }
php
static function countContentObjectByEmail( $email, $status = false ) { $statusString = ""; if ( $status !== false ) { $statusString = " AND status = $status"; } $sql = "SELECT COUNT(*) as row_count FROM " . "( SELECT DISTINCT contentobject_id, language_id ". " FROM ezcomment " . " WHERE email='$email'" . "$statusString" . ") as contentobject"; $db = eZDB::instance(); $result = $db->arrayQuery( $sql ); return $result[0]['row_count']; }
[ "static", "function", "countContentObjectByEmail", "(", "$", "email", ",", "$", "status", "=", "false", ")", "{", "$", "statusString", "=", "\"\"", ";", "if", "(", "$", "status", "!==", "false", ")", "{", "$", "statusString", "=", "\" AND status = $status\"", ";", "}", "$", "sql", "=", "\"SELECT COUNT(*) as row_count FROM \"", ".", "\"( SELECT DISTINCT contentobject_id, language_id \"", ".", "\" FROM ezcomment \"", ".", "\" WHERE email='$email'\"", ".", "\"$statusString\"", ".", "\") as contentobject\"", ";", "$", "db", "=", "eZDB", "::", "instance", "(", ")", ";", "$", "result", "=", "$", "db", "->", "arrayQuery", "(", "$", "sql", ")", ";", "return", "$", "result", "[", "0", "]", "[", "'row_count'", "]", ";", "}" ]
Fetch the count of contentobject the user commented on @param $email user's email @param $status status of comment @return count of contentobject with id.
[ "Fetch", "the", "count", "of", "contentobject", "the", "user", "commented", "on" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcomment.php#L292-L308
24,176
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.forks
public static function forks($number, callable $childHandler = null) { $num = (int)$number > 0 ? (int)$number : 0; if ($num <= 0) { return false; } $pidAry = []; for ($id = 0; $id < $num; $id++) { $child = self::fork($id, $childHandler); $pidAry[$child['pid']] = $child; } return $pidAry; }
php
public static function forks($number, callable $childHandler = null) { $num = (int)$number > 0 ? (int)$number : 0; if ($num <= 0) { return false; } $pidAry = []; for ($id = 0; $id < $num; $id++) { $child = self::fork($id, $childHandler); $pidAry[$child['pid']] = $child; } return $pidAry; }
[ "public", "static", "function", "forks", "(", "$", "number", ",", "callable", "$", "childHandler", "=", "null", ")", "{", "$", "num", "=", "(", "int", ")", "$", "number", ">", "0", "?", "(", "int", ")", "$", "number", ":", "0", ";", "if", "(", "$", "num", "<=", "0", ")", "{", "return", "false", ";", "}", "$", "pidAry", "=", "[", "]", ";", "for", "(", "$", "id", "=", "0", ";", "$", "id", "<", "$", "num", ";", "$", "id", "++", ")", "{", "$", "child", "=", "self", "::", "fork", "(", "$", "id", ",", "$", "childHandler", ")", ";", "$", "pidAry", "[", "$", "child", "[", "'pid'", "]", "]", "=", "$", "child", ";", "}", "return", "$", "pidAry", ";", "}" ]
fork multi child processes. @param int $number @param callable|null $childHandler @return array|int
[ "fork", "multi", "child", "processes", "." ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L60-L76
24,177
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.fork
public static function fork($id = 0, callable $childHandler = null) { $info = []; $pid = pcntl_fork(); if ($pid > 0) {// at parent, get forked child info $info = [ 'id' => $id, 'pid' => $pid, 'startTime' => time(), ]; } elseif ($pid === 0) { // at child $pid = getmypid(); if ($childHandler) { $childHandler($id, $pid); } } else { Cli::stderr("Fork child process failed! exiting.\n"); } return $info; }
php
public static function fork($id = 0, callable $childHandler = null) { $info = []; $pid = pcntl_fork(); if ($pid > 0) {// at parent, get forked child info $info = [ 'id' => $id, 'pid' => $pid, 'startTime' => time(), ]; } elseif ($pid === 0) { // at child $pid = getmypid(); if ($childHandler) { $childHandler($id, $pid); } } else { Cli::stderr("Fork child process failed! exiting.\n"); } return $info; }
[ "public", "static", "function", "fork", "(", "$", "id", "=", "0", ",", "callable", "$", "childHandler", "=", "null", ")", "{", "$", "info", "=", "[", "]", ";", "$", "pid", "=", "pcntl_fork", "(", ")", ";", "if", "(", "$", "pid", ">", "0", ")", "{", "// at parent, get forked child info", "$", "info", "=", "[", "'id'", "=>", "$", "id", ",", "'pid'", "=>", "$", "pid", ",", "'startTime'", "=>", "time", "(", ")", ",", "]", ";", "}", "elseif", "(", "$", "pid", "===", "0", ")", "{", "// at child", "$", "pid", "=", "getmypid", "(", ")", ";", "if", "(", "$", "childHandler", ")", "{", "$", "childHandler", "(", "$", "id", ",", "$", "pid", ")", ";", "}", "}", "else", "{", "Cli", "::", "stderr", "(", "\"Fork child process failed! exiting.\\n\"", ")", ";", "}", "return", "$", "info", ";", "}" ]
fork a child process. @param int $id @param callable|null $childHandler param bool $first @return array
[ "fork", "a", "child", "process", "." ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L85-L108
24,178
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.kill
public static function kill($pid, $force = false, $timeout = 3) { return self::sendSignal($pid, $force ? SIGKILL : SIGTERM, $timeout); }
php
public static function kill($pid, $force = false, $timeout = 3) { return self::sendSignal($pid, $force ? SIGKILL : SIGTERM, $timeout); }
[ "public", "static", "function", "kill", "(", "$", "pid", ",", "$", "force", "=", "false", ",", "$", "timeout", "=", "3", ")", "{", "return", "self", "::", "sendSignal", "(", "$", "pid", ",", "$", "force", "?", "SIGKILL", ":", "SIGTERM", ",", "$", "timeout", ")", ";", "}" ]
send kill signal to the process @param int $pid @param bool $force @param int $timeout @return bool
[ "send", "kill", "signal", "to", "the", "process" ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L198-L201
24,179
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.changeScriptOwner
public static function changeScriptOwner($user, $group = '') { $uInfo = posix_getpwnam($user); if (!$uInfo || !isset($uInfo['uid'])) { throw new \RuntimeException("User ({$user}) not found."); } $uid = (int)$uInfo['uid']; // Get gid. if ($group) { if (!$gInfo = posix_getgrnam($group)) { throw new \RuntimeException("Group {$group} not exists", -300); } $gid = (int)$gInfo['gid']; } else { $gid = (int)$uInfo['gid']; } if (!posix_initgroups($uInfo['name'], $gid)) { throw new \RuntimeException("The user [{$user}] is not in the user group ID [GID:{$gid}]", -300); } posix_setgid($gid); if (posix_geteuid() !== $gid) { throw new \RuntimeException("Unable to change group to {$user} (UID: {$gid}).", -300); } posix_setuid($uid); if (posix_geteuid() !== $uid) { throw new \RuntimeException("Unable to change user to {$user} (UID: {$uid}).", -300); } }
php
public static function changeScriptOwner($user, $group = '') { $uInfo = posix_getpwnam($user); if (!$uInfo || !isset($uInfo['uid'])) { throw new \RuntimeException("User ({$user}) not found."); } $uid = (int)$uInfo['uid']; // Get gid. if ($group) { if (!$gInfo = posix_getgrnam($group)) { throw new \RuntimeException("Group {$group} not exists", -300); } $gid = (int)$gInfo['gid']; } else { $gid = (int)$uInfo['gid']; } if (!posix_initgroups($uInfo['name'], $gid)) { throw new \RuntimeException("The user [{$user}] is not in the user group ID [GID:{$gid}]", -300); } posix_setgid($gid); if (posix_geteuid() !== $gid) { throw new \RuntimeException("Unable to change group to {$user} (UID: {$gid}).", -300); } posix_setuid($uid); if (posix_geteuid() !== $uid) { throw new \RuntimeException("Unable to change user to {$user} (UID: {$uid}).", -300); } }
[ "public", "static", "function", "changeScriptOwner", "(", "$", "user", ",", "$", "group", "=", "''", ")", "{", "$", "uInfo", "=", "posix_getpwnam", "(", "$", "user", ")", ";", "if", "(", "!", "$", "uInfo", "||", "!", "isset", "(", "$", "uInfo", "[", "'uid'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"User ({$user}) not found.\"", ")", ";", "}", "$", "uid", "=", "(", "int", ")", "$", "uInfo", "[", "'uid'", "]", ";", "// Get gid.", "if", "(", "$", "group", ")", "{", "if", "(", "!", "$", "gInfo", "=", "posix_getgrnam", "(", "$", "group", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Group {$group} not exists\"", ",", "-", "300", ")", ";", "}", "$", "gid", "=", "(", "int", ")", "$", "gInfo", "[", "'gid'", "]", ";", "}", "else", "{", "$", "gid", "=", "(", "int", ")", "$", "uInfo", "[", "'gid'", "]", ";", "}", "if", "(", "!", "posix_initgroups", "(", "$", "uInfo", "[", "'name'", "]", ",", "$", "gid", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"The user [{$user}] is not in the user group ID [GID:{$gid}]\"", ",", "-", "300", ")", ";", "}", "posix_setgid", "(", "$", "gid", ")", ";", "if", "(", "posix_geteuid", "(", ")", "!==", "$", "gid", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Unable to change group to {$user} (UID: {$gid}).\"", ",", "-", "300", ")", ";", "}", "posix_setuid", "(", "$", "uid", ")", ";", "if", "(", "posix_geteuid", "(", ")", "!==", "$", "uid", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Unable to change user to {$user} (UID: {$uid}).\"", ",", "-", "300", ")", ";", "}", "}" ]
Set unix user and group for current process script. @param string $user @param string $group @throws \RuntimeException
[ "Set", "unix", "user", "and", "group", "for", "current", "process", "script", "." ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L421-L457
24,180
inhere/php-librarys
src/Helpers/ProcessHelper.php
ProcessHelper.getPidFromFile
public static function getPidFromFile($pidFile, $check = false) { if ($pidFile && file_exists($pidFile)) { $pid = (int)file_get_contents($pidFile); // check if ($check && self::isRunning($pid)) { return $pid; } unlink($pidFile); } return 0; }
php
public static function getPidFromFile($pidFile, $check = false) { if ($pidFile && file_exists($pidFile)) { $pid = (int)file_get_contents($pidFile); // check if ($check && self::isRunning($pid)) { return $pid; } unlink($pidFile); } return 0; }
[ "public", "static", "function", "getPidFromFile", "(", "$", "pidFile", ",", "$", "check", "=", "false", ")", "{", "if", "(", "$", "pidFile", "&&", "file_exists", "(", "$", "pidFile", ")", ")", "{", "$", "pid", "=", "(", "int", ")", "file_get_contents", "(", "$", "pidFile", ")", ";", "// check", "if", "(", "$", "check", "&&", "self", "::", "isRunning", "(", "$", "pid", ")", ")", "{", "return", "$", "pid", ";", "}", "unlink", "(", "$", "pidFile", ")", ";", "}", "return", "0", ";", "}" ]
get Pid from File @param string $pidFile @param bool $check @return int
[ "get", "Pid", "from", "File" ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/ProcessHelper.php#L482-L496
24,181
mslib/resource-proxy
Msl/ResourceProxy/Source/Pop.php
Pop.toString
public function toString() { return sprintf( 'Pop Source Object [host:\'%s\'][port:\'%s\'][user:\'%s\']', $this->sourceConfig->getHost(), $this->sourceConfig->getPort(), $this->sourceConfig->getUsername() ); }
php
public function toString() { return sprintf( 'Pop Source Object [host:\'%s\'][port:\'%s\'][user:\'%s\']', $this->sourceConfig->getHost(), $this->sourceConfig->getPort(), $this->sourceConfig->getUsername() ); }
[ "public", "function", "toString", "(", ")", "{", "return", "sprintf", "(", "'Pop Source Object [host:\\'%s\\'][port:\\'%s\\'][user:\\'%s\\']'", ",", "$", "this", "->", "sourceConfig", "->", "getHost", "(", ")", ",", "$", "this", "->", "sourceConfig", "->", "getPort", "(", ")", ",", "$", "this", "->", "sourceConfig", "->", "getUsername", "(", ")", ")", ";", "}" ]
Returns a string representation for the source object @return string
[ "Returns", "a", "string", "representation", "for", "the", "source", "object" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Pop.php#L76-L84
24,182
hametuha/wpametu
src/WPametu/API/Ajax/AjaxForm.php
AjaxForm.form
public static function form($slug, $name = '', array $attributes = []){ $class_name = get_called_class(); /** @var AjaxBaseForm $instance */ $instance = $class_name::get_instance(); $instance->form_open($attributes); $args = $instance->form_arguments(); $instance->load_template($slug, $name, $args); $instance->form_close(); }
php
public static function form($slug, $name = '', array $attributes = []){ $class_name = get_called_class(); /** @var AjaxBaseForm $instance */ $instance = $class_name::get_instance(); $instance->form_open($attributes); $args = $instance->form_arguments(); $instance->load_template($slug, $name, $args); $instance->form_close(); }
[ "public", "static", "function", "form", "(", "$", "slug", ",", "$", "name", "=", "''", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "class_name", "=", "get_called_class", "(", ")", ";", "/** @var AjaxBaseForm $instance */", "$", "instance", "=", "$", "class_name", "::", "get_instance", "(", ")", ";", "$", "instance", "->", "form_open", "(", "$", "attributes", ")", ";", "$", "args", "=", "$", "instance", "->", "form_arguments", "(", ")", ";", "$", "instance", "->", "load_template", "(", "$", "slug", ",", "$", "name", ",", "$", "args", ")", ";", "$", "instance", "->", "form_close", "(", ")", ";", "}" ]
Display form control @param string $slug @param string $name @param array $attributes
[ "Display", "form", "control" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Ajax/AjaxForm.php#L62-L70
24,183
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeMethod
public function encodeMethod($method, $params) { $string = $this->encoder->encodeMethod($method, $params); return $this->encrypt($string); }
php
public function encodeMethod($method, $params) { $string = $this->encoder->encodeMethod($method, $params); return $this->encrypt($string); }
[ "public", "function", "encodeMethod", "(", "$", "method", ",", "$", "params", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeMethod", "(", "$", "method", ",", "$", "params", ")", ";", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}" ]
Encode a method call. @param $mixed @return string
[ "Encode", "a", "method", "call", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L55-L60
24,184
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeException
public function encodeException(\Exception $exception) { $string = $this->encoder->encodeException($exception); try { return $this->encrypt($string); } catch (\Exception $e) { if ($this->plainExceptions) { return $string; } throw $e; } }
php
public function encodeException(\Exception $exception) { $string = $this->encoder->encodeException($exception); try { return $this->encrypt($string); } catch (\Exception $e) { if ($this->plainExceptions) { return $string; } throw $e; } }
[ "public", "function", "encodeException", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeException", "(", "$", "exception", ")", ";", "try", "{", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "plainExceptions", ")", "{", "return", "$", "string", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Encode an exception. @param \Exception $exception @return string
[ "Encode", "an", "exception", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L69-L82
24,185
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.encodeResult
public function encodeResult($result) { $string = $this->encoder->encodeResult($result); return $this->encrypt($string); }
php
public function encodeResult($result) { $string = $this->encoder->encodeResult($result); return $this->encrypt($string); }
[ "public", "function", "encodeResult", "(", "$", "result", ")", "{", "$", "string", "=", "$", "this", "->", "encoder", "->", "encodeResult", "(", "$", "result", ")", ";", "return", "$", "this", "->", "encrypt", "(", "$", "string", ")", ";", "}" ]
Encode a result from the method call. @param mixed $result @return string
[ "Encode", "a", "result", "from", "the", "method", "call", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L91-L96
24,186
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.decodeMethod
public function decodeMethod($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeMethod($string); }
php
public function decodeMethod($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeMethod($string); }
[ "public", "function", "decodeMethod", "(", "$", "crypt", ")", "{", "$", "string", "=", "$", "this", "->", "decrypt", "(", "$", "crypt", ")", ";", "return", "$", "this", "->", "encoder", "->", "decodeMethod", "(", "$", "string", ")", ";", "}" ]
Decode an encoded method. @param $string @return array An array with 2 elements: [<method name>, <method params>] @throws Throw an exception, if $string is an error or contains an error.
[ "Decode", "an", "encoded", "method", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L107-L112
24,187
bit3archive/php-remote-objects
src/RemoteObjects/Encode/CryptEncoder.php
CryptEncoder.decodeResult
public function decodeResult($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeResult($string); }
php
public function decodeResult($crypt) { $string = $this->decrypt($crypt); return $this->encoder->decodeResult($string); }
[ "public", "function", "decodeResult", "(", "$", "crypt", ")", "{", "$", "string", "=", "$", "this", "->", "decrypt", "(", "$", "crypt", ")", ";", "return", "$", "this", "->", "encoder", "->", "decodeResult", "(", "$", "string", ")", ";", "}" ]
Decode an encoded result. @param $string @return mixed @throws Throw an exception, if $string is an error or contains an error.
[ "Decode", "an", "encoded", "result", "." ]
0a917cdb261d83b1e89bdbdce3627584823bff5f
https://github.com/bit3archive/php-remote-objects/blob/0a917cdb261d83b1e89bdbdce3627584823bff5f/src/RemoteObjects/Encode/CryptEncoder.php#L123-L128
24,188
ekuiter/feature-php
FeaturePhp/File/ChunkFile.php
ChunkFile.getContent
public function getContent() { return new TextFileContent( $this->content . ($this->footer === "" ? "" : $this->footer . $this->newline)); }
php
public function getContent() { return new TextFileContent( $this->content . ($this->footer === "" ? "" : $this->footer . $this->newline)); }
[ "public", "function", "getContent", "(", ")", "{", "return", "new", "TextFileContent", "(", "$", "this", "->", "content", ".", "(", "$", "this", "->", "footer", "===", "\"\"", "?", "\"\"", ":", "$", "this", "->", "footer", ".", "$", "this", "->", "newline", ")", ")", ";", "}" ]
Returns the chunked file's content. The content consists of the header, then every chunk and then the footer. @return TextFileContent
[ "Returns", "the", "chunked", "file", "s", "content", ".", "The", "content", "consists", "of", "the", "header", "then", "every", "chunk", "and", "then", "the", "footer", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/ChunkFile.php#L78-L81
24,189
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.getImageConvertExecutable
public static function getImageConvertExecutable() { if ( !is_null( self::$imageConvert ) ) { return self::$imageConvert; } return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) ); }
php
public static function getImageConvertExecutable() { if ( !is_null( self::$imageConvert ) ) { return self::$imageConvert; } return ( self::$imageConvert = self::findExecutableInPath( 'convert' ) ); }
[ "public", "static", "function", "getImageConvertExecutable", "(", ")", "{", "if", "(", "!", "is_null", "(", "self", "::", "$", "imageConvert", ")", ")", "{", "return", "self", "::", "$", "imageConvert", ";", "}", "return", "(", "self", "::", "$", "imageConvert", "=", "self", "::", "findExecutableInPath", "(", "'convert'", ")", ")", ";", "}" ]
Returns the path to the ImageMagick convert utility. On Linux, Unix,... it will return something like: /usr/bin/convert On Windows it will return something like: C:\Windows\System32\convert.exe @return string
[ "Returns", "the", "path", "to", "the", "ImageMagick", "convert", "utility", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L109-L116
24,190
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.getImageIdentifyExecutable
public static function getImageIdentifyExecutable() { if ( !is_null( self::$imageIdentify ) ) { return self::$imageIdentify; } return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) ); }
php
public static function getImageIdentifyExecutable() { if ( !is_null( self::$imageIdentify ) ) { return self::$imageIdentify; } return ( self::$imageIdentify = self::findExecutableInPath( 'identify' ) ); }
[ "public", "static", "function", "getImageIdentifyExecutable", "(", ")", "{", "if", "(", "!", "is_null", "(", "self", "::", "$", "imageIdentify", ")", ")", "{", "return", "self", "::", "$", "imageIdentify", ";", "}", "return", "(", "self", "::", "$", "imageIdentify", "=", "self", "::", "findExecutableInPath", "(", "'identify'", ")", ")", ";", "}" ]
Returns the path to the ImageMagick identify utility. On Linux, Unix,... it will return something like: /usr/bin/identify On Windows it will return something like: C:\Windows\System32\identify.exe @return string
[ "Returns", "the", "path", "to", "the", "ImageMagick", "identify", "utility", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L136-L143
24,191
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.hasExtensionSupport
public static function hasExtensionSupport( $extension, $version = null ) { if ( is_null( $version ) ) { return extension_loaded( $extension ); } return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ; }
php
public static function hasExtensionSupport( $extension, $version = null ) { if ( is_null( $version ) ) { return extension_loaded( $extension ); } return extension_loaded( $extension ) && version_compare( phpversion( $extension ), $version, ">=" ) ; }
[ "public", "static", "function", "hasExtensionSupport", "(", "$", "extension", ",", "$", "version", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "version", ")", ")", "{", "return", "extension_loaded", "(", "$", "extension", ")", ";", "}", "return", "extension_loaded", "(", "$", "extension", ")", "&&", "version_compare", "(", "phpversion", "(", "$", "extension", ")", ",", "$", "version", ",", "\">=\"", ")", ";", "}" ]
Determines if the specified extension is loaded. If $version is specified, the specified extension will be tested also against the version of the loaded extension. Examples: <code> hasExtensionSupport( 'gzip' ); </code> will return true if gzip extension is loaded. <code> hasExtensionSupport( 'pdo_mysql', '1.0.2' ); </code> will return true if pdo_mysql extension is loaded and its version is at least 1.0.2. @param string $extension @param string $version @return bool
[ "Determines", "if", "the", "specified", "extension", "is", "loaded", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L166-L173
24,192
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.classExists
public static function classExists( $className, $autoload = true ) { try { if ( class_exists( $className, $autoload ) ) { return true; } return false; } catch ( ezcBaseAutoloadException $e ) { return false; } }
php
public static function classExists( $className, $autoload = true ) { try { if ( class_exists( $className, $autoload ) ) { return true; } return false; } catch ( ezcBaseAutoloadException $e ) { return false; } }
[ "public", "static", "function", "classExists", "(", "$", "className", ",", "$", "autoload", "=", "true", ")", "{", "try", "{", "if", "(", "class_exists", "(", "$", "className", ",", "$", "autoload", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "catch", "(", "ezcBaseAutoloadException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Returns if a given class exists. Checks for a given class name and returns if this class exists or not. Catches the ezcBaseAutoloadException and returns false, if it was thrown. @param string $className The class to check for. @param bool $autoload True to use __autoload(), otherwise false. @return bool True if the class exists. Otherwise false.
[ "Returns", "if", "a", "given", "class", "exists", ".", "Checks", "for", "a", "given", "class", "name", "and", "returns", "if", "this", "class", "exists", "or", "not", ".", "Catches", "the", "ezcBaseAutoloadException", "and", "returns", "false", "if", "it", "was", "thrown", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L202-L216
24,193
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.os
public static function os() { if ( is_null( self::$os ) ) { $uname = php_uname( 's' ); if ( substr( $uname, 0, 7 ) == 'Windows' ) { self::$os = 'Windows'; } elseif ( substr( $uname, 0, 3 ) == 'Mac' ) { self::$os = 'Mac'; } elseif ( strtolower( $uname ) == 'linux' ) { self::$os = 'Linux'; } elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' ) { self::$os = 'FreeBSD'; } else { self::$os = PHP_OS; } } return self::$os; }
php
public static function os() { if ( is_null( self::$os ) ) { $uname = php_uname( 's' ); if ( substr( $uname, 0, 7 ) == 'Windows' ) { self::$os = 'Windows'; } elseif ( substr( $uname, 0, 3 ) == 'Mac' ) { self::$os = 'Mac'; } elseif ( strtolower( $uname ) == 'linux' ) { self::$os = 'Linux'; } elseif ( strtolower( substr( $uname, 0, 7 ) ) == 'freebsd' ) { self::$os = 'FreeBSD'; } else { self::$os = PHP_OS; } } return self::$os; }
[ "public", "static", "function", "os", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "os", ")", ")", "{", "$", "uname", "=", "php_uname", "(", "'s'", ")", ";", "if", "(", "substr", "(", "$", "uname", ",", "0", ",", "7", ")", "==", "'Windows'", ")", "{", "self", "::", "$", "os", "=", "'Windows'", ";", "}", "elseif", "(", "substr", "(", "$", "uname", ",", "0", ",", "3", ")", "==", "'Mac'", ")", "{", "self", "::", "$", "os", "=", "'Mac'", ";", "}", "elseif", "(", "strtolower", "(", "$", "uname", ")", "==", "'linux'", ")", "{", "self", "::", "$", "os", "=", "'Linux'", ";", "}", "elseif", "(", "strtolower", "(", "substr", "(", "$", "uname", ",", "0", ",", "7", ")", ")", "==", "'freebsd'", ")", "{", "self", "::", "$", "os", "=", "'FreeBSD'", ";", "}", "else", "{", "self", "::", "$", "os", "=", "PHP_OS", ";", "}", "}", "return", "self", "::", "$", "os", ";", "}" ]
Returns the operating system on which PHP is running. This method returns a sanitized form of the OS name, example return values are "Windows", "Mac", "Linux" and "FreeBSD". In all other cases it returns the value of the internal PHP constant PHP_OS. @return string
[ "Returns", "the", "operating", "system", "on", "which", "PHP", "is", "running", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L228-L255
24,194
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.findExecutableInPath
public static function findExecutableInPath( $fileName ) { if ( array_key_exists( 'PATH', $_ENV ) ) { $envPath = trim( $_ENV['PATH'] ); } else if ( ( $envPath = getenv( 'PATH' ) ) !== false ) { $envPath = trim( $envPath ); } if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 ) { $envPath = false; } switch ( self::os() ) { case 'Unix': case 'FreeBSD': case 'Mac': case 'MacOS': case 'Darwin': case 'Linux': case 'SunOS': if ( $envPath ) { $dirs = explode( ':', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( file_exists( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "./{$fileName}" ) ) { return $fileName; } break; case 'Windows': if ( $envPath ) { $dirs = explode( ';', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( @file_exists( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "{$fileName}.exe" ) ) { return "{$fileName}.exe"; } break; } return null; }
php
public static function findExecutableInPath( $fileName ) { if ( array_key_exists( 'PATH', $_ENV ) ) { $envPath = trim( $_ENV['PATH'] ); } else if ( ( $envPath = getenv( 'PATH' ) ) !== false ) { $envPath = trim( $envPath ); } if ( is_string( $envPath ) && strlen( trim( $envPath ) ) == 0 ) { $envPath = false; } switch ( self::os() ) { case 'Unix': case 'FreeBSD': case 'Mac': case 'MacOS': case 'Darwin': case 'Linux': case 'SunOS': if ( $envPath ) { $dirs = explode( ':', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( file_exists( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "./{$fileName}" ) ) { return $fileName; } break; case 'Windows': if ( $envPath ) { $dirs = explode( ';', $envPath ); foreach ( $dirs as $dir ) { // The @-operator is used here mainly to avoid // open_basedir warnings. If open_basedir (or any other // circumstance) prevents the desired file from being // accessed, it is fine for file_exists() to return // false, since it is useless for use then, anyway. if ( @file_exists( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe"; } } } // The @-operator is used here mainly to avoid open_basedir // warnings. If open_basedir (or any other circumstance) // prevents the desired file from being accessed, it is fine // for file_exists() to return false, since it is useless for // use then, anyway. elseif ( @file_exists( "{$fileName}.exe" ) ) { return "{$fileName}.exe"; } break; } return null; }
[ "public", "static", "function", "findExecutableInPath", "(", "$", "fileName", ")", "{", "if", "(", "array_key_exists", "(", "'PATH'", ",", "$", "_ENV", ")", ")", "{", "$", "envPath", "=", "trim", "(", "$", "_ENV", "[", "'PATH'", "]", ")", ";", "}", "else", "if", "(", "(", "$", "envPath", "=", "getenv", "(", "'PATH'", ")", ")", "!==", "false", ")", "{", "$", "envPath", "=", "trim", "(", "$", "envPath", ")", ";", "}", "if", "(", "is_string", "(", "$", "envPath", ")", "&&", "strlen", "(", "trim", "(", "$", "envPath", ")", ")", "==", "0", ")", "{", "$", "envPath", "=", "false", ";", "}", "switch", "(", "self", "::", "os", "(", ")", ")", "{", "case", "'Unix'", ":", "case", "'FreeBSD'", ":", "case", "'Mac'", ":", "case", "'MacOS'", ":", "case", "'Darwin'", ":", "case", "'Linux'", ":", "case", "'SunOS'", ":", "if", "(", "$", "envPath", ")", "{", "$", "dirs", "=", "explode", "(", "':'", ",", "$", "envPath", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "// The @-operator is used here mainly to avoid", "// open_basedir warnings. If open_basedir (or any other", "// circumstance) prevents the desired file from being", "// accessed, it is fine for file_exists() to return", "// false, since it is useless for use then, anyway.", "if", "(", "file_exists", "(", "\"{$dir}/{$fileName}\"", ")", ")", "{", "return", "\"{$dir}/{$fileName}\"", ";", "}", "}", "}", "// The @-operator is used here mainly to avoid open_basedir", "// warnings. If open_basedir (or any other circumstance)", "// prevents the desired file from being accessed, it is fine", "// for file_exists() to return false, since it is useless for", "// use then, anyway.", "elseif", "(", "@", "file_exists", "(", "\"./{$fileName}\"", ")", ")", "{", "return", "$", "fileName", ";", "}", "break", ";", "case", "'Windows'", ":", "if", "(", "$", "envPath", ")", "{", "$", "dirs", "=", "explode", "(", "';'", ",", "$", "envPath", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "// The @-operator is used here mainly to avoid", "// open_basedir warnings. If open_basedir (or any other", "// circumstance) prevents the desired file from being", "// accessed, it is fine for file_exists() to return", "// false, since it is useless for use then, anyway.", "if", "(", "@", "file_exists", "(", "\"{$dir}\\\\{$fileName}.exe\"", ")", ")", "{", "return", "\"{$dir}\\\\{$fileName}.exe\"", ";", "}", "}", "}", "// The @-operator is used here mainly to avoid open_basedir", "// warnings. If open_basedir (or any other circumstance)", "// prevents the desired file from being accessed, it is fine", "// for file_exists() to return false, since it is useless for", "// use then, anyway.", "elseif", "(", "@", "file_exists", "(", "\"{$fileName}.exe\"", ")", ")", "{", "return", "\"{$fileName}.exe\"", ";", "}", "break", ";", "}", "return", "null", ";", "}" ]
Returns the path of the specified executable, if it can be found in the system's path. It scans the PATH enviroment variable based on the OS to find the $fileName. For Windows, the path is with \, not /. If $fileName is not found, it returns null. @todo consider using getenv( 'PATH' ) instead of $_ENV['PATH'] (but that won't work under IIS) @param string $fileName @return string
[ "Returns", "the", "path", "of", "the", "specified", "executable", "if", "it", "can", "be", "found", "in", "the", "system", "s", "path", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L270-L349
24,195
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php
ezcBaseFeatures.reset
public static function reset() { self::$imageIdentify = null; self::$imageConvert = null; self::$os = null; }
php
public static function reset() { self::$imageIdentify = null; self::$imageConvert = null; self::$os = null; }
[ "public", "static", "function", "reset", "(", ")", "{", "self", "::", "$", "imageIdentify", "=", "null", ";", "self", "::", "$", "imageConvert", "=", "null", ";", "self", "::", "$", "os", "=", "null", ";", "}" ]
Reset the cached information. @return void @access private @ignore
[ "Reset", "the", "cached", "information", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/features.php#L358-L363
24,196
kenphp/ken
src/Log/Targets/FileTarget.php
FileTarget.writeLog
private function writeLog($log) { $fh = fopen($this->_filepath, 'a'); fwrite($fh, $log); fclose($fh); }
php
private function writeLog($log) { $fh = fopen($this->_filepath, 'a'); fwrite($fh, $log); fclose($fh); }
[ "private", "function", "writeLog", "(", "$", "log", ")", "{", "$", "fh", "=", "fopen", "(", "$", "this", "->", "_filepath", ",", "'a'", ")", ";", "fwrite", "(", "$", "fh", ",", "$", "log", ")", ";", "fclose", "(", "$", "fh", ")", ";", "}" ]
Writes log to media. @param string $log
[ "Writes", "log", "to", "media", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/Targets/FileTarget.php#L70-L76
24,197
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Aspect/PublishingAspect.php
PublishingAspect.publishEventAdvice
public function publishEventAdvice(JoinPointInterface $joinPoint) { $event = array_values($joinPoint->getMethodArguments())[0]; $this->broker->queueEvent($event); }
php
public function publishEventAdvice(JoinPointInterface $joinPoint) { $event = array_values($joinPoint->getMethodArguments())[0]; $this->broker->queueEvent($event); }
[ "public", "function", "publishEventAdvice", "(", "JoinPointInterface", "$", "joinPoint", ")", "{", "$", "event", "=", "array_values", "(", "$", "joinPoint", "->", "getMethodArguments", "(", ")", ")", "[", "0", "]", ";", "$", "this", "->", "broker", "->", "queueEvent", "(", "$", "event", ")", ";", "}" ]
Publishes an event as soon as a method with an event annotation is called. @param JoinPointInterface $joinPoint The join point. @return void @Flow\After("methodAnnotatedWith(Helmich\EventBroker\Annotations\Event)")
[ "Publishes", "an", "event", "as", "soon", "as", "a", "method", "with", "an", "event", "annotation", "is", "called", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Aspect/PublishingAspect.php#L47-L51
24,198
hametuha/wpametu
src/WPametu/Utility/WPametuCommand.php
WPametuCommand.assets
public function assets( $args, $assoc_args ) { list( $type ) = $args; $global = self::get_flag( 'global', $assoc_args ); if ( false === array_search( $type, [ 'css', 'js' ] ) ) { self::e( $this->__( 'Only css and js are supported.' ) ); } $header = [ 'Handle', 'Source', 'Dependency', 'Version', 'css' === $type ? 'Media' : 'Footer', ]; $rows = []; if ( $global ) { switch ( $type ) { case 'js': break; case 'css': break; default: // Do nothing break; } } else { $assets = Library::all_assets()[ $type ]; foreach ( $assets as $handle => $asset ) { $rows[] = array_merge( [ $handle ], array_map( function ( $var ) { if ( is_bool( $var ) ) { return $var ? 'Yes' : 'No'; } elseif ( is_array( $var ) ) { return empty( $var ) ? '-' : implode( ', ', $var ); } elseif ( is_null( $var ) ) { return '-'; } else { return $var; } }, $asset ) ); } } self::table( $header, $rows ); self::l( '' ); self::s( sprintf( '%d %s are available on WPametu.', count( $rows ), $type ) ); }
php
public function assets( $args, $assoc_args ) { list( $type ) = $args; $global = self::get_flag( 'global', $assoc_args ); if ( false === array_search( $type, [ 'css', 'js' ] ) ) { self::e( $this->__( 'Only css and js are supported.' ) ); } $header = [ 'Handle', 'Source', 'Dependency', 'Version', 'css' === $type ? 'Media' : 'Footer', ]; $rows = []; if ( $global ) { switch ( $type ) { case 'js': break; case 'css': break; default: // Do nothing break; } } else { $assets = Library::all_assets()[ $type ]; foreach ( $assets as $handle => $asset ) { $rows[] = array_merge( [ $handle ], array_map( function ( $var ) { if ( is_bool( $var ) ) { return $var ? 'Yes' : 'No'; } elseif ( is_array( $var ) ) { return empty( $var ) ? '-' : implode( ', ', $var ); } elseif ( is_null( $var ) ) { return '-'; } else { return $var; } }, $asset ) ); } } self::table( $header, $rows ); self::l( '' ); self::s( sprintf( '%d %s are available on WPametu.', count( $rows ), $type ) ); }
[ "public", "function", "assets", "(", "$", "args", ",", "$", "assoc_args", ")", "{", "list", "(", "$", "type", ")", "=", "$", "args", ";", "$", "global", "=", "self", "::", "get_flag", "(", "'global'", ",", "$", "assoc_args", ")", ";", "if", "(", "false", "===", "array_search", "(", "$", "type", ",", "[", "'css'", ",", "'js'", "]", ")", ")", "{", "self", "::", "e", "(", "$", "this", "->", "__", "(", "'Only css and js are supported.'", ")", ")", ";", "}", "$", "header", "=", "[", "'Handle'", ",", "'Source'", ",", "'Dependency'", ",", "'Version'", ",", "'css'", "===", "$", "type", "?", "'Media'", ":", "'Footer'", ",", "]", ";", "$", "rows", "=", "[", "]", ";", "if", "(", "$", "global", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'js'", ":", "break", ";", "case", "'css'", ":", "break", ";", "default", ":", "// Do nothing", "break", ";", "}", "}", "else", "{", "$", "assets", "=", "Library", "::", "all_assets", "(", ")", "[", "$", "type", "]", ";", "foreach", "(", "$", "assets", "as", "$", "handle", "=>", "$", "asset", ")", "{", "$", "rows", "[", "]", "=", "array_merge", "(", "[", "$", "handle", "]", ",", "array_map", "(", "function", "(", "$", "var", ")", "{", "if", "(", "is_bool", "(", "$", "var", ")", ")", "{", "return", "$", "var", "?", "'Yes'", ":", "'No'", ";", "}", "elseif", "(", "is_array", "(", "$", "var", ")", ")", "{", "return", "empty", "(", "$", "var", ")", "?", "'-'", ":", "implode", "(", "', '", ",", "$", "var", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "var", ")", ")", "{", "return", "'-'", ";", "}", "else", "{", "return", "$", "var", ";", "}", "}", ",", "$", "asset", ")", ")", ";", "}", "}", "self", "::", "table", "(", "$", "header", ",", "$", "rows", ")", ";", "self", "::", "l", "(", "''", ")", ";", "self", "::", "s", "(", "sprintf", "(", "'%d %s are available on WPametu.'", ",", "count", "(", "$", "rows", ")", ",", "$", "type", ")", ")", ";", "}" ]
Show all asset libraries of WPametu ## OPTIONS <type> : Assets type. 'css', 'js' are supported. [--global] : Show global assets registered without WPametu ## EXAMPLES wp ametu assets css @synopsis <type> [--global]
[ "Show", "all", "asset", "libraries", "of", "WPametu" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/WPametuCommand.php#L41-L87
24,199
hametuha/wpametu
src/WPametu/Utility/WPametuCommand.php
WPametuCommand.akismet
public function akismet() { try { if ( ! class_exists( 'Akismet' ) ) { throw new \Exception( 'Akismet is not installed.' ); } if ( ! ( $key = \Akismet::get_api_key() ) ) { throw new \Exception( 'Akismet API key is not set.' ); } if ( 'valid' !== \Akismet::verify_key( $key ) ) { throw new \Exception( 'Akismet API key is invalid.' ); } static::s( 'Akismet is available!' ); } catch ( \Exception $e ) { static::e( $e->getMessage() ); } }
php
public function akismet() { try { if ( ! class_exists( 'Akismet' ) ) { throw new \Exception( 'Akismet is not installed.' ); } if ( ! ( $key = \Akismet::get_api_key() ) ) { throw new \Exception( 'Akismet API key is not set.' ); } if ( 'valid' !== \Akismet::verify_key( $key ) ) { throw new \Exception( 'Akismet API key is invalid.' ); } static::s( 'Akismet is available!' ); } catch ( \Exception $e ) { static::e( $e->getMessage() ); } }
[ "public", "function", "akismet", "(", ")", "{", "try", "{", "if", "(", "!", "class_exists", "(", "'Akismet'", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet is not installed.'", ")", ";", "}", "if", "(", "!", "(", "$", "key", "=", "\\", "Akismet", "::", "get_api_key", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet API key is not set.'", ")", ";", "}", "if", "(", "'valid'", "!==", "\\", "Akismet", "::", "verify_key", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Akismet API key is invalid.'", ")", ";", "}", "static", "::", "s", "(", "'Akismet is available!'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "static", "::", "e", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Check if akismet is available ## OPTIONS ## EXAMPLES wp ametu akismet @synopsis
[ "Check", "if", "akismet", "is", "available" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/WPametuCommand.php#L100-L115