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
20,600
WellCommerce/AppBundle
Service/Currency/Importer/AbstractExchangeRatesImporter.php
AbstractExchangeRatesImporter.addUpdateExchangeRate
protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate) { if (!in_array($currencyTo, $this->managedCurrencies)) { return false; } $exchangeRate = $this->currencyRateRepository->findOneBy([ 'currencyFrom' => $currencyFrom, 'currencyTo' => $currencyTo, ]); if (null === $exchangeRate) { $exchangeRate = new CurrencyRate(); $exchangeRate->setCurrencyFrom($currencyFrom); $exchangeRate->setCurrencyTo($currencyTo); $exchangeRate->setExchangeRate($rate); $this->helper->getEntityManager()->persist($exchangeRate); } else { $exchangeRate->setExchangeRate($rate); } return true; }
php
protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate) { if (!in_array($currencyTo, $this->managedCurrencies)) { return false; } $exchangeRate = $this->currencyRateRepository->findOneBy([ 'currencyFrom' => $currencyFrom, 'currencyTo' => $currencyTo, ]); if (null === $exchangeRate) { $exchangeRate = new CurrencyRate(); $exchangeRate->setCurrencyFrom($currencyFrom); $exchangeRate->setCurrencyTo($currencyTo); $exchangeRate->setExchangeRate($rate); $this->helper->getEntityManager()->persist($exchangeRate); } else { $exchangeRate->setExchangeRate($rate); } return true; }
[ "protected", "function", "addUpdateExchangeRate", "(", "$", "currencyFrom", ",", "$", "currencyTo", ",", "$", "rate", ")", "{", "if", "(", "!", "in_array", "(", "$", "currencyTo", ",", "$", "this", "->", "managedCurrencies", ")", ")", "{", "return", "false", ";", "}", "$", "exchangeRate", "=", "$", "this", "->", "currencyRateRepository", "->", "findOneBy", "(", "[", "'currencyFrom'", "=>", "$", "currencyFrom", ",", "'currencyTo'", "=>", "$", "currencyTo", ",", "]", ")", ";", "if", "(", "null", "===", "$", "exchangeRate", ")", "{", "$", "exchangeRate", "=", "new", "CurrencyRate", "(", ")", ";", "$", "exchangeRate", "->", "setCurrencyFrom", "(", "$", "currencyFrom", ")", ";", "$", "exchangeRate", "->", "setCurrencyTo", "(", "$", "currencyTo", ")", ";", "$", "exchangeRate", "->", "setExchangeRate", "(", "$", "rate", ")", ";", "$", "this", "->", "helper", "->", "getEntityManager", "(", ")", "->", "persist", "(", "$", "exchangeRate", ")", ";", "}", "else", "{", "$", "exchangeRate", "->", "setExchangeRate", "(", "$", "rate", ")", ";", "}", "return", "true", ";", "}" ]
Adds new rate or updates existing one @param string $currencyFrom @param string $currencyTo @param float $rate
[ "Adds", "new", "rate", "or", "updates", "existing", "one" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Service/Currency/Importer/AbstractExchangeRatesImporter.php#L72-L94
20,601
tystuyfzand/flysystem-seaweedfs
src/Mapping/CacheMapper.php
CacheMapper.store
public function store($path, $fileId, $mimeType, $size) { $this->cache->put('seaweedfs.' . md5($path), [ 'fid' => $fileId, 'mimeType' => $mimeType, 'size' => $size ]); }
php
public function store($path, $fileId, $mimeType, $size) { $this->cache->put('seaweedfs.' . md5($path), [ 'fid' => $fileId, 'mimeType' => $mimeType, 'size' => $size ]); }
[ "public", "function", "store", "(", "$", "path", ",", "$", "fileId", ",", "$", "mimeType", ",", "$", "size", ")", "{", "$", "this", "->", "cache", "->", "put", "(", "'seaweedfs.'", ".", "md5", "(", "$", "path", ")", ",", "[", "'fid'", "=>", "$", "fileId", ",", "'mimeType'", "=>", "$", "mimeType", ",", "'size'", "=>", "$", "size", "]", ")", ";", "}" ]
Store a path to a seaweedfs file id @param $path @param $fileId @param $mimeType @param $size @return mixed
[ "Store", "a", "path", "to", "a", "seaweedfs", "file", "id" ]
992334ba1d8e26fe6bbb9e33feedbf66b4872613
https://github.com/tystuyfzand/flysystem-seaweedfs/blob/992334ba1d8e26fe6bbb9e33feedbf66b4872613/src/Mapping/CacheMapper.php#L32-L38
20,602
zhouyl/mellivora
Mellivora/View/Factory.php
Factory.render
public function render($view, $data = [], $mergeData = []) { return $this->make($view, $this->parseData($data), $mergeData)->render(); }
php
public function render($view, $data = [], $mergeData = []) { return $this->make($view, $this->parseData($data), $mergeData)->render(); }
[ "public", "function", "render", "(", "$", "view", ",", "$", "data", "=", "[", "]", ",", "$", "mergeData", "=", "[", "]", ")", "{", "return", "$", "this", "->", "make", "(", "$", "view", ",", "$", "this", "->", "parseData", "(", "$", "data", ")", ",", "$", "mergeData", ")", "->", "render", "(", ")", ";", "}" ]
Get the rendered content of the view based @param string $view @param array $data @param array $mergeData @return string
[ "Get", "the", "rendered", "content", "of", "the", "view", "based" ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Factory.php#L149-L152
20,603
gpupo/common-schema
src/ORM/Entity/Banking/Report/Report.php
Report.addRecord
public function addRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { $this->records[] = $record; return $this; }
php
public function addRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { $this->records[] = $record; return $this; }
[ "public", "function", "addRecord", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Record", "$", "record", ")", "{", "$", "this", "->", "records", "[", "]", "=", "$", "record", ";", "return", "$", "this", ";", "}" ]
Add record. @param \Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record @return Report
[ "Add", "record", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Report.php#L403-L408
20,604
gpupo/common-schema
src/ORM/Entity/Banking/Report/Report.php
Report.removeRecord
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { return $this->records->removeElement($record); }
php
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { return $this->records->removeElement($record); }
[ "public", "function", "removeRecord", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Record", "$", "record", ")", "{", "return", "$", "this", "->", "records", "->", "removeElement", "(", "$", "record", ")", ";", "}" ]
Remove record. @param \Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record @return bool TRUE if this collection contained the specified element, FALSE otherwise
[ "Remove", "record", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Report.php#L417-L420
20,605
nabab/bbn
src/bbn/file/system2.php
system2._check_filter
private function _check_filter($item, $filter): bool { if ( $filter ){ if ( is_string($filter) ){ return strtolower(substr(\is_array($item) ? $item['path'] : $item, - strlen($filter))) === strtolower($filter); } if ( is_callable($filter) ){ return $filter($item); } } return true; }
php
private function _check_filter($item, $filter): bool { if ( $filter ){ if ( is_string($filter) ){ return strtolower(substr(\is_array($item) ? $item['path'] : $item, - strlen($filter))) === strtolower($filter); } if ( is_callable($filter) ){ return $filter($item); } } return true; }
[ "private", "function", "_check_filter", "(", "$", "item", ",", "$", "filter", ")", ":", "bool", "{", "if", "(", "$", "filter", ")", "{", "if", "(", "is_string", "(", "$", "filter", ")", ")", "{", "return", "strtolower", "(", "substr", "(", "\\", "is_array", "(", "$", "item", ")", "?", "$", "item", "[", "'path'", "]", ":", "$", "item", ",", "-", "strlen", "(", "$", "filter", ")", ")", ")", "===", "strtolower", "(", "$", "filter", ")", ";", "}", "if", "(", "is_callable", "(", "$", "filter", ")", ")", "{", "return", "$", "filter", "(", "$", "item", ")", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the given files name ends with the given suffix string @param array|string $item @param callable|string $filter @return bool
[ "Checks", "if", "the", "given", "files", "name", "ends", "with", "the", "given", "suffix", "string" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/system2.php#L142-L153
20,606
surebert/surebert-framework
src/sb/Email.php
Email.addIcalendarEvent
public function addIcalendarEvent(\sb\ICalendar\Event $event) { $a = new \sb\Email\Attachment(); $a->mime_type = 'text/calendar;'; $a->setEncoding('8bit'); $a->name = 'event.ics'; $a->contents = $event->__toString(); $this->addAttachment($a); }
php
public function addIcalendarEvent(\sb\ICalendar\Event $event) { $a = new \sb\Email\Attachment(); $a->mime_type = 'text/calendar;'; $a->setEncoding('8bit'); $a->name = 'event.ics'; $a->contents = $event->__toString(); $this->addAttachment($a); }
[ "public", "function", "addIcalendarEvent", "(", "\\", "sb", "\\", "ICalendar", "\\", "Event", "$", "event", ")", "{", "$", "a", "=", "new", "\\", "sb", "\\", "Email", "\\", "Attachment", "(", ")", ";", "$", "a", "->", "mime_type", "=", "'text/calendar;'", ";", "$", "a", "->", "setEncoding", "(", "'8bit'", ")", ";", "$", "a", "->", "name", "=", "'event.ics'", ";", "$", "a", "->", "contents", "=", "$", "event", "->", "__toString", "(", ")", ";", "$", "this", "->", "addAttachment", "(", "$", "a", ")", ";", "}" ]
Add an \sb\ICalendar\Event request @param \sb\ICalendar\Event $event
[ "Add", "an", "\\", "sb", "\\", "ICalendar", "\\", "Event", "request" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L234-L244
20,607
surebert/surebert-framework
src/sb/Email.php
Email.onBeforeSend
public function onBeforeSend() { if(!isset($this->__added_sent_by_stamp)){ $this->body .= "\n\nSent Using Surebert Mail" ." recorded: \nSending IP: " . \sb\Gateway::$remote_addr . " \nSending Host: " . \sb\Gateway::$http_host; if (!empty($this->body_HTML)) { $this->body_HTML .= '<br /><br />' .'<span style="font-size:10px;color:#BCBCBC;margin-top:20px;">' .'Sent Using Surebert Mail:' .'<br />Sending IP:' . \sb\Gateway::$remote_addr .' <br />Sending Host: ' . \sb\Gateway::$http_host. '</span>'; } $this->__added_sent_by_stamp = true; } return true; }
php
public function onBeforeSend() { if(!isset($this->__added_sent_by_stamp)){ $this->body .= "\n\nSent Using Surebert Mail" ." recorded: \nSending IP: " . \sb\Gateway::$remote_addr . " \nSending Host: " . \sb\Gateway::$http_host; if (!empty($this->body_HTML)) { $this->body_HTML .= '<br /><br />' .'<span style="font-size:10px;color:#BCBCBC;margin-top:20px;">' .'Sent Using Surebert Mail:' .'<br />Sending IP:' . \sb\Gateway::$remote_addr .' <br />Sending Host: ' . \sb\Gateway::$http_host. '</span>'; } $this->__added_sent_by_stamp = true; } return true; }
[ "public", "function", "onBeforeSend", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "__added_sent_by_stamp", ")", ")", "{", "$", "this", "->", "body", ".=", "\"\\n\\nSent Using Surebert Mail\"", ".", "\" recorded: \\nSending IP: \"", ".", "\\", "sb", "\\", "Gateway", "::", "$", "remote_addr", ".", "\" \\nSending Host: \"", ".", "\\", "sb", "\\", "Gateway", "::", "$", "http_host", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "body_HTML", ")", ")", "{", "$", "this", "->", "body_HTML", ".=", "'<br /><br />'", ".", "'<span style=\"font-size:10px;color:#BCBCBC;margin-top:20px;\">'", ".", "'Sent Using Surebert Mail:'", ".", "'<br />Sending IP:'", ".", "\\", "sb", "\\", "Gateway", "::", "$", "remote_addr", ".", "' <br />Sending Host: '", ".", "\\", "sb", "\\", "Gateway", "::", "$", "http_host", ".", "'</span>'", ";", "}", "$", "this", "->", "__added_sent_by_stamp", "=", "true", ";", "}", "return", "true", ";", "}" ]
Fires before sending, if returns false, then sending does not occur @return boolean
[ "Fires", "before", "sending", "if", "returns", "false", "then", "sending", "does", "not", "occur" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L256-L275
20,608
surebert/surebert-framework
src/sb/Email.php
Email.send
public function send($outbox=null) { if($outbox instanceof Writer){ self::$outbox = $outbox; } elseif(!self::$outbox){ self::$outbox = new Writer(); } if($this->onBeforeSend($this) !== false){ self::$outbox->addEmailToOutbox($this); //return if sent return self::$outbox->send(); } }
php
public function send($outbox=null) { if($outbox instanceof Writer){ self::$outbox = $outbox; } elseif(!self::$outbox){ self::$outbox = new Writer(); } if($this->onBeforeSend($this) !== false){ self::$outbox->addEmailToOutbox($this); //return if sent return self::$outbox->send(); } }
[ "public", "function", "send", "(", "$", "outbox", "=", "null", ")", "{", "if", "(", "$", "outbox", "instanceof", "Writer", ")", "{", "self", "::", "$", "outbox", "=", "$", "outbox", ";", "}", "elseif", "(", "!", "self", "::", "$", "outbox", ")", "{", "self", "::", "$", "outbox", "=", "new", "Writer", "(", ")", ";", "}", "if", "(", "$", "this", "->", "onBeforeSend", "(", "$", "this", ")", "!==", "false", ")", "{", "self", "::", "$", "outbox", "->", "addEmailToOutbox", "(", "$", "this", ")", ";", "//return if sent", "return", "self", "::", "$", "outbox", "->", "send", "(", ")", ";", "}", "}" ]
Uses sb_Email_Writer to send the email
[ "Uses", "sb_Email_Writer", "to", "send", "the", "email" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L279-L296
20,609
gedex/php-janrain-api
lib/Janrain/Api/Engage/Mapping.php
Mapping.map
public function map(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('map', $params); }
php
public function map(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('map', $params); }
[ "public", "function", "map", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'ientifier'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'primaryKey'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'primaryKey'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'format'", "]", ")", ")", "{", "$", "params", "[", "'format'", "]", "=", "'json'", ";", "}", "return", "$", "this", "->", "post", "(", "'map'", ",", "$", "params", ")", ";", "}" ]
Associates a primary key with a user's social identity. @param array $params
[ "Associates", "a", "primary", "key", "with", "a", "user", "s", "social", "identity", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Mapping.php#L27-L42
20,610
gedex/php-janrain-api
lib/Janrain/Api/Engage/Mapping.php
Mapping.unmap
public function unmap(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['all_identifiers'])) { throw new MissingArgumentException('all_identifiers'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['unlink'])) { throw new MissingArgumentException('unlink'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('unmap', $params); }
php
public function unmap(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['all_identifiers'])) { throw new MissingArgumentException('all_identifiers'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['unlink'])) { throw new MissingArgumentException('unlink'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('unmap', $params); }
[ "public", "function", "unmap", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'ientifier'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'all_identifiers'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'all_identifiers'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'primaryKey'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'primaryKey'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'unlink'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'unlink'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'format'", "]", ")", ")", "{", "$", "params", "[", "'format'", "]", "=", "'json'", ";", "}", "return", "$", "this", "->", "post", "(", "'unmap'", ",", "$", "params", ")", ";", "}" ]
Removes an identity provider from a primary key as well as allowing you to optionally unlink your application from the user's account with the provider. @param array $params
[ "Removes", "an", "identity", "provider", "from", "a", "primary", "key", "as", "well", "as", "allowing", "you", "to", "optionally", "unlink", "your", "application", "from", "the", "user", "s", "account", "with", "the", "provider", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Mapping.php#L62-L85
20,611
odiaseo/pagebuilder
src/PageBuilder/Controller/PageController.php
PageController.get
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getPageLayout($id) ); }
php
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getPageLayout($id) ); }
[ "public", "function", "get", "(", "$", "id", ")", "{", "return", "$", "this", "->", "_sendPayload", "(", "$", "this", "->", "_getService", "(", "$", "this", "->", "_pageServiceKey", ")", "->", "getPageLayout", "(", "$", "id", ")", ")", ";", "}" ]
Get page layout details @param mixed $id @return mixed|\Zend\View\Model\ModelInterface
[ "Get", "page", "layout", "details" ]
88ef7cccf305368561307efe4ca07fac8e5774f3
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/PageController.php#L19-L24
20,612
gpupo/common-schema
src/ORM/Entity/Banking/Report/Record.php
Record.setReport
public function setReport(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report = null) { $this->report = $report; return $this; }
php
public function setReport(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report = null) { $this->report = $report; return $this; }
[ "public", "function", "setReport", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Report", "$", "report", "=", "null", ")", "{", "$", "this", "->", "report", "=", "$", "report", ";", "return", "$", "this", ";", "}" ]
Set report. @param null|\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report @return Record
[ "Set", "report", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Record.php#L615-L620
20,613
oroinc/OroLayoutComponent
ContextDataCollection.php
ContextDataCollection.get
public function get($name) { if (!isset($this->items[$name]) && !array_key_exists($name, $this->items) && !$this->applyDefaultValue($name) ) { throw new \OutOfBoundsException(sprintf('Undefined data item index: %s.', $name)); }; return $this->items[$name]; }
php
public function get($name) { if (!isset($this->items[$name]) && !array_key_exists($name, $this->items) && !$this->applyDefaultValue($name) ) { throw new \OutOfBoundsException(sprintf('Undefined data item index: %s.', $name)); }; return $this->items[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "name", "]", ")", "&&", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "items", ")", "&&", "!", "$", "this", "->", "applyDefaultValue", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "OutOfBoundsException", "(", "sprintf", "(", "'Undefined data item index: %s.'", ",", "$", "name", ")", ")", ";", "}", ";", "return", "$", "this", "->", "items", "[", "$", "name", "]", ";", "}" ]
Gets a value stored in the context data variable. @param string $name The data item name @return mixed @throws \OutOfBoundsException if the data item does not exist
[ "Gets", "a", "value", "stored", "in", "the", "context", "data", "variable", "." ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ContextDataCollection.php#L48-L58
20,614
webdevvie/pheanstalk-task-queue-bundle
Command/AbstractWorker.php
AbstractWorker.logException
protected function logException(\Exception $exception) { $this->logger->error( $exception->getMessage(), array( 'class'=>get_class($exception), 'message'=>$exception->getMessage(), 'file'=>$exception->getMessage(), 'line'=>$exception->getMessage(), 'command'=>$this->getName() ) ); }
php
protected function logException(\Exception $exception) { $this->logger->error( $exception->getMessage(), array( 'class'=>get_class($exception), 'message'=>$exception->getMessage(), 'file'=>$exception->getMessage(), 'line'=>$exception->getMessage(), 'command'=>$this->getName() ) ); }
[ "protected", "function", "logException", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "array", "(", "'class'", "=>", "get_class", "(", "$", "exception", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'command'", "=>", "$", "this", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Logs an exception to the logger @param \Exception $exception @return void
[ "Logs", "an", "exception", "to", "the", "logger" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/AbstractWorker.php#L133-L145
20,615
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.zip
public static function zip($zip, $check_usps = true) { $result = new \sb\Validate\Results(); $result->value = $zip; $result->is_valid = false; if (preg_match("/^(\d{5})(-\d{4})*$/", $zip)) { $result->message = "Valid zip code format"; $result->is_valid = true; if ($check_usps) { $page = @file_get_contents("https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=" . substr($zip, 0, 5)); if (!$page) { $result->message .= ' cannot reach USPS site to validate zip code existence'; } else { preg_match("~<p class=\"std-address\">(.*?)</p>~", $page, $city); if (isset($city[1])) { $data = trim($city[1]); $result->state = substr($data, -2, 2); $result->city = ucwords(strtolower(preg_replace("~" . $result->state . "$~", "", $data))); $result->message .= " for " . $result->city . ',' . $result->state; } else { $result->message .= " but city not found!"; $result->is_valid = false; } } } } else { $result->message = "Invalid zip code format "; } return $result; }
php
public static function zip($zip, $check_usps = true) { $result = new \sb\Validate\Results(); $result->value = $zip; $result->is_valid = false; if (preg_match("/^(\d{5})(-\d{4})*$/", $zip)) { $result->message = "Valid zip code format"; $result->is_valid = true; if ($check_usps) { $page = @file_get_contents("https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=" . substr($zip, 0, 5)); if (!$page) { $result->message .= ' cannot reach USPS site to validate zip code existence'; } else { preg_match("~<p class=\"std-address\">(.*?)</p>~", $page, $city); if (isset($city[1])) { $data = trim($city[1]); $result->state = substr($data, -2, 2); $result->city = ucwords(strtolower(preg_replace("~" . $result->state . "$~", "", $data))); $result->message .= " for " . $result->city . ',' . $result->state; } else { $result->message .= " but city not found!"; $result->is_valid = false; } } } } else { $result->message = "Invalid zip code format "; } return $result; }
[ "public", "static", "function", "zip", "(", "$", "zip", ",", "$", "check_usps", "=", "true", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "zip", ";", "$", "result", "->", "is_valid", "=", "false", ";", "if", "(", "preg_match", "(", "\"/^(\\d{5})(-\\d{4})*$/\"", ",", "$", "zip", ")", ")", "{", "$", "result", "->", "message", "=", "\"Valid zip code format\"", ";", "$", "result", "->", "is_valid", "=", "true", ";", "if", "(", "$", "check_usps", ")", "{", "$", "page", "=", "@", "file_get_contents", "(", "\"https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=\"", ".", "substr", "(", "$", "zip", ",", "0", ",", "5", ")", ")", ";", "if", "(", "!", "$", "page", ")", "{", "$", "result", "->", "message", ".=", "' cannot reach USPS site to validate zip code existence'", ";", "}", "else", "{", "preg_match", "(", "\"~<p class=\\\"std-address\\\">(.*?)</p>~\"", ",", "$", "page", ",", "$", "city", ")", ";", "if", "(", "isset", "(", "$", "city", "[", "1", "]", ")", ")", "{", "$", "data", "=", "trim", "(", "$", "city", "[", "1", "]", ")", ";", "$", "result", "->", "state", "=", "substr", "(", "$", "data", ",", "-", "2", ",", "2", ")", ";", "$", "result", "->", "city", "=", "ucwords", "(", "strtolower", "(", "preg_replace", "(", "\"~\"", ".", "$", "result", "->", "state", ".", "\"$~\"", ",", "\"\"", ",", "$", "data", ")", ")", ")", ";", "$", "result", "->", "message", ".=", "\" for \"", ".", "$", "result", "->", "city", ".", "','", ".", "$", "result", "->", "state", ";", "}", "else", "{", "$", "result", "->", "message", ".=", "\" but city not found!\"", ";", "$", "result", "->", "is_valid", "=", "false", ";", "}", "}", "}", "}", "else", "{", "$", "result", "->", "message", "=", "\"Invalid zip code format \"", ";", "}", "return", "$", "result", ";", "}" ]
Validates a zip code @author [email protected] @version 1.2 13/18/2008 @param string $zip The zip code to validate in xxxxx or xxxxx-xxxx format @param boolean check_usps Check the usps sie look for validation @return \sb\Validate_Results The message property includes the city if it exists
[ "Validates", "a", "zip", "code" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L133-L169
20,616
PayBreak/foundation
src/Decision/Risk.php
Risk.normalize
public static function normalize($risk) { return (float) max(min($risk, self::MAXIMUM_RISK), self::MINIMUM_RISK); }
php
public static function normalize($risk) { return (float) max(min($risk, self::MAXIMUM_RISK), self::MINIMUM_RISK); }
[ "public", "static", "function", "normalize", "(", "$", "risk", ")", "{", "return", "(", "float", ")", "max", "(", "min", "(", "$", "risk", ",", "self", "::", "MAXIMUM_RISK", ")", ",", "self", "::", "MINIMUM_RISK", ")", ";", "}" ]
Normalize Risk - make sure that risk will be in bound @author WN @param $risk @return float <0,1>
[ "Normalize", "Risk", "-", "make", "sure", "that", "risk", "will", "be", "in", "bound" ]
3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Risk.php#L65-L68
20,617
Smile-SA/EzUICronBundle
Controller/StatusController.php
StatusController.listAction
public function listAction() { $this->performAccessChecks(); $crons = $this->cronService->listCronsStatus(); $cronRows = array(); foreach ($crons as $cron) { $cronRows[] = array( 'alias' => $cron->getAlias(), 'queued' => $cron instanceof SmileCron ? ($cron->getQueued() ? $cron->getQueued()->format('d-m-Y H:i') : false) : false, 'started' => $cron instanceof SmileCron ? ($cron->getStarted() ? $cron->getStarted()->format('d-m-Y H:i') : false) : false, 'ended' => $cron instanceof SmileCron ? ($cron->getEnded() ? $cron->getEnded()->format('d-m-Y H:i') : false) : false, 'status' => $cron instanceof SmileCron ? $cron->getStatus() : false ); } return $this->render('SmileEzUICronBundle:cron:tab/status/list.html.twig', [ 'datas' => $cronRows ]); }
php
public function listAction() { $this->performAccessChecks(); $crons = $this->cronService->listCronsStatus(); $cronRows = array(); foreach ($crons as $cron) { $cronRows[] = array( 'alias' => $cron->getAlias(), 'queued' => $cron instanceof SmileCron ? ($cron->getQueued() ? $cron->getQueued()->format('d-m-Y H:i') : false) : false, 'started' => $cron instanceof SmileCron ? ($cron->getStarted() ? $cron->getStarted()->format('d-m-Y H:i') : false) : false, 'ended' => $cron instanceof SmileCron ? ($cron->getEnded() ? $cron->getEnded()->format('d-m-Y H:i') : false) : false, 'status' => $cron instanceof SmileCron ? $cron->getStatus() : false ); } return $this->render('SmileEzUICronBundle:cron:tab/status/list.html.twig', [ 'datas' => $cronRows ]); }
[ "public", "function", "listAction", "(", ")", "{", "$", "this", "->", "performAccessChecks", "(", ")", ";", "$", "crons", "=", "$", "this", "->", "cronService", "->", "listCronsStatus", "(", ")", ";", "$", "cronRows", "=", "array", "(", ")", ";", "foreach", "(", "$", "crons", "as", "$", "cron", ")", "{", "$", "cronRows", "[", "]", "=", "array", "(", "'alias'", "=>", "$", "cron", "->", "getAlias", "(", ")", ",", "'queued'", "=>", "$", "cron", "instanceof", "SmileCron", "?", "(", "$", "cron", "->", "getQueued", "(", ")", "?", "$", "cron", "->", "getQueued", "(", ")", "->", "format", "(", "'d-m-Y H:i'", ")", ":", "false", ")", ":", "false", ",", "'started'", "=>", "$", "cron", "instanceof", "SmileCron", "?", "(", "$", "cron", "->", "getStarted", "(", ")", "?", "$", "cron", "->", "getStarted", "(", ")", "->", "format", "(", "'d-m-Y H:i'", ")", ":", "false", ")", ":", "false", ",", "'ended'", "=>", "$", "cron", "instanceof", "SmileCron", "?", "(", "$", "cron", "->", "getEnded", "(", ")", "?", "$", "cron", "->", "getEnded", "(", ")", "->", "format", "(", "'d-m-Y H:i'", ")", ":", "false", ")", ":", "false", ",", "'status'", "=>", "$", "cron", "instanceof", "SmileCron", "?", "$", "cron", "->", "getStatus", "(", ")", ":", "false", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'SmileEzUICronBundle:cron:tab/status/list.html.twig'", ",", "[", "'datas'", "=>", "$", "cronRows", "]", ")", ";", "}" ]
List crons status @return \Symfony\Component\HttpFoundation\Response
[ "List", "crons", "status" ]
c62fc6a3ab0b39e3f911742d9affe4aade90cf66
https://github.com/Smile-SA/EzUICronBundle/blob/c62fc6a3ab0b39e3f911742d9affe4aade90cf66/Controller/StatusController.php#L33-L59
20,618
philiplb/Valdi
src/Valdi/Validator.php
Validator.createValidators
protected function createValidators(array $validators) { $this->availableValidators = []; foreach ($validators as $name => $type) { $class = '\\Valdi\\Validator\\'.$type; $this->availableValidators[$name] = new $class(); } }
php
protected function createValidators(array $validators) { $this->availableValidators = []; foreach ($validators as $name => $type) { $class = '\\Valdi\\Validator\\'.$type; $this->availableValidators[$name] = new $class(); } }
[ "protected", "function", "createValidators", "(", "array", "$", "validators", ")", "{", "$", "this", "->", "availableValidators", "=", "[", "]", ";", "foreach", "(", "$", "validators", "as", "$", "name", "=>", "$", "type", ")", "{", "$", "class", "=", "'\\\\Valdi\\\\Validator\\\\'", ".", "$", "type", ";", "$", "this", "->", "availableValidators", "[", "$", "name", "]", "=", "new", "$", "class", "(", ")", ";", "}", "}" ]
Creates instances of the available validators. @param array $validators the validators to load, key = name, value = classname within the namespace "\Valdi\Validator"
[ "Creates", "instances", "of", "the", "available", "validators", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L34-L40
20,619
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValidRule
protected function isValidRule($validator, $parameters, $value) { if (!array_key_exists($validator, $this->availableValidators)) { throw new ValidatorException('"'.$validator.'" not found as available validator.'); } return $this->availableValidators[$validator]->isValid($value, $parameters) ? null : $this->availableValidators[$validator]->getInvalidDetails(); }
php
protected function isValidRule($validator, $parameters, $value) { if (!array_key_exists($validator, $this->availableValidators)) { throw new ValidatorException('"'.$validator.'" not found as available validator.'); } return $this->availableValidators[$validator]->isValid($value, $parameters) ? null : $this->availableValidators[$validator]->getInvalidDetails(); }
[ "protected", "function", "isValidRule", "(", "$", "validator", ",", "$", "parameters", ",", "$", "value", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "validator", ",", "$", "this", "->", "availableValidators", ")", ")", "{", "throw", "new", "ValidatorException", "(", "'\"'", ".", "$", "validator", ".", "'\" not found as available validator.'", ")", ";", "}", "return", "$", "this", "->", "availableValidators", "[", "$", "validator", "]", "->", "isValid", "(", "$", "value", ",", "$", "parameters", ")", "?", "null", ":", "$", "this", "->", "availableValidators", "[", "$", "validator", "]", "->", "getInvalidDetails", "(", ")", ";", "}" ]
Validates a single rule. @param string $validator the validator to use @param string[] $parameters the validation parameters, depending on the validator @param string $value the value to validate @return boolean true if the value is valid @throws ValidationException thrown if the validator is not available
[ "Validates", "a", "single", "rule", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L58-L64
20,620
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValidValue
public function isValidValue($rules, $value) { $result = []; foreach ($rules as $rule) { $parameters = $rule; $name = array_shift($parameters); $valid = $this->isValidRule($name, $parameters, $value); if ($valid !== null) { $result[] = $valid; } } return $result; }
php
public function isValidValue($rules, $value) { $result = []; foreach ($rules as $rule) { $parameters = $rule; $name = array_shift($parameters); $valid = $this->isValidRule($name, $parameters, $value); if ($valid !== null) { $result[] = $valid; } } return $result; }
[ "public", "function", "isValidValue", "(", "$", "rules", ",", "$", "value", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "parameters", "=", "$", "rule", ";", "$", "name", "=", "array_shift", "(", "$", "parameters", ")", ";", "$", "valid", "=", "$", "this", "->", "isValidRule", "(", "$", "name", ",", "$", "parameters", ",", "$", "value", ")", ";", "if", "(", "$", "valid", "!==", "null", ")", "{", "$", "result", "[", "]", "=", "$", "valid", ";", "}", "}", "return", "$", "result", ";", "}" ]
Validates a value via the given rules. @param array $rules the validation rules @param string $value the value to validate @return string[] the fields where the validation failed
[ "Validates", "a", "value", "via", "the", "given", "rules", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L114-L125
20,621
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValid
public function isValid(array $rules, array $data) { $errors = []; foreach ($rules as $field => $fieldRules) { $value = isset($data[$field]) ? $data[$field] : null; $fieldErrors = $this->isValidValue($fieldRules, $value); if (!empty($fieldErrors)) { $errors[$field] = $fieldErrors; } } return [ 'valid' => count($errors) === 0, 'errors' => $errors ]; }
php
public function isValid(array $rules, array $data) { $errors = []; foreach ($rules as $field => $fieldRules) { $value = isset($data[$field]) ? $data[$field] : null; $fieldErrors = $this->isValidValue($fieldRules, $value); if (!empty($fieldErrors)) { $errors[$field] = $fieldErrors; } } return [ 'valid' => count($errors) === 0, 'errors' => $errors ]; }
[ "public", "function", "isValid", "(", "array", "$", "rules", ",", "array", "$", "data", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "field", "=>", "$", "fieldRules", ")", "{", "$", "value", "=", "isset", "(", "$", "data", "[", "$", "field", "]", ")", "?", "$", "data", "[", "$", "field", "]", ":", "null", ";", "$", "fieldErrors", "=", "$", "this", "->", "isValidValue", "(", "$", "fieldRules", ",", "$", "value", ")", ";", "if", "(", "!", "empty", "(", "$", "fieldErrors", ")", ")", "{", "$", "errors", "[", "$", "field", "]", "=", "$", "fieldErrors", ";", "}", "}", "return", "[", "'valid'", "=>", "count", "(", "$", "errors", ")", "===", "0", ",", "'errors'", "=>", "$", "errors", "]", ";", "}" ]
Performs the actual validation. @param array $rules the validation rules: an array with a field name as key and an array of rules to use for this field; each rule is an array with the validator name as first element and parameters as following elements; example: array('a' => array(array('required')), 'b' => array(array('min', 1))) @param array $data the data to validate as a map @return array<string,boolean|array> the validation result having the keys "valid" (true or false) and the key "errors" containing all failed fields as keys with arrays of the failed validator names; example where the field "b" from the above sample failed due to the min validator: array('valid' => false, errors => array('b' => array('min'))) the "or" validator doesn't return a single string on validation error; instead, it returns an array listing all failed validators of it: array('or' => array('url', 'email')
[ "Performs", "the", "actual", "validation", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L148-L161
20,622
mrgarry/yii2-omj-fidavista
FidavistaStatement.php
FidavistaStatement.saveToDb
public function saveToDb($incomingOnly = false) { $count = ($incomingOnly) ? $this->dbInterface->executeDataImportIncoming() : $this->dbInterface->executeDataImport(); return $count; }
php
public function saveToDb($incomingOnly = false) { $count = ($incomingOnly) ? $this->dbInterface->executeDataImportIncoming() : $this->dbInterface->executeDataImport(); return $count; }
[ "public", "function", "saveToDb", "(", "$", "incomingOnly", "=", "false", ")", "{", "$", "count", "=", "(", "$", "incomingOnly", ")", "?", "$", "this", "->", "dbInterface", "->", "executeDataImportIncoming", "(", ")", ":", "$", "this", "->", "dbInterface", "->", "executeDataImport", "(", ")", ";", "return", "$", "count", ";", "}" ]
Saves the data to DB using iAccountStatementDbController @param bool $incomingOnly @return int Optinally can be implemented in iAccountStatementDbController - num of rows imported
[ "Saves", "the", "data", "to", "DB", "using", "iAccountStatementDbController" ]
ee4ecadd6648b68e891352c214ff33a72622941b
https://github.com/mrgarry/yii2-omj-fidavista/blob/ee4ecadd6648b68e891352c214ff33a72622941b/FidavistaStatement.php#L259-L262
20,623
zhouyl/mellivora
Mellivora/View/Concerns/ManagesLoops.php
ManagesLoops.addLoop
public function addLoop($data) { $length = is_array($data) || $data instanceof Countable ? count($data) : null; $parent = Arr::last($this->loopsStack); $this->loopsStack[] = [ 'iteration' => 0, 'index' => 0, 'remaining' => isset($length) ? $length : null, 'count' => $length, 'first' => true, 'last' => isset($length) ? $length === 1 : null, 'depth' => count($this->loopsStack) + 1, 'parent' => $parent ? (object) $parent : null, ]; }
php
public function addLoop($data) { $length = is_array($data) || $data instanceof Countable ? count($data) : null; $parent = Arr::last($this->loopsStack); $this->loopsStack[] = [ 'iteration' => 0, 'index' => 0, 'remaining' => isset($length) ? $length : null, 'count' => $length, 'first' => true, 'last' => isset($length) ? $length === 1 : null, 'depth' => count($this->loopsStack) + 1, 'parent' => $parent ? (object) $parent : null, ]; }
[ "public", "function", "addLoop", "(", "$", "data", ")", "{", "$", "length", "=", "is_array", "(", "$", "data", ")", "||", "$", "data", "instanceof", "Countable", "?", "count", "(", "$", "data", ")", ":", "null", ";", "$", "parent", "=", "Arr", "::", "last", "(", "$", "this", "->", "loopsStack", ")", ";", "$", "this", "->", "loopsStack", "[", "]", "=", "[", "'iteration'", "=>", "0", ",", "'index'", "=>", "0", ",", "'remaining'", "=>", "isset", "(", "$", "length", ")", "?", "$", "length", ":", "null", ",", "'count'", "=>", "$", "length", ",", "'first'", "=>", "true", ",", "'last'", "=>", "isset", "(", "$", "length", ")", "?", "$", "length", "===", "1", ":", "null", ",", "'depth'", "=>", "count", "(", "$", "this", "->", "loopsStack", ")", "+", "1", ",", "'parent'", "=>", "$", "parent", "?", "(", "object", ")", "$", "parent", ":", "null", ",", "]", ";", "}" ]
Add new loop to the stack. @param array|\Countable $data @return void
[ "Add", "new", "loop", "to", "the", "stack", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Concerns/ManagesLoops.php#L24-L40
20,624
zhouyl/mellivora
Mellivora/View/Concerns/ManagesLoops.php
ManagesLoops.incrementLoopIndices
public function incrementLoopIndices() { $loop = $this->loopsStack[$index = count($this->loopsStack) - 1]; $this->loopsStack[$index] = array_merge($this->loopsStack[$index], [ 'iteration' => $loop['iteration'] + 1, 'index' => $loop['iteration'], 'first' => $loop['iteration'] === 0, 'remaining' => isset($loop['count']) ? $loop['remaining'] - 1 : null, 'last' => isset($loop['count']) ? $loop['iteration'] === $loop['count'] - 1 : null, ]); }
php
public function incrementLoopIndices() { $loop = $this->loopsStack[$index = count($this->loopsStack) - 1]; $this->loopsStack[$index] = array_merge($this->loopsStack[$index], [ 'iteration' => $loop['iteration'] + 1, 'index' => $loop['iteration'], 'first' => $loop['iteration'] === 0, 'remaining' => isset($loop['count']) ? $loop['remaining'] - 1 : null, 'last' => isset($loop['count']) ? $loop['iteration'] === $loop['count'] - 1 : null, ]); }
[ "public", "function", "incrementLoopIndices", "(", ")", "{", "$", "loop", "=", "$", "this", "->", "loopsStack", "[", "$", "index", "=", "count", "(", "$", "this", "->", "loopsStack", ")", "-", "1", "]", ";", "$", "this", "->", "loopsStack", "[", "$", "index", "]", "=", "array_merge", "(", "$", "this", "->", "loopsStack", "[", "$", "index", "]", ",", "[", "'iteration'", "=>", "$", "loop", "[", "'iteration'", "]", "+", "1", ",", "'index'", "=>", "$", "loop", "[", "'iteration'", "]", ",", "'first'", "=>", "$", "loop", "[", "'iteration'", "]", "===", "0", ",", "'remaining'", "=>", "isset", "(", "$", "loop", "[", "'count'", "]", ")", "?", "$", "loop", "[", "'remaining'", "]", "-", "1", ":", "null", ",", "'last'", "=>", "isset", "(", "$", "loop", "[", "'count'", "]", ")", "?", "$", "loop", "[", "'iteration'", "]", "===", "$", "loop", "[", "'count'", "]", "-", "1", ":", "null", ",", "]", ")", ";", "}" ]
Increment the top loop's indices. @return void
[ "Increment", "the", "top", "loop", "s", "indices", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Concerns/ManagesLoops.php#L47-L58
20,625
expectation-php/expect
src/MatcherEvaluator.php
MatcherEvaluator.evaluate
public function evaluate($actual) { $matcherResult = $this->matcher->match($actual); $expected = $this->negated ? false : true; $result = $matcherResult === $expected; return new Result($actual, $this->negated, $this->matcher, $result); }
php
public function evaluate($actual) { $matcherResult = $this->matcher->match($actual); $expected = $this->negated ? false : true; $result = $matcherResult === $expected; return new Result($actual, $this->negated, $this->matcher, $result); }
[ "public", "function", "evaluate", "(", "$", "actual", ")", "{", "$", "matcherResult", "=", "$", "this", "->", "matcher", "->", "match", "(", "$", "actual", ")", ";", "$", "expected", "=", "$", "this", "->", "negated", "?", "false", ":", "true", ";", "$", "result", "=", "$", "matcherResult", "===", "$", "expected", ";", "return", "new", "Result", "(", "$", "actual", ",", "$", "this", "->", "negated", ",", "$", "this", "->", "matcher", ",", "$", "result", ")", ";", "}" ]
Evaluate the value of actual. @param mixed $actual value of actual @return \expect\Result
[ "Evaluate", "the", "value", "of", "actual", "." ]
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherEvaluator.php#L92-L100
20,626
ronaldborla/chikka
src/Borla/Chikka/Support/Utilities.php
Utilities.parseMobileNumber
static function parseMobileNumber($number) { // Extract numerics $numerics = static::extractNumerics($number); // Set country code $countryCode = ''; // Get last 10 digits $short = static::right($numerics, 10, $countryCode); // Set carrier code $carriercode = ''; // Get number $number = static::right($short, 7, $carrierCode); // Return return compact('countryCode', 'carrierCode', 'number'); }
php
static function parseMobileNumber($number) { // Extract numerics $numerics = static::extractNumerics($number); // Set country code $countryCode = ''; // Get last 10 digits $short = static::right($numerics, 10, $countryCode); // Set carrier code $carriercode = ''; // Get number $number = static::right($short, 7, $carrierCode); // Return return compact('countryCode', 'carrierCode', 'number'); }
[ "static", "function", "parseMobileNumber", "(", "$", "number", ")", "{", "// Extract numerics", "$", "numerics", "=", "static", "::", "extractNumerics", "(", "$", "number", ")", ";", "// Set country code", "$", "countryCode", "=", "''", ";", "// Get last 10 digits", "$", "short", "=", "static", "::", "right", "(", "$", "numerics", ",", "10", ",", "$", "countryCode", ")", ";", "// Set carrier code", "$", "carriercode", "=", "''", ";", "// Get number", "$", "number", "=", "static", "::", "right", "(", "$", "short", ",", "7", ",", "$", "carrierCode", ")", ";", "// Return", "return", "compact", "(", "'countryCode'", ",", "'carrierCode'", ",", "'number'", ")", ";", "}" ]
Parse mobile number
[ "Parse", "mobile", "number" ]
446987706f81d5a0efbc8bd6b7d3b259d0527719
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Support/Utilities.php#L52-L65
20,627
ronaldborla/chikka
src/Borla/Chikka/Support/Utilities.php
Utilities.arrayExtract
static function arrayExtract(array $keys, array $array, array $callbacks = []) { // Set extracted $extracted = []; // Loop through keys foreach ($keys as $key) { // Add to extracted, only if it exists if (array_key_exists($key, $array)) { // Set item $item = $array[$key]; // If there's a callback if (isset($callbacks[$key]) && is_callable($callbacks[$key])) { // Call it $item = call_user_func_array($callbacks[$key], [$item]); } // Add to extracted $extracted[$key] = $item; } } // Return extracted return $extracted; }
php
static function arrayExtract(array $keys, array $array, array $callbacks = []) { // Set extracted $extracted = []; // Loop through keys foreach ($keys as $key) { // Add to extracted, only if it exists if (array_key_exists($key, $array)) { // Set item $item = $array[$key]; // If there's a callback if (isset($callbacks[$key]) && is_callable($callbacks[$key])) { // Call it $item = call_user_func_array($callbacks[$key], [$item]); } // Add to extracted $extracted[$key] = $item; } } // Return extracted return $extracted; }
[ "static", "function", "arrayExtract", "(", "array", "$", "keys", ",", "array", "$", "array", ",", "array", "$", "callbacks", "=", "[", "]", ")", "{", "// Set extracted", "$", "extracted", "=", "[", "]", ";", "// Loop through keys", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "// Add to extracted, only if it exists", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "// Set item", "$", "item", "=", "$", "array", "[", "$", "key", "]", ";", "// If there's a callback", "if", "(", "isset", "(", "$", "callbacks", "[", "$", "key", "]", ")", "&&", "is_callable", "(", "$", "callbacks", "[", "$", "key", "]", ")", ")", "{", "// Call it", "$", "item", "=", "call_user_func_array", "(", "$", "callbacks", "[", "$", "key", "]", ",", "[", "$", "item", "]", ")", ";", "}", "// Add to extracted", "$", "extracted", "[", "$", "key", "]", "=", "$", "item", ";", "}", "}", "// Return extracted", "return", "$", "extracted", ";", "}" ]
Extract array from array with keys
[ "Extract", "array", "from", "array", "with", "keys" ]
446987706f81d5a0efbc8bd6b7d3b259d0527719
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Support/Utilities.php#L105-L125
20,628
WellCommerce/AppBundle
EventListener/LayoutBoxSubscriber.php
LayoutBoxSubscriber.onLayoutBoxFormInit
public function onLayoutBoxFormInit(FormEvent $event) { $builder = $event->getFormBuilder(); $form = $event->getForm(); $configurators = $this->container->get('layout_box.configurator.collection')->all(); $resource = $event->getResource(); $boxSettings = $resource->getSettings(); foreach ($configurators as $configurator) { if ($configurator instanceof LayoutBoxConfiguratorInterface) { $defaults = []; if ($resource->getBoxType() == $configurator->getType()) { $defaults = $boxSettings; } $configurator->addFormFields($builder, $form, $defaults); } } }
php
public function onLayoutBoxFormInit(FormEvent $event) { $builder = $event->getFormBuilder(); $form = $event->getForm(); $configurators = $this->container->get('layout_box.configurator.collection')->all(); $resource = $event->getResource(); $boxSettings = $resource->getSettings(); foreach ($configurators as $configurator) { if ($configurator instanceof LayoutBoxConfiguratorInterface) { $defaults = []; if ($resource->getBoxType() == $configurator->getType()) { $defaults = $boxSettings; } $configurator->addFormFields($builder, $form, $defaults); } } }
[ "public", "function", "onLayoutBoxFormInit", "(", "FormEvent", "$", "event", ")", "{", "$", "builder", "=", "$", "event", "->", "getFormBuilder", "(", ")", ";", "$", "form", "=", "$", "event", "->", "getForm", "(", ")", ";", "$", "configurators", "=", "$", "this", "->", "container", "->", "get", "(", "'layout_box.configurator.collection'", ")", "->", "all", "(", ")", ";", "$", "resource", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "boxSettings", "=", "$", "resource", "->", "getSettings", "(", ")", ";", "foreach", "(", "$", "configurators", "as", "$", "configurator", ")", "{", "if", "(", "$", "configurator", "instanceof", "LayoutBoxConfiguratorInterface", ")", "{", "$", "defaults", "=", "[", "]", ";", "if", "(", "$", "resource", "->", "getBoxType", "(", ")", "==", "$", "configurator", "->", "getType", "(", ")", ")", "{", "$", "defaults", "=", "$", "boxSettings", ";", "}", "$", "configurator", "->", "addFormFields", "(", "$", "builder", ",", "$", "form", ",", "$", "defaults", ")", ";", "}", "}", "}" ]
Adds configurator fields to main layout box edit form. Loops through all configurators, renders the fieldset and sets default data @param FormEvent $event
[ "Adds", "configurator", "fields", "to", "main", "layout", "box", "edit", "form", ".", "Loops", "through", "all", "configurators", "renders", "the", "fieldset", "and", "sets", "default", "data" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/EventListener/LayoutBoxSubscriber.php#L43-L61
20,629
WellCommerce/AppBundle
EventListener/LayoutBoxSubscriber.php
LayoutBoxSubscriber.onLayoutBoxPreUpdate
public function onLayoutBoxPreUpdate(EntityEvent $event) { $resource = $event->getEntity(); if ($resource instanceof LayoutBox) { $request = $this->getRequestHelper()->getCurrentRequest(); $settings = $this->getBoxSettingsFromRequest($request); $settings = $this->mergeUnmodifiedSettings($resource->getSettings(), $settings); $resource->setSettings($settings); } }
php
public function onLayoutBoxPreUpdate(EntityEvent $event) { $resource = $event->getEntity(); if ($resource instanceof LayoutBox) { $request = $this->getRequestHelper()->getCurrentRequest(); $settings = $this->getBoxSettingsFromRequest($request); $settings = $this->mergeUnmodifiedSettings($resource->getSettings(), $settings); $resource->setSettings($settings); } }
[ "public", "function", "onLayoutBoxPreUpdate", "(", "EntityEvent", "$", "event", ")", "{", "$", "resource", "=", "$", "event", "->", "getEntity", "(", ")", ";", "if", "(", "$", "resource", "instanceof", "LayoutBox", ")", "{", "$", "request", "=", "$", "this", "->", "getRequestHelper", "(", ")", "->", "getCurrentRequest", "(", ")", ";", "$", "settings", "=", "$", "this", "->", "getBoxSettingsFromRequest", "(", "$", "request", ")", ";", "$", "settings", "=", "$", "this", "->", "mergeUnmodifiedSettings", "(", "$", "resource", "->", "getSettings", "(", ")", ",", "$", "settings", ")", ";", "$", "resource", "->", "setSettings", "(", "$", "settings", ")", ";", "}", "}" ]
Sets resource settings fetched from fieldset corresponding to selected box type @param EntityEvent $event
[ "Sets", "resource", "settings", "fetched", "from", "fieldset", "corresponding", "to", "selected", "box", "type" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/EventListener/LayoutBoxSubscriber.php#L68-L77
20,630
ekuiter/feature-php
FeaturePhp/Exporter/LocalExporter.php
LocalExporter.export
public function export($product) { $files = $product->generateFiles(); mkdir($this->target, 0777, true); foreach ($files as $file) if (!$file->getContent()->copy(fphp\Helper\Path::join($this->target, $file->getTarget()))) throw new LocalExporterException("could not copy file \"{$file->getTarget()}\""); }
php
public function export($product) { $files = $product->generateFiles(); mkdir($this->target, 0777, true); foreach ($files as $file) if (!$file->getContent()->copy(fphp\Helper\Path::join($this->target, $file->getTarget()))) throw new LocalExporterException("could not copy file \"{$file->getTarget()}\""); }
[ "public", "function", "export", "(", "$", "product", ")", "{", "$", "files", "=", "$", "product", "->", "generateFiles", "(", ")", ";", "mkdir", "(", "$", "this", "->", "target", ",", "0777", ",", "true", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "if", "(", "!", "$", "file", "->", "getContent", "(", ")", "->", "copy", "(", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "this", "->", "target", ",", "$", "file", "->", "getTarget", "(", ")", ")", ")", ")", "throw", "new", "LocalExporterException", "(", "\"could not copy file \\\"{$file->getTarget()}\\\"\"", ")", ";", "}" ]
Exports a product in the local filesystem. Every generated file is copied to the filesystem at its target path. @param \FeaturePhp\ProductLine\Product $product
[ "Exports", "a", "product", "in", "the", "local", "filesystem", ".", "Every", "generated", "file", "is", "copied", "to", "the", "filesystem", "at", "its", "target", "path", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/LocalExporter.php#L44-L51
20,631
DevGroup-ru/yii2-users-module
src/scenarios/BaseAuthorizationPair.php
BaseAuthorizationPair.validatePassword
protected function validatePassword(LoginForm &$loginForm) { return [ 'password', function ($attribute) use (&$loginForm) { if ($loginForm->user === null || !PasswordHelper::validate($loginForm->password, $loginForm->user->password_hash) ) { $loginForm->addError($attribute, Yii::t('users', 'Invalid login or password')); } } ]; }
php
protected function validatePassword(LoginForm &$loginForm) { return [ 'password', function ($attribute) use (&$loginForm) { if ($loginForm->user === null || !PasswordHelper::validate($loginForm->password, $loginForm->user->password_hash) ) { $loginForm->addError($attribute, Yii::t('users', 'Invalid login or password')); } } ]; }
[ "protected", "function", "validatePassword", "(", "LoginForm", "&", "$", "loginForm", ")", "{", "return", "[", "'password'", ",", "function", "(", "$", "attribute", ")", "use", "(", "&", "$", "loginForm", ")", "{", "if", "(", "$", "loginForm", "->", "user", "===", "null", "||", "!", "PasswordHelper", "::", "validate", "(", "$", "loginForm", "->", "password", ",", "$", "loginForm", "->", "user", "->", "password_hash", ")", ")", "{", "$", "loginForm", "->", "addError", "(", "$", "attribute", ",", "Yii", "::", "t", "(", "'users'", ",", "'Invalid login or password'", ")", ")", ";", "}", "}", "]", ";", "}" ]
Adds password validation rule for login scenario @param \DevGroup\Users\models\LoginForm $loginForm @return array
[ "Adds", "password", "validation", "rule", "for", "login", "scenario" ]
ff0103dc55c3462627ccc704c33e70c96053f750
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/scenarios/BaseAuthorizationPair.php#L105-L117
20,632
DevGroup-ru/yii2-users-module
src/scenarios/BaseAuthorizationPair.php
BaseAuthorizationPair.inactiveUsers
protected function inactiveUsers(LoginForm &$loginForm) { if (UsersModule::module()->allowLoginInactiveAccounts === false) { return []; } return [ 'username', function ($attribute) use (&$loginForm) { if ($loginForm->user !== null && $loginForm->user->is_active === false) { $loginForm->addError($attribute, Yii::t('users', 'You need to confirm your email address')); } } ]; }
php
protected function inactiveUsers(LoginForm &$loginForm) { if (UsersModule::module()->allowLoginInactiveAccounts === false) { return []; } return [ 'username', function ($attribute) use (&$loginForm) { if ($loginForm->user !== null && $loginForm->user->is_active === false) { $loginForm->addError($attribute, Yii::t('users', 'You need to confirm your email address')); } } ]; }
[ "protected", "function", "inactiveUsers", "(", "LoginForm", "&", "$", "loginForm", ")", "{", "if", "(", "UsersModule", "::", "module", "(", ")", "->", "allowLoginInactiveAccounts", "===", "false", ")", "{", "return", "[", "]", ";", "}", "return", "[", "'username'", ",", "function", "(", "$", "attribute", ")", "use", "(", "&", "$", "loginForm", ")", "{", "if", "(", "$", "loginForm", "->", "user", "!==", "null", "&&", "$", "loginForm", "->", "user", "->", "is_active", "===", "false", ")", "{", "$", "loginForm", "->", "addError", "(", "$", "attribute", ",", "Yii", "::", "t", "(", "'users'", ",", "'You need to confirm your email address'", ")", ")", ";", "}", "}", "]", ";", "}" ]
Adds validation rule to not accept inactive users if such feature is toggled on in module configuration. @param \DevGroup\Users\models\LoginForm $loginForm @return array
[ "Adds", "validation", "rule", "to", "not", "accept", "inactive", "users", "if", "such", "feature", "is", "toggled", "on", "in", "module", "configuration", "." ]
ff0103dc55c3462627ccc704c33e70c96053f750
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/scenarios/BaseAuthorizationPair.php#L126-L139
20,633
mikebarlow/html-helper
src/Html.php
Html.tag
public function tag($tag, $attr = null, $content = null, $close = false) { $tag = strtolower($tag); if (! empty($attr) && is_array($attr)) { $attr = $this->Attr->attr($attr); } if ($close) { return sprintf('<%s%s>%s</%1$s>', $tag, $attr, $content); } else { return sprintf('<%s%s>', $tag, $attr); } }
php
public function tag($tag, $attr = null, $content = null, $close = false) { $tag = strtolower($tag); if (! empty($attr) && is_array($attr)) { $attr = $this->Attr->attr($attr); } if ($close) { return sprintf('<%s%s>%s</%1$s>', $tag, $attr, $content); } else { return sprintf('<%s%s>', $tag, $attr); } }
[ "public", "function", "tag", "(", "$", "tag", ",", "$", "attr", "=", "null", ",", "$", "content", "=", "null", ",", "$", "close", "=", "false", ")", "{", "$", "tag", "=", "strtolower", "(", "$", "tag", ")", ";", "if", "(", "!", "empty", "(", "$", "attr", ")", "&&", "is_array", "(", "$", "attr", ")", ")", "{", "$", "attr", "=", "$", "this", "->", "Attr", "->", "attr", "(", "$", "attr", ")", ";", "}", "if", "(", "$", "close", ")", "{", "return", "sprintf", "(", "'<%s%s>%s</%1$s>'", ",", "$", "tag", ",", "$", "attr", ",", "$", "content", ")", ";", "}", "else", "{", "return", "sprintf", "(", "'<%s%s>'", ",", "$", "tag", ",", "$", "attr", ")", ";", "}", "}" ]
render a tag @param string tag to render @param array attributes for the tag @param string contents of tag when not self closing @param bool close the tag? @return string
[ "render", "a", "tag" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L50-L63
20,634
mikebarlow/html-helper
src/Html.php
Html.processList
public function processList($list, $subListType = 'ul') { $out = ''; foreach ($list as $key => $value) { if (is_array($value) && (isset($value['list']) || isset($value['attr']))) { $attr = (isset($value['attr'])) ? $value['attr'] : null; $listAttr = (isset($value['listAttr'])) ? $value['listAttr'] : null; $subList = (isset($value['list'])) ? $this->{$subListType}($value['list'], $listAttr) : ''; $out .= $this->tag('li', $attr, $key . $subList, true); } elseif (is_array($value)) { $out .= $this->tag('li', null, $key . $this->{$subListType}($value), true); } else { $out .= $this->tag('li', null, $value, true); } } return $out; }
php
public function processList($list, $subListType = 'ul') { $out = ''; foreach ($list as $key => $value) { if (is_array($value) && (isset($value['list']) || isset($value['attr']))) { $attr = (isset($value['attr'])) ? $value['attr'] : null; $listAttr = (isset($value['listAttr'])) ? $value['listAttr'] : null; $subList = (isset($value['list'])) ? $this->{$subListType}($value['list'], $listAttr) : ''; $out .= $this->tag('li', $attr, $key . $subList, true); } elseif (is_array($value)) { $out .= $this->tag('li', null, $key . $this->{$subListType}($value), true); } else { $out .= $this->tag('li', null, $value, true); } } return $out; }
[ "public", "function", "processList", "(", "$", "list", ",", "$", "subListType", "=", "'ul'", ")", "{", "$", "out", "=", "''", ";", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "(", "isset", "(", "$", "value", "[", "'list'", "]", ")", "||", "isset", "(", "$", "value", "[", "'attr'", "]", ")", ")", ")", "{", "$", "attr", "=", "(", "isset", "(", "$", "value", "[", "'attr'", "]", ")", ")", "?", "$", "value", "[", "'attr'", "]", ":", "null", ";", "$", "listAttr", "=", "(", "isset", "(", "$", "value", "[", "'listAttr'", "]", ")", ")", "?", "$", "value", "[", "'listAttr'", "]", ":", "null", ";", "$", "subList", "=", "(", "isset", "(", "$", "value", "[", "'list'", "]", ")", ")", "?", "$", "this", "->", "{", "$", "subListType", "}", "(", "$", "value", "[", "'list'", "]", ",", "$", "listAttr", ")", ":", "''", ";", "$", "out", ".=", "$", "this", "->", "tag", "(", "'li'", ",", "$", "attr", ",", "$", "key", ".", "$", "subList", ",", "true", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "out", ".=", "$", "this", "->", "tag", "(", "'li'", ",", "null", ",", "$", "key", ".", "$", "this", "->", "{", "$", "subListType", "}", "(", "$", "value", ")", ",", "true", ")", ";", "}", "else", "{", "$", "out", ".=", "$", "this", "->", "tag", "(", "'li'", ",", "null", ",", "$", "value", ",", "true", ")", ";", "}", "}", "return", "$", "out", ";", "}" ]
process list items @todo add ability to define sublists from within the list @param array Array of list items to process @param string method to use for sub-lists @return string
[ "process", "list", "items" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L137-L156
20,635
mikebarlow/html-helper
src/Html.php
Html.image
public function image($src, $attr = array()) { $src = $this->Assets->getImage($src); $attr['src'] = $src; return $this->tag('img', $attr); }
php
public function image($src, $attr = array()) { $src = $this->Assets->getImage($src); $attr['src'] = $src; return $this->tag('img', $attr); }
[ "public", "function", "image", "(", "$", "src", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "src", "=", "$", "this", "->", "Assets", "->", "getImage", "(", "$", "src", ")", ";", "$", "attr", "[", "'src'", "]", "=", "$", "src", ";", "return", "$", "this", "->", "tag", "(", "'img'", ",", "$", "attr", ")", ";", "}" ]
create an image @param mixed image path data - will be passed to the assets interface for processing @param array attributes to be placed on the img tag @return string
[ "create", "an", "image" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L180-L185
20,636
mikebarlow/html-helper
src/Html.php
Html.style
public function style($src, $attr = array()) { $src = $this->Assets->getStyle($src); $attr['href'] = $src; $attr = array_merge( array( 'media' => 'screen', 'rel' => 'stylesheet', 'type' => 'text/css' ), $attr ); return $this->tag('link', $attr); }
php
public function style($src, $attr = array()) { $src = $this->Assets->getStyle($src); $attr['href'] = $src; $attr = array_merge( array( 'media' => 'screen', 'rel' => 'stylesheet', 'type' => 'text/css' ), $attr ); return $this->tag('link', $attr); }
[ "public", "function", "style", "(", "$", "src", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "src", "=", "$", "this", "->", "Assets", "->", "getStyle", "(", "$", "src", ")", ";", "$", "attr", "[", "'href'", "]", "=", "$", "src", ";", "$", "attr", "=", "array_merge", "(", "array", "(", "'media'", "=>", "'screen'", ",", "'rel'", "=>", "'stylesheet'", ",", "'type'", "=>", "'text/css'", ")", ",", "$", "attr", ")", ";", "return", "$", "this", "->", "tag", "(", "'link'", ",", "$", "attr", ")", ";", "}" ]
create a style link @param mixed style path data - will be passed to the assets interface for processing @param array attributes to be placed on the link tag @return string
[ "create", "a", "style", "link" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L194-L209
20,637
mikebarlow/html-helper
src/Html.php
Html.script
public function script($src, $attr = array()) { $src = $this->Assets->getScript($src); $attr['src'] = $src; return $this->tag('script', $attr, '', true); }
php
public function script($src, $attr = array()) { $src = $this->Assets->getScript($src); $attr['src'] = $src; return $this->tag('script', $attr, '', true); }
[ "public", "function", "script", "(", "$", "src", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "src", "=", "$", "this", "->", "Assets", "->", "getScript", "(", "$", "src", ")", ";", "$", "attr", "[", "'src'", "]", "=", "$", "src", ";", "return", "$", "this", "->", "tag", "(", "'script'", ",", "$", "attr", ",", "''", ",", "true", ")", ";", "}" ]
create a script tag @param mixed script path data - will be passed to the assets interface for processing @param array attributes to be placed on the script tag @return string
[ "create", "a", "script", "tag" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L218-L223
20,638
mikebarlow/html-helper
src/Html.php
Html.setRouter
public function setRouter($Router) { if (! is_object($Router) || ! $Router instanceof Router) { throw new \InvalidArgumentException( 'The Router Interface must be a valid Router Object' ); } $this->Router = $Router; return true; }
php
public function setRouter($Router) { if (! is_object($Router) || ! $Router instanceof Router) { throw new \InvalidArgumentException( 'The Router Interface must be a valid Router Object' ); } $this->Router = $Router; return true; }
[ "public", "function", "setRouter", "(", "$", "Router", ")", "{", "if", "(", "!", "is_object", "(", "$", "Router", ")", "||", "!", "$", "Router", "instanceof", "Router", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The Router Interface must be a valid Router Object'", ")", ";", "}", "$", "this", "->", "Router", "=", "$", "Router", ";", "return", "true", ";", "}" ]
check and set the router interface @param Object Instance of an Router @return bool @throws \InvalidArgumentException
[ "check", "and", "set", "the", "router", "interface" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L232-L242
20,639
mikebarlow/html-helper
src/Html.php
Html.setAssets
public function setAssets($Assets) { if (! is_object($Assets) || ! $Assets instanceof Assets) { throw new \InvalidArgumentException( 'The Assets Interface must be a valid Assets Object' ); } $this->Assets = $Assets; return true; }
php
public function setAssets($Assets) { if (! is_object($Assets) || ! $Assets instanceof Assets) { throw new \InvalidArgumentException( 'The Assets Interface must be a valid Assets Object' ); } $this->Assets = $Assets; return true; }
[ "public", "function", "setAssets", "(", "$", "Assets", ")", "{", "if", "(", "!", "is_object", "(", "$", "Assets", ")", "||", "!", "$", "Assets", "instanceof", "Assets", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The Assets Interface must be a valid Assets Object'", ")", ";", "}", "$", "this", "->", "Assets", "=", "$", "Assets", ";", "return", "true", ";", "}" ]
check and set the Asset interface @param Object Instance of an Assets @return bool @throws \InvalidArgumentException
[ "check", "and", "set", "the", "Asset", "interface" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L251-L261
20,640
mikebarlow/html-helper
src/Html.php
Html.setForm
public function setForm($Form) { if (! is_object($Form) || ! $Form instanceof Helpers\Form) { throw new \InvalidArgumentException( 'The Form Object must be a valid Helpers\Form Object' ); } $this->Form = $Form; return true; }
php
public function setForm($Form) { if (! is_object($Form) || ! $Form instanceof Helpers\Form) { throw new \InvalidArgumentException( 'The Form Object must be a valid Helpers\Form Object' ); } $this->Form = $Form; return true; }
[ "public", "function", "setForm", "(", "$", "Form", ")", "{", "if", "(", "!", "is_object", "(", "$", "Form", ")", "||", "!", "$", "Form", "instanceof", "Helpers", "\\", "Form", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The Form Object must be a valid Helpers\\Form Object'", ")", ";", "}", "$", "this", "->", "Form", "=", "$", "Form", ";", "return", "true", ";", "}" ]
check and set the Form Object @param Object Instance of an Helpers\Form @return bool @throws \InvalidArgumentException
[ "check", "and", "set", "the", "Form", "Object" ]
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Html.php#L270-L280
20,641
gpupo/common-schema
src/ORM/Entity/Trading/Trading.php
Trading.removePayment
public function removePayment(\Gpupo\CommonSchema\ORM\Entity\Trading\Payment\Payment $payment) { return $this->payments->removeElement($payment); }
php
public function removePayment(\Gpupo\CommonSchema\ORM\Entity\Trading\Payment\Payment $payment) { return $this->payments->removeElement($payment); }
[ "public", "function", "removePayment", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Trading", "\\", "Payment", "\\", "Payment", "$", "payment", ")", "{", "return", "$", "this", "->", "payments", "->", "removeElement", "(", "$", "payment", ")", ";", "}" ]
Remove payment. @param \Gpupo\CommonSchema\ORM\Entity\Trading\Payment\Payment $payment @return bool TRUE if this collection contained the specified element, FALSE otherwise
[ "Remove", "payment", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Trading/Trading.php#L138-L141
20,642
wenbinye/PhalconX
src/Mvc/ViewHelper.php
ViewHelper.baseUrl
public function baseUrl() { if (!$this->baseUrl) { $this->baseUrl = $this->request->getScheme() . '://' . $this->request->getHttpHost(); } return $this->baseUrl; }
php
public function baseUrl() { if (!$this->baseUrl) { $this->baseUrl = $this->request->getScheme() . '://' . $this->request->getHttpHost(); } return $this->baseUrl; }
[ "public", "function", "baseUrl", "(", ")", "{", "if", "(", "!", "$", "this", "->", "baseUrl", ")", "{", "$", "this", "->", "baseUrl", "=", "$", "this", "->", "request", "->", "getScheme", "(", ")", ".", "'://'", ".", "$", "this", "->", "request", "->", "getHttpHost", "(", ")", ";", "}", "return", "$", "this", "->", "baseUrl", ";", "}" ]
Gets the base url @return string
[ "Gets", "the", "base", "url" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/ViewHelper.php#L66-L73
20,643
wenbinye/PhalconX
src/Mvc/ViewHelper.php
ViewHelper.absoluteUrl
public function absoluteUrl($uri = null, $args = null) { if (isset($uri)) { $uri = '/'. ltrim($uri, "/"); return $this->baseUrl() . $this->url->get($uri, $args); } else { return $this->baseUrl() . $this->url->getBaseUri(); } }
php
public function absoluteUrl($uri = null, $args = null) { if (isset($uri)) { $uri = '/'. ltrim($uri, "/"); return $this->baseUrl() . $this->url->get($uri, $args); } else { return $this->baseUrl() . $this->url->getBaseUri(); } }
[ "public", "function", "absoluteUrl", "(", "$", "uri", "=", "null", ",", "$", "args", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "uri", ")", ")", "{", "$", "uri", "=", "'/'", ".", "ltrim", "(", "$", "uri", ",", "\"/\"", ")", ";", "return", "$", "this", "->", "baseUrl", "(", ")", ".", "$", "this", "->", "url", "->", "get", "(", "$", "uri", ",", "$", "args", ")", ";", "}", "else", "{", "return", "$", "this", "->", "baseUrl", "(", ")", ".", "$", "this", "->", "url", "->", "getBaseUri", "(", ")", ";", "}", "}" ]
Gets absolute url @return string
[ "Gets", "absolute", "url" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/ViewHelper.php#L80-L88
20,644
wenbinye/PhalconX
src/Mvc/ViewHelper.php
ViewHelper.ltrim
public function ltrim($str, $charlist = null) { return isset($charlist) ? ltrim($str, $charlist) : ltrim($str); }
php
public function ltrim($str, $charlist = null) { return isset($charlist) ? ltrim($str, $charlist) : ltrim($str); }
[ "public", "function", "ltrim", "(", "$", "str", ",", "$", "charlist", "=", "null", ")", "{", "return", "isset", "(", "$", "charlist", ")", "?", "ltrim", "(", "$", "str", ",", "$", "charlist", ")", ":", "ltrim", "(", "$", "str", ")", ";", "}" ]
left trim string @param string $str @param array $charlist @return string
[ "left", "trim", "string" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/ViewHelper.php#L109-L112
20,645
wenbinye/PhalconX
src/Mvc/ViewHelper.php
ViewHelper.rtrim
public function rtrim($str, $charlist = null) { return isset($charlist) ? rtrim($str, $charlist) : rtrim($str); }
php
public function rtrim($str, $charlist = null) { return isset($charlist) ? rtrim($str, $charlist) : rtrim($str); }
[ "public", "function", "rtrim", "(", "$", "str", ",", "$", "charlist", "=", "null", ")", "{", "return", "isset", "(", "$", "charlist", ")", "?", "rtrim", "(", "$", "str", ",", "$", "charlist", ")", ":", "rtrim", "(", "$", "str", ")", ";", "}" ]
right trim string @param string $str @param array $charlist @return string
[ "right", "trim", "string" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/ViewHelper.php#L121-L124
20,646
phpnfe/tools
src/Certificado/Pkcs12.php
Pkcs12.zSignatureExists
private function zSignatureExists($dom) { $signature = $dom->getElementsByTagName('Signature')->item(0); if (! isset($signature)) { return false; } return true; }
php
private function zSignatureExists($dom) { $signature = $dom->getElementsByTagName('Signature')->item(0); if (! isset($signature)) { return false; } return true; }
[ "private", "function", "zSignatureExists", "(", "$", "dom", ")", "{", "$", "signature", "=", "$", "dom", "->", "getElementsByTagName", "(", "'Signature'", ")", "->", "item", "(", "0", ")", ";", "if", "(", "!", "isset", "(", "$", "signature", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
signatureExists Check se o xml possi a tag Signature. @param DOMDocument $dom @return bool
[ "signatureExists", "Check", "se", "o", "xml", "possi", "a", "tag", "Signature", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Pkcs12.php#L511-L519
20,647
phpnfe/tools
src/Certificado/Pkcs12.php
Pkcs12.zLeaveParam
private function zLeaveParam() { $this->pfxCert = ''; $this->pubKey = ''; $this->priKey = ''; $this->certKey = ''; $this->pubKeyFile = ''; $this->priKeyFile = ''; $this->certKeyFile = ''; $this->expireTimestamp = ''; }
php
private function zLeaveParam() { $this->pfxCert = ''; $this->pubKey = ''; $this->priKey = ''; $this->certKey = ''; $this->pubKeyFile = ''; $this->priKeyFile = ''; $this->certKeyFile = ''; $this->expireTimestamp = ''; }
[ "private", "function", "zLeaveParam", "(", ")", "{", "$", "this", "->", "pfxCert", "=", "''", ";", "$", "this", "->", "pubKey", "=", "''", ";", "$", "this", "->", "priKey", "=", "''", ";", "$", "this", "->", "certKey", "=", "''", ";", "$", "this", "->", "pubKeyFile", "=", "''", ";", "$", "this", "->", "priKeyFile", "=", "''", ";", "$", "this", "->", "certKeyFile", "=", "''", ";", "$", "this", "->", "expireTimestamp", "=", "''", ";", "}" ]
zLeaveParam Limpa os parametros da classe.
[ "zLeaveParam", "Limpa", "os", "parametros", "da", "classe", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Pkcs12.php#L737-L747
20,648
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/DescriptorAbstract.php
DescriptorAbstract.getPackage
public function getPackage() { $inheritedElement = $this->getInheritedElement(); if ($this->package instanceof PackageDescriptor && ! ($this->package->getName() === '\\' && $inheritedElement)) { return $this->package; } if ($inheritedElement instanceof DescriptorAbstract) { return $inheritedElement->getPackage(); } return null; }
php
public function getPackage() { $inheritedElement = $this->getInheritedElement(); if ($this->package instanceof PackageDescriptor && ! ($this->package->getName() === '\\' && $inheritedElement)) { return $this->package; } if ($inheritedElement instanceof DescriptorAbstract) { return $inheritedElement->getPackage(); } return null; }
[ "public", "function", "getPackage", "(", ")", "{", "$", "inheritedElement", "=", "$", "this", "->", "getInheritedElement", "(", ")", ";", "if", "(", "$", "this", "->", "package", "instanceof", "PackageDescriptor", "&&", "!", "(", "$", "this", "->", "package", "->", "getName", "(", ")", "===", "'\\\\'", "&&", "$", "inheritedElement", ")", ")", "{", "return", "$", "this", "->", "package", ";", "}", "if", "(", "$", "inheritedElement", "instanceof", "DescriptorAbstract", ")", "{", "return", "$", "inheritedElement", "->", "getPackage", "(", ")", ";", "}", "return", "null", ";", "}" ]
Returns the package name for this element. @return PackageDescriptor
[ "Returns", "the", "package", "name", "for", "this", "element", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/DescriptorAbstract.php#L306-L319
20,649
wenbinye/PhalconX
src/Php/NodeVisitor.php
NodeVisitor.buildMethods
protected function buildMethods() { $refl = new \ReflectionClass($this); $enterMethods = []; $leaveMethods = []; foreach ($refl->getMethods() as $method) { $name = $method->getName(); if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) { $params = $method->getParameters(); if ($params && $params[0]->getClass()) { $nodeType = $params[0]->getClass()->getName(); if (Text::startsWith($name, 'enter')) { $enterMethods[$nodeType][] = $name; } else { $leaveMethods[$nodeType][] = $name; } } } } self::$enterMethods[get_class($this)] = $enterMethods; self::$leaveMethods[get_class($this)] = $leaveMethods; }
php
protected function buildMethods() { $refl = new \ReflectionClass($this); $enterMethods = []; $leaveMethods = []; foreach ($refl->getMethods() as $method) { $name = $method->getName(); if (preg_match('/^(enter|leave).+/', $name) && !preg_match('/^(enter|leave)Node$/', $name)) { $params = $method->getParameters(); if ($params && $params[0]->getClass()) { $nodeType = $params[0]->getClass()->getName(); if (Text::startsWith($name, 'enter')) { $enterMethods[$nodeType][] = $name; } else { $leaveMethods[$nodeType][] = $name; } } } } self::$enterMethods[get_class($this)] = $enterMethods; self::$leaveMethods[get_class($this)] = $leaveMethods; }
[ "protected", "function", "buildMethods", "(", ")", "{", "$", "refl", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "enterMethods", "=", "[", "]", ";", "$", "leaveMethods", "=", "[", "]", ";", "foreach", "(", "$", "refl", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "name", "=", "$", "method", "->", "getName", "(", ")", ";", "if", "(", "preg_match", "(", "'/^(enter|leave).+/'", ",", "$", "name", ")", "&&", "!", "preg_match", "(", "'/^(enter|leave)Node$/'", ",", "$", "name", ")", ")", "{", "$", "params", "=", "$", "method", "->", "getParameters", "(", ")", ";", "if", "(", "$", "params", "&&", "$", "params", "[", "0", "]", "->", "getClass", "(", ")", ")", "{", "$", "nodeType", "=", "$", "params", "[", "0", "]", "->", "getClass", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "Text", "::", "startsWith", "(", "$", "name", ",", "'enter'", ")", ")", "{", "$", "enterMethods", "[", "$", "nodeType", "]", "[", "]", "=", "$", "name", ";", "}", "else", "{", "$", "leaveMethods", "[", "$", "nodeType", "]", "[", "]", "=", "$", "name", ";", "}", "}", "}", "}", "self", "::", "$", "enterMethods", "[", "get_class", "(", "$", "this", ")", "]", "=", "$", "enterMethods", ";", "self", "::", "$", "leaveMethods", "[", "get_class", "(", "$", "this", ")", "]", "=", "$", "leaveMethods", ";", "}" ]
collect all rule method according to node type of parameter
[ "collect", "all", "rule", "method", "according", "to", "node", "type", "of", "parameter" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Php/NodeVisitor.php#L57-L79
20,650
trunda/SmfMenu
src/Smf/Menu/Renderer/BootstrapNavRenderer.php
BootstrapNavRenderer.setDefaults
protected function setDefaults(array $defaultOptions = array()) { $defaultOptions = array_merge(array( 'depth' => null, 'ancestorCurrencyDepth' => null, 'currentClass' => 'active', 'ancestorClass' => 'active', 'firstClass' => null, 'lastClass' => null ), $defaultOptions); parent::setDefaults($defaultOptions); }
php
protected function setDefaults(array $defaultOptions = array()) { $defaultOptions = array_merge(array( 'depth' => null, 'ancestorCurrencyDepth' => null, 'currentClass' => 'active', 'ancestorClass' => 'active', 'firstClass' => null, 'lastClass' => null ), $defaultOptions); parent::setDefaults($defaultOptions); }
[ "protected", "function", "setDefaults", "(", "array", "$", "defaultOptions", "=", "array", "(", ")", ")", "{", "$", "defaultOptions", "=", "array_merge", "(", "array", "(", "'depth'", "=>", "null", ",", "'ancestorCurrencyDepth'", "=>", "null", ",", "'currentClass'", "=>", "'active'", ",", "'ancestorClass'", "=>", "'active'", ",", "'firstClass'", "=>", "null", ",", "'lastClass'", "=>", "null", ")", ",", "$", "defaultOptions", ")", ";", "parent", "::", "setDefaults", "(", "$", "defaultOptions", ")", ";", "}" ]
Overwriting some options - classes, etc. @param array $defaultOptions
[ "Overwriting", "some", "options", "-", "classes", "etc", "." ]
739e74fb664c1f018b4a74142bd28d20c004bac6
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Renderer/BootstrapNavRenderer.php#L19-L31
20,651
dragonmantank/fillet
src/Fillet/Writer/PostWriter.php
PostWriter.write
public function write($data) { $post_date_string = $data['post_date']->format('Y-m-d H:i:s'); $slug = $this->generateSlug($data['title']); $filename = $data['post_date']->format('Y-m-d') . '-' . $slug; $headerData = [ 'title' => $data['title'], 'date' => $post_date_string, 'layout' => 'post', 'slug' => $slug, 'categories' => $data['categories'], 'tags' => $data['tags'], ]; $dumper = new YamlDumper(); $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; $filename = $this->destinationFolder . $filename; if ($this->isMarkdownEnabled()) { $filename .= '.md'; $data['content'] = $this->toMarkdown($data['content']); } else { $filename .= '.html'; } file_put_contents($filename, $header . PHP_EOL . $data['content']); }
php
public function write($data) { $post_date_string = $data['post_date']->format('Y-m-d H:i:s'); $slug = $this->generateSlug($data['title']); $filename = $data['post_date']->format('Y-m-d') . '-' . $slug; $headerData = [ 'title' => $data['title'], 'date' => $post_date_string, 'layout' => 'post', 'slug' => $slug, 'categories' => $data['categories'], 'tags' => $data['tags'], ]; $dumper = new YamlDumper(); $header = '---' . PHP_EOL . $dumper->dump($headerData, 2) . '---' . PHP_EOL; $filename = $this->destinationFolder . $filename; if ($this->isMarkdownEnabled()) { $filename .= '.md'; $data['content'] = $this->toMarkdown($data['content']); } else { $filename .= '.html'; } file_put_contents($filename, $header . PHP_EOL . $data['content']); }
[ "public", "function", "write", "(", "$", "data", ")", "{", "$", "post_date_string", "=", "$", "data", "[", "'post_date'", "]", "->", "format", "(", "'Y-m-d H:i:s'", ")", ";", "$", "slug", "=", "$", "this", "->", "generateSlug", "(", "$", "data", "[", "'title'", "]", ")", ";", "$", "filename", "=", "$", "data", "[", "'post_date'", "]", "->", "format", "(", "'Y-m-d'", ")", ".", "'-'", ".", "$", "slug", ";", "$", "headerData", "=", "[", "'title'", "=>", "$", "data", "[", "'title'", "]", ",", "'date'", "=>", "$", "post_date_string", ",", "'layout'", "=>", "'post'", ",", "'slug'", "=>", "$", "slug", ",", "'categories'", "=>", "$", "data", "[", "'categories'", "]", ",", "'tags'", "=>", "$", "data", "[", "'tags'", "]", ",", "]", ";", "$", "dumper", "=", "new", "YamlDumper", "(", ")", ";", "$", "header", "=", "'---'", ".", "PHP_EOL", ".", "$", "dumper", "->", "dump", "(", "$", "headerData", ",", "2", ")", ".", "'---'", ".", "PHP_EOL", ";", "$", "filename", "=", "$", "this", "->", "destinationFolder", ".", "$", "filename", ";", "if", "(", "$", "this", "->", "isMarkdownEnabled", "(", ")", ")", "{", "$", "filename", ".=", "'.md'", ";", "$", "data", "[", "'content'", "]", "=", "$", "this", "->", "toMarkdown", "(", "$", "data", "[", "'content'", "]", ")", ";", "}", "else", "{", "$", "filename", ".=", "'.html'", ";", "}", "file_put_contents", "(", "$", "filename", ",", "$", "header", ".", "PHP_EOL", ".", "$", "data", "[", "'content'", "]", ")", ";", "}" ]
Write out a set of data into a file @param array $data Data to use for constructing the page
[ "Write", "out", "a", "set", "of", "data", "into", "a", "file" ]
b197947608c05ac2318e8f6b296345494004d9c6
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Writer/PostWriter.php#L19-L45
20,652
kuria/url
src/Url.php
Url.parse
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE) { $components = parse_url($url); if ($components === false) { throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url)); } $query = []; if (isset($components['query'])) { parse_str($components['query'], $query); } return new static( $components['scheme'] ?? null, $components['host'] ?? null, $components['port'] ?? null, $components['path'] ?? '', $query, $components['fragment'] ?? null, $preferredFormat ); }
php
static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE) { $components = parse_url($url); if ($components === false) { throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url)); } $query = []; if (isset($components['query'])) { parse_str($components['query'], $query); } return new static( $components['scheme'] ?? null, $components['host'] ?? null, $components['port'] ?? null, $components['path'] ?? '', $query, $components['fragment'] ?? null, $preferredFormat ); }
[ "static", "function", "parse", "(", "string", "$", "url", ",", "?", "int", "$", "preferredFormat", "=", "self", "::", "ABSOLUTE", ")", "{", "$", "components", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "$", "components", "===", "false", ")", "{", "throw", "new", "InvalidUrlException", "(", "sprintf", "(", "'The given URL \"%s\" is invalid'", ",", "$", "url", ")", ")", ";", "}", "$", "query", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "components", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "components", "[", "'query'", "]", ",", "$", "query", ")", ";", "}", "return", "new", "static", "(", "$", "components", "[", "'scheme'", "]", "??", "null", ",", "$", "components", "[", "'host'", "]", "??", "null", ",", "$", "components", "[", "'port'", "]", "??", "null", ",", "$", "components", "[", "'path'", "]", "??", "''", ",", "$", "query", ",", "$", "components", "[", "'fragment'", "]", "??", "null", ",", "$", "preferredFormat", ")", ";", "}" ]
Parse an URL @throws InvalidUrlException if the URL is invalid @return static
[ "Parse", "an", "URL" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L63-L86
20,653
kuria/url
src/Url.php
Url.getFullHost
function getFullHost(): ?string { if ($this->host === null) { return null; } $fullHost = $this->host; if ($this->port !== null) { $fullHost .= ':' . $this->port; } return $fullHost; }
php
function getFullHost(): ?string { if ($this->host === null) { return null; } $fullHost = $this->host; if ($this->port !== null) { $fullHost .= ':' . $this->port; } return $fullHost; }
[ "function", "getFullHost", "(", ")", ":", "?", "string", "{", "if", "(", "$", "this", "->", "host", "===", "null", ")", "{", "return", "null", ";", "}", "$", "fullHost", "=", "$", "this", "->", "host", ";", "if", "(", "$", "this", "->", "port", "!==", "null", ")", "{", "$", "fullHost", ".=", "':'", ".", "$", "this", "->", "port", ";", "}", "return", "$", "fullHost", ";", "}" ]
Get host name, including the port, if defined E.g. example.com:8080
[ "Get", "host", "name", "including", "the", "port", "if", "defined" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L113-L126
20,654
kuria/url
src/Url.php
Url.add
function add(array $parameters): void { foreach ($parameters as $parameter => $value) { $this->query[$parameter] = $value; } }
php
function add(array $parameters): void { foreach ($parameters as $parameter => $value) { $this->query[$parameter] = $value; } }
[ "function", "add", "(", "array", "$", "parameters", ")", ":", "void", "{", "foreach", "(", "$", "parameters", "as", "$", "parameter", "=>", "$", "value", ")", "{", "$", "this", "->", "query", "[", "$", "parameter", "]", "=", "$", "value", ";", "}", "}" ]
Add multiple query parameters Already defined parameters with the same key will be overriden.
[ "Add", "multiple", "query", "parameters" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L258-L263
20,655
kuria/url
src/Url.php
Url.build
function build(): string { if ($this->host !== null && $this->preferredFormat === static::ABSOLUTE) { return $this->buildAbsolute(); } else { return $this->buildRelative(); } }
php
function build(): string { if ($this->host !== null && $this->preferredFormat === static::ABSOLUTE) { return $this->buildAbsolute(); } else { return $this->buildRelative(); } }
[ "function", "build", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "host", "!==", "null", "&&", "$", "this", "->", "preferredFormat", "===", "static", "::", "ABSOLUTE", ")", "{", "return", "$", "this", "->", "buildAbsolute", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "buildRelative", "(", ")", ";", "}", "}" ]
Build an absolute or relative URL - if no host is specified, a relative URL will be returned - if the host is specified, an absolute URL will be returned (unless the preferred format option is set to relative) @see Url::setPreferredFormat()
[ "Build", "an", "absolute", "or", "relative", "URL" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L292-L299
20,656
kuria/url
src/Url.php
Url.buildAbsolute
function buildAbsolute(): string { $output = ''; if ($this->host === null) { throw new IncompleteUrlException('No host specified'); } // scheme if ($this->scheme !== null) { $output .= $this->scheme; $output .= '://'; } else { // protocol-relative $output .= '//'; } // host, port $output .= $this->getFullHost(); // ensure a forward slash between host and a non-empty path if ($this->path !== '' && $this->path[0] !== '/') { $output .= '/'; } // path, query, fragment $output .= $this->buildRelative(); return $output; }
php
function buildAbsolute(): string { $output = ''; if ($this->host === null) { throw new IncompleteUrlException('No host specified'); } // scheme if ($this->scheme !== null) { $output .= $this->scheme; $output .= '://'; } else { // protocol-relative $output .= '//'; } // host, port $output .= $this->getFullHost(); // ensure a forward slash between host and a non-empty path if ($this->path !== '' && $this->path[0] !== '/') { $output .= '/'; } // path, query, fragment $output .= $this->buildRelative(); return $output; }
[ "function", "buildAbsolute", "(", ")", ":", "string", "{", "$", "output", "=", "''", ";", "if", "(", "$", "this", "->", "host", "===", "null", ")", "{", "throw", "new", "IncompleteUrlException", "(", "'No host specified'", ")", ";", "}", "// scheme", "if", "(", "$", "this", "->", "scheme", "!==", "null", ")", "{", "$", "output", ".=", "$", "this", "->", "scheme", ";", "$", "output", ".=", "'://'", ";", "}", "else", "{", "// protocol-relative", "$", "output", ".=", "'//'", ";", "}", "// host, port", "$", "output", ".=", "$", "this", "->", "getFullHost", "(", ")", ";", "// ensure a forward slash between host and a non-empty path", "if", "(", "$", "this", "->", "path", "!==", "''", "&&", "$", "this", "->", "path", "[", "0", "]", "!==", "'/'", ")", "{", "$", "output", ".=", "'/'", ";", "}", "// path, query, fragment", "$", "output", ".=", "$", "this", "->", "buildRelative", "(", ")", ";", "return", "$", "output", ";", "}" ]
Build an absolute URL @throws IncompleteUrlException if no host is specified
[ "Build", "an", "absolute", "URL" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L306-L335
20,657
kuria/url
src/Url.php
Url.buildRelative
function buildRelative(): string { $output = ''; // path $output .= $this->path; // query if ($this->query) { $output .= '?'; $output .= $this->getQueryString(); } // fragment if ($this->fragment !== null) { $output .= '#'; $output .= $this->fragment; } return $output; }
php
function buildRelative(): string { $output = ''; // path $output .= $this->path; // query if ($this->query) { $output .= '?'; $output .= $this->getQueryString(); } // fragment if ($this->fragment !== null) { $output .= '#'; $output .= $this->fragment; } return $output; }
[ "function", "buildRelative", "(", ")", ":", "string", "{", "$", "output", "=", "''", ";", "// path", "$", "output", ".=", "$", "this", "->", "path", ";", "// query", "if", "(", "$", "this", "->", "query", ")", "{", "$", "output", ".=", "'?'", ";", "$", "output", ".=", "$", "this", "->", "getQueryString", "(", ")", ";", "}", "// fragment", "if", "(", "$", "this", "->", "fragment", "!==", "null", ")", "{", "$", "output", ".=", "'#'", ";", "$", "output", ".=", "$", "this", "->", "fragment", ";", "}", "return", "$", "output", ";", "}" ]
Build a relative URL
[ "Build", "a", "relative", "URL" ]
5f405abb9bd4b722a907363b3d7c43207365c411
https://github.com/kuria/url/blob/5f405abb9bd4b722a907363b3d7c43207365c411/src/Url.php#L340-L360
20,658
mmanos/laravel-casset
src/Mmanos/Casset/Casset.php
Casset.container
public function container($container = 'default') { if (!isset($this->containers[$container])) { $this->containers[$container] = new Container($container); } return $this->containers[$container]; }
php
public function container($container = 'default') { if (!isset($this->containers[$container])) { $this->containers[$container] = new Container($container); } return $this->containers[$container]; }
[ "public", "function", "container", "(", "$", "container", "=", "'default'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "containers", "[", "$", "container", "]", ")", ")", "{", "$", "this", "->", "containers", "[", "$", "container", "]", "=", "new", "Container", "(", "$", "container", ")", ";", "}", "return", "$", "this", "->", "containers", "[", "$", "container", "]", ";", "}" ]
Retrieve the requested asset container object. @param string $container Name of container. @return Container
[ "Retrieve", "the", "requested", "asset", "container", "object", "." ]
0f7db71211c1daa99bde30afa41da2692a39b81c
https://github.com/mmanos/laravel-casset/blob/0f7db71211c1daa99bde30afa41da2692a39b81c/src/Mmanos/Casset/Casset.php#L19-L26
20,659
xiewulong/yii2-fileupload
oss/libs/guzzle/http/Guzzle/Http/Client.php
Client.preparePharCacert
public function preparePharCacert($md5Check = true) { $from = __DIR__ . '/Resources/cacert.pem'; $certFile = sys_get_temp_dir() . '/guzzle-cacert.pem'; if (!file_exists($certFile) && !copy($from, $certFile)) { throw new RuntimeException("Could not copy {$from} to {$certFile}: " . var_export(error_get_last(), true)); } elseif ($md5Check) { $actualMd5 = md5_file($certFile); $expectedMd5 = trim(file_get_contents("{$from}.md5")); if ($actualMd5 != $expectedMd5) { throw new RuntimeException("{$certFile} MD5 mismatch: expected {$expectedMd5} but got {$actualMd5}"); } } return $certFile; }
php
public function preparePharCacert($md5Check = true) { $from = __DIR__ . '/Resources/cacert.pem'; $certFile = sys_get_temp_dir() . '/guzzle-cacert.pem'; if (!file_exists($certFile) && !copy($from, $certFile)) { throw new RuntimeException("Could not copy {$from} to {$certFile}: " . var_export(error_get_last(), true)); } elseif ($md5Check) { $actualMd5 = md5_file($certFile); $expectedMd5 = trim(file_get_contents("{$from}.md5")); if ($actualMd5 != $expectedMd5) { throw new RuntimeException("{$certFile} MD5 mismatch: expected {$expectedMd5} but got {$actualMd5}"); } } return $certFile; }
[ "public", "function", "preparePharCacert", "(", "$", "md5Check", "=", "true", ")", "{", "$", "from", "=", "__DIR__", ".", "'/Resources/cacert.pem'", ";", "$", "certFile", "=", "sys_get_temp_dir", "(", ")", ".", "'/guzzle-cacert.pem'", ";", "if", "(", "!", "file_exists", "(", "$", "certFile", ")", "&&", "!", "copy", "(", "$", "from", ",", "$", "certFile", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not copy {$from} to {$certFile}: \"", ".", "var_export", "(", "error_get_last", "(", ")", ",", "true", ")", ")", ";", "}", "elseif", "(", "$", "md5Check", ")", "{", "$", "actualMd5", "=", "md5_file", "(", "$", "certFile", ")", ";", "$", "expectedMd5", "=", "trim", "(", "file_get_contents", "(", "\"{$from}.md5\"", ")", ")", ";", "if", "(", "$", "actualMd5", "!=", "$", "expectedMd5", ")", "{", "throw", "new", "RuntimeException", "(", "\"{$certFile} MD5 mismatch: expected {$expectedMd5} but got {$actualMd5}\"", ")", ";", "}", "}", "return", "$", "certFile", ";", "}" ]
Copy the cacert.pem file from the phar if it is not in the temp folder and validate the MD5 checksum @param bool $md5Check Set to false to not perform the MD5 validation @return string Returns the path to the extracted cacert @throws RuntimeException if the file cannot be copied or there is a MD5 mismatch
[ "Copy", "the", "cacert", ".", "pem", "file", "from", "the", "phar", "if", "it", "is", "not", "in", "the", "temp", "folder", "and", "validate", "the", "MD5", "checksum" ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/http/Guzzle/Http/Client.php#L344-L359
20,660
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
ezcBaseFile.findRecursiveCallback
static protected function findRecursiveCallback( ezcBaseFileFindContext $context, $sourceDir, $fileName, $fileInfo ) { // ignore if we have a directory if ( $fileInfo['mode'] & 0x4000 ) { return; } // update the statistics $context->elements[] = $sourceDir . DIRECTORY_SEPARATOR . $fileName; $context->count++; $context->size += $fileInfo['size']; }
php
static protected function findRecursiveCallback( ezcBaseFileFindContext $context, $sourceDir, $fileName, $fileInfo ) { // ignore if we have a directory if ( $fileInfo['mode'] & 0x4000 ) { return; } // update the statistics $context->elements[] = $sourceDir . DIRECTORY_SEPARATOR . $fileName; $context->count++; $context->size += $fileInfo['size']; }
[ "static", "protected", "function", "findRecursiveCallback", "(", "ezcBaseFileFindContext", "$", "context", ",", "$", "sourceDir", ",", "$", "fileName", ",", "$", "fileInfo", ")", "{", "// ignore if we have a directory", "if", "(", "$", "fileInfo", "[", "'mode'", "]", "&", "0x4000", ")", "{", "return", ";", "}", "// update the statistics", "$", "context", "->", "elements", "[", "]", "=", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ";", "$", "context", "->", "count", "++", ";", "$", "context", "->", "size", "+=", "$", "fileInfo", "[", "'size'", "]", ";", "}" ]
This is the callback used by findRecursive to collect data. This callback method works together with walkRecursive() and is called for every file/and or directory. The $context is a callback specific container in which data can be stored and shared between the different calls to the callback function. The walkRecursive() function also passes in the full absolute directory in $sourceDir, the filename in $fileName and file information (such as size, modes, types) as an array as returned by PHP's stat() in the $fileInfo parameter. @param ezcBaseFileFindContext $context @param string $sourceDir @param string $fileName @param array(stat) $fileInfo
[ "This", "is", "the", "callback", "used", "by", "findRecursive", "to", "collect", "data", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php#L58-L70
20,661
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
ezcBaseFile.walkRecursive
static public function walkRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), $callback, &$callbackContext ) { if ( !is_dir( $sourceDir ) ) { throw new ezcBaseFileNotFoundException( $sourceDir, 'directory' ); } $elements = array(); $d = @dir( $sourceDir ); if ( !$d ) { throw new ezcBaseFilePermissionException( $sourceDir, ezcBaseFileException::READ ); } while ( ( $entry = $d->read() ) !== false ) { if ( $entry == '.' || $entry == '..' ) { continue; } $fileInfo = @stat( $sourceDir . DIRECTORY_SEPARATOR . $entry ); if ( !$fileInfo ) { $fileInfo = array( 'size' => 0, 'mode' => 0 ); } if ( $fileInfo['mode'] & 0x4000 ) { // We need to ignore the Permission exceptions here as it can // be normal that a directory can not be accessed. We only need // the exception if the top directory could not be read. try { call_user_func_array( $callback, array( $callbackContext, $sourceDir, $entry, $fileInfo ) ); $subList = self::walkRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry, $includeFilters, $excludeFilters, $callback, $callbackContext ); $elements = array_merge( $elements, $subList ); } catch ( ezcBaseFilePermissionException $e ) { } } else { // By default a file is included in the return list $ok = true; // Iterate over the $includeFilters and prohibit the file from // being returned when atleast one of them does not match foreach ( $includeFilters as $filter ) { if ( !preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { $ok = false; break; } } // Iterate over the $excludeFilters and prohibit the file from // being returns when atleast one of them matches foreach ( $excludeFilters as $filter ) { if ( preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { $ok = false; break; } } // If everything's allright, call the callback and add the // entry to the elements array if ( $ok ) { call_user_func( $callback, $callbackContext, $sourceDir, $entry, $fileInfo ); $elements[] = $sourceDir . DIRECTORY_SEPARATOR . $entry; } } } sort( $elements ); return $elements; }
php
static public function walkRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), $callback, &$callbackContext ) { if ( !is_dir( $sourceDir ) ) { throw new ezcBaseFileNotFoundException( $sourceDir, 'directory' ); } $elements = array(); $d = @dir( $sourceDir ); if ( !$d ) { throw new ezcBaseFilePermissionException( $sourceDir, ezcBaseFileException::READ ); } while ( ( $entry = $d->read() ) !== false ) { if ( $entry == '.' || $entry == '..' ) { continue; } $fileInfo = @stat( $sourceDir . DIRECTORY_SEPARATOR . $entry ); if ( !$fileInfo ) { $fileInfo = array( 'size' => 0, 'mode' => 0 ); } if ( $fileInfo['mode'] & 0x4000 ) { // We need to ignore the Permission exceptions here as it can // be normal that a directory can not be accessed. We only need // the exception if the top directory could not be read. try { call_user_func_array( $callback, array( $callbackContext, $sourceDir, $entry, $fileInfo ) ); $subList = self::walkRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry, $includeFilters, $excludeFilters, $callback, $callbackContext ); $elements = array_merge( $elements, $subList ); } catch ( ezcBaseFilePermissionException $e ) { } } else { // By default a file is included in the return list $ok = true; // Iterate over the $includeFilters and prohibit the file from // being returned when atleast one of them does not match foreach ( $includeFilters as $filter ) { if ( !preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { $ok = false; break; } } // Iterate over the $excludeFilters and prohibit the file from // being returns when atleast one of them matches foreach ( $excludeFilters as $filter ) { if ( preg_match( $filter, $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { $ok = false; break; } } // If everything's allright, call the callback and add the // entry to the elements array if ( $ok ) { call_user_func( $callback, $callbackContext, $sourceDir, $entry, $fileInfo ); $elements[] = $sourceDir . DIRECTORY_SEPARATOR . $entry; } } } sort( $elements ); return $elements; }
[ "static", "public", "function", "walkRecursive", "(", "$", "sourceDir", ",", "array", "$", "includeFilters", "=", "array", "(", ")", ",", "array", "$", "excludeFilters", "=", "array", "(", ")", ",", "$", "callback", ",", "&", "$", "callbackContext", ")", "{", "if", "(", "!", "is_dir", "(", "$", "sourceDir", ")", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "sourceDir", ",", "'directory'", ")", ";", "}", "$", "elements", "=", "array", "(", ")", ";", "$", "d", "=", "@", "dir", "(", "$", "sourceDir", ")", ";", "if", "(", "!", "$", "d", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "sourceDir", ",", "ezcBaseFileException", "::", "READ", ")", ";", "}", "while", "(", "(", "$", "entry", "=", "$", "d", "->", "read", "(", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "entry", "==", "'.'", "||", "$", "entry", "==", "'..'", ")", "{", "continue", ";", "}", "$", "fileInfo", "=", "@", "stat", "(", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", ";", "if", "(", "!", "$", "fileInfo", ")", "{", "$", "fileInfo", "=", "array", "(", "'size'", "=>", "0", ",", "'mode'", "=>", "0", ")", ";", "}", "if", "(", "$", "fileInfo", "[", "'mode'", "]", "&", "0x4000", ")", "{", "// We need to ignore the Permission exceptions here as it can", "// be normal that a directory can not be accessed. We only need", "// the exception if the top directory could not be read.", "try", "{", "call_user_func_array", "(", "$", "callback", ",", "array", "(", "$", "callbackContext", ",", "$", "sourceDir", ",", "$", "entry", ",", "$", "fileInfo", ")", ")", ";", "$", "subList", "=", "self", "::", "walkRecursive", "(", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ",", "$", "includeFilters", ",", "$", "excludeFilters", ",", "$", "callback", ",", "$", "callbackContext", ")", ";", "$", "elements", "=", "array_merge", "(", "$", "elements", ",", "$", "subList", ")", ";", "}", "catch", "(", "ezcBaseFilePermissionException", "$", "e", ")", "{", "}", "}", "else", "{", "// By default a file is included in the return list", "$", "ok", "=", "true", ";", "// Iterate over the $includeFilters and prohibit the file from", "// being returned when atleast one of them does not match", "foreach", "(", "$", "includeFilters", "as", "$", "filter", ")", "{", "if", "(", "!", "preg_match", "(", "$", "filter", ",", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", ")", "{", "$", "ok", "=", "false", ";", "break", ";", "}", "}", "// Iterate over the $excludeFilters and prohibit the file from", "// being returns when atleast one of them matches", "foreach", "(", "$", "excludeFilters", "as", "$", "filter", ")", "{", "if", "(", "preg_match", "(", "$", "filter", ",", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", ")", "{", "$", "ok", "=", "false", ";", "break", ";", "}", "}", "// If everything's allright, call the callback and add the", "// entry to the elements array", "if", "(", "$", "ok", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "callbackContext", ",", "$", "sourceDir", ",", "$", "entry", ",", "$", "fileInfo", ")", ";", "$", "elements", "[", "]", "=", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ";", "}", "}", "}", "sort", "(", "$", "elements", ")", ";", "return", "$", "elements", ";", "}" ]
Walks files and directories recursively on a file system This method walks over a directory and calls a callback from every file and directory it finds. You can use $includeFilters to include only specific files, and $excludeFilters to exclude certain files from being returned. The function will always go into subdirectories even if the entry would not have passed the filters. The callback is passed in the $callback parameter, and the $callbackContext will be send to the callback function/method as parameter so that you can store data in there that persists with all the calls and recursive calls to this method. It's up to the callback method to do something useful with this. The callback function's parameters are in order: <ul> <li>ezcBaseFileFindContext $context</li> <li>string $sourceDir</li> <li>string $fileName</li> <li>array(stat) $fileInfo</li> </ul> See {@see findRecursiveCallback()} for an example of a callback function. Filters are regular expressions and are therefore required to have starting and ending delimiters. The Perl Compatible syntax is used as regular expression language. @param string $sourceDir @param array(string) $includeFilters @param array(string) $excludeFilters @param callback $callback @param mixed $callbackContext @throws ezcBaseFileNotFoundException if the $sourceDir directory is not a directory or does not exist. @throws ezcBaseFilePermissionException if the $sourceDir directory could not be opened for reading. @return array
[ "Walks", "files", "and", "directories", "recursively", "on", "a", "file", "system" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php#L113-L190
20,662
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
ezcBaseFile.findRecursive
static public function findRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), &$statistics = null ) { // init statistics array if ( !is_array( $statistics ) || !array_key_exists( 'size', $statistics ) || !array_key_exists( 'count', $statistics ) ) { $statistics['size'] = 0; $statistics['count'] = 0; } // create the context, and then start walking over the array $context = new ezcBaseFileFindContext; self::walkRecursive( $sourceDir, $includeFilters, $excludeFilters, array( 'ezcBaseFile', 'findRecursiveCallback' ), $context ); // collect the statistics $statistics['size'] = $context->size; $statistics['count'] = $context->count; // return the found and pattern-matched files sort( $context->elements ); return $context->elements; }
php
static public function findRecursive( $sourceDir, array $includeFilters = array(), array $excludeFilters = array(), &$statistics = null ) { // init statistics array if ( !is_array( $statistics ) || !array_key_exists( 'size', $statistics ) || !array_key_exists( 'count', $statistics ) ) { $statistics['size'] = 0; $statistics['count'] = 0; } // create the context, and then start walking over the array $context = new ezcBaseFileFindContext; self::walkRecursive( $sourceDir, $includeFilters, $excludeFilters, array( 'ezcBaseFile', 'findRecursiveCallback' ), $context ); // collect the statistics $statistics['size'] = $context->size; $statistics['count'] = $context->count; // return the found and pattern-matched files sort( $context->elements ); return $context->elements; }
[ "static", "public", "function", "findRecursive", "(", "$", "sourceDir", ",", "array", "$", "includeFilters", "=", "array", "(", ")", ",", "array", "$", "excludeFilters", "=", "array", "(", ")", ",", "&", "$", "statistics", "=", "null", ")", "{", "// init statistics array", "if", "(", "!", "is_array", "(", "$", "statistics", ")", "||", "!", "array_key_exists", "(", "'size'", ",", "$", "statistics", ")", "||", "!", "array_key_exists", "(", "'count'", ",", "$", "statistics", ")", ")", "{", "$", "statistics", "[", "'size'", "]", "=", "0", ";", "$", "statistics", "[", "'count'", "]", "=", "0", ";", "}", "// create the context, and then start walking over the array", "$", "context", "=", "new", "ezcBaseFileFindContext", ";", "self", "::", "walkRecursive", "(", "$", "sourceDir", ",", "$", "includeFilters", ",", "$", "excludeFilters", ",", "array", "(", "'ezcBaseFile'", ",", "'findRecursiveCallback'", ")", ",", "$", "context", ")", ";", "// collect the statistics", "$", "statistics", "[", "'size'", "]", "=", "$", "context", "->", "size", ";", "$", "statistics", "[", "'count'", "]", "=", "$", "context", "->", "count", ";", "// return the found and pattern-matched files", "sort", "(", "$", "context", "->", "elements", ")", ";", "return", "$", "context", "->", "elements", ";", "}" ]
Finds files recursively on a file system With this method you can scan the file system for files. You can use $includeFilters to include only specific files, and $excludeFilters to exclude certain files from being returned. The function will always go into subdirectories even if the entry would not have passed the filters. It uses the {@see walkRecursive()} method to do the actually recursion. Filters are regular expressions and are therefore required to have starting and ending delimiters. The Perl Compatible syntax is used as regular expression language. If you pass an empty array to the $statistics argument, the function will in details about the number of files found into the 'count' array element, and the total filesize in the 'size' array element. Because this argument is passed by reference, you *have* to pass a variable and you can not pass a constant value such as "array()". @param string $sourceDir @param array(string) $includeFilters @param array(string) $excludeFilters @param array() $statistics @throws ezcBaseFileNotFoundException if the $sourceDir directory is not a directory or does not exist. @throws ezcBaseFilePermissionException if the $sourceDir directory could not be opened for reading. @return array
[ "Finds", "files", "recursively", "on", "a", "file", "system" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php#L222-L242
20,663
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
ezcBaseFile.removeRecursive
static public function removeRecursive( $directory ) { $sourceDir = realpath( $directory ); if ( !$sourceDir ) { throw new ezcBaseFileNotFoundException( $directory, 'directory' ); } $d = @dir( $sourceDir ); if ( !$d ) { throw new ezcBaseFilePermissionException( $directory, ezcBaseFileException::READ ); } // check if we can remove the dir $parentDir = realpath( $directory . DIRECTORY_SEPARATOR . '..' ); if ( !is_writable( $parentDir ) ) { throw new ezcBaseFilePermissionException( $parentDir, ezcBaseFileException::WRITE ); } // loop over contents while ( ( $entry = $d->read() ) !== false ) { if ( $entry == '.' || $entry == '..' ) { continue; } if ( is_dir( $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { self::removeRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry ); } else { if ( @unlink( $sourceDir . DIRECTORY_SEPARATOR . $entry ) === false ) { throw new ezcBaseFilePermissionException( $directory . DIRECTORY_SEPARATOR . $entry, ezcBaseFileException::REMOVE ); } } } $d->close(); rmdir( $sourceDir ); }
php
static public function removeRecursive( $directory ) { $sourceDir = realpath( $directory ); if ( !$sourceDir ) { throw new ezcBaseFileNotFoundException( $directory, 'directory' ); } $d = @dir( $sourceDir ); if ( !$d ) { throw new ezcBaseFilePermissionException( $directory, ezcBaseFileException::READ ); } // check if we can remove the dir $parentDir = realpath( $directory . DIRECTORY_SEPARATOR . '..' ); if ( !is_writable( $parentDir ) ) { throw new ezcBaseFilePermissionException( $parentDir, ezcBaseFileException::WRITE ); } // loop over contents while ( ( $entry = $d->read() ) !== false ) { if ( $entry == '.' || $entry == '..' ) { continue; } if ( is_dir( $sourceDir . DIRECTORY_SEPARATOR . $entry ) ) { self::removeRecursive( $sourceDir . DIRECTORY_SEPARATOR . $entry ); } else { if ( @unlink( $sourceDir . DIRECTORY_SEPARATOR . $entry ) === false ) { throw new ezcBaseFilePermissionException( $directory . DIRECTORY_SEPARATOR . $entry, ezcBaseFileException::REMOVE ); } } } $d->close(); rmdir( $sourceDir ); }
[ "static", "public", "function", "removeRecursive", "(", "$", "directory", ")", "{", "$", "sourceDir", "=", "realpath", "(", "$", "directory", ")", ";", "if", "(", "!", "$", "sourceDir", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "directory", ",", "'directory'", ")", ";", "}", "$", "d", "=", "@", "dir", "(", "$", "sourceDir", ")", ";", "if", "(", "!", "$", "d", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "directory", ",", "ezcBaseFileException", "::", "READ", ")", ";", "}", "// check if we can remove the dir", "$", "parentDir", "=", "realpath", "(", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ")", ";", "if", "(", "!", "is_writable", "(", "$", "parentDir", ")", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "parentDir", ",", "ezcBaseFileException", "::", "WRITE", ")", ";", "}", "// loop over contents", "while", "(", "(", "$", "entry", "=", "$", "d", "->", "read", "(", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "entry", "==", "'.'", "||", "$", "entry", "==", "'..'", ")", "{", "continue", ";", "}", "if", "(", "is_dir", "(", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", ")", "{", "self", "::", "removeRecursive", "(", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", ";", "}", "else", "{", "if", "(", "@", "unlink", "(", "$", "sourceDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "entry", ",", "ezcBaseFileException", "::", "REMOVE", ")", ";", "}", "}", "}", "$", "d", "->", "close", "(", ")", ";", "rmdir", "(", "$", "sourceDir", ")", ";", "}" ]
Removes files and directories recursively from a file system This method recursively removes the $directory and all its contents. You should be <b>extremely</b> careful with this method as it has the potential to erase everything that the current user has access to. @param string $directory
[ "Removes", "files", "and", "directories", "recursively", "from", "a", "file", "system" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php#L254-L294
20,664
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
ezcBaseFile.copyRecursive
static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 ) { // Check if source file exists at all. if ( !is_file( $source ) && !is_dir( $source ) ) { throw new ezcBaseFileNotFoundException( $source ); } // Destination file should NOT exist if ( is_file( $destination ) || is_dir( $destination ) ) { throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE ); } // Skip non readable files in source directory if ( !is_readable( $source ) ) { return; } // Copy if ( is_dir( $source ) ) { mkdir( $destination ); // To ignore umask, umask() should not be changed with // multithreaded servers... chmod( $destination, $dirMode ); } elseif ( is_file( $source ) ) { copy( $source, $destination ); chmod( $destination, $fileMode ); } if ( ( $depth === 0 ) || ( !is_dir( $source ) ) ) { // Do not recurse (any more) return; } // Recurse $dh = opendir( $source ); while ( ( $file = readdir( $dh ) ) !== false ) { if ( ( $file === '.' ) || ( $file === '..' ) ) { continue; } self::copyRecursive( $source . '/' . $file, $destination . '/' . $file, $depth - 1, $dirMode, $fileMode ); } }
php
static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 ) { // Check if source file exists at all. if ( !is_file( $source ) && !is_dir( $source ) ) { throw new ezcBaseFileNotFoundException( $source ); } // Destination file should NOT exist if ( is_file( $destination ) || is_dir( $destination ) ) { throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE ); } // Skip non readable files in source directory if ( !is_readable( $source ) ) { return; } // Copy if ( is_dir( $source ) ) { mkdir( $destination ); // To ignore umask, umask() should not be changed with // multithreaded servers... chmod( $destination, $dirMode ); } elseif ( is_file( $source ) ) { copy( $source, $destination ); chmod( $destination, $fileMode ); } if ( ( $depth === 0 ) || ( !is_dir( $source ) ) ) { // Do not recurse (any more) return; } // Recurse $dh = opendir( $source ); while ( ( $file = readdir( $dh ) ) !== false ) { if ( ( $file === '.' ) || ( $file === '..' ) ) { continue; } self::copyRecursive( $source . '/' . $file, $destination . '/' . $file, $depth - 1, $dirMode, $fileMode ); } }
[ "static", "public", "function", "copyRecursive", "(", "$", "source", ",", "$", "destination", ",", "$", "depth", "=", "-", "1", ",", "$", "dirMode", "=", "0775", ",", "$", "fileMode", "=", "0664", ")", "{", "// Check if source file exists at all.", "if", "(", "!", "is_file", "(", "$", "source", ")", "&&", "!", "is_dir", "(", "$", "source", ")", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "source", ")", ";", "}", "// Destination file should NOT exist", "if", "(", "is_file", "(", "$", "destination", ")", "||", "is_dir", "(", "$", "destination", ")", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "destination", ",", "ezcBaseFileException", "::", "WRITE", ")", ";", "}", "// Skip non readable files in source directory", "if", "(", "!", "is_readable", "(", "$", "source", ")", ")", "{", "return", ";", "}", "// Copy", "if", "(", "is_dir", "(", "$", "source", ")", ")", "{", "mkdir", "(", "$", "destination", ")", ";", "// To ignore umask, umask() should not be changed with", "// multithreaded servers...", "chmod", "(", "$", "destination", ",", "$", "dirMode", ")", ";", "}", "elseif", "(", "is_file", "(", "$", "source", ")", ")", "{", "copy", "(", "$", "source", ",", "$", "destination", ")", ";", "chmod", "(", "$", "destination", ",", "$", "fileMode", ")", ";", "}", "if", "(", "(", "$", "depth", "===", "0", ")", "||", "(", "!", "is_dir", "(", "$", "source", ")", ")", ")", "{", "// Do not recurse (any more)", "return", ";", "}", "// Recurse", "$", "dh", "=", "opendir", "(", "$", "source", ")", ";", "while", "(", "(", "$", "file", "=", "readdir", "(", "$", "dh", ")", ")", "!==", "false", ")", "{", "if", "(", "(", "$", "file", "===", "'.'", ")", "||", "(", "$", "file", "===", "'..'", ")", ")", "{", "continue", ";", "}", "self", "::", "copyRecursive", "(", "$", "source", ".", "'/'", ".", "$", "file", ",", "$", "destination", ".", "'/'", ".", "$", "file", ",", "$", "depth", "-", "1", ",", "$", "dirMode", ",", "$", "fileMode", ")", ";", "}", "}" ]
Recursively copy a file or directory. Recursively copy a file or directory in $source to the given destination. If a depth is given, the operation will stop, if the given recursion depth is reached. A depth of -1 means no limit, while a depth of 0 means, that only the current file or directory will be copied, without any recursion. You may optionally define modes used to create files and directories. @throws ezcBaseFileNotFoundException If the $sourceDir directory is not a directory or does not exist. @throws ezcBaseFilePermissionException If the $sourceDir directory could not be opened for reading, or the destination is not writeable. @param string $source @param string $destination @param int $depth @param int $dirMode @param int $fileMode @return void
[ "Recursively", "copy", "a", "file", "or", "directory", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php#L320-L377
20,665
shipmile/shipmile-api-php
lib/Shipmile/HttpClient/HttpClient.php
HttpClient.request
public function request($path, $body = null, $httpMethod = 'GET', array $options = array()) { $headers = array(); $options = array_merge($this->options, $options); if (isset($options['headers'])) { $headers = $options['headers']; unset($options['headers']); } $headers = array_merge($this->headers, array_change_key_case($headers)); unset($options['body']); unset($options['base']); unset($options['user_agent']); $request = $this->createRequest($httpMethod, $path, null, $headers, $options); if ($httpMethod != 'GET') { $request = $this->setBody($request, $body, $options); } try { $response = $this->client->send($request); } catch (\LogicException $e) { throw new \ErrorException($e->getMessage()); } catch (\RuntimeException $e) { throw new \RuntimeException($e->getMessage()); } return new Response($this->getBody($response), $response->getStatusCode(), $response->getHeaders()); }
php
public function request($path, $body = null, $httpMethod = 'GET', array $options = array()) { $headers = array(); $options = array_merge($this->options, $options); if (isset($options['headers'])) { $headers = $options['headers']; unset($options['headers']); } $headers = array_merge($this->headers, array_change_key_case($headers)); unset($options['body']); unset($options['base']); unset($options['user_agent']); $request = $this->createRequest($httpMethod, $path, null, $headers, $options); if ($httpMethod != 'GET') { $request = $this->setBody($request, $body, $options); } try { $response = $this->client->send($request); } catch (\LogicException $e) { throw new \ErrorException($e->getMessage()); } catch (\RuntimeException $e) { throw new \RuntimeException($e->getMessage()); } return new Response($this->getBody($response), $response->getStatusCode(), $response->getHeaders()); }
[ "public", "function", "request", "(", "$", "path", ",", "$", "body", "=", "null", ",", "$", "httpMethod", "=", "'GET'", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "$", "options", "=", "array_merge", "(", "$", "this", "->", "options", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'headers'", "]", ")", ")", "{", "$", "headers", "=", "$", "options", "[", "'headers'", "]", ";", "unset", "(", "$", "options", "[", "'headers'", "]", ")", ";", "}", "$", "headers", "=", "array_merge", "(", "$", "this", "->", "headers", ",", "array_change_key_case", "(", "$", "headers", ")", ")", ";", "unset", "(", "$", "options", "[", "'body'", "]", ")", ";", "unset", "(", "$", "options", "[", "'base'", "]", ")", ";", "unset", "(", "$", "options", "[", "'user_agent'", "]", ")", ";", "$", "request", "=", "$", "this", "->", "createRequest", "(", "$", "httpMethod", ",", "$", "path", ",", "null", ",", "$", "headers", ",", "$", "options", ")", ";", "if", "(", "$", "httpMethod", "!=", "'GET'", ")", "{", "$", "request", "=", "$", "this", "->", "setBody", "(", "$", "request", ",", "$", "body", ",", "$", "options", ")", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}", "catch", "(", "\\", "LogicException", "$", "e", ")", "{", "throw", "new", "\\", "ErrorException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "new", "Response", "(", "$", "this", "->", "getBody", "(", "$", "response", ")", ",", "$", "response", "->", "getStatusCode", "(", ")", ",", "$", "response", "->", "getHeaders", "(", ")", ")", ";", "}" ]
Intermediate function which does three main things - Transforms the body of request into correct format - Creates the requests with give parameters - Returns response body after parsing it into correct format
[ "Intermediate", "function", "which", "does", "three", "main", "things" ]
b8272613b3a27f0f27e8722cbee277e41e9dfe59
https://github.com/shipmile/shipmile-api-php/blob/b8272613b3a27f0f27e8722cbee277e41e9dfe59/lib/Shipmile/HttpClient/HttpClient.php#L99-L132
20,666
shipmile/shipmile-api-php
lib/Shipmile/HttpClient/HttpClient.php
HttpClient.createRequest
public function createRequest($httpMethod, $path, $body = null, array $headers = array(), array $options = array()) { $version = (isset($options['api_version']) ? "/".$options['api_version'] : ""); $path = $version.$path; return $this->client->createRequest($httpMethod, $path, $headers, $body, $options); }
php
public function createRequest($httpMethod, $path, $body = null, array $headers = array(), array $options = array()) { $version = (isset($options['api_version']) ? "/".$options['api_version'] : ""); $path = $version.$path; return $this->client->createRequest($httpMethod, $path, $headers, $body, $options); }
[ "public", "function", "createRequest", "(", "$", "httpMethod", ",", "$", "path", ",", "$", "body", "=", "null", ",", "array", "$", "headers", "=", "array", "(", ")", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "version", "=", "(", "isset", "(", "$", "options", "[", "'api_version'", "]", ")", "?", "\"/\"", ".", "$", "options", "[", "'api_version'", "]", ":", "\"\"", ")", ";", "$", "path", "=", "$", "version", ".", "$", "path", ";", "return", "$", "this", "->", "client", "->", "createRequest", "(", "$", "httpMethod", ",", "$", "path", ",", "$", "headers", ",", "$", "body", ",", "$", "options", ")", ";", "}" ]
Creating a request with the given arguments If api_version is set, appends it immediately after host
[ "Creating", "a", "request", "with", "the", "given", "arguments" ]
b8272613b3a27f0f27e8722cbee277e41e9dfe59
https://github.com/shipmile/shipmile-api-php/blob/b8272613b3a27f0f27e8722cbee277e41e9dfe59/lib/Shipmile/HttpClient/HttpClient.php#L139-L146
20,667
shipmile/shipmile-api-php
lib/Shipmile/HttpClient/HttpClient.php
HttpClient.setBody
public function setBody(RequestInterface $request, $body, $options) { return RequestHandler::setBody($request, $body, $options); }
php
public function setBody(RequestInterface $request, $body, $options) { return RequestHandler::setBody($request, $body, $options); }
[ "public", "function", "setBody", "(", "RequestInterface", "$", "request", ",", "$", "body", ",", "$", "options", ")", "{", "return", "RequestHandler", "::", "setBody", "(", "$", "request", ",", "$", "body", ",", "$", "options", ")", ";", "}" ]
Set request body in correct format
[ "Set", "request", "body", "in", "correct", "format" ]
b8272613b3a27f0f27e8722cbee277e41e9dfe59
https://github.com/shipmile/shipmile-api-php/blob/b8272613b3a27f0f27e8722cbee277e41e9dfe59/lib/Shipmile/HttpClient/HttpClient.php#L159-L162
20,668
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getClient
public function getClient() { if (!$this->client) { $client = new GuzzleHelper(); $this->configureClient($client); return $this->client = $client->getClient(); } return $this->client; }
php
public function getClient() { if (!$this->client) { $client = new GuzzleHelper(); $this->configureClient($client); return $this->client = $client->getClient(); } return $this->client; }
[ "public", "function", "getClient", "(", ")", "{", "if", "(", "!", "$", "this", "->", "client", ")", "{", "$", "client", "=", "new", "GuzzleHelper", "(", ")", ";", "$", "this", "->", "configureClient", "(", "$", "client", ")", ";", "return", "$", "this", "->", "client", "=", "$", "client", "->", "getClient", "(", ")", ";", "}", "return", "$", "this", "->", "client", ";", "}" ]
Get new Curl instance @return Curl curl
[ "Get", "new", "Curl", "instance" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L36-L47
20,669
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.performRequest
public function performRequest($url) { $client = $this->getClient(); return $this->response = $client->get($url); }
php
public function performRequest($url) { $client = $this->getClient(); return $this->response = $client->get($url); }
[ "public", "function", "performRequest", "(", "$", "url", ")", "{", "$", "client", "=", "$", "this", "->", "getClient", "(", ")", ";", "return", "$", "this", "->", "response", "=", "$", "client", "->", "get", "(", "$", "url", ")", ";", "}" ]
Perform HTTP request @param string url @return CurlResponse response
[ "Perform", "HTTP", "request" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L66-L71
20,670
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageTitle
public function getPageTitle() { if (!$this->parser) { return; } $node = $this->parser->find('title', 0); if ($node) { return $node->innertext; } }
php
public function getPageTitle() { if (!$this->parser) { return; } $node = $this->parser->find('title', 0); if ($node) { return $node->innertext; } }
[ "public", "function", "getPageTitle", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "node", "=", "$", "this", "->", "parser", "->", "find", "(", "'title'", ",", "0", ")", ";", "if", "(", "$", "node", ")", "{", "return", "$", "node", "->", "innertext", ";", "}", "}" ]
Get page title @return string title
[ "Get", "page", "title" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L136-L147
20,671
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageDescription
public function getPageDescription() { if (!$this->parser) { return; } $node = $this->parser->find('meta[name=description]', 0); if ($node) { return $node->getAttribute('content'); } }
php
public function getPageDescription() { if (!$this->parser) { return; } $node = $this->parser->find('meta[name=description]', 0); if ($node) { return $node->getAttribute('content'); } }
[ "public", "function", "getPageDescription", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "node", "=", "$", "this", "->", "parser", "->", "find", "(", "'meta[name=description]'", ",", "0", ")", ";", "if", "(", "$", "node", ")", "{", "return", "$", "node", "->", "getAttribute", "(", "'content'", ")", ";", "}", "}" ]
Get page description @return string description
[ "Get", "page", "description" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L154-L165
20,672
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageKeywords
public function getPageKeywords() { if (!$this->parser) { return; } $node = $this->parser->find('meta[name=keywords]', 0); if ($node) { return $node->getAttribute('content'); } }
php
public function getPageKeywords() { if (!$this->parser) { return; } $node = $this->parser->find('meta[name=keywords]', 0); if ($node) { return $node->getAttribute('content'); } }
[ "public", "function", "getPageKeywords", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "node", "=", "$", "this", "->", "parser", "->", "find", "(", "'meta[name=keywords]'", ",", "0", ")", ";", "if", "(", "$", "node", ")", "{", "return", "$", "node", "->", "getAttribute", "(", "'content'", ")", ";", "}", "}" ]
Get page keywords @return string url
[ "Get", "page", "keywords" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L172-L183
20,673
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageCanonical
public function getPageCanonical() { if (!$this->parser) { return; } $node = $this->parser->find('link[rel=canonical]', 0); if ($node) { return $node->getAttribute('href'); } }
php
public function getPageCanonical() { if (!$this->parser) { return; } $node = $this->parser->find('link[rel=canonical]', 0); if ($node) { return $node->getAttribute('href'); } }
[ "public", "function", "getPageCanonical", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "node", "=", "$", "this", "->", "parser", "->", "find", "(", "'link[rel=canonical]'", ",", "0", ")", ";", "if", "(", "$", "node", ")", "{", "return", "$", "node", "->", "getAttribute", "(", "'href'", ")", ";", "}", "}" ]
Get page canonical url @return string url
[ "Get", "page", "canonical", "url" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L190-L201
20,674
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageFavicon
public function getPageFavicon() { if (!$this->parser) { return; } $node = $this->parser->find('link[rel=shortcut], link[rel=icon], link[rel=shortcut icon]', 0); if ($node) { return $node->getAttribute('href'); } }
php
public function getPageFavicon() { if (!$this->parser) { return; } $node = $this->parser->find('link[rel=shortcut], link[rel=icon], link[rel=shortcut icon]', 0); if ($node) { return $node->getAttribute('href'); } }
[ "public", "function", "getPageFavicon", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "node", "=", "$", "this", "->", "parser", "->", "find", "(", "'link[rel=shortcut], link[rel=icon], link[rel=shortcut icon]'", ",", "0", ")", ";", "if", "(", "$", "node", ")", "{", "return", "$", "node", "->", "getAttribute", "(", "'href'", ")", ";", "}", "}" ]
Get page favicon url @return string url
[ "Get", "page", "favicon", "url" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L208-L219
20,675
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageMetas
public function getPageMetas() { if (!$this->parser) { return; } $nodes = $this->parser->find('meta'); $metas = array(); foreach ($nodes as $node) { if ($node->hasAttribute('name')) { $metas[ $node->getAttribute('name') ] = $node->getAttribute('content'); } elseif ($node->hasAttribute('property')) { $metas[ $node->getAttribute('property') ] = $node->getAttribute('content'); } } return $metas; }
php
public function getPageMetas() { if (!$this->parser) { return; } $nodes = $this->parser->find('meta'); $metas = array(); foreach ($nodes as $node) { if ($node->hasAttribute('name')) { $metas[ $node->getAttribute('name') ] = $node->getAttribute('content'); } elseif ($node->hasAttribute('property')) { $metas[ $node->getAttribute('property') ] = $node->getAttribute('content'); } } return $metas; }
[ "public", "function", "getPageMetas", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "nodes", "=", "$", "this", "->", "parser", "->", "find", "(", "'meta'", ")", ";", "$", "metas", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "hasAttribute", "(", "'name'", ")", ")", "{", "$", "metas", "[", "$", "node", "->", "getAttribute", "(", "'name'", ")", "]", "=", "$", "node", "->", "getAttribute", "(", "'content'", ")", ";", "}", "elseif", "(", "$", "node", "->", "hasAttribute", "(", "'property'", ")", ")", "{", "$", "metas", "[", "$", "node", "->", "getAttribute", "(", "'property'", ")", "]", "=", "$", "node", "->", "getAttribute", "(", "'content'", ")", ";", "}", "}", "return", "$", "metas", ";", "}" ]
Get meta description @return array metas
[ "Get", "meta", "description" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L226-L245
20,676
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.getPageFeeds
public function getPageFeeds() { if (!$this->parser) { return; } $nodes = $this->parser->find('link'); $feeds = array(); $types = array( 'application/rss+xml', 'application/atom+xml', 'text/xml', ); foreach ($nodes as $node) { $type = strtolower($node->getAttribute('type')); if (in_array($type, $types)) { $feeds[] = $node->getAttribute('href'); } } return $feeds; }
php
public function getPageFeeds() { if (!$this->parser) { return; } $nodes = $this->parser->find('link'); $feeds = array(); $types = array( 'application/rss+xml', 'application/atom+xml', 'text/xml', ); foreach ($nodes as $node) { $type = strtolower($node->getAttribute('type')); if (in_array($type, $types)) { $feeds[] = $node->getAttribute('href'); } } return $feeds; }
[ "public", "function", "getPageFeeds", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parser", ")", "{", "return", ";", "}", "$", "nodes", "=", "$", "this", "->", "parser", "->", "find", "(", "'link'", ")", ";", "$", "feeds", "=", "array", "(", ")", ";", "$", "types", "=", "array", "(", "'application/rss+xml'", ",", "'application/atom+xml'", ",", "'text/xml'", ",", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "type", "=", "strtolower", "(", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", ";", "if", "(", "in_array", "(", "$", "type", ",", "$", "types", ")", ")", "{", "$", "feeds", "[", "]", "=", "$", "node", "->", "getAttribute", "(", "'href'", ")", ";", "}", "}", "return", "$", "feeds", ";", "}" ]
Get rss feeds urls @return array feeds
[ "Get", "rss", "feeds", "urls" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L252-L277
20,677
chemel/dom-parser-helper
src/HtmlDomParserHelper.php
HtmlDomParserHelper.clear
public function clear() { $this->response = null; if ($this->parser) { $this->parser->clear(); } $this->parser = null; }
php
public function clear() { $this->response = null; if ($this->parser) { $this->parser->clear(); } $this->parser = null; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "response", "=", "null", ";", "if", "(", "$", "this", "->", "parser", ")", "{", "$", "this", "->", "parser", "->", "clear", "(", ")", ";", "}", "$", "this", "->", "parser", "=", "null", ";", "}" ]
Clean up memory
[ "Clean", "up", "memory" ]
0ec7df13b19e3f3df4453023b37cba6bb16eb10a
https://github.com/chemel/dom-parser-helper/blob/0ec7df13b19e3f3df4453023b37cba6bb16eb10a/src/HtmlDomParserHelper.php#L336-L345
20,678
hametuha/wpametu
src/WPametu/DB/Column.php
Column.data_type
private static function data_type($column){ /** @var $wpdb \wpdb */ global $wpdb; // Let's create query $sql = $column['type']; // Is DECIMAL? if( self::DECIMAL == $column['type'] ){ $sql .= sprintf('(%d, %d)', $column['max_digit'], $column['float']); } // Add length if( isset($column['length']) ){ $sql .= sprintf('(%d)', $column['length']); } // Is enum or set? if( self::is_set($column['type']) ){ $values = []; foreach($column['values'] as $val){ $values[] = $wpdb->prepare('%s', $val); } $sql .= sprintf('(%s)', implode(', ', $values)); } // Is unsigned? if( self::is_numeric($column['type']) && isset($column['signed']) && !$column['signed'] ){ $sql .= ' UNSIGNED'; } // Is not null? if( !$column['null'] ){ $sql .= ' NOT NULL'; } // Is auto increment? if( isset($column['auto_increment']) && $column['auto_increment'] ){ $sql .= ' AUTO_INCREMENT'; } // Is primary key? if( isset($column['primary']) && $column['primary'] ){ $sql .= ' PRIMARY KEY'; } // Has default? if( isset($column['default']) ){ if( self::is_numeric($column['default']) ){ $repl = ' DEFAULT '.$column['default']; }else{ switch( $column['default'] ){ case 'CURRENT_TIMESTAMP': // Without replace $sql .= " DEFAULT {$column['default']}"; break; default: // Replace $sql .= $wpdb->prepare(' DEFAULT %s', $column['default']); break; } } } return $sql; }
php
private static function data_type($column){ /** @var $wpdb \wpdb */ global $wpdb; // Let's create query $sql = $column['type']; // Is DECIMAL? if( self::DECIMAL == $column['type'] ){ $sql .= sprintf('(%d, %d)', $column['max_digit'], $column['float']); } // Add length if( isset($column['length']) ){ $sql .= sprintf('(%d)', $column['length']); } // Is enum or set? if( self::is_set($column['type']) ){ $values = []; foreach($column['values'] as $val){ $values[] = $wpdb->prepare('%s', $val); } $sql .= sprintf('(%s)', implode(', ', $values)); } // Is unsigned? if( self::is_numeric($column['type']) && isset($column['signed']) && !$column['signed'] ){ $sql .= ' UNSIGNED'; } // Is not null? if( !$column['null'] ){ $sql .= ' NOT NULL'; } // Is auto increment? if( isset($column['auto_increment']) && $column['auto_increment'] ){ $sql .= ' AUTO_INCREMENT'; } // Is primary key? if( isset($column['primary']) && $column['primary'] ){ $sql .= ' PRIMARY KEY'; } // Has default? if( isset($column['default']) ){ if( self::is_numeric($column['default']) ){ $repl = ' DEFAULT '.$column['default']; }else{ switch( $column['default'] ){ case 'CURRENT_TIMESTAMP': // Without replace $sql .= " DEFAULT {$column['default']}"; break; default: // Replace $sql .= $wpdb->prepare(' DEFAULT %s', $column['default']); break; } } } return $sql; }
[ "private", "static", "function", "data_type", "(", "$", "column", ")", "{", "/** @var $wpdb \\wpdb */", "global", "$", "wpdb", ";", "// Let's create query", "$", "sql", "=", "$", "column", "[", "'type'", "]", ";", "// Is DECIMAL?", "if", "(", "self", "::", "DECIMAL", "==", "$", "column", "[", "'type'", "]", ")", "{", "$", "sql", ".=", "sprintf", "(", "'(%d, %d)'", ",", "$", "column", "[", "'max_digit'", "]", ",", "$", "column", "[", "'float'", "]", ")", ";", "}", "// Add length", "if", "(", "isset", "(", "$", "column", "[", "'length'", "]", ")", ")", "{", "$", "sql", ".=", "sprintf", "(", "'(%d)'", ",", "$", "column", "[", "'length'", "]", ")", ";", "}", "// Is enum or set?", "if", "(", "self", "::", "is_set", "(", "$", "column", "[", "'type'", "]", ")", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "column", "[", "'values'", "]", "as", "$", "val", ")", "{", "$", "values", "[", "]", "=", "$", "wpdb", "->", "prepare", "(", "'%s'", ",", "$", "val", ")", ";", "}", "$", "sql", ".=", "sprintf", "(", "'(%s)'", ",", "implode", "(", "', '", ",", "$", "values", ")", ")", ";", "}", "// Is unsigned?", "if", "(", "self", "::", "is_numeric", "(", "$", "column", "[", "'type'", "]", ")", "&&", "isset", "(", "$", "column", "[", "'signed'", "]", ")", "&&", "!", "$", "column", "[", "'signed'", "]", ")", "{", "$", "sql", ".=", "' UNSIGNED'", ";", "}", "// Is not null?", "if", "(", "!", "$", "column", "[", "'null'", "]", ")", "{", "$", "sql", ".=", "' NOT NULL'", ";", "}", "// Is auto increment?", "if", "(", "isset", "(", "$", "column", "[", "'auto_increment'", "]", ")", "&&", "$", "column", "[", "'auto_increment'", "]", ")", "{", "$", "sql", ".=", "' AUTO_INCREMENT'", ";", "}", "// Is primary key?", "if", "(", "isset", "(", "$", "column", "[", "'primary'", "]", ")", "&&", "$", "column", "[", "'primary'", "]", ")", "{", "$", "sql", ".=", "' PRIMARY KEY'", ";", "}", "// Has default?", "if", "(", "isset", "(", "$", "column", "[", "'default'", "]", ")", ")", "{", "if", "(", "self", "::", "is_numeric", "(", "$", "column", "[", "'default'", "]", ")", ")", "{", "$", "repl", "=", "' DEFAULT '", ".", "$", "column", "[", "'default'", "]", ";", "}", "else", "{", "switch", "(", "$", "column", "[", "'default'", "]", ")", "{", "case", "'CURRENT_TIMESTAMP'", ":", "// Without replace", "$", "sql", ".=", "\" DEFAULT {$column['default']}\"", ";", "break", ";", "default", ":", "// Replace", "$", "sql", ".=", "$", "wpdb", "->", "prepare", "(", "' DEFAULT %s'", ",", "$", "column", "[", "'default'", "]", ")", ";", "break", ";", "}", "}", "}", "return", "$", "sql", ";", "}" ]
Build data type on create statement @param array $column @return string
[ "Build", "data", "type", "on", "create", "statement" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/Column.php#L149-L204
20,679
hametuha/wpametu
src/WPametu/DB/Column.php
Column.filter
public static function filter($column){ $column = wp_parse_args($column, [ 'type' => '', 'null' => false, ]); // Type required. if( !self::exists($column['type']) ){ throw new \Exception('You must properly specify the data type of column.'); } // Check varchar length if( self::is_length_required($column['type']) && !isset($column['length']) ){ throw new \Exception(sprintf('Column %s requires length property.', $column['type'])); } // Signed or Unsigned? if( self::is_numeric($column['type']) ){ $column['signed'] = isset($column['signed']) ? (bool)$column['signed'] : true; } // If decimal, test_required params if( $column['type'] == self::DECIMAL ){ if( !isset($column['max_digit'], $column['float']) ){ throw new \Exception(sprintf('Column %s requires max_digit and float property.', self::DECIMAL)); } } // If enum or set, test required properties. if( self::is_set($column['type']) && ( !is_array($column['values']) || empty($column['values']) ) ){ throw new \Exception(sprintf('Column %s requires values property as array.', $column['type'])); } return $column; }
php
public static function filter($column){ $column = wp_parse_args($column, [ 'type' => '', 'null' => false, ]); // Type required. if( !self::exists($column['type']) ){ throw new \Exception('You must properly specify the data type of column.'); } // Check varchar length if( self::is_length_required($column['type']) && !isset($column['length']) ){ throw new \Exception(sprintf('Column %s requires length property.', $column['type'])); } // Signed or Unsigned? if( self::is_numeric($column['type']) ){ $column['signed'] = isset($column['signed']) ? (bool)$column['signed'] : true; } // If decimal, test_required params if( $column['type'] == self::DECIMAL ){ if( !isset($column['max_digit'], $column['float']) ){ throw new \Exception(sprintf('Column %s requires max_digit and float property.', self::DECIMAL)); } } // If enum or set, test required properties. if( self::is_set($column['type']) && ( !is_array($column['values']) || empty($column['values']) ) ){ throw new \Exception(sprintf('Column %s requires values property as array.', $column['type'])); } return $column; }
[ "public", "static", "function", "filter", "(", "$", "column", ")", "{", "$", "column", "=", "wp_parse_args", "(", "$", "column", ",", "[", "'type'", "=>", "''", ",", "'null'", "=>", "false", ",", "]", ")", ";", "// Type required.", "if", "(", "!", "self", "::", "exists", "(", "$", "column", "[", "'type'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You must properly specify the data type of column.'", ")", ";", "}", "// Check varchar length", "if", "(", "self", "::", "is_length_required", "(", "$", "column", "[", "'type'", "]", ")", "&&", "!", "isset", "(", "$", "column", "[", "'length'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Column %s requires length property.'", ",", "$", "column", "[", "'type'", "]", ")", ")", ";", "}", "// Signed or Unsigned?", "if", "(", "self", "::", "is_numeric", "(", "$", "column", "[", "'type'", "]", ")", ")", "{", "$", "column", "[", "'signed'", "]", "=", "isset", "(", "$", "column", "[", "'signed'", "]", ")", "?", "(", "bool", ")", "$", "column", "[", "'signed'", "]", ":", "true", ";", "}", "// If decimal, test_required params", "if", "(", "$", "column", "[", "'type'", "]", "==", "self", "::", "DECIMAL", ")", "{", "if", "(", "!", "isset", "(", "$", "column", "[", "'max_digit'", "]", ",", "$", "column", "[", "'float'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Column %s requires max_digit and float property.'", ",", "self", "::", "DECIMAL", ")", ")", ";", "}", "}", "// If enum or set, test required properties.", "if", "(", "self", "::", "is_set", "(", "$", "column", "[", "'type'", "]", ")", "&&", "(", "!", "is_array", "(", "$", "column", "[", "'values'", "]", ")", "||", "empty", "(", "$", "column", "[", "'values'", "]", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Column %s requires values property as array.'", ",", "$", "column", "[", "'type'", "]", ")", ")", ";", "}", "return", "$", "column", ";", "}" ]
Filter column array @param array $column @return array @throws \Exception
[ "Filter", "column", "array" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/Column.php#L213-L241
20,680
f1nder/SolutionPipelineBuilder
src/Solution/MongoAggregation/Pipeline/Query.php
Query.convertArgs
protected function convertArgs($step) { if ($step instanceof Operator) { $arguments = $step->getArguments(); } else { $arguments = $step; } if (is_array($arguments)) { $values = []; foreach ($arguments as $key => $args) { if ($args instanceof Operator) { if (is_string($key)) { $values[$key] = [$this->cmd.$args->getOperatorName() => $this->convertArgs($args)]; } else { $values[] = [$this->cmd.$args->getOperatorName() => $this->convertArgs($args)]; } } else { if (is_string($key)) { $values[$key] = $this->convertArgs($args); } else { $values[] = $args; } } } return $values; } elseif ($arguments instanceof Operator) { return [$this->cmd.$arguments->getOperatorName() => $this->convertArgs($arguments)]; } else { return $arguments; } }
php
protected function convertArgs($step) { if ($step instanceof Operator) { $arguments = $step->getArguments(); } else { $arguments = $step; } if (is_array($arguments)) { $values = []; foreach ($arguments as $key => $args) { if ($args instanceof Operator) { if (is_string($key)) { $values[$key] = [$this->cmd.$args->getOperatorName() => $this->convertArgs($args)]; } else { $values[] = [$this->cmd.$args->getOperatorName() => $this->convertArgs($args)]; } } else { if (is_string($key)) { $values[$key] = $this->convertArgs($args); } else { $values[] = $args; } } } return $values; } elseif ($arguments instanceof Operator) { return [$this->cmd.$arguments->getOperatorName() => $this->convertArgs($arguments)]; } else { return $arguments; } }
[ "protected", "function", "convertArgs", "(", "$", "step", ")", "{", "if", "(", "$", "step", "instanceof", "Operator", ")", "{", "$", "arguments", "=", "$", "step", "->", "getArguments", "(", ")", ";", "}", "else", "{", "$", "arguments", "=", "$", "step", ";", "}", "if", "(", "is_array", "(", "$", "arguments", ")", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "args", ")", "{", "if", "(", "$", "args", "instanceof", "Operator", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "values", "[", "$", "key", "]", "=", "[", "$", "this", "->", "cmd", ".", "$", "args", "->", "getOperatorName", "(", ")", "=>", "$", "this", "->", "convertArgs", "(", "$", "args", ")", "]", ";", "}", "else", "{", "$", "values", "[", "]", "=", "[", "$", "this", "->", "cmd", ".", "$", "args", "->", "getOperatorName", "(", ")", "=>", "$", "this", "->", "convertArgs", "(", "$", "args", ")", "]", ";", "}", "}", "else", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "values", "[", "$", "key", "]", "=", "$", "this", "->", "convertArgs", "(", "$", "args", ")", ";", "}", "else", "{", "$", "values", "[", "]", "=", "$", "args", ";", "}", "}", "}", "return", "$", "values", ";", "}", "elseif", "(", "$", "arguments", "instanceof", "Operator", ")", "{", "return", "[", "$", "this", "->", "cmd", ".", "$", "arguments", "->", "getOperatorName", "(", ")", "=>", "$", "this", "->", "convertArgs", "(", "$", "arguments", ")", "]", ";", "}", "else", "{", "return", "$", "arguments", ";", "}", "}" ]
Recursive convert args @todo refactor @param $step @return array|string
[ "Recursive", "convert", "args" ]
aca3cdfb2262fb3ceea82310b903c908c4c9b983
https://github.com/f1nder/SolutionPipelineBuilder/blob/aca3cdfb2262fb3ceea82310b903c908c4c9b983/src/Solution/MongoAggregation/Pipeline/Query.php#L70-L103
20,681
impensavel/essence
src/SOAP.php
SOAP.makeCall
public function makeCall(array $input) { $input = array_replace_recursive(array( 'function' => null, ), $input, array( 'arguments' => array(), 'options' => array(), 'headers' => array(), )); if (empty($input['function'])) { throw new EssenceException('The SOAP function is not set'); } try { $this->client->__soapCall( $input['function'], array($input['arguments']), $input['options'], $input['headers'], $this->lastResponseHeaders ); $this->lastRequest = $this->client->__getLastRequest(); $this->lastResponse = $this->client->__getLastResponse(); return $this->lastResponse; } catch (SoapFault $e) { $this->lastRequest = $this->client->__getLastRequest(); $this->lastResponse = $this->client->__getLastResponse(); throw new EssenceException($e->getMessage(), $e->getCode(), $e); } }
php
public function makeCall(array $input) { $input = array_replace_recursive(array( 'function' => null, ), $input, array( 'arguments' => array(), 'options' => array(), 'headers' => array(), )); if (empty($input['function'])) { throw new EssenceException('The SOAP function is not set'); } try { $this->client->__soapCall( $input['function'], array($input['arguments']), $input['options'], $input['headers'], $this->lastResponseHeaders ); $this->lastRequest = $this->client->__getLastRequest(); $this->lastResponse = $this->client->__getLastResponse(); return $this->lastResponse; } catch (SoapFault $e) { $this->lastRequest = $this->client->__getLastRequest(); $this->lastResponse = $this->client->__getLastResponse(); throw new EssenceException($e->getMessage(), $e->getCode(), $e); } }
[ "public", "function", "makeCall", "(", "array", "$", "input", ")", "{", "$", "input", "=", "array_replace_recursive", "(", "array", "(", "'function'", "=>", "null", ",", ")", ",", "$", "input", ",", "array", "(", "'arguments'", "=>", "array", "(", ")", ",", "'options'", "=>", "array", "(", ")", ",", "'headers'", "=>", "array", "(", ")", ",", ")", ")", ";", "if", "(", "empty", "(", "$", "input", "[", "'function'", "]", ")", ")", "{", "throw", "new", "EssenceException", "(", "'The SOAP function is not set'", ")", ";", "}", "try", "{", "$", "this", "->", "client", "->", "__soapCall", "(", "$", "input", "[", "'function'", "]", ",", "array", "(", "$", "input", "[", "'arguments'", "]", ")", ",", "$", "input", "[", "'options'", "]", ",", "$", "input", "[", "'headers'", "]", ",", "$", "this", "->", "lastResponseHeaders", ")", ";", "$", "this", "->", "lastRequest", "=", "$", "this", "->", "client", "->", "__getLastRequest", "(", ")", ";", "$", "this", "->", "lastResponse", "=", "$", "this", "->", "client", "->", "__getLastResponse", "(", ")", ";", "return", "$", "this", "->", "lastResponse", ";", "}", "catch", "(", "SoapFault", "$", "e", ")", "{", "$", "this", "->", "lastRequest", "=", "$", "this", "->", "client", "->", "__getLastRequest", "(", ")", ";", "$", "this", "->", "lastResponse", "=", "$", "this", "->", "client", "->", "__getLastResponse", "(", ")", ";", "throw", "new", "EssenceException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "}" ]
Make SOAP call @param array $input Input data @throws EssenceException @return string
[ "Make", "SOAP", "call" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/SOAP.php#L110-L143
20,682
unclecheese/silverstripe-blubber
code/Outputter.php
Outputter.ask
public function ask($question, $weight = "y") { $question = self::format($question); $y = $weight == 'y' ? 'Y' : 'y'; $n = $weight == 'n' ? 'N' : 'n'; $answer = $this->prompt("$question [$y/$n]"); $line = trim(strtolower($answer)); if(empty($line)) { $line = $weight; } return in_array($line, array('y','yes')); }
php
public function ask($question, $weight = "y") { $question = self::format($question); $y = $weight == 'y' ? 'Y' : 'y'; $n = $weight == 'n' ? 'N' : 'n'; $answer = $this->prompt("$question [$y/$n]"); $line = trim(strtolower($answer)); if(empty($line)) { $line = $weight; } return in_array($line, array('y','yes')); }
[ "public", "function", "ask", "(", "$", "question", ",", "$", "weight", "=", "\"y\"", ")", "{", "$", "question", "=", "self", "::", "format", "(", "$", "question", ")", ";", "$", "y", "=", "$", "weight", "==", "'y'", "?", "'Y'", ":", "'y'", ";", "$", "n", "=", "$", "weight", "==", "'n'", "?", "'N'", ":", "'n'", ";", "$", "answer", "=", "$", "this", "->", "prompt", "(", "\"$question [$y/$n]\"", ")", ";", "$", "line", "=", "trim", "(", "strtolower", "(", "$", "answer", ")", ")", ";", "if", "(", "empty", "(", "$", "line", ")", ")", "{", "$", "line", "=", "$", "weight", ";", "}", "return", "in_array", "(", "$", "line", ",", "array", "(", "'y'", ",", "'yes'", ")", ")", ";", "}" ]
Asks the user a question. If a 'y' value is entered, returns true @param string $question @param string $weight Either 'y' or 'n' can have the default value (on enter key) @return boolean
[ "Asks", "the", "user", "a", "question", ".", "If", "a", "y", "value", "is", "entered", "returns", "true" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/Outputter.php#L79-L91
20,683
unclecheese/silverstripe-blubber
code/Outputter.php
Outputter.prompt
public function prompt($question) { $question = self::format($question); $this->write("$question: "); $handle = fopen("php://stdin","r"); return fgets($handle); }
php
public function prompt($question) { $question = self::format($question); $this->write("$question: "); $handle = fopen("php://stdin","r"); return fgets($handle); }
[ "public", "function", "prompt", "(", "$", "question", ")", "{", "$", "question", "=", "self", "::", "format", "(", "$", "question", ")", ";", "$", "this", "->", "write", "(", "\"$question: \"", ")", ";", "$", "handle", "=", "fopen", "(", "\"php://stdin\"", ",", "\"r\"", ")", ";", "return", "fgets", "(", "$", "handle", ")", ";", "}" ]
Prompts the user for input @param string $question @return string
[ "Prompts", "the", "user", "for", "input" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/Outputter.php#L99-L105
20,684
unclecheese/silverstripe-blubber
code/Outputter.php
Outputter.updateProgress
public function updateProgress($text) { $text = self::format($text); if($this->progressValue) { $len = strlen($this->progressValue); fwrite(STDOUT, "\033[{$len}D"); } $this->progressValue = $text; fwrite(STDOUT, $this->progressValue); }
php
public function updateProgress($text) { $text = self::format($text); if($this->progressValue) { $len = strlen($this->progressValue); fwrite(STDOUT, "\033[{$len}D"); } $this->progressValue = $text; fwrite(STDOUT, $this->progressValue); }
[ "public", "function", "updateProgress", "(", "$", "text", ")", "{", "$", "text", "=", "self", "::", "format", "(", "$", "text", ")", ";", "if", "(", "$", "this", "->", "progressValue", ")", "{", "$", "len", "=", "strlen", "(", "$", "this", "->", "progressValue", ")", ";", "fwrite", "(", "STDOUT", ",", "\"\\033[{$len}D\"", ")", ";", "}", "$", "this", "->", "progressValue", "=", "$", "text", ";", "fwrite", "(", "STDOUT", ",", "$", "this", "->", "progressValue", ")", ";", "}" ]
Updates the output with new text @param string $text
[ "Updates", "the", "output", "with", "new", "text" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/Outputter.php#L112-L121
20,685
gedex/php-janrain-api
lib/Janrain/Api/Engage/ConfigureRP.php
ConfigureRP.setBackplaneProperties
public function setBackplaneProperties(array $params) { if (!isset($params['server'])) { throw new MissingArgumentException('server'); } if (!isset($params['bus'])) { throw new MissingArgumentException('bus'); } return $this->post('set_backplane_properties', $params); }
php
public function setBackplaneProperties(array $params) { if (!isset($params['server'])) { throw new MissingArgumentException('server'); } if (!isset($params['bus'])) { throw new MissingArgumentException('bus'); } return $this->post('set_backplane_properties', $params); }
[ "public", "function", "setBackplaneProperties", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'server'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'server'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "params", "[", "'bus'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'bus'", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'set_backplane_properties'", ",", "$", "params", ")", ";", "}" ]
Configures Backplane server used to communicate with all of the Backplane enabled widgets on a page. @param array $params @link http://developers.janrain.com/documentation/api-methods/engage/configure-rp/set_backplane_properties/
[ "Configures", "Backplane", "server", "used", "to", "communicate", "with", "all", "of", "the", "Backplane", "enabled", "widgets", "on", "a", "page", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/ConfigureRP.php#L64-L75
20,686
NuclearCMS/Hierarchy
src/Builders/FormBuilder.php
FormBuilder.build
public function build($name, Collection $fields = null) { $path = $this->getClassFilePath($name); $contents = view('_hierarchy::entities.form', [ 'name' => $this->getClassName($name), 'fields' => $fields ?: [] ])->render(); $this->write($path, $contents); }
php
public function build($name, Collection $fields = null) { $path = $this->getClassFilePath($name); $contents = view('_hierarchy::entities.form', [ 'name' => $this->getClassName($name), 'fields' => $fields ?: [] ])->render(); $this->write($path, $contents); }
[ "public", "function", "build", "(", "$", "name", ",", "Collection", "$", "fields", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "getClassFilePath", "(", "$", "name", ")", ";", "$", "contents", "=", "view", "(", "'_hierarchy::entities.form'", ",", "[", "'name'", "=>", "$", "this", "->", "getClassName", "(", "$", "name", ")", ",", "'fields'", "=>", "$", "fields", "?", ":", "[", "]", "]", ")", "->", "render", "(", ")", ";", "$", "this", "->", "write", "(", "$", "path", ",", "$", "contents", ")", ";", "}" ]
Builds a source form @param string $name @param Collection|null $fields
[ "Builds", "a", "source", "form" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/FormBuilder.php#L20-L30
20,687
endorphin-studio/browser-detector-data
src/Storage/FileStorage.php
FileStorage.getFileNames
protected function getFileNames(string $directory = 'default'): array { $directoryIterator = $this->getDirectoryIterator($directory); $files = []; foreach ($directoryIterator as $file) { $this->resolveFile($file, $files); } return $files; }
php
protected function getFileNames(string $directory = 'default'): array { $directoryIterator = $this->getDirectoryIterator($directory); $files = []; foreach ($directoryIterator as $file) { $this->resolveFile($file, $files); } return $files; }
[ "protected", "function", "getFileNames", "(", "string", "$", "directory", "=", "'default'", ")", ":", "array", "{", "$", "directoryIterator", "=", "$", "this", "->", "getDirectoryIterator", "(", "$", "directory", ")", ";", "$", "files", "=", "[", "]", ";", "foreach", "(", "$", "directoryIterator", "as", "$", "file", ")", "{", "$", "this", "->", "resolveFile", "(", "$", "file", ",", "$", "files", ")", ";", "}", "return", "$", "files", ";", "}" ]
Get list of paths in directory @param string $directory @return array
[ "Get", "list", "of", "paths", "in", "directory" ]
cb1ace9f52f9677616c89f3b80c5148936d47b82
https://github.com/endorphin-studio/browser-detector-data/blob/cb1ace9f52f9677616c89f3b80c5148936d47b82/src/Storage/FileStorage.php#L35-L43
20,688
endorphin-studio/browser-detector-data
src/Storage/FileStorage.php
FileStorage.resolveFile
private function resolveFile(\DirectoryIterator $file, array &$files) { if ($file->isDir() && !$file->isDot()) { $files = Tools::resolvePath($files, $this->getFileNames()); } if ($file->isFile() && !$file->isLink() && $file->isReadable()) { $files = Tools::resolvePath($files, $file->getRealPath()); } }
php
private function resolveFile(\DirectoryIterator $file, array &$files) { if ($file->isDir() && !$file->isDot()) { $files = Tools::resolvePath($files, $this->getFileNames()); } if ($file->isFile() && !$file->isLink() && $file->isReadable()) { $files = Tools::resolvePath($files, $file->getRealPath()); } }
[ "private", "function", "resolveFile", "(", "\\", "DirectoryIterator", "$", "file", ",", "array", "&", "$", "files", ")", "{", "if", "(", "$", "file", "->", "isDir", "(", ")", "&&", "!", "$", "file", "->", "isDot", "(", ")", ")", "{", "$", "files", "=", "Tools", "::", "resolvePath", "(", "$", "files", ",", "$", "this", "->", "getFileNames", "(", ")", ")", ";", "}", "if", "(", "$", "file", "->", "isFile", "(", ")", "&&", "!", "$", "file", "->", "isLink", "(", ")", "&&", "$", "file", "->", "isReadable", "(", ")", ")", "{", "$", "files", "=", "Tools", "::", "resolvePath", "(", "$", "files", ",", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "}", "}" ]
Add file to list or scan directory @param \DirectoryIterator $file @param array $files
[ "Add", "file", "to", "list", "or", "scan", "directory" ]
cb1ace9f52f9677616c89f3b80c5148936d47b82
https://github.com/endorphin-studio/browser-detector-data/blob/cb1ace9f52f9677616c89f3b80c5148936d47b82/src/Storage/FileStorage.php#L50-L59
20,689
endorphin-studio/browser-detector-data
src/Storage/FileStorage.php
FileStorage.getDirectoryIterator
private function getDirectoryIterator(string $directory): \DirectoryIterator { if ($directory === 'default') { return new \DirectoryIterator($this->dataDirectory); } return new \DirectoryIterator($directory); }
php
private function getDirectoryIterator(string $directory): \DirectoryIterator { if ($directory === 'default') { return new \DirectoryIterator($this->dataDirectory); } return new \DirectoryIterator($directory); }
[ "private", "function", "getDirectoryIterator", "(", "string", "$", "directory", ")", ":", "\\", "DirectoryIterator", "{", "if", "(", "$", "directory", "===", "'default'", ")", "{", "return", "new", "\\", "DirectoryIterator", "(", "$", "this", "->", "dataDirectory", ")", ";", "}", "return", "new", "\\", "DirectoryIterator", "(", "$", "directory", ")", ";", "}" ]
Get Directory Iterator @param string $directory @return \DirectoryIterator
[ "Get", "Directory", "Iterator" ]
cb1ace9f52f9677616c89f3b80c5148936d47b82
https://github.com/endorphin-studio/browser-detector-data/blob/cb1ace9f52f9677616c89f3b80c5148936d47b82/src/Storage/FileStorage.php#L66-L72
20,690
philiplb/Valdi
src/Valdi/Validator/AbstractDateTimeComparator.php
AbstractDateTimeComparator.getDateTimeFormat
protected function getDateTimeFormat($parameters) { $format = 'Y-m-d H:i:s'; $parametersCount = count($parameters); if ($parametersCount > $this->amountOfParameters) { $format = $parameters[$parametersCount - 1]; } return $format; }
php
protected function getDateTimeFormat($parameters) { $format = 'Y-m-d H:i:s'; $parametersCount = count($parameters); if ($parametersCount > $this->amountOfParameters) { $format = $parameters[$parametersCount - 1]; } return $format; }
[ "protected", "function", "getDateTimeFormat", "(", "$", "parameters", ")", "{", "$", "format", "=", "'Y-m-d H:i:s'", ";", "$", "parametersCount", "=", "count", "(", "$", "parameters", ")", ";", "if", "(", "$", "parametersCount", ">", "$", "this", "->", "amountOfParameters", ")", "{", "$", "format", "=", "$", "parameters", "[", "$", "parametersCount", "-", "1", "]", ";", "}", "return", "$", "format", ";", "}" ]
Gets a date time format from the parameters if given or a default one. @param string[] $parameters the parameters @return string the date time format
[ "Gets", "a", "date", "time", "format", "from", "the", "parameters", "if", "given", "or", "a", "default", "one", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/AbstractDateTimeComparator.php#L63-L70
20,691
philiplb/Valdi
src/Valdi/Validator/AbstractDateTimeComparator.php
AbstractDateTimeComparator.getDateTimes
protected function getDateTimes(array $parameters, $format) { if (!$this->dateTimeParameters) { return []; } $datetimes = []; for ($i = 0; $i < $this->amountOfParameters; ++$i) { $datetime = \DateTime::createFromFormat($format, $parameters[$i]); if ($datetime === false) { throw new ValidationException('"'.$this->type.'" expects a date of the format "'.$format.'".'); } $datetimes[] = $datetime; } return $datetimes; }
php
protected function getDateTimes(array $parameters, $format) { if (!$this->dateTimeParameters) { return []; } $datetimes = []; for ($i = 0; $i < $this->amountOfParameters; ++$i) { $datetime = \DateTime::createFromFormat($format, $parameters[$i]); if ($datetime === false) { throw new ValidationException('"'.$this->type.'" expects a date of the format "'.$format.'".'); } $datetimes[] = $datetime; } return $datetimes; }
[ "protected", "function", "getDateTimes", "(", "array", "$", "parameters", ",", "$", "format", ")", "{", "if", "(", "!", "$", "this", "->", "dateTimeParameters", ")", "{", "return", "[", "]", ";", "}", "$", "datetimes", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "amountOfParameters", ";", "++", "$", "i", ")", "{", "$", "datetime", "=", "\\", "DateTime", "::", "createFromFormat", "(", "$", "format", ",", "$", "parameters", "[", "$", "i", "]", ")", ";", "if", "(", "$", "datetime", "===", "false", ")", "{", "throw", "new", "ValidationException", "(", "'\"'", ".", "$", "this", "->", "type", ".", "'\" expects a date of the format \"'", ".", "$", "format", ".", "'\".'", ")", ";", "}", "$", "datetimes", "[", "]", "=", "$", "datetime", ";", "}", "return", "$", "datetimes", ";", "}" ]
Interprets the given parameters as date times and returns them. @param array $parameters the parameters @param string $format the date time format @return \DateTime[] the date times @throws ValidationException thrown if one of the parameters is not a date in the given format
[ "Interprets", "the", "given", "parameters", "as", "date", "times", "and", "returns", "them", "." ]
9927ec34a2cb00cec705e952d3c2374e2dc3c972
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/AbstractDateTimeComparator.php#L86-L99
20,692
ouropencode/dachi
src/Model.php
Model.jsonSerialize
public function jsonSerialize() { $json = array(); foreach(get_object_vars($this) as $var => $val) { if($val instanceof \DateTime) $json[$var] = $val->getTimestamp(); else $json[$var] = $val; } return $json; }
php
public function jsonSerialize() { $json = array(); foreach(get_object_vars($this) as $var => $val) { if($val instanceof \DateTime) $json[$var] = $val->getTimestamp(); else $json[$var] = $val; } return $json; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "json", "=", "array", "(", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "var", "=>", "$", "val", ")", "{", "if", "(", "$", "val", "instanceof", "\\", "DateTime", ")", "$", "json", "[", "$", "var", "]", "=", "$", "val", "->", "getTimestamp", "(", ")", ";", "else", "$", "json", "[", "$", "var", "]", "=", "$", "val", ";", "}", "return", "$", "json", ";", "}" ]
Get a json serialized version of this object. @return array
[ "Get", "a", "json", "serialized", "version", "of", "this", "object", "." ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Model.php#L18-L29
20,693
andromeda-framework/doctrine
src/Doctrine/Cache/Cache.php
Cache.doSaveDependingOnFiles
protected function doSaveDependingOnFiles($id, $data, array $files, $lifeTime = 0) { $dependencies = [ NetteCache::TAGS => ['doctrine'], NetteCache::FILES => $files ]; if ($lifeTime != 0) { $dependencies[NetteCache::EXPIRE] = time() + $lifeTime; } $this->cache->save($id, $data, $dependencies); return TRUE; }
php
protected function doSaveDependingOnFiles($id, $data, array $files, $lifeTime = 0) { $dependencies = [ NetteCache::TAGS => ['doctrine'], NetteCache::FILES => $files ]; if ($lifeTime != 0) { $dependencies[NetteCache::EXPIRE] = time() + $lifeTime; } $this->cache->save($id, $data, $dependencies); return TRUE; }
[ "protected", "function", "doSaveDependingOnFiles", "(", "$", "id", ",", "$", "data", ",", "array", "$", "files", ",", "$", "lifeTime", "=", "0", ")", "{", "$", "dependencies", "=", "[", "NetteCache", "::", "TAGS", "=>", "[", "'doctrine'", "]", ",", "NetteCache", "::", "FILES", "=>", "$", "files", "]", ";", "if", "(", "$", "lifeTime", "!=", "0", ")", "{", "$", "dependencies", "[", "NetteCache", "::", "EXPIRE", "]", "=", "time", "(", ")", "+", "$", "lifeTime", ";", "}", "$", "this", "->", "cache", "->", "save", "(", "$", "id", ",", "$", "data", ",", "$", "dependencies", ")", ";", "return", "TRUE", ";", "}" ]
Puts data into the cache and makes them depending on the files. @param string $id the cache id @param string $data the cache entry/data @param string[] $files the list of files the data are depending on @param int $lifeTime the lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime) @return bool TRUE
[ "Puts", "data", "into", "the", "cache", "and", "makes", "them", "depending", "on", "the", "files", "." ]
46924d91c09e0b9fbe5764518cbad70e467ffad4
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/Cache/Cache.php#L126-L138
20,694
dragonmantank/fillet
src/Fillet/Writer/AbstractWriter.php
AbstractWriter.toMarkdown
protected function toMarkdown($content) { $tmpfname = tempnam(sys_get_temp_dir(), 'fillet'); // good file_put_contents($tmpfname, $content); $cmd = $this->config['pandoc']['bin'] . ' --no-wrap -f html -t markdown ' . $tmpfname; $content = shell_exec($cmd); unlink($tmpfname); return $content; }
php
protected function toMarkdown($content) { $tmpfname = tempnam(sys_get_temp_dir(), 'fillet'); // good file_put_contents($tmpfname, $content); $cmd = $this->config['pandoc']['bin'] . ' --no-wrap -f html -t markdown ' . $tmpfname; $content = shell_exec($cmd); unlink($tmpfname); return $content; }
[ "protected", "function", "toMarkdown", "(", "$", "content", ")", "{", "$", "tmpfname", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'fillet'", ")", ";", "// good", "file_put_contents", "(", "$", "tmpfname", ",", "$", "content", ")", ";", "$", "cmd", "=", "$", "this", "->", "config", "[", "'pandoc'", "]", "[", "'bin'", "]", ".", "' --no-wrap -f html -t markdown '", ".", "$", "tmpfname", ";", "$", "content", "=", "shell_exec", "(", "$", "cmd", ")", ";", "unlink", "(", "$", "tmpfname", ")", ";", "return", "$", "content", ";", "}" ]
Converts content from HTML to Markdown via pandoc @param $content @return string
[ "Converts", "content", "from", "HTML", "to", "Markdown", "via", "pandoc" ]
b197947608c05ac2318e8f6b296345494004d9c6
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Writer/AbstractWriter.php#L44-L52
20,695
willhoffmann/domuserp-php
src/Resources/Addresses/Secondary/Streets.php
Streets.get
public function get($id) { $resource = self::$BASE_URI . '/' . $this->cityId . '/bairros/' . $this->neighborhoodId . '/logradouro/' . $id; $data = $this->execute(self::HTTP_GET, $resource); return $data; }
php
public function get($id) { $resource = self::$BASE_URI . '/' . $this->cityId . '/bairros/' . $this->neighborhoodId . '/logradouro/' . $id; $data = $this->execute(self::HTTP_GET, $resource); return $data; }
[ "public", "function", "get", "(", "$", "id", ")", "{", "$", "resource", "=", "self", "::", "$", "BASE_URI", ".", "'/'", ".", "$", "this", "->", "cityId", ".", "'/bairros/'", ".", "$", "this", "->", "neighborhoodId", ".", "'/logradouro/'", ".", "$", "id", ";", "$", "data", "=", "$", "this", "->", "execute", "(", "self", "::", "HTTP_GET", ",", "$", "resource", ")", ";", "return", "$", "data", ";", "}" ]
Gets the street data according to the id parameter @param int $id @return array|string @throws \GuzzleHttp\Exception\GuzzleException
[ "Gets", "the", "street", "data", "according", "to", "the", "id", "parameter" ]
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Addresses/Secondary/Streets.php#L64-L70
20,696
gitiki/Gitiki
src/RouteCollection.php
RouteCollection.addBefore
public function addBefore($before, $name, SymfonyRoute $route) { $newRoute = $route; foreach ($this->all() as $routeName => $route) { if (null !== $newRoute && $before === $routeName) { $this->add($name, $newRoute); $newRoute = null; } if (null === $newRoute) { // move the existing route onto the end of collection $this->add($routeName, $route); } } if (null !== $newRoute) { throw new \InvalidArgumentException(sprintf('The route "%s" cannot be added before "%s", because the route "%2$s" was not found.', $name, $before)); } }
php
public function addBefore($before, $name, SymfonyRoute $route) { $newRoute = $route; foreach ($this->all() as $routeName => $route) { if (null !== $newRoute && $before === $routeName) { $this->add($name, $newRoute); $newRoute = null; } if (null === $newRoute) { // move the existing route onto the end of collection $this->add($routeName, $route); } } if (null !== $newRoute) { throw new \InvalidArgumentException(sprintf('The route "%s" cannot be added before "%s", because the route "%2$s" was not found.', $name, $before)); } }
[ "public", "function", "addBefore", "(", "$", "before", ",", "$", "name", ",", "SymfonyRoute", "$", "route", ")", "{", "$", "newRoute", "=", "$", "route", ";", "foreach", "(", "$", "this", "->", "all", "(", ")", "as", "$", "routeName", "=>", "$", "route", ")", "{", "if", "(", "null", "!==", "$", "newRoute", "&&", "$", "before", "===", "$", "routeName", ")", "{", "$", "this", "->", "add", "(", "$", "name", ",", "$", "newRoute", ")", ";", "$", "newRoute", "=", "null", ";", "}", "if", "(", "null", "===", "$", "newRoute", ")", "{", "// move the existing route onto the end of collection", "$", "this", "->", "add", "(", "$", "routeName", ",", "$", "route", ")", ";", "}", "}", "if", "(", "null", "!==", "$", "newRoute", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The route \"%s\" cannot be added before \"%s\", because the route \"%2$s\" was not found.'", ",", "$", "name", ",", "$", "before", ")", ")", ";", "}", "}" ]
Adds a route before another. @param string $before The before route name @param string $name The route name @param Route $route A Route instance @throws \InvalidArgumentException If the before route name cannot be found
[ "Adds", "a", "route", "before", "another", "." ]
f017672d4f5d0ef6015fad44724f05e3b1f08463
https://github.com/gitiki/Gitiki/blob/f017672d4f5d0ef6015fad44724f05e3b1f08463/src/RouteCollection.php#L20-L38
20,697
hametuha/wpametu
src/WPametu/Utility/IteratorWalker.php
IteratorWalker.key_search
public function key_search( array $array, $key, $value ) { foreach ( $array as $key => $a ) { if ( isset( $a[ $key ] ) && $a[ $key ] == $value ) { return $key; } } return false; }
php
public function key_search( array $array, $key, $value ) { foreach ( $array as $key => $a ) { if ( isset( $a[ $key ] ) && $a[ $key ] == $value ) { return $key; } } return false; }
[ "public", "function", "key_search", "(", "array", "$", "array", ",", "$", "key", ",", "$", "value", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "a", ")", "{", "if", "(", "isset", "(", "$", "a", "[", "$", "key", "]", ")", "&&", "$", "a", "[", "$", "key", "]", "==", "$", "value", ")", "{", "return", "$", "key", ";", "}", "}", "return", "false", ";", "}" ]
Get index of array member with specified key @param array $array @param string $key @param mixed $value @return false|int|string
[ "Get", "index", "of", "array", "member", "with", "specified", "key" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/IteratorWalker.php#L36-L44
20,698
hametuha/wpametu
src/WPametu/Utility/IteratorWalker.php
IteratorWalker.prop_search
public function prop_search( array $array, $property, $value ) { foreach ( $array as $key => $a ) { if ( property_exists( $a, $property ) && $a->{$property} == $value ) { return $key; } } return false; }
php
public function prop_search( array $array, $property, $value ) { foreach ( $array as $key => $a ) { if ( property_exists( $a, $property ) && $a->{$property} == $value ) { return $key; } } return false; }
[ "public", "function", "prop_search", "(", "array", "$", "array", ",", "$", "property", ",", "$", "value", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "a", ")", "{", "if", "(", "property_exists", "(", "$", "a", ",", "$", "property", ")", "&&", "$", "a", "->", "{", "$", "property", "}", "==", "$", "value", ")", "{", "return", "$", "key", ";", "}", "}", "return", "false", ";", "}" ]
Search array member with specified property @param array $array @param string $property @param mixed $value @return false|int|string
[ "Search", "array", "member", "with", "specified", "property" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/IteratorWalker.php#L68-L76
20,699
krakphp/job
src/Kernel.php
Kernel.queueConfigs
private function queueConfigs() { $config = $this->getConfig(); if (!isset($config['schedulers'])) { yield $config; return; } foreach ($config['schedulers'] as $child_config) { yield mergeConfigOptions($config, $child_config); } }
php
private function queueConfigs() { $config = $this->getConfig(); if (!isset($config['schedulers'])) { yield $config; return; } foreach ($config['schedulers'] as $child_config) { yield mergeConfigOptions($config, $child_config); } }
[ "private", "function", "queueConfigs", "(", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'schedulers'", "]", ")", ")", "{", "yield", "$", "config", ";", "return", ";", "}", "foreach", "(", "$", "config", "[", "'schedulers'", "]", "as", "$", "child_config", ")", "{", "yield", "mergeConfigOptions", "(", "$", "config", ",", "$", "child_config", ")", ";", "}", "}" ]
return only the normalized queue configurations
[ "return", "only", "the", "normalized", "queue", "configurations" ]
0c16020c1baa13d91f819ecba8334861ba7c4d6c
https://github.com/krakphp/job/blob/0c16020c1baa13d91f819ecba8334861ba7c4d6c/src/Kernel.php#L65-L75