repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
nguyenanhung/requests
src/GetContents.php
GetContents.setJsonPretty
public function setJsonPretty($value = FALSE) { if (!$value) { $this->isJsonPretty = FALSE; } else { $this->isJsonPretty = TRUE; } }
php
public function setJsonPretty($value = FALSE) { if (!$value) { $this->isJsonPretty = FALSE; } else { $this->isJsonPretty = TRUE; } }
[ "public", "function", "setJsonPretty", "(", "$", "value", "=", "FALSE", ")", "{", "if", "(", "!", "$", "value", ")", "{", "$", "this", "->", "isJsonPretty", "=", "FALSE", ";", "}", "else", "{", "$", "this", "->", "isJsonPretty", "=", "TRUE", ";", "}", "}" ]
Should JSON being sent be encoded in an easily readable format? Only useful for debugging @param boolean $value true for JSON_PRETTY_PRINT @author: 713uk13m <[email protected]> @time : 10/7/18 02:17
[ "Should", "JSON", "being", "sent", "be", "encoded", "in", "an", "easily", "readable", "format?", "Only", "useful", "for", "debugging" ]
train
https://github.com/nguyenanhung/requests/blob/fae98614a256be6a3ff9bea34a273d182a3ae730/src/GetContents.php#L755-L762
nguyenanhung/requests
src/GetContents.php
GetContents.setVerifyPeer
public function setVerifyPeer($value = FALSE) { if (!$value) { $this->verifyPeer = FALSE; } else { $this->verifyPeer = TRUE; } }
php
public function setVerifyPeer($value = FALSE) { if (!$value) { $this->verifyPeer = FALSE; } else { $this->verifyPeer = TRUE; } }
[ "public", "function", "setVerifyPeer", "(", "$", "value", "=", "FALSE", ")", "{", "if", "(", "!", "$", "value", ")", "{", "$", "this", "->", "verifyPeer", "=", "FALSE", ";", "}", "else", "{", "$", "this", "->", "verifyPeer", "=", "TRUE", ";", "}", "}" ]
Should SSL peers be verified? @author: 713uk13m <[email protected]> @time : 10/7/18 02:17 @param bool $value
[ "Should", "SSL", "peers", "be", "verified?" ]
train
https://github.com/nguyenanhung/requests/blob/fae98614a256be6a3ff9bea34a273d182a3ae730/src/GetContents.php#L772-L779
nguyenanhung/requests
src/GetContents.php
GetContents.parseReturnHeaders
public function parseReturnHeaders($headers) { $head = []; foreach ($headers as $k => $v) { $t = explode(':', $v, 2); if (isset($t[1])) { $head[trim($t[0])] = trim($t[1]); } else { $head[] = $v; if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) { $head['reponse_code'] = intval($out[1]); } } } $this->debug->debug(__FUNCTION__, 'Response Header: ', $head); return $head; }
php
public function parseReturnHeaders($headers) { $head = []; foreach ($headers as $k => $v) { $t = explode(':', $v, 2); if (isset($t[1])) { $head[trim($t[0])] = trim($t[1]); } else { $head[] = $v; if (preg_match("#HTTP/[0-9\.]+\s+([0-9]+)#", $v, $out)) { $head['reponse_code'] = intval($out[1]); } } } $this->debug->debug(__FUNCTION__, 'Response Header: ', $head); return $head; }
[ "public", "function", "parseReturnHeaders", "(", "$", "headers", ")", "{", "$", "head", "=", "[", "]", ";", "foreach", "(", "$", "headers", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "t", "=", "explode", "(", "':'", ",", "$", "v", ",", "2", ")", ";", "if", "(", "isset", "(", "$", "t", "[", "1", "]", ")", ")", "{", "$", "head", "[", "trim", "(", "$", "t", "[", "0", "]", ")", "]", "=", "trim", "(", "$", "t", "[", "1", "]", ")", ";", "}", "else", "{", "$", "head", "[", "]", "=", "$", "v", ";", "if", "(", "preg_match", "(", "\"#HTTP/[0-9\\.]+\\s+([0-9]+)#\"", ",", "$", "v", ",", "$", "out", ")", ")", "{", "$", "head", "[", "'reponse_code'", "]", "=", "intval", "(", "$", "out", "[", "1", "]", ")", ";", "}", "}", "}", "$", "this", "->", "debug", "->", "debug", "(", "__FUNCTION__", ",", "'Response Header: '", ",", "$", "head", ")", ";", "return", "$", "head", ";", "}" ]
Parse HTTP response headers @author: 713uk13m <[email protected]> @time : 10/7/18 02:17 @param array $headers @return array Header Response
[ "Parse", "HTTP", "response", "headers" ]
train
https://github.com/nguyenanhung/requests/blob/fae98614a256be6a3ff9bea34a273d182a3ae730/src/GetContents.php#L806-L823
cmsgears/module-community
admin/controllers/apix/ChatController.php
ChatController.init
public function init() { parent::init(); // Permission $this->crudPermission = CmnGlobal::PERM_GROUP_ADMIN; // Services $this->modelService = Yii::$app->factory->get( 'chatService' ); }
php
public function init() { parent::init(); // Permission $this->crudPermission = CmnGlobal::PERM_GROUP_ADMIN; // Services $this->modelService = Yii::$app->factory->get( 'chatService' ); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "// Permission", "$", "this", "->", "crudPermission", "=", "CmnGlobal", "::", "PERM_GROUP_ADMIN", ";", "// Services", "$", "this", "->", "modelService", "=", "Yii", "::", "$", "app", "->", "factory", "->", "get", "(", "'chatService'", ")", ";", "}" ]
Constructor and Initialisation ------------------------------
[ "Constructor", "and", "Initialisation", "------------------------------" ]
train
https://github.com/cmsgears/module-community/blob/0ca9cf0aa0cee395a4788bd6085f291e10728555/admin/controllers/apix/ChatController.php#L40-L49
bseddon/XPath20
Iterator/PositionFilterNodeIterator.php
PositionFilterNodeIterator.NextItem
protected function NextItem() { while ( $this->iter->MoveNext() ) { if ( $this->iter->getSequentialPosition() == $this->position ) { $this->iter->ResetSequentialPosition(); return $this->iter->getCurrent(); } } return null; }
php
protected function NextItem() { while ( $this->iter->MoveNext() ) { if ( $this->iter->getSequentialPosition() == $this->position ) { $this->iter->ResetSequentialPosition(); return $this->iter->getCurrent(); } } return null; }
[ "protected", "function", "NextItem", "(", ")", "{", "while", "(", "$", "this", "->", "iter", "->", "MoveNext", "(", ")", ")", "{", "if", "(", "$", "this", "->", "iter", "->", "getSequentialPosition", "(", ")", "==", "$", "this", "->", "position", ")", "{", "$", "this", "->", "iter", "->", "ResetSequentialPosition", "(", ")", ";", "return", "$", "this", "->", "iter", "->", "getCurrent", "(", ")", ";", "}", "}", "return", "null", ";", "}" ]
NextItem @return XPathItem
[ "NextItem" ]
train
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Iterator/PositionFilterNodeIterator.php#L85-L96
Hnto/nuki
src/Application/Application.php
Application.registerService
public function registerService($service, $name = '') { if (empty($name)) { $name = Assist::classNameShort($service); } static::$container->offsetSet(strtolower($name), $service); }
php
public function registerService($service, $name = '') { if (empty($name)) { $name = Assist::classNameShort($service); } static::$container->offsetSet(strtolower($name), $service); }
[ "public", "function", "registerService", "(", "$", "service", ",", "$", "name", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "Assist", "::", "classNameShort", "(", "$", "service", ")", ";", "}", "static", "::", "$", "container", "->", "offsetSet", "(", "strtolower", "(", "$", "name", ")", ",", "$", "service", ")", ";", "}" ]
Register a service @param object $service @param string $name
[ "Register", "a", "service" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L155-L161
Hnto/nuki
src/Application/Application.php
Application.getService
public function getService($serviceName) { if (static::$container->offsetExists($serviceName) === false) { return null; } return static::$container->offsetGet($serviceName); }
php
public function getService($serviceName) { if (static::$container->offsetExists($serviceName) === false) { return null; } return static::$container->offsetGet($serviceName); }
[ "public", "function", "getService", "(", "$", "serviceName", ")", "{", "if", "(", "static", "::", "$", "container", "->", "offsetExists", "(", "$", "serviceName", ")", "===", "false", ")", "{", "return", "null", ";", "}", "return", "static", "::", "$", "container", "->", "offsetGet", "(", "$", "serviceName", ")", ";", "}" ]
Get a service @param string $serviceName @return object|null
[ "Get", "a", "service" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L169-L175
Hnto/nuki
src/Application/Application.php
Application.run
public function run() { /** @var Request $request */ $request = $this->getService('request-handler'); //Process incoming request $request->incoming($this); //Register helper services $helpers = static::$container['helpers']; foreach($helpers as $helper => $options) { $this->registerService(new $helper($options)); } //Start session $this->getService('session-handler')->start(); //Execute callback if ($this->getService('router')->routeIsCallable()) { $this->executeCallback(); return; } //Execute extenders $this->executeUnitExtenders($this->getActiveUnit()); $this->executeService(); }
php
public function run() { /** @var Request $request */ $request = $this->getService('request-handler'); //Process incoming request $request->incoming($this); //Register helper services $helpers = static::$container['helpers']; foreach($helpers as $helper => $options) { $this->registerService(new $helper($options)); } //Start session $this->getService('session-handler')->start(); //Execute callback if ($this->getService('router')->routeIsCallable()) { $this->executeCallback(); return; } //Execute extenders $this->executeUnitExtenders($this->getActiveUnit()); $this->executeService(); }
[ "public", "function", "run", "(", ")", "{", "/** @var Request $request */", "$", "request", "=", "$", "this", "->", "getService", "(", "'request-handler'", ")", ";", "//Process incoming request", "$", "request", "->", "incoming", "(", "$", "this", ")", ";", "//Register helper services", "$", "helpers", "=", "static", "::", "$", "container", "[", "'helpers'", "]", ";", "foreach", "(", "$", "helpers", "as", "$", "helper", "=>", "$", "options", ")", "{", "$", "this", "->", "registerService", "(", "new", "$", "helper", "(", "$", "options", ")", ")", ";", "}", "//Start session", "$", "this", "->", "getService", "(", "'session-handler'", ")", "->", "start", "(", ")", ";", "//Execute callback", "if", "(", "$", "this", "->", "getService", "(", "'router'", ")", "->", "routeIsCallable", "(", ")", ")", "{", "$", "this", "->", "executeCallback", "(", ")", ";", "return", ";", "}", "//Execute extenders", "$", "this", "->", "executeUnitExtenders", "(", "$", "this", "->", "getActiveUnit", "(", ")", ")", ";", "$", "this", "->", "executeService", "(", ")", ";", "}" ]
Run the application - Incoming request will be handled - Registration in the application will be done - Session will be started - Service will be executed @return mixed
[ "Run", "the", "application", "-", "Incoming", "request", "will", "be", "handled", "-", "Registration", "in", "the", "application", "will", "be", "done", "-", "Session", "will", "be", "started", "-", "Service", "will", "be", "executed" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L278-L306
Hnto/nuki
src/Application/Application.php
Application.executeUnitExtenders
public function executeUnitExtenders(string $unit) { $extenders = $this->getService('unit-extenders'); if (!is_array($extenders)) { return; } foreach ($extenders as $extender) { if (!class_exists($extender)) { continue; } /** @var Resolver $resolver */ $resolver = $this->getService('resolver'); try { $resolver->resolve( $extender, Extender::EXECUTE_METHOD, $this ); } catch (Base $e) { $this->getService('response-handler') ->setContent(new Content($e->getMessage())) ->send(); } } }
php
public function executeUnitExtenders(string $unit) { $extenders = $this->getService('unit-extenders'); if (!is_array($extenders)) { return; } foreach ($extenders as $extender) { if (!class_exists($extender)) { continue; } /** @var Resolver $resolver */ $resolver = $this->getService('resolver'); try { $resolver->resolve( $extender, Extender::EXECUTE_METHOD, $this ); } catch (Base $e) { $this->getService('response-handler') ->setContent(new Content($e->getMessage())) ->send(); } } }
[ "public", "function", "executeUnitExtenders", "(", "string", "$", "unit", ")", "{", "$", "extenders", "=", "$", "this", "->", "getService", "(", "'unit-extenders'", ")", ";", "if", "(", "!", "is_array", "(", "$", "extenders", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "extenders", "as", "$", "extender", ")", "{", "if", "(", "!", "class_exists", "(", "$", "extender", ")", ")", "{", "continue", ";", "}", "/** @var Resolver $resolver */", "$", "resolver", "=", "$", "this", "->", "getService", "(", "'resolver'", ")", ";", "try", "{", "$", "resolver", "->", "resolve", "(", "$", "extender", ",", "Extender", "::", "EXECUTE_METHOD", ",", "$", "this", ")", ";", "}", "catch", "(", "Base", "$", "e", ")", "{", "$", "this", "->", "getService", "(", "'response-handler'", ")", "->", "setContent", "(", "new", "Content", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", "->", "send", "(", ")", ";", "}", "}", "}" ]
Execute unit extenders @param string $unit
[ "Execute", "unit", "extenders" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L313-L341
Hnto/nuki
src/Application/Application.php
Application.executeService
public function executeService() { //Add route to last used route $this->getService('router') ->setLastRouteUsed( $this->getService('request-handler')->queryPath() ); /** @var Resolver $resolver */ $resolver = $this->getService('resolver'); //Execute service and process try { $resolver->resolve( $this->getActiveUnit() . self::APPLICATION_SERVICES_TRAIL . $this->getActiveService(), $this->getActiveProcess(), $this ); } catch (Base $e) { $this->getService('response-handler') ->setContent(new Content($e->getMessage())) ->send(); } }
php
public function executeService() { //Add route to last used route $this->getService('router') ->setLastRouteUsed( $this->getService('request-handler')->queryPath() ); /** @var Resolver $resolver */ $resolver = $this->getService('resolver'); //Execute service and process try { $resolver->resolve( $this->getActiveUnit() . self::APPLICATION_SERVICES_TRAIL . $this->getActiveService(), $this->getActiveProcess(), $this ); } catch (Base $e) { $this->getService('response-handler') ->setContent(new Content($e->getMessage())) ->send(); } }
[ "public", "function", "executeService", "(", ")", "{", "//Add route to last used route", "$", "this", "->", "getService", "(", "'router'", ")", "->", "setLastRouteUsed", "(", "$", "this", "->", "getService", "(", "'request-handler'", ")", "->", "queryPath", "(", ")", ")", ";", "/** @var Resolver $resolver */", "$", "resolver", "=", "$", "this", "->", "getService", "(", "'resolver'", ")", ";", "//Execute service and process", "try", "{", "$", "resolver", "->", "resolve", "(", "$", "this", "->", "getActiveUnit", "(", ")", ".", "self", "::", "APPLICATION_SERVICES_TRAIL", ".", "$", "this", "->", "getActiveService", "(", ")", ",", "$", "this", "->", "getActiveProcess", "(", ")", ",", "$", "this", ")", ";", "}", "catch", "(", "Base", "$", "e", ")", "{", "$", "this", "->", "getService", "(", "'response-handler'", ")", "->", "setContent", "(", "new", "Content", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", "->", "send", "(", ")", ";", "}", "}" ]
Execute service
[ "Execute", "service" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L346-L369
Hnto/nuki
src/Application/Application.php
Application.executeCallback
public function executeCallback() { call_user_func_array( $this::getContainer() ->offsetGet('callback') ->get('action'), $this::getContainer() ->offsetGet('callback') ->get('params') ); }
php
public function executeCallback() { call_user_func_array( $this::getContainer() ->offsetGet('callback') ->get('action'), $this::getContainer() ->offsetGet('callback') ->get('params') ); }
[ "public", "function", "executeCallback", "(", ")", "{", "call_user_func_array", "(", "$", "this", "::", "getContainer", "(", ")", "->", "offsetGet", "(", "'callback'", ")", "->", "get", "(", "'action'", ")", ",", "$", "this", "::", "getContainer", "(", ")", "->", "offsetGet", "(", "'callback'", ")", "->", "get", "(", "'params'", ")", ")", ";", "}" ]
Execute callback
[ "Execute", "callback" ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L374-L384
Hnto/nuki
src/Application/Application.php
Application.terminate
public function terminate() { /** @var EventHandler $eventHandler */ $eventHandler = $this->getService('event-handler'); $eventHandler->getEvent(TerminateApplication::class)->attach(new LogBeforeTerminate()); $eventHandler->getEvent(TerminateApplication::class)->attach(new ExitApplication()); $eventHandler->fire(TerminateApplication::class, ['app' => $this]); }
php
public function terminate() { /** @var EventHandler $eventHandler */ $eventHandler = $this->getService('event-handler'); $eventHandler->getEvent(TerminateApplication::class)->attach(new LogBeforeTerminate()); $eventHandler->getEvent(TerminateApplication::class)->attach(new ExitApplication()); $eventHandler->fire(TerminateApplication::class, ['app' => $this]); }
[ "public", "function", "terminate", "(", ")", "{", "/** @var EventHandler $eventHandler */", "$", "eventHandler", "=", "$", "this", "->", "getService", "(", "'event-handler'", ")", ";", "$", "eventHandler", "->", "getEvent", "(", "TerminateApplication", "::", "class", ")", "->", "attach", "(", "new", "LogBeforeTerminate", "(", ")", ")", ";", "$", "eventHandler", "->", "getEvent", "(", "TerminateApplication", "::", "class", ")", "->", "attach", "(", "new", "ExitApplication", "(", ")", ")", ";", "$", "eventHandler", "->", "fire", "(", "TerminateApplication", "::", "class", ",", "[", "'app'", "=>", "$", "this", "]", ")", ";", "}" ]
Fire TerminateApplication event with two framework watchers. One to log and one to actually exit.
[ "Fire", "TerminateApplication", "event", "with", "two", "framework", "watchers", ".", "One", "to", "log", "and", "one", "to", "actually", "exit", "." ]
train
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Application/Application.php#L391-L400
Linkvalue-Interne/MobileNotifBundle
Client/GcmClient.php
GcmClient.push
public function push(Message $message) { $profilingEvent = $this->clientProfiler->startProfiling(sprintf('GcmClient::push(%s)', $message->getPayloadAsJson())); try { parent::push($message); $this->clientProfiler->stopProfiling($profilingEvent, array( 'error' => false, 'error_message' => null, )); } catch (\Exception $e) { $this->clientProfiler->stopProfiling($profilingEvent, array( 'error' => true, 'error_message' => $e->getMessage(), )); throw $e; } }
php
public function push(Message $message) { $profilingEvent = $this->clientProfiler->startProfiling(sprintf('GcmClient::push(%s)', $message->getPayloadAsJson())); try { parent::push($message); $this->clientProfiler->stopProfiling($profilingEvent, array( 'error' => false, 'error_message' => null, )); } catch (\Exception $e) { $this->clientProfiler->stopProfiling($profilingEvent, array( 'error' => true, 'error_message' => $e->getMessage(), )); throw $e; } }
[ "public", "function", "push", "(", "Message", "$", "message", ")", "{", "$", "profilingEvent", "=", "$", "this", "->", "clientProfiler", "->", "startProfiling", "(", "sprintf", "(", "'GcmClient::push(%s)'", ",", "$", "message", "->", "getPayloadAsJson", "(", ")", ")", ")", ";", "try", "{", "parent", "::", "push", "(", "$", "message", ")", ";", "$", "this", "->", "clientProfiler", "->", "stopProfiling", "(", "$", "profilingEvent", ",", "array", "(", "'error'", "=>", "false", ",", "'error_message'", "=>", "null", ",", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "clientProfiler", "->", "stopProfiling", "(", "$", "profilingEvent", ",", "array", "(", "'error'", "=>", "true", ",", "'error_message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", ")", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Push a notification to a mobile client. @param Message $message @throws \Exception if an Exception is thrown while pushing $message.
[ "Push", "a", "notification", "to", "a", "mobile", "client", "." ]
train
https://github.com/Linkvalue-Interne/MobileNotifBundle/blob/8124f4132c581516be9928ece81ae2cf9f59763d/Client/GcmClient.php#L45-L65
geniv/nette-general-form
src/GeneralControl.php
GeneralControl.render
public function render() { $template = $this->getTemplate(); $template->setTranslator($this->translator); $template->setFile($this->templatePath); $template->render(); }
php
public function render() { $template = $this->getTemplate(); $template->setTranslator($this->translator); $template->setFile($this->templatePath); $template->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "template", "=", "$", "this", "->", "getTemplate", "(", ")", ";", "$", "template", "->", "setTranslator", "(", "$", "this", "->", "translator", ")", ";", "$", "template", "->", "setFile", "(", "$", "this", "->", "templatePath", ")", ";", "$", "template", "->", "render", "(", ")", ";", "}" ]
Render.
[ "Render", "." ]
train
https://github.com/geniv/nette-general-form/blob/0d0548b63cf7db58c17ee12d6933f2dd995a64e6/src/GeneralControl.php#L63-L70
geniv/nette-general-form
src/GeneralControl.php
GeneralControl.createComponentForm
protected function createComponentForm(string $name): Form { $form = new Form($this, $name); $form->setTranslator($this->translator); $this->formContainer->getForm($form); $form->onSuccess[] = $this->eventContainer; return $form; }
php
protected function createComponentForm(string $name): Form { $form = new Form($this, $name); $form->setTranslator($this->translator); $this->formContainer->getForm($form); $form->onSuccess[] = $this->eventContainer; return $form; }
[ "protected", "function", "createComponentForm", "(", "string", "$", "name", ")", ":", "Form", "{", "$", "form", "=", "new", "Form", "(", "$", "this", ",", "$", "name", ")", ";", "$", "form", "->", "setTranslator", "(", "$", "this", "->", "translator", ")", ";", "$", "this", "->", "formContainer", "->", "getForm", "(", "$", "form", ")", ";", "$", "form", "->", "onSuccess", "[", "]", "=", "$", "this", "->", "eventContainer", ";", "return", "$", "form", ";", "}" ]
Create component form. @param string $name @return Form
[ "Create", "component", "form", "." ]
train
https://github.com/geniv/nette-general-form/blob/0d0548b63cf7db58c17ee12d6933f2dd995a64e6/src/GeneralControl.php#L79-L87
ekyna/SettingBundle
Validator/Constraints/RedirectionValidator.php
RedirectionValidator.validate
public function validate($redirection, Constraint $constraint) { if (! $constraint instanceof Redirection) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\RedirectionToPath'); } if (! $redirection instanceof Entity) { throw new UnexpectedTypeException($redirection, 'Ekyna\Bundle\SettingBundle\Entity\Redirection'); } if (0 < strlen($fromPath = $redirection->getFromPath())) { if ('/' !== $fromPath[0]) { $this->context->addViolationAt('fromPath', $constraint->bad_format); } elseif ($this->isPathAccessible($fromPath)) { $this->context->addViolationAt('fromPath', $constraint->from_path_exists); } } if (0 < strlen($toPath = $redirection->getToPath())) { if ('/' !== $toPath[0]) { $this->context->addViolationAt('toPath', $constraint->bad_format); } elseif (!$this->isPathAccessible($toPath)) { $this->context->addViolationAt('toPath', $constraint->to_path_not_found); } } }
php
public function validate($redirection, Constraint $constraint) { if (! $constraint instanceof Redirection) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\RedirectionToPath'); } if (! $redirection instanceof Entity) { throw new UnexpectedTypeException($redirection, 'Ekyna\Bundle\SettingBundle\Entity\Redirection'); } if (0 < strlen($fromPath = $redirection->getFromPath())) { if ('/' !== $fromPath[0]) { $this->context->addViolationAt('fromPath', $constraint->bad_format); } elseif ($this->isPathAccessible($fromPath)) { $this->context->addViolationAt('fromPath', $constraint->from_path_exists); } } if (0 < strlen($toPath = $redirection->getToPath())) { if ('/' !== $toPath[0]) { $this->context->addViolationAt('toPath', $constraint->bad_format); } elseif (!$this->isPathAccessible($toPath)) { $this->context->addViolationAt('toPath', $constraint->to_path_not_found); } } }
[ "public", "function", "validate", "(", "$", "redirection", ",", "Constraint", "$", "constraint", ")", "{", "if", "(", "!", "$", "constraint", "instanceof", "Redirection", ")", "{", "throw", "new", "UnexpectedTypeException", "(", "$", "constraint", ",", "__NAMESPACE__", ".", "'\\RedirectionToPath'", ")", ";", "}", "if", "(", "!", "$", "redirection", "instanceof", "Entity", ")", "{", "throw", "new", "UnexpectedTypeException", "(", "$", "redirection", ",", "'Ekyna\\Bundle\\SettingBundle\\Entity\\Redirection'", ")", ";", "}", "if", "(", "0", "<", "strlen", "(", "$", "fromPath", "=", "$", "redirection", "->", "getFromPath", "(", ")", ")", ")", "{", "if", "(", "'/'", "!==", "$", "fromPath", "[", "0", "]", ")", "{", "$", "this", "->", "context", "->", "addViolationAt", "(", "'fromPath'", ",", "$", "constraint", "->", "bad_format", ")", ";", "}", "elseif", "(", "$", "this", "->", "isPathAccessible", "(", "$", "fromPath", ")", ")", "{", "$", "this", "->", "context", "->", "addViolationAt", "(", "'fromPath'", ",", "$", "constraint", "->", "from_path_exists", ")", ";", "}", "}", "if", "(", "0", "<", "strlen", "(", "$", "toPath", "=", "$", "redirection", "->", "getToPath", "(", ")", ")", ")", "{", "if", "(", "'/'", "!==", "$", "toPath", "[", "0", "]", ")", "{", "$", "this", "->", "context", "->", "addViolationAt", "(", "'toPath'", ",", "$", "constraint", "->", "bad_format", ")", ";", "}", "elseif", "(", "!", "$", "this", "->", "isPathAccessible", "(", "$", "toPath", ")", ")", "{", "$", "this", "->", "context", "->", "addViolationAt", "(", "'toPath'", ",", "$", "constraint", "->", "to_path_not_found", ")", ";", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ekyna/SettingBundle/blob/df58f83eb3a01ef56cd76ea73639322c581e75c1/Validator/Constraints/RedirectionValidator.php#L52-L76
ekyna/SettingBundle
Validator/Constraints/RedirectionValidator.php
RedirectionValidator.isPathAccessible
private function isPathAccessible($path) { $uri = $this->httpUtils->generateUri($this->requestStack->getMasterRequest(), $path); /** @var \Buzz\Message\Response $res */ $res = $this->browser->get($uri); if ($res->isSuccessful()) { return true; } return false; }
php
private function isPathAccessible($path) { $uri = $this->httpUtils->generateUri($this->requestStack->getMasterRequest(), $path); /** @var \Buzz\Message\Response $res */ $res = $this->browser->get($uri); if ($res->isSuccessful()) { return true; } return false; }
[ "private", "function", "isPathAccessible", "(", "$", "path", ")", "{", "$", "uri", "=", "$", "this", "->", "httpUtils", "->", "generateUri", "(", "$", "this", "->", "requestStack", "->", "getMasterRequest", "(", ")", ",", "$", "path", ")", ";", "/** @var \\Buzz\\Message\\Response $res */", "$", "res", "=", "$", "this", "->", "browser", "->", "get", "(", "$", "uri", ")", ";", "if", "(", "$", "res", "->", "isSuccessful", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether the given path is accessible through http or not. @param $path @return bool
[ "Returns", "whether", "the", "given", "path", "is", "accessible", "through", "http", "or", "not", "." ]
train
https://github.com/ekyna/SettingBundle/blob/df58f83eb3a01ef56cd76ea73639322c581e75c1/Validator/Constraints/RedirectionValidator.php#L84-L95
goulaheau/symfony-rest-bundle
Core/RestParams/Condition.php
Condition.setProperty
public function setProperty($property) { if (!$this->fromExpression && !RestParams::hasPrefix($property)) { $property = "o.$property"; } $this->property = $property; return $this; }
php
public function setProperty($property) { if (!$this->fromExpression && !RestParams::hasPrefix($property)) { $property = "o.$property"; } $this->property = $property; return $this; }
[ "public", "function", "setProperty", "(", "$", "property", ")", "{", "if", "(", "!", "$", "this", "->", "fromExpression", "&&", "!", "RestParams", "::", "hasPrefix", "(", "$", "property", ")", ")", "{", "$", "property", "=", "\"o.$property\"", ";", "}", "$", "this", "->", "property", "=", "$", "property", ";", "return", "$", "this", ";", "}" ]
@param string $property @return self
[ "@param", "string", "$property" ]
train
https://github.com/goulaheau/symfony-rest-bundle/blob/688a120540f144aa1033a72b75803fae34ba3953/Core/RestParams/Condition.php#L73-L82
Retentio/Boomgo
src/Boomgo/Formatter/Underscore2CamelFormatter.php
Underscore2CamelFormatter.camelize
private function camelize($string, $lower = true) { $words = explode('_', strtolower($string)); $camelized = ''; foreach ($words as $word) { if (strpos($word, '_') === false) { $camelized .= ucfirst(trim($word)); } } return ($lower) ? lcfirst($camelized) : $camelized; }
php
private function camelize($string, $lower = true) { $words = explode('_', strtolower($string)); $camelized = ''; foreach ($words as $word) { if (strpos($word, '_') === false) { $camelized .= ucfirst(trim($word)); } } return ($lower) ? lcfirst($camelized) : $camelized; }
[ "private", "function", "camelize", "(", "$", "string", ",", "$", "lower", "=", "true", ")", "{", "$", "words", "=", "explode", "(", "'_'", ",", "strtolower", "(", "$", "string", ")", ")", ";", "$", "camelized", "=", "''", ";", "foreach", "(", "$", "words", "as", "$", "word", ")", "{", "if", "(", "strpos", "(", "$", "word", ",", "'_'", ")", "===", "false", ")", "{", "$", "camelized", ".=", "ucfirst", "(", "trim", "(", "$", "word", ")", ")", ";", "}", "}", "return", "(", "$", "lower", ")", "?", "lcfirst", "(", "$", "camelized", ")", ":", "$", "camelized", ";", "}" ]
Convert underscored string to lower|upper camelCase @param string $string An underscored string @param bool $lower @return string @example my_great_key -> myGreatKey|MyGreatKey
[ "Convert", "underscored", "string", "to", "lower|upper", "camelCase" ]
train
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Formatter/Underscore2CamelFormatter.php#L92-L105
anime-db/catalog-bundle
src/Service/Item/Search/Manager.php
Manager.search
public function search( Search $data, $limit = 0, $offset = 0, $sort_column = self::DEFAULT_SORT_COLUMN, $sort_direction = self::DEFAULT_SORT_DIRECTION ) { return $this->driver->search( $data, ($limit > 0 ? (int) $limit : 0), ($offset > 0 ? (int) $offset : 0), $this->getValidSortColumn($sort_column), $this->getValidSortDirection($sort_direction) ); }
php
public function search( Search $data, $limit = 0, $offset = 0, $sort_column = self::DEFAULT_SORT_COLUMN, $sort_direction = self::DEFAULT_SORT_DIRECTION ) { return $this->driver->search( $data, ($limit > 0 ? (int) $limit : 0), ($offset > 0 ? (int) $offset : 0), $this->getValidSortColumn($sort_column), $this->getValidSortDirection($sort_direction) ); }
[ "public", "function", "search", "(", "Search", "$", "data", ",", "$", "limit", "=", "0", ",", "$", "offset", "=", "0", ",", "$", "sort_column", "=", "self", "::", "DEFAULT_SORT_COLUMN", ",", "$", "sort_direction", "=", "self", "::", "DEFAULT_SORT_DIRECTION", ")", "{", "return", "$", "this", "->", "driver", "->", "search", "(", "$", "data", ",", "(", "$", "limit", ">", "0", "?", "(", "int", ")", "$", "limit", ":", "0", ")", ",", "(", "$", "offset", ">", "0", "?", "(", "int", ")", "$", "offset", ":", "0", ")", ",", "$", "this", "->", "getValidSortColumn", "(", "$", "sort_column", ")", ",", "$", "this", "->", "getValidSortDirection", "(", "$", "sort_direction", ")", ")", ";", "}" ]
@param Search $data @param int|null $limit @param int|null $offset @param string|null $sort_column @param string|null $sort_direction @return array {list:[],total:0}
[ "@param", "Search", "$data", "@param", "int|null", "$limit", "@param", "int|null", "$offset", "@param", "string|null", "$sort_column", "@param", "string|null", "$sort_direction" ]
train
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/Search/Manager.php#L72-L86
anime-db/catalog-bundle
src/Service/Item/Search/Manager.php
Manager.getValidSortColumn
public function getValidSortColumn($column = self::DEFAULT_SORT_COLUMN) { return in_array($column, self::$sort_columns) ? $column : self::DEFAULT_SORT_COLUMN; }
php
public function getValidSortColumn($column = self::DEFAULT_SORT_COLUMN) { return in_array($column, self::$sort_columns) ? $column : self::DEFAULT_SORT_COLUMN; }
[ "public", "function", "getValidSortColumn", "(", "$", "column", "=", "self", "::", "DEFAULT_SORT_COLUMN", ")", "{", "return", "in_array", "(", "$", "column", ",", "self", "::", "$", "sort_columns", ")", "?", "$", "column", ":", "self", "::", "DEFAULT_SORT_COLUMN", ";", "}" ]
@param string|null $column @return string
[ "@param", "string|null", "$column" ]
train
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/Search/Manager.php#L104-L107
anime-db/catalog-bundle
src/Service/Item/Search/Manager.php
Manager.getValidSortDirection
public function getValidSortDirection($direction = self::DEFAULT_SORT_DIRECTION) { return in_array($direction, self::$sort_direction) ? $direction : self::DEFAULT_SORT_DIRECTION; }
php
public function getValidSortDirection($direction = self::DEFAULT_SORT_DIRECTION) { return in_array($direction, self::$sort_direction) ? $direction : self::DEFAULT_SORT_DIRECTION; }
[ "public", "function", "getValidSortDirection", "(", "$", "direction", "=", "self", "::", "DEFAULT_SORT_DIRECTION", ")", "{", "return", "in_array", "(", "$", "direction", ",", "self", "::", "$", "sort_direction", ")", "?", "$", "direction", ":", "self", "::", "DEFAULT_SORT_DIRECTION", ";", "}" ]
@param string|null $direction @return string
[ "@param", "string|null", "$direction" ]
train
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Item/Search/Manager.php#L114-L117
TodoMove/intercessor
src/TodoMove/Intercessor/Repeat.php
Repeat.type
public function type($type = null) { if (is_null($type)) { return $this->type; } $this->type = $type; return $this; }
php
public function type($type = null) { if (is_null($type)) { return $this->type; } $this->type = $type; return $this; }
[ "public", "function", "type", "(", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "return", "$", "this", "->", "type", ";", "}", "$", "this", "->", "type", "=", "$", "type", ";", "return", "$", "this", ";", "}" ]
@param null $type @return $this|string
[ "@param", "null", "$type" ]
train
https://github.com/TodoMove/intercessor/blob/546f9cdaaeaa2db52f8ed33f4870db5526105e50/src/TodoMove/Intercessor/Repeat.php#L31-L40
TodoMove/intercessor
src/TodoMove/Intercessor/Repeat.php
Repeat.interval
public function interval($interval = null) { if (is_null($interval)) { return (int) $this->interval; } $this->interval = (int) $interval; return $this; }
php
public function interval($interval = null) { if (is_null($interval)) { return (int) $this->interval; } $this->interval = (int) $interval; return $this; }
[ "public", "function", "interval", "(", "$", "interval", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "interval", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "interval", ";", "}", "$", "this", "->", "interval", "=", "(", "int", ")", "$", "interval", ";", "return", "$", "this", ";", "}" ]
@param null $interval @return $this|int
[ "@param", "null", "$interval" ]
train
https://github.com/TodoMove/intercessor/blob/546f9cdaaeaa2db52f8ed33f4870db5526105e50/src/TodoMove/Intercessor/Repeat.php#L47-L56
TodoMove/intercessor
src/TodoMove/Intercessor/Repeat.php
Repeat.time
public function time(array $time = null) { if (is_null($time)) { return $this->time; } $validKeys = (count(array_diff(['hour', 'minute', 'second'], array_keys($time))) === 0); if (false === $validKeys) { throw new \InvalidArgumentException('Invalid arguments provided: '.implode($time)); } $this->time = $time; return $this; }
php
public function time(array $time = null) { if (is_null($time)) { return $this->time; } $validKeys = (count(array_diff(['hour', 'minute', 'second'], array_keys($time))) === 0); if (false === $validKeys) { throw new \InvalidArgumentException('Invalid arguments provided: '.implode($time)); } $this->time = $time; return $this; }
[ "public", "function", "time", "(", "array", "$", "time", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "time", ")", ")", "{", "return", "$", "this", "->", "time", ";", "}", "$", "validKeys", "=", "(", "count", "(", "array_diff", "(", "[", "'hour'", ",", "'minute'", ",", "'second'", "]", ",", "array_keys", "(", "$", "time", ")", ")", ")", "===", "0", ")", ";", "if", "(", "false", "===", "$", "validKeys", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid arguments provided: '", ".", "implode", "(", "$", "time", ")", ")", ";", "}", "$", "this", "->", "time", "=", "$", "time", ";", "return", "$", "this", ";", "}" ]
@param array|null $time - must pass 'hour', 'minute' and 'second' keys to be used with \DateTime->setTime() @return $this
[ "@param", "array|null", "$time", "-", "must", "pass", "hour", "minute", "and", "second", "keys", "to", "be", "used", "with", "\\", "DateTime", "-", ">", "setTime", "()" ]
train
https://github.com/TodoMove/intercessor/blob/546f9cdaaeaa2db52f8ed33f4870db5526105e50/src/TodoMove/Intercessor/Repeat.php#L74-L89
TodoMove/intercessor
src/TodoMove/Intercessor/Repeat.php
Repeat.nextDate
public function nextDate($withDate = null) { if (is_string($withDate)) { $withDate = new \DateTime($withDate); } elseif (is_null($withDate)) { $withDate = new \DateTime(); } if ($this->time()) { $withDate->setTime($this->time()['hour'], $this->time()['minute'], $this->time()['second']); } $datePeriod = new \DatePeriod($withDate, $this->dateInterval(), 1); foreach ($datePeriod as $date) { } return $date; }
php
public function nextDate($withDate = null) { if (is_string($withDate)) { $withDate = new \DateTime($withDate); } elseif (is_null($withDate)) { $withDate = new \DateTime(); } if ($this->time()) { $withDate->setTime($this->time()['hour'], $this->time()['minute'], $this->time()['second']); } $datePeriod = new \DatePeriod($withDate, $this->dateInterval(), 1); foreach ($datePeriod as $date) { } return $date; }
[ "public", "function", "nextDate", "(", "$", "withDate", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "withDate", ")", ")", "{", "$", "withDate", "=", "new", "\\", "DateTime", "(", "$", "withDate", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "withDate", ")", ")", "{", "$", "withDate", "=", "new", "\\", "DateTime", "(", ")", ";", "}", "if", "(", "$", "this", "->", "time", "(", ")", ")", "{", "$", "withDate", "->", "setTime", "(", "$", "this", "->", "time", "(", ")", "[", "'hour'", "]", ",", "$", "this", "->", "time", "(", ")", "[", "'minute'", "]", ",", "$", "this", "->", "time", "(", ")", "[", "'second'", "]", ")", ";", "}", "$", "datePeriod", "=", "new", "\\", "DatePeriod", "(", "$", "withDate", ",", "$", "this", "->", "dateInterval", "(", ")", ",", "1", ")", ";", "foreach", "(", "$", "datePeriod", "as", "$", "date", ")", "{", "}", "return", "$", "date", ";", "}" ]
null = now, string will be converted to a DateTime object so will need to be a valid argument to \DateTime::construct. @param \DateTime|string|null $withDate - Which date should we use to calculate the next occurence? @return mixed
[ "null", "=", "now", "string", "will", "be", "converted", "to", "a", "DateTime", "object", "so", "will", "need", "to", "be", "a", "valid", "argument", "to", "\\", "DateTime", "::", "construct", "." ]
train
https://github.com/TodoMove/intercessor/blob/546f9cdaaeaa2db52f8ed33f4870db5526105e50/src/TodoMove/Intercessor/Repeat.php#L98-L116
ekyna/Resource
ResourceComponent.php
ResourceComponent.configureResources
public function configureResources(array $definitions, array $interfaceMap) { $inheritanceMap = $translationMap = []; $registry = $this->getConfigurationRegistry(); $factory = $this->getConfigurationFactory(); foreach ($definitions as $namespace => $resources) { foreach ($resources as $id => $config) { $translation = null; if (isset($config['translation'])) { $translation = $config['translation']; unset($config['translation']); $translationMap[$translation['entity']] = $config['entity']; $translationMap[$config['entity']] = $translation['entity']; } $inheritance = [ 'class' => $config['entity'], ]; if (array_key_exists('repository', $config)) { $inheritance['repository'] = $config['repository']; } $inheritanceMap = [ $namespace.'.'.$id => $inheritance, ]; $registry->addConfiguration($factory->createConfiguration([ 'namespace' => $namespace, 'id' => $id, 'classes' => $config, 'translation' => $translation, ])); } } $evm = $this->em->getEventManager(); // Resolve entity target subscriber if (!empty($interfaceMap)) { $rtel = new ResolveTargetEntityListener(); foreach ($interfaceMap as $model => $implementation) { $rtel->addResolveTargetEntity($model, $implementation, []); } $evm->addEventSubscriber($rtel); } // Load metadata listener $lms = new LoadMetadataListener($inheritanceMap, $interfaceMap); $evm->addEventSubscriber($lms); // Translatable listener $tl = new TranslatableListener( $this->getConfigurationRegistry(), $this->getLocaleProvider(), $translationMap ); $evm->addEventSubscriber($tl); // Load Entity listener $el = new EntityListener($this->getPersistenceEventQueue()); $evm->addEventSubscriber($el); return [$inheritanceMap, $translationMap]; }
php
public function configureResources(array $definitions, array $interfaceMap) { $inheritanceMap = $translationMap = []; $registry = $this->getConfigurationRegistry(); $factory = $this->getConfigurationFactory(); foreach ($definitions as $namespace => $resources) { foreach ($resources as $id => $config) { $translation = null; if (isset($config['translation'])) { $translation = $config['translation']; unset($config['translation']); $translationMap[$translation['entity']] = $config['entity']; $translationMap[$config['entity']] = $translation['entity']; } $inheritance = [ 'class' => $config['entity'], ]; if (array_key_exists('repository', $config)) { $inheritance['repository'] = $config['repository']; } $inheritanceMap = [ $namespace.'.'.$id => $inheritance, ]; $registry->addConfiguration($factory->createConfiguration([ 'namespace' => $namespace, 'id' => $id, 'classes' => $config, 'translation' => $translation, ])); } } $evm = $this->em->getEventManager(); // Resolve entity target subscriber if (!empty($interfaceMap)) { $rtel = new ResolveTargetEntityListener(); foreach ($interfaceMap as $model => $implementation) { $rtel->addResolveTargetEntity($model, $implementation, []); } $evm->addEventSubscriber($rtel); } // Load metadata listener $lms = new LoadMetadataListener($inheritanceMap, $interfaceMap); $evm->addEventSubscriber($lms); // Translatable listener $tl = new TranslatableListener( $this->getConfigurationRegistry(), $this->getLocaleProvider(), $translationMap ); $evm->addEventSubscriber($tl); // Load Entity listener $el = new EntityListener($this->getPersistenceEventQueue()); $evm->addEventSubscriber($el); return [$inheritanceMap, $translationMap]; }
[ "public", "function", "configureResources", "(", "array", "$", "definitions", ",", "array", "$", "interfaceMap", ")", "{", "$", "inheritanceMap", "=", "$", "translationMap", "=", "[", "]", ";", "$", "registry", "=", "$", "this", "->", "getConfigurationRegistry", "(", ")", ";", "$", "factory", "=", "$", "this", "->", "getConfigurationFactory", "(", ")", ";", "foreach", "(", "$", "definitions", "as", "$", "namespace", "=>", "$", "resources", ")", "{", "foreach", "(", "$", "resources", "as", "$", "id", "=>", "$", "config", ")", "{", "$", "translation", "=", "null", ";", "if", "(", "isset", "(", "$", "config", "[", "'translation'", "]", ")", ")", "{", "$", "translation", "=", "$", "config", "[", "'translation'", "]", ";", "unset", "(", "$", "config", "[", "'translation'", "]", ")", ";", "$", "translationMap", "[", "$", "translation", "[", "'entity'", "]", "]", "=", "$", "config", "[", "'entity'", "]", ";", "$", "translationMap", "[", "$", "config", "[", "'entity'", "]", "]", "=", "$", "translation", "[", "'entity'", "]", ";", "}", "$", "inheritance", "=", "[", "'class'", "=>", "$", "config", "[", "'entity'", "]", ",", "]", ";", "if", "(", "array_key_exists", "(", "'repository'", ",", "$", "config", ")", ")", "{", "$", "inheritance", "[", "'repository'", "]", "=", "$", "config", "[", "'repository'", "]", ";", "}", "$", "inheritanceMap", "=", "[", "$", "namespace", ".", "'.'", ".", "$", "id", "=>", "$", "inheritance", ",", "]", ";", "$", "registry", "->", "addConfiguration", "(", "$", "factory", "->", "createConfiguration", "(", "[", "'namespace'", "=>", "$", "namespace", ",", "'id'", "=>", "$", "id", ",", "'classes'", "=>", "$", "config", ",", "'translation'", "=>", "$", "translation", ",", "]", ")", ")", ";", "}", "}", "$", "evm", "=", "$", "this", "->", "em", "->", "getEventManager", "(", ")", ";", "// Resolve entity target subscriber", "if", "(", "!", "empty", "(", "$", "interfaceMap", ")", ")", "{", "$", "rtel", "=", "new", "ResolveTargetEntityListener", "(", ")", ";", "foreach", "(", "$", "interfaceMap", "as", "$", "model", "=>", "$", "implementation", ")", "{", "$", "rtel", "->", "addResolveTargetEntity", "(", "$", "model", ",", "$", "implementation", ",", "[", "]", ")", ";", "}", "$", "evm", "->", "addEventSubscriber", "(", "$", "rtel", ")", ";", "}", "// Load metadata listener", "$", "lms", "=", "new", "LoadMetadataListener", "(", "$", "inheritanceMap", ",", "$", "interfaceMap", ")", ";", "$", "evm", "->", "addEventSubscriber", "(", "$", "lms", ")", ";", "// Translatable listener", "$", "tl", "=", "new", "TranslatableListener", "(", "$", "this", "->", "getConfigurationRegistry", "(", ")", ",", "$", "this", "->", "getLocaleProvider", "(", ")", ",", "$", "translationMap", ")", ";", "$", "evm", "->", "addEventSubscriber", "(", "$", "tl", ")", ";", "// Load Entity listener", "$", "el", "=", "new", "EntityListener", "(", "$", "this", "->", "getPersistenceEventQueue", "(", ")", ")", ";", "$", "evm", "->", "addEventSubscriber", "(", "$", "el", ")", ";", "return", "[", "$", "inheritanceMap", ",", "$", "translationMap", "]", ";", "}" ]
Configures the resources. @param array $definitions @param array $interfaceMap @return array The inheritance map and the translation map.
[ "Configures", "the", "resources", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L77-L143
ekyna/Resource
ResourceComponent.php
ResourceComponent.getConfigurationFactory
public function getConfigurationFactory() { if (null === $this->configurationFactory) { $this->configurationFactory = new Configuration\ConfigurationFactory(); } return $this->configurationFactory; }
php
public function getConfigurationFactory() { if (null === $this->configurationFactory) { $this->configurationFactory = new Configuration\ConfigurationFactory(); } return $this->configurationFactory; }
[ "public", "function", "getConfigurationFactory", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "configurationFactory", ")", "{", "$", "this", "->", "configurationFactory", "=", "new", "Configuration", "\\", "ConfigurationFactory", "(", ")", ";", "}", "return", "$", "this", "->", "configurationFactory", ";", "}" ]
Returns the configuration factory. @return Configuration\ConfigurationFactory
[ "Returns", "the", "configuration", "factory", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L151-L158
ekyna/Resource
ResourceComponent.php
ResourceComponent.getConfigurationRegistry
public function getConfigurationRegistry() { if (null === $this->configurationRegistry) { $this->configurationRegistry = new Configuration\ConfigurationRegistry(); } return $this->configurationRegistry; }
php
public function getConfigurationRegistry() { if (null === $this->configurationRegistry) { $this->configurationRegistry = new Configuration\ConfigurationRegistry(); } return $this->configurationRegistry; }
[ "public", "function", "getConfigurationRegistry", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "configurationRegistry", ")", "{", "$", "this", "->", "configurationRegistry", "=", "new", "Configuration", "\\", "ConfigurationRegistry", "(", ")", ";", "}", "return", "$", "this", "->", "configurationRegistry", ";", "}" ]
Returns the configuration registry. @return Configuration\ConfigurationRegistry
[ "Returns", "the", "configuration", "registry", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L165-L172
ekyna/Resource
ResourceComponent.php
ResourceComponent.getEventDispatcher
public function getEventDispatcher() { if (null === $this->eventDispatcher) { $this->eventDispatcher = new Dispatcher\ResourceEventDispatcher(); $this->eventDispatcher->setConfigurationRegistry($this->getConfigurationRegistry()); $this->eventDispatcher->setEventQueue($this->getEventQueue()); } return $this->eventDispatcher; }
php
public function getEventDispatcher() { if (null === $this->eventDispatcher) { $this->eventDispatcher = new Dispatcher\ResourceEventDispatcher(); $this->eventDispatcher->setConfigurationRegistry($this->getConfigurationRegistry()); $this->eventDispatcher->setEventQueue($this->getEventQueue()); } return $this->eventDispatcher; }
[ "public", "function", "getEventDispatcher", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "eventDispatcher", ")", "{", "$", "this", "->", "eventDispatcher", "=", "new", "Dispatcher", "\\", "ResourceEventDispatcher", "(", ")", ";", "$", "this", "->", "eventDispatcher", "->", "setConfigurationRegistry", "(", "$", "this", "->", "getConfigurationRegistry", "(", ")", ")", ";", "$", "this", "->", "eventDispatcher", "->", "setEventQueue", "(", "$", "this", "->", "getEventQueue", "(", ")", ")", ";", "}", "return", "$", "this", "->", "eventDispatcher", ";", "}" ]
Returns the event dispatcher. @return Dispatcher\ResourceEventDispatcher
[ "Returns", "the", "event", "dispatcher", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L179-L188
ekyna/Resource
ResourceComponent.php
ResourceComponent.getLocaleProvider
public function getLocaleProvider() { if (null === $this->localeProvider) { $this->localeProvider = new Locale\LocaleProvider('fr', 'en', ['fr', 'en']); } return $this->localeProvider; }
php
public function getLocaleProvider() { if (null === $this->localeProvider) { $this->localeProvider = new Locale\LocaleProvider('fr', 'en', ['fr', 'en']); } return $this->localeProvider; }
[ "public", "function", "getLocaleProvider", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "localeProvider", ")", "{", "$", "this", "->", "localeProvider", "=", "new", "Locale", "\\", "LocaleProvider", "(", "'fr'", ",", "'en'", ",", "[", "'fr'", ",", "'en'", "]", ")", ";", "}", "return", "$", "this", "->", "localeProvider", ";", "}" ]
Returns the locale provider. @return Locale\LocaleProviderInterface
[ "Returns", "the", "locale", "provider", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L195-L202
ekyna/Resource
ResourceComponent.php
ResourceComponent.getEventQueue
public function getEventQueue() { if (null === $this->eventQueue) { $this->eventQueue = new Event\EventQueue( $this->getConfigurationRegistry(), $this->getEventDispatcher() ); } return $this->eventQueue; }
php
public function getEventQueue() { if (null === $this->eventQueue) { $this->eventQueue = new Event\EventQueue( $this->getConfigurationRegistry(), $this->getEventDispatcher() ); } return $this->eventQueue; }
[ "public", "function", "getEventQueue", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "eventQueue", ")", "{", "$", "this", "->", "eventQueue", "=", "new", "Event", "\\", "EventQueue", "(", "$", "this", "->", "getConfigurationRegistry", "(", ")", ",", "$", "this", "->", "getEventDispatcher", "(", ")", ")", ";", "}", "return", "$", "this", "->", "eventQueue", ";", "}" ]
Returns the event queue. @return Event\EventQueue
[ "Returns", "the", "event", "queue", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L209-L219
ekyna/Resource
ResourceComponent.php
ResourceComponent.getPersistenceEventQueue
public function getPersistenceEventQueue() { if (null === $this->persistenceEventQueue) { $this->persistenceEventQueue = new Persistence\PersistenceEventQueue( $this->getConfigurationRegistry(), $this->getEventDispatcher() ); } return $this->persistenceEventQueue; }
php
public function getPersistenceEventQueue() { if (null === $this->persistenceEventQueue) { $this->persistenceEventQueue = new Persistence\PersistenceEventQueue( $this->getConfigurationRegistry(), $this->getEventDispatcher() ); } return $this->persistenceEventQueue; }
[ "public", "function", "getPersistenceEventQueue", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "persistenceEventQueue", ")", "{", "$", "this", "->", "persistenceEventQueue", "=", "new", "Persistence", "\\", "PersistenceEventQueue", "(", "$", "this", "->", "getConfigurationRegistry", "(", ")", ",", "$", "this", "->", "getEventDispatcher", "(", ")", ")", ";", "}", "return", "$", "this", "->", "persistenceEventQueue", ";", "}" ]
Returns the persistence event queue. @return Persistence\PersistenceEventQueue
[ "Returns", "the", "persistence", "event", "queue", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L226-L236
ekyna/Resource
ResourceComponent.php
ResourceComponent.getPersistenceHelper
public function getPersistenceHelper() { if (null === $this->persistenceHelper) { $this->persistenceHelper = new Doctrine\ORM\PersistenceHelper( $this->em, $this->getPersistenceEventQueue() ); } return $this->persistenceHelper; }
php
public function getPersistenceHelper() { if (null === $this->persistenceHelper) { $this->persistenceHelper = new Doctrine\ORM\PersistenceHelper( $this->em, $this->getPersistenceEventQueue() ); } return $this->persistenceHelper; }
[ "public", "function", "getPersistenceHelper", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "persistenceHelper", ")", "{", "$", "this", "->", "persistenceHelper", "=", "new", "Doctrine", "\\", "ORM", "\\", "PersistenceHelper", "(", "$", "this", "->", "em", ",", "$", "this", "->", "getPersistenceEventQueue", "(", ")", ")", ";", "}", "return", "$", "this", "->", "persistenceHelper", ";", "}" ]
Returns the persistence helper. @return Persistence\PersistenceHelperInterface
[ "Returns", "the", "persistence", "helper", "." ]
train
https://github.com/ekyna/Resource/blob/96ee3d28e02bd9513705408e3bb7f88a76e52f56/ResourceComponent.php#L243-L253
Innmind/Compose
src/Definition/Argument/Type/Map.php
Map.accepts
public function accepts($value): bool { if (!$value instanceof MapInterface) { return false; } return (string) $value->keyType() === $this->key && (string) $value->valueType() === $this->value; }
php
public function accepts($value): bool { if (!$value instanceof MapInterface) { return false; } return (string) $value->keyType() === $this->key && (string) $value->valueType() === $this->value; }
[ "public", "function", "accepts", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "$", "value", "instanceof", "MapInterface", ")", "{", "return", "false", ";", "}", "return", "(", "string", ")", "$", "value", "->", "keyType", "(", ")", "===", "$", "this", "->", "key", "&&", "(", "string", ")", "$", "value", "->", "valueType", "(", ")", "===", "$", "this", "->", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/Compose/blob/1a833d7ba2f6248e9c472c00cd7aca041c1a2ba9/src/Definition/Argument/Type/Map.php#L30-L38
Innmind/Compose
src/Definition/Argument/Type/Map.php
Map.fromString
public static function fromString(Str $value): Type { if (!$value->matches(self::PATTERN)) { throw new ValueNotSupported((string) $value); } $components = $value->capture(self::PATTERN); return new self( (string) $components->get('key'), (string) $components->get('value') ); }
php
public static function fromString(Str $value): Type { if (!$value->matches(self::PATTERN)) { throw new ValueNotSupported((string) $value); } $components = $value->capture(self::PATTERN); return new self( (string) $components->get('key'), (string) $components->get('value') ); }
[ "public", "static", "function", "fromString", "(", "Str", "$", "value", ")", ":", "Type", "{", "if", "(", "!", "$", "value", "->", "matches", "(", "self", "::", "PATTERN", ")", ")", "{", "throw", "new", "ValueNotSupported", "(", "(", "string", ")", "$", "value", ")", ";", "}", "$", "components", "=", "$", "value", "->", "capture", "(", "self", "::", "PATTERN", ")", ";", "return", "new", "self", "(", "(", "string", ")", "$", "components", "->", "get", "(", "'key'", ")", ",", "(", "string", ")", "$", "components", "->", "get", "(", "'value'", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/Compose/blob/1a833d7ba2f6248e9c472c00cd7aca041c1a2ba9/src/Definition/Argument/Type/Map.php#L43-L55
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.dir_opendir
public function dir_opendir($path, $options) { $this->context = opendir($this->getPath($path)); return is_resource($this->context); }
php
public function dir_opendir($path, $options) { $this->context = opendir($this->getPath($path)); return is_resource($this->context); }
[ "public", "function", "dir_opendir", "(", "$", "path", ",", "$", "options", ")", "{", "$", "this", "->", "context", "=", "opendir", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ")", ";", "return", "is_resource", "(", "$", "this", "->", "context", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L40-L45
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.mkdir
public function mkdir($path, $mode, $options) { if ($this->isStreamWritable($path) === false) { return false; } $recursive = (($options & STREAM_MKDIR_RECURSIVE) > 0); return mkdir($this->getPath($path), $mode, $recursive); }
php
public function mkdir($path, $mode, $options) { if ($this->isStreamWritable($path) === false) { return false; } $recursive = (($options & STREAM_MKDIR_RECURSIVE) > 0); return mkdir($this->getPath($path), $mode, $recursive); }
[ "public", "function", "mkdir", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ")", "{", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "recursive", "=", "(", "(", "$", "options", "&", "STREAM_MKDIR_RECURSIVE", ")", ">", "0", ")", ";", "return", "mkdir", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ",", "$", "mode", ",", "$", "recursive", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L80-L89
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.rename
public function rename($path_from, $path_to) { if ($this->isStreamWritable($path_from) === false) { return false; } return rename(static::getPath($path_from), static::getPath($path_to)); }
php
public function rename($path_from, $path_to) { if ($this->isStreamWritable($path_from) === false) { return false; } return rename(static::getPath($path_from), static::getPath($path_to)); }
[ "public", "function", "rename", "(", "$", "path_from", ",", "$", "path_to", ")", "{", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path_from", ")", "===", "false", ")", "{", "return", "false", ";", "}", "return", "rename", "(", "static", "::", "getPath", "(", "$", "path_from", ")", ",", "static", "::", "getPath", "(", "$", "path_to", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L94-L101
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.rmdir
public function rmdir($path, $options) { if ($this->isStreamWritable($path) === false) { return false; } return rmdir($this->getPath($path)); }
php
public function rmdir($path, $options) { if ($this->isStreamWritable($path) === false) { return false; } return rmdir($this->getPath($path)); }
[ "public", "function", "rmdir", "(", "$", "path", ",", "$", "options", ")", "{", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "return", "rmdir", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L106-L113
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.stream_metadata
public function stream_metadata($path, $option, $value) { if ($this->isStreamWritable($path) === false) { return false; } switch ($option) { case STREAM_META_ACCESS: return chmod($this->getPath($path), $value); case STREAM_META_GROUP: case STREAM_META_GROUP_NAME: return chgrp($this->getPath($path), $value); case STREAM_META_OWNER: case STREAM_META_OWNER_NAME: return chown($this->getPath($path), $value); case STREAM_META_TOUCH: array_unshift($value, $this->getPath($path)); return call_user_func_array('touch', $value); } return false; }
php
public function stream_metadata($path, $option, $value) { if ($this->isStreamWritable($path) === false) { return false; } switch ($option) { case STREAM_META_ACCESS: return chmod($this->getPath($path), $value); case STREAM_META_GROUP: case STREAM_META_GROUP_NAME: return chgrp($this->getPath($path), $value); case STREAM_META_OWNER: case STREAM_META_OWNER_NAME: return chown($this->getPath($path), $value); case STREAM_META_TOUCH: array_unshift($value, $this->getPath($path)); return call_user_func_array('touch', $value); } return false; }
[ "public", "function", "stream_metadata", "(", "$", "path", ",", "$", "option", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "switch", "(", "$", "option", ")", "{", "case", "STREAM_META_ACCESS", ":", "return", "chmod", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ",", "$", "value", ")", ";", "case", "STREAM_META_GROUP", ":", "case", "STREAM_META_GROUP_NAME", ":", "return", "chgrp", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ",", "$", "value", ")", ";", "case", "STREAM_META_OWNER", ":", "case", "STREAM_META_OWNER_NAME", ":", "return", "chown", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ",", "$", "value", ")", ";", "case", "STREAM_META_TOUCH", ":", "array_unshift", "(", "$", "value", ",", "$", "this", "->", "getPath", "(", "$", "path", ")", ")", ";", "return", "call_user_func_array", "(", "'touch'", ",", "$", "value", ")", ";", "}", "return", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L162-L184
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.stream_open
public function stream_open($path, $mode, $options, &$opened_path) { $use_path = (($options & STREAM_USE_PATH) > 0); if ($this->isStreamWritable($path) === false && strpos($mode, 'w') !== false) { return false; } $this->context = @fopen($this->getPath($path), $mode, false); if ($this->context !== false && $use_path) { $opened_path = $this->getPath($path); } return $this->context !== false; }
php
public function stream_open($path, $mode, $options, &$opened_path) { $use_path = (($options & STREAM_USE_PATH) > 0); if ($this->isStreamWritable($path) === false && strpos($mode, 'w') !== false) { return false; } $this->context = @fopen($this->getPath($path), $mode, false); if ($this->context !== false && $use_path) { $opened_path = $this->getPath($path); } return $this->context !== false; }
[ "public", "function", "stream_open", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ",", "&", "$", "opened_path", ")", "{", "$", "use_path", "=", "(", "(", "$", "options", "&", "STREAM_USE_PATH", ")", ">", "0", ")", ";", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path", ")", "===", "false", "&&", "strpos", "(", "$", "mode", ",", "'w'", ")", "!==", "false", ")", "{", "return", "false", ";", "}", "$", "this", "->", "context", "=", "@", "fopen", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ",", "$", "mode", ",", "false", ")", ";", "if", "(", "$", "this", "->", "context", "!==", "false", "&&", "$", "use_path", ")", "{", "$", "opened_path", "=", "$", "this", "->", "getPath", "(", "$", "path", ")", ";", "}", "return", "$", "this", "->", "context", "!==", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L189-L203
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.unlink
public function unlink($path) { if ($this->isStreamWritable($path) === false) { return false; } return unlink($this->getPath($path)); }
php
public function unlink($path) { if ($this->isStreamWritable($path) === false) { return false; } return unlink($this->getPath($path)); }
[ "public", "function", "unlink", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "isStreamWritable", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "return", "unlink", "(", "$", "this", "->", "getPath", "(", "$", "path", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L264-L271
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.getStreamByPathScheme
private function getStreamByPathScheme($path) { $scheme = parse_url($path, PHP_URL_SCHEME); return $this->streamManager->getStream($scheme); }
php
private function getStreamByPathScheme($path) { $scheme = parse_url($path, PHP_URL_SCHEME); return $this->streamManager->getStream($scheme); }
[ "private", "function", "getStreamByPathScheme", "(", "$", "path", ")", "{", "$", "scheme", "=", "parse_url", "(", "$", "path", ",", "PHP_URL_SCHEME", ")", ";", "return", "$", "this", "->", "streamManager", "->", "getStream", "(", "$", "scheme", ")", ";", "}" ]
Returns the stream instance by the uri scheme in path. @param string $path @return StreamInterface
[ "Returns", "the", "stream", "instance", "by", "the", "uri", "scheme", "in", "path", "." ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L288-L293
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.isStreamWritable
private function isStreamWritable($path) { $stream = $this->getStreamByPathScheme($path); if ($stream instanceof StreamInterface) { return $stream->isWritable(); } return false; }
php
private function isStreamWritable($path) { $stream = $this->getStreamByPathScheme($path); if ($stream instanceof StreamInterface) { return $stream->isWritable(); } return false; }
[ "private", "function", "isStreamWritable", "(", "$", "path", ")", "{", "$", "stream", "=", "$", "this", "->", "getStreamByPathScheme", "(", "$", "path", ")", ";", "if", "(", "$", "stream", "instanceof", "StreamInterface", ")", "{", "return", "$", "stream", "->", "isWritable", "(", ")", ";", "}", "return", "false", ";", "}" ]
Returns true if the stream for the path is writable. @param string $path @return bool
[ "Returns", "true", "if", "the", "stream", "for", "the", "path", "is", "writable", "." ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L302-L310
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.getPath
private function getPath($path) { $uri = parse_url($path); $stream = $this->getStreamByPathScheme($path); if ($stream instanceof StreamInterface) { foreach ($stream->getPaths() as $streamDomain => $streamPath) { if ($streamDomain === $uri['host']) { $realPath = $this->getRealPath($uri, $streamPath); if (strpos($realPath, $streamPath) === 0) { return $realPath; } } } } }
php
private function getPath($path) { $uri = parse_url($path); $stream = $this->getStreamByPathScheme($path); if ($stream instanceof StreamInterface) { foreach ($stream->getPaths() as $streamDomain => $streamPath) { if ($streamDomain === $uri['host']) { $realPath = $this->getRealPath($uri, $streamPath); if (strpos($realPath, $streamPath) === 0) { return $realPath; } } } } }
[ "private", "function", "getPath", "(", "$", "path", ")", "{", "$", "uri", "=", "parse_url", "(", "$", "path", ")", ";", "$", "stream", "=", "$", "this", "->", "getStreamByPathScheme", "(", "$", "path", ")", ";", "if", "(", "$", "stream", "instanceof", "StreamInterface", ")", "{", "foreach", "(", "$", "stream", "->", "getPaths", "(", ")", "as", "$", "streamDomain", "=>", "$", "streamPath", ")", "{", "if", "(", "$", "streamDomain", "===", "$", "uri", "[", "'host'", "]", ")", "{", "$", "realPath", "=", "$", "this", "->", "getRealPath", "(", "$", "uri", ",", "$", "streamPath", ")", ";", "if", "(", "strpos", "(", "$", "realPath", ",", "$", "streamPath", ")", "===", "0", ")", "{", "return", "$", "realPath", ";", "}", "}", "}", "}", "}" ]
Returns the real path. @param string $path @return string
[ "Returns", "the", "real", "path", "." ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L319-L334
niels-nijens/protocol-stream
src/Wrapper/StreamWrapper.php
StreamWrapper.getRealPath
private function getRealPath(array $uri, $streamPath) { $path = $streamPath; if (isset($uri['path'])) { $path .= $uri['path']; } $realParts = array(); $path = preg_replace('/\/+/', '/', str_replace('\\', '/', $path)); $pathParts = explode('/', $path); foreach ($pathParts as $pathPart) { if ($pathPart === '..') { $realPart = array_pop($realParts); if ($realPart !== null && $realPart !== '..') { continue; } if ($realPart === '..') { $realParts[] = $realPart; } } if ($pathPart !== '.') { $realParts[] = $pathPart; } } return implode(DIRECTORY_SEPARATOR, $realParts); }
php
private function getRealPath(array $uri, $streamPath) { $path = $streamPath; if (isset($uri['path'])) { $path .= $uri['path']; } $realParts = array(); $path = preg_replace('/\/+/', '/', str_replace('\\', '/', $path)); $pathParts = explode('/', $path); foreach ($pathParts as $pathPart) { if ($pathPart === '..') { $realPart = array_pop($realParts); if ($realPart !== null && $realPart !== '..') { continue; } if ($realPart === '..') { $realParts[] = $realPart; } } if ($pathPart !== '.') { $realParts[] = $pathPart; } } return implode(DIRECTORY_SEPARATOR, $realParts); }
[ "private", "function", "getRealPath", "(", "array", "$", "uri", ",", "$", "streamPath", ")", "{", "$", "path", "=", "$", "streamPath", ";", "if", "(", "isset", "(", "$", "uri", "[", "'path'", "]", ")", ")", "{", "$", "path", ".=", "$", "uri", "[", "'path'", "]", ";", "}", "$", "realParts", "=", "array", "(", ")", ";", "$", "path", "=", "preg_replace", "(", "'/\\/+/'", ",", "'/'", ",", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ")", ";", "$", "pathParts", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "foreach", "(", "$", "pathParts", "as", "$", "pathPart", ")", "{", "if", "(", "$", "pathPart", "===", "'..'", ")", "{", "$", "realPart", "=", "array_pop", "(", "$", "realParts", ")", ";", "if", "(", "$", "realPart", "!==", "null", "&&", "$", "realPart", "!==", "'..'", ")", "{", "continue", ";", "}", "if", "(", "$", "realPart", "===", "'..'", ")", "{", "$", "realParts", "[", "]", "=", "$", "realPart", ";", "}", "}", "if", "(", "$", "pathPart", "!==", "'.'", ")", "{", "$", "realParts", "[", "]", "=", "$", "pathPart", ";", "}", "}", "return", "implode", "(", "DIRECTORY_SEPARATOR", ",", "$", "realParts", ")", ";", "}" ]
Returns the real path. @param array $uri @param string $streamPath @return string
[ "Returns", "the", "real", "path", "." ]
train
https://github.com/niels-nijens/protocol-stream/blob/c45b8d282bbb83f2a3d17adeb1d66500c14a868c/src/Wrapper/StreamWrapper.php#L344-L371
OpencontentCoop/ocembed
classes/ocembed.php
OCEmbed.maybe_make_link
function maybe_make_link( $url ) { if ( array_key_exists( $url, $this->links ) ) { if ( is_array( $this->links[$url] ) ) { $output = $this->links[$url][0]; } else { $output = $this->links[$url]; } } else { $output = $url; } return $output; }
php
function maybe_make_link( $url ) { if ( array_key_exists( $url, $this->links ) ) { if ( is_array( $this->links[$url] ) ) { $output = $this->links[$url][0]; } else { $output = $this->links[$url]; } } else { $output = $url; } return $output; }
[ "function", "maybe_make_link", "(", "$", "url", ")", "{", "if", "(", "array_key_exists", "(", "$", "url", ",", "$", "this", "->", "links", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "links", "[", "$", "url", "]", ")", ")", "{", "$", "output", "=", "$", "this", "->", "links", "[", "$", "url", "]", "[", "0", "]", ";", "}", "else", "{", "$", "output", "=", "$", "this", "->", "links", "[", "$", "url", "]", ";", "}", "}", "else", "{", "$", "output", "=", "$", "url", ";", "}", "return", "$", "output", ";", "}" ]
Conditionally makes a hyperlink based on an internal class variable. @param string $url URL to potentially be linked. @return string Linked URL or the original URL.
[ "Conditionally", "makes", "a", "hyperlink", "based", "on", "an", "internal", "class", "variable", "." ]
train
https://github.com/OpencontentCoop/ocembed/blob/e8c990a9bcc284c2f48ac5688ee6e66ee6dd8043/classes/ocembed.php#L227-L245
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/ValueGenerator/IncrementGenerator.php
IncrementGenerator.generate
public function generate(DocumentManager $dm, $document) { $qb = $this->prepareQuery($dm); $class = $dm->getClassMetadata($this->className); $mapping = $class->getPropertyMetadata($this->propertyName); $type = $mapping->getType(); $idAttribute = $qb->attr('current_value'); $idAttribute->exists(true); $idAttribute->set($idAttribute, Set::MODIFIER_PLUS, 1); try { $query = $qb->getQuery()->returnValues(Operation::RETURN_VALUES_UPDATED_NEW); $result = $query->execute(); $value = $result['Attributes']['current_value']; return $type->convertToPHPValue($value); } catch (DynamoDbException $e) { if ($e->getAwsErrorCode() !== 'ConditionalCheckFailedException') { throw $e; } } /* * Updated nothing - counter doesn't exist, creating new counter. * Not bothering with {$exists: false} in the criteria as that won't avoid * an exception during a possible race condition. */ $qb = $this->prepareQuery($dm); $qb->attr('current_value')->set($this->startingValue); $query = $qb->getQuery()->returnValues(Operation::RETURN_VALUES_UPDATED_NEW); $result = $query->execute(); $value = $result['Attributes']['current_value']; return $type->convertToPHPValue($value); }
php
public function generate(DocumentManager $dm, $document) { $qb = $this->prepareQuery($dm); $class = $dm->getClassMetadata($this->className); $mapping = $class->getPropertyMetadata($this->propertyName); $type = $mapping->getType(); $idAttribute = $qb->attr('current_value'); $idAttribute->exists(true); $idAttribute->set($idAttribute, Set::MODIFIER_PLUS, 1); try { $query = $qb->getQuery()->returnValues(Operation::RETURN_VALUES_UPDATED_NEW); $result = $query->execute(); $value = $result['Attributes']['current_value']; return $type->convertToPHPValue($value); } catch (DynamoDbException $e) { if ($e->getAwsErrorCode() !== 'ConditionalCheckFailedException') { throw $e; } } /* * Updated nothing - counter doesn't exist, creating new counter. * Not bothering with {$exists: false} in the criteria as that won't avoid * an exception during a possible race condition. */ $qb = $this->prepareQuery($dm); $qb->attr('current_value')->set($this->startingValue); $query = $qb->getQuery()->returnValues(Operation::RETURN_VALUES_UPDATED_NEW); $result = $query->execute(); $value = $result['Attributes']['current_value']; return $type->convertToPHPValue($value); }
[ "public", "function", "generate", "(", "DocumentManager", "$", "dm", ",", "$", "document", ")", "{", "$", "qb", "=", "$", "this", "->", "prepareQuery", "(", "$", "dm", ")", ";", "$", "class", "=", "$", "dm", "->", "getClassMetadata", "(", "$", "this", "->", "className", ")", ";", "$", "mapping", "=", "$", "class", "->", "getPropertyMetadata", "(", "$", "this", "->", "propertyName", ")", ";", "$", "type", "=", "$", "mapping", "->", "getType", "(", ")", ";", "$", "idAttribute", "=", "$", "qb", "->", "attr", "(", "'current_value'", ")", ";", "$", "idAttribute", "->", "exists", "(", "true", ")", ";", "$", "idAttribute", "->", "set", "(", "$", "idAttribute", ",", "Set", "::", "MODIFIER_PLUS", ",", "1", ")", ";", "try", "{", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "returnValues", "(", "Operation", "::", "RETURN_VALUES_UPDATED_NEW", ")", ";", "$", "result", "=", "$", "query", "->", "execute", "(", ")", ";", "$", "value", "=", "$", "result", "[", "'Attributes'", "]", "[", "'current_value'", "]", ";", "return", "$", "type", "->", "convertToPHPValue", "(", "$", "value", ")", ";", "}", "catch", "(", "DynamoDbException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getAwsErrorCode", "(", ")", "!==", "'ConditionalCheckFailedException'", ")", "{", "throw", "$", "e", ";", "}", "}", "/*\n * Updated nothing - counter doesn't exist, creating new counter.\n * Not bothering with {$exists: false} in the criteria as that won't avoid\n * an exception during a possible race condition.\n */", "$", "qb", "=", "$", "this", "->", "prepareQuery", "(", "$", "dm", ")", ";", "$", "qb", "->", "attr", "(", "'current_value'", ")", "->", "set", "(", "$", "this", "->", "startingValue", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "returnValues", "(", "Operation", "::", "RETURN_VALUES_UPDATED_NEW", ")", ";", "$", "result", "=", "$", "query", "->", "execute", "(", ")", ";", "$", "value", "=", "$", "result", "[", "'Attributes'", "]", "[", "'current_value'", "]", ";", "return", "$", "type", "->", "convertToPHPValue", "(", "$", "value", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/ValueGenerator/IncrementGenerator.php#L90-L127
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/ValueGenerator/IncrementGenerator.php
IncrementGenerator.prepareQuery
private function prepareQuery(DocumentManager $dm) { $qb = $dm->createQueryBuilder($this->className); $qb->attr('hash')->equals($this->hash); $qb->attr('range')->equals($this->range); return $qb; }
php
private function prepareQuery(DocumentManager $dm) { $qb = $dm->createQueryBuilder($this->className); $qb->attr('hash')->equals($this->hash); $qb->attr('range')->equals($this->range); return $qb; }
[ "private", "function", "prepareQuery", "(", "DocumentManager", "$", "dm", ")", "{", "$", "qb", "=", "$", "dm", "->", "createQueryBuilder", "(", "$", "this", "->", "className", ")", ";", "$", "qb", "->", "attr", "(", "'hash'", ")", "->", "equals", "(", "$", "this", "->", "hash", ")", ";", "$", "qb", "->", "attr", "(", "'range'", ")", "->", "equals", "(", "$", "this", "->", "range", ")", ";", "return", "$", "qb", ";", "}" ]
@param DocumentManager $dm @return QueryBuilder
[ "@param", "DocumentManager", "$dm" ]
train
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/ValueGenerator/IncrementGenerator.php#L178-L186
mtils/cmsable
src/Cmsable/PageType/TemplateConfigTypeRepository.php
TemplateConfigTypeRepository.getConfigType
public function getConfigType($pageType){ $id = $this->pageTypeId($pageType); if(isset($this->configTypes[$id])){ return $this->configTypes[$id]; } if(!isset($this->templates[$id])){ throw new OutOfBoundsException("Config of PageType '$id' not found"); } return $this->typeFactory->create($this->templates[$id]); }
php
public function getConfigType($pageType){ $id = $this->pageTypeId($pageType); if(isset($this->configTypes[$id])){ return $this->configTypes[$id]; } if(!isset($this->templates[$id])){ throw new OutOfBoundsException("Config of PageType '$id' not found"); } return $this->typeFactory->create($this->templates[$id]); }
[ "public", "function", "getConfigType", "(", "$", "pageType", ")", "{", "$", "id", "=", "$", "this", "->", "pageTypeId", "(", "$", "pageType", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "configTypes", "[", "$", "id", "]", ")", ")", "{", "return", "$", "this", "->", "configTypes", "[", "$", "id", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "templates", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"Config of PageType '$id' not found\"", ")", ";", "}", "return", "$", "this", "->", "typeFactory", "->", "create", "(", "$", "this", "->", "templates", "[", "$", "id", "]", ")", ";", "}" ]
Get the config TYPE of page-type $pageType @param mixed $pageType PageType or pageTypeId @return \XType\NamedFieldType
[ "Get", "the", "config", "TYPE", "of", "page", "-", "type", "$pageType" ]
train
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/PageType/TemplateConfigTypeRepository.php#L31-L45
swaros/golib
src/Types/EnumSet.php
EnumSet.checkValue
private function checkValue($valueSet){ $check = $this->getPossibleValueArray(); if (!is_array($check) || empty($check)){ $this->handleError("No Check Array defined (getPossibleValuArray())", EnumException::NoEnumsDefined); } if (!is_array($valueSet)){ $this->handleError("Invalid Value, must be Array", EnumException::Invalidvalue); } foreach ($valueSet as $value) { if (!in_array($value, $check)){ $this->handleError("Invalid Value, {$value} is not in ENUM", EnumException::Invalidvalue); } } }
php
private function checkValue($valueSet){ $check = $this->getPossibleValueArray(); if (!is_array($check) || empty($check)){ $this->handleError("No Check Array defined (getPossibleValuArray())", EnumException::NoEnumsDefined); } if (!is_array($valueSet)){ $this->handleError("Invalid Value, must be Array", EnumException::Invalidvalue); } foreach ($valueSet as $value) { if (!in_array($value, $check)){ $this->handleError("Invalid Value, {$value} is not in ENUM", EnumException::Invalidvalue); } } }
[ "private", "function", "checkValue", "(", "$", "valueSet", ")", "{", "$", "check", "=", "$", "this", "->", "getPossibleValueArray", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "check", ")", "||", "empty", "(", "$", "check", ")", ")", "{", "$", "this", "->", "handleError", "(", "\"No Check Array defined (getPossibleValuArray())\"", ",", "EnumException", "::", "NoEnumsDefined", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "valueSet", ")", ")", "{", "$", "this", "->", "handleError", "(", "\"Invalid Value, must be Array\"", ",", "EnumException", "::", "Invalidvalue", ")", ";", "}", "foreach", "(", "$", "valueSet", "as", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "$", "check", ")", ")", "{", "$", "this", "->", "handleError", "(", "\"Invalid Value, {$value} is not in ENUM\"", ",", "EnumException", "::", "Invalidvalue", ")", ";", "}", "}", "}" ]
checks if given $value valid @param array $valueSet @throws \InvalidArgumentException
[ "checks", "if", "given", "$value", "valid" ]
train
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/EnumSet.php#L44-L59
itcreator/custom-cmf
Module/Event/src/Cmf/Event/TSharedListenerAggregate.php
TSharedListenerAggregate.detachShared
public function detachShared(SharedEventManagerInterface $events) { $key = $this->getEventsKey($events); if (empty($this->listeners[$key])) { return; } foreach ($this->listeners[$key] as $index => $callback) { foreach ($this->identity as $id) { if ($events->detach($id, $callback)) { unset($this->listeners[$key][$index]); } } } }
php
public function detachShared(SharedEventManagerInterface $events) { $key = $this->getEventsKey($events); if (empty($this->listeners[$key])) { return; } foreach ($this->listeners[$key] as $index => $callback) { foreach ($this->identity as $id) { if ($events->detach($id, $callback)) { unset($this->listeners[$key][$index]); } } } }
[ "public", "function", "detachShared", "(", "SharedEventManagerInterface", "$", "events", ")", "{", "$", "key", "=", "$", "this", "->", "getEventsKey", "(", "$", "events", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "listeners", "[", "$", "key", "]", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "key", "]", "as", "$", "index", "=>", "$", "callback", ")", "{", "foreach", "(", "$", "this", "->", "identity", "as", "$", "id", ")", "{", "if", "(", "$", "events", "->", "detach", "(", "$", "id", ",", "$", "callback", ")", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "key", "]", "[", "$", "index", "]", ")", ";", "}", "}", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/itcreator/custom-cmf/blob/42fc0535dfa0f641856f06673f6ab596b2020c40/Module/Event/src/Cmf/Event/TSharedListenerAggregate.php#L61-L75
Kris-Kuiper/sFire-Framework
src/MVC/ViewModel.php
ViewModel.getVariable
public function getVariable($variable) { if(true === isset($this -> variables[$variable])) { return $this -> variables[$variable]; } }
php
public function getVariable($variable) { if(true === isset($this -> variables[$variable])) { return $this -> variables[$variable]; } }
[ "public", "function", "getVariable", "(", "$", "variable", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "variables", "[", "$", "variable", "]", ")", ")", "{", "return", "$", "this", "->", "variables", "[", "$", "variable", "]", ";", "}", "}" ]
Getter for returning variables by key @param mixed $variable @return mixed
[ "Getter", "for", "returning", "variables", "by", "key" ]
train
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/ViewModel.php#L111-L116
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fopen
final protected function fopen( $filename = 'php://temp', $use_include_path = false, $mode = 'a+', $context = null ) { $this->fhandle = is_resource($context) ? fopen($filename, $mode, $use_include_path, $context) : fopen($filename, $mode, $use_include_path); return $this; }
php
final protected function fopen( $filename = 'php://temp', $use_include_path = false, $mode = 'a+', $context = null ) { $this->fhandle = is_resource($context) ? fopen($filename, $mode, $use_include_path, $context) : fopen($filename, $mode, $use_include_path); return $this; }
[ "final", "protected", "function", "fopen", "(", "$", "filename", "=", "'php://temp'", ",", "$", "use_include_path", "=", "false", ",", "$", "mode", "=", "'a+'", ",", "$", "context", "=", "null", ")", "{", "$", "this", "->", "fhandle", "=", "is_resource", "(", "$", "context", ")", "?", "fopen", "(", "$", "filename", ",", "$", "mode", ",", "$", "use_include_path", ",", "$", "context", ")", ":", "fopen", "(", "$", "filename", ",", "$", "mode", ",", "$", "use_include_path", ")", ";", "return", "$", "this", ";", "}" ]
Opens file or URL @param string $filename Filename or URL @param bool $use_include_path Use include path? @param string $mode Type of access required to the stream @param resource $context https://php.net/manual/en/book.stream.php @return self @see https://php.net/manual/en/function.fopen.php
[ "Opens", "file", "or", "URL" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L51-L63
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fsockopen
final protected function fsockopen( $hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null ) { $this->fhandle = fsockopen($hostname, $port, $errno, $errstr, $timeout); return $this; }
php
final protected function fsockopen( $hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null ) { $this->fhandle = fsockopen($hostname, $port, $errno, $errstr, $timeout); return $this; }
[ "final", "protected", "function", "fsockopen", "(", "$", "hostname", ",", "$", "port", "=", "-", "1", ",", "&", "$", "errno", "=", "0", ",", "&", "$", "errstr", "=", "''", ",", "$", "timeout", "=", "null", ")", "{", "$", "this", "->", "fhandle", "=", "fsockopen", "(", "$", "hostname", ",", "$", "port", ",", "$", "errno", ",", "$", "errstr", ",", "$", "timeout", ")", ";", "return", "$", "this", ";", "}" ]
Open Internet or Unix domain socket connection @param string $hostname [description] @param int $port Port number @param int $errno Holds system level error number @param string $errstr The error message as a string @param float $timeout The connection timeout, in seconds @return self @see https://php.net/manual/en/function.fpassthru.php @todo Test this
[ "Open", "Internet", "or", "Unix", "domain", "socket", "connection" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L77-L87
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.flock
final protected function flock($operation = LOCK_EX, &$wouldblock = 0) { $this->flocked = flock($this->fhandle, $operation, $wouldblock); return $this; }
php
final protected function flock($operation = LOCK_EX, &$wouldblock = 0) { $this->flocked = flock($this->fhandle, $operation, $wouldblock); return $this; }
[ "final", "protected", "function", "flock", "(", "$", "operation", "=", "LOCK_EX", ",", "&", "$", "wouldblock", "=", "0", ")", "{", "$", "this", "->", "flocked", "=", "flock", "(", "$", "this", "->", "fhandle", ",", "$", "operation", ",", "$", "wouldblock", ")", ";", "return", "$", "this", ";", "}" ]
Portable advisory file locking @param int $operation Type of lock (LOCK_SH, LOCK_EX, or LOCK_UN) @param int $wouldblock Set to 1 if the lock would block @return self @see https://php.net/manual/en/function.flock.php
[ "Portable", "advisory", "file", "locking" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L97-L101
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fwrite
final protected function fwrite($string, $length = null) { return is_int($length) ? fwrite($this->fhandle, $string, $length) : fwrite($this->fhandle, $string); }
php
final protected function fwrite($string, $length = null) { return is_int($length) ? fwrite($this->fhandle, $string, $length) : fwrite($this->fhandle, $string); }
[ "final", "protected", "function", "fwrite", "(", "$", "string", ",", "$", "length", "=", "null", ")", "{", "return", "is_int", "(", "$", "length", ")", "?", "fwrite", "(", "$", "this", "->", "fhandle", ",", "$", "string", ",", "$", "length", ")", ":", "fwrite", "(", "$", "this", "->", "fhandle", ",", "$", "string", ")", ";", "}" ]
Binary-safe file write @param string $string The string that is to be written. @param int $length Stop after $length bytes have been written @return self @see https://php.net/manual/en/function.fwrite.php
[ "Binary", "-", "safe", "file", "write" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L125-L130
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fread
final protected function fread($length = null) { if (! is_int($length)) { $length = $this->fstat('size'); } return fread($this->fhandle, $length); }
php
final protected function fread($length = null) { if (! is_int($length)) { $length = $this->fstat('size'); } return fread($this->fhandle, $length); }
[ "final", "protected", "function", "fread", "(", "$", "length", "=", "null", ")", "{", "if", "(", "!", "is_int", "(", "$", "length", ")", ")", "{", "$", "length", "=", "$", "this", "->", "fstat", "(", "'size'", ")", ";", "}", "return", "fread", "(", "$", "this", "->", "fhandle", ",", "$", "length", ")", ";", "}" ]
Binary-safe file read @param int $length Up to $length number of bytes read. @return string The read string or FALSE on failure. @see https://php.net/manual/en/function.fread.php
[ "Binary", "-", "safe", "file", "read" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L159-L165
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fgets
final protected function fgets($length = null) { if (! is_int($length)) { $length = $this->fstat('size'); } return fgets($this->fhandle, $length); }
php
final protected function fgets($length = null) { if (! is_int($length)) { $length = $this->fstat('size'); } return fgets($this->fhandle, $length); }
[ "final", "protected", "function", "fgets", "(", "$", "length", "=", "null", ")", "{", "if", "(", "!", "is_int", "(", "$", "length", ")", ")", "{", "$", "length", "=", "$", "this", "->", "fstat", "(", "'size'", ")", ";", "}", "return", "fgets", "(", "$", "this", "->", "fhandle", ",", "$", "length", ")", ";", "}" ]
Gets line from file pointer @param int $length Reading ends when $length - 1 bytes have been read @return string String of $length - 1 bytes @see https://php.net/manual/en/function.fgets.php
[ "Gets", "line", "from", "file", "pointer" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L174-L180
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fgetss
final protected function fgetss($length, array $allowable_tags = array()) { array_walk( $allowable_tags, function($tag) { $tag = '<' . trim('<>', trim($tag)). '>'; } ); if (! is_int($length)) { $length = $this->fstat('size'); } return fgetss($this->fhandle, $length, join(null, $allowable_tags)); }
php
final protected function fgetss($length, array $allowable_tags = array()) { array_walk( $allowable_tags, function($tag) { $tag = '<' . trim('<>', trim($tag)). '>'; } ); if (! is_int($length)) { $length = $this->fstat('size'); } return fgetss($this->fhandle, $length, join(null, $allowable_tags)); }
[ "final", "protected", "function", "fgetss", "(", "$", "length", ",", "array", "$", "allowable_tags", "=", "array", "(", ")", ")", "{", "array_walk", "(", "$", "allowable_tags", ",", "function", "(", "$", "tag", ")", "{", "$", "tag", "=", "'<'", ".", "trim", "(", "'<>'", ",", "trim", "(", "$", "tag", ")", ")", ".", "'>'", ";", "}", ")", ";", "if", "(", "!", "is_int", "(", "$", "length", ")", ")", "{", "$", "length", "=", "$", "this", "->", "fstat", "(", "'size'", ")", ";", "}", "return", "fgetss", "(", "$", "this", "->", "fhandle", ",", "$", "length", ",", "join", "(", "null", ",", "$", "allowable_tags", ")", ")", ";", "}" ]
Gets line from file pointer and strip HTML tags Unlike the function, this uses an array for $allowable_tags @param int $length Length of the data to be retrieved @param array $allowable_tags Array of tags to allow @return string A string of up to length - 1 bytes read @see https://php.net/manual/en/function.fgetss.php
[ "Gets", "line", "from", "file", "pointer", "and", "strip", "HTML", "tags", "Unlike", "the", "function", "this", "uses", "an", "array", "for", "$allowable_tags" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L191-L204
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fgetcsv
final protected function fgetcsv( $length = 0, $delimiter = ',', $enclosure = '"', $escape = '\\' ) { return fgetcsv($this->fhandle, $length, $delimiter, $enclosure, $escape); }
php
final protected function fgetcsv( $length = 0, $delimiter = ',', $enclosure = '"', $escape = '\\' ) { return fgetcsv($this->fhandle, $length, $delimiter, $enclosure, $escape); }
[ "final", "protected", "function", "fgetcsv", "(", "$", "length", "=", "0", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape", "=", "'\\\\'", ")", "{", "return", "fgetcsv", "(", "$", "this", "->", "fhandle", ",", "$", "length", ",", "$", "delimiter", ",", "$", "enclosure", ",", "$", "escape", ")", ";", "}" ]
Gets line from file pointer and parse for CSV fields @param int $length Maximum line length (0 is unlimited) @param string $delimiter Sets the field delimiter (1 character only) @param string $enclosure Sets the field enclosure (1 character only) @param string $escape Sets the escape character (1 character only) @return array An indexed array containing the fields read. @see https://php.net/manual/en/function.fgetcsv.php
[ "Gets", "line", "from", "file", "pointer", "and", "parse", "for", "CSV", "fields" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L228-L236
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fputcsv
final protected function fputcsv( array $fields, $delimiter = ',', $enclosure = '"', $escape_char = '\\' ) { return fputcsv( $this->fhandle, $fields, $delimiter, $enclosure, $escape_char ); }
php
final protected function fputcsv( array $fields, $delimiter = ',', $enclosure = '"', $escape_char = '\\' ) { return fputcsv( $this->fhandle, $fields, $delimiter, $enclosure, $escape_char ); }
[ "final", "protected", "function", "fputcsv", "(", "array", "$", "fields", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape_char", "=", "'\\\\'", ")", "{", "return", "fputcsv", "(", "$", "this", "->", "fhandle", ",", "$", "fields", ",", "$", "delimiter", ",", "$", "enclosure", ",", "$", "escape_char", ")", ";", "}" ]
Format line as CSV and write to file pointer @param array $fields An array of values. @param string $delimiter Sets the field delimiter (1 character only) @param string $enclosure Sets the field enclosure (1 character only) @param string $escape_char Sets the escape character (1 character only) @return int Length of the written string or FALSE on failure. @see https://php.net/manual/en/function.fputcsv.php
[ "Format", "line", "as", "CSV", "and", "write", "to", "file", "pointer" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L248-L262
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fscanf
final protected function fscanf($format, array &$params = array()) { if (empty($params)) { return fscanf($this->fhandle, $format); } array_shift($params, $this->fhandle, $format); $results = call_user_func_array('fscanf', $params); array_splice($params, 2); return $results; }
php
final protected function fscanf($format, array &$params = array()) { if (empty($params)) { return fscanf($this->fhandle, $format); } array_shift($params, $this->fhandle, $format); $results = call_user_func_array('fscanf', $params); array_splice($params, 2); return $results; }
[ "final", "protected", "function", "fscanf", "(", "$", "format", ",", "array", "&", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "return", "fscanf", "(", "$", "this", "->", "fhandle", ",", "$", "format", ")", ";", "}", "array_shift", "(", "$", "params", ",", "$", "this", "->", "fhandle", ",", "$", "format", ")", ";", "$", "results", "=", "call_user_func_array", "(", "'fscanf'", ",", "$", "params", ")", ";", "array_splice", "(", "$", "params", ",", "2", ")", ";", "return", "$", "results", ";", "}" ]
Parses input from a file according to a format @param string $format [description] @param array $params [description] @return mixed @see https://php.net/manual/en/function.fscanf.php @todo Test and make work with additional params beyond $format
[ "Parses", "input", "from", "a", "file", "according", "to", "a", "format" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L329-L338
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.filePutContents
final public function filePutContents($data, $flags = FILE_APPEND) { if ($flags & FILE_APPEND) { $this->fseek(-1, SEEK_END); } else { $this->ftruncate(); } if ($flags & LOCK_EX) { $this->flock(LOCK_EX); } if (is_array($data)) { $data = join(null, $data); } $this->fwrite($data); }
php
final public function filePutContents($data, $flags = FILE_APPEND) { if ($flags & FILE_APPEND) { $this->fseek(-1, SEEK_END); } else { $this->ftruncate(); } if ($flags & LOCK_EX) { $this->flock(LOCK_EX); } if (is_array($data)) { $data = join(null, $data); } $this->fwrite($data); }
[ "final", "public", "function", "filePutContents", "(", "$", "data", ",", "$", "flags", "=", "FILE_APPEND", ")", "{", "if", "(", "$", "flags", "&", "FILE_APPEND", ")", "{", "$", "this", "->", "fseek", "(", "-", "1", ",", "SEEK_END", ")", ";", "}", "else", "{", "$", "this", "->", "ftruncate", "(", ")", ";", "}", "if", "(", "$", "flags", "&", "LOCK_EX", ")", "{", "$", "this", "->", "flock", "(", "LOCK_EX", ")", ";", "}", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "join", "(", "null", ",", "$", "data", ")", ";", "}", "$", "this", "->", "fwrite", "(", "$", "data", ")", ";", "}" ]
Write a string to a file @param mixed $data The data to write. String or single dimension array @param int $flags FILE_APPEND... no others have any effect
[ "Write", "a", "string", "to", "a", "file" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L382-L397
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fileGetContents
final public function fileGetContents($offset = -1, $maxlen = null) { $this->fseek($offset + 1, SEEK_SET); return $this->fread($maxlen); }
php
final public function fileGetContents($offset = -1, $maxlen = null) { $this->fseek($offset + 1, SEEK_SET); return $this->fread($maxlen); }
[ "final", "public", "function", "fileGetContents", "(", "$", "offset", "=", "-", "1", ",", "$", "maxlen", "=", "null", ")", "{", "$", "this", "->", "fseek", "(", "$", "offset", "+", "1", ",", "SEEK_SET", ")", ";", "return", "$", "this", "->", "fread", "(", "$", "maxlen", ")", ";", "}" ]
Reads entire file into a string @param int $offset The offset where the reading starts on the original stream. @param int $maxlen Maximum length of data read
[ "Reads", "entire", "file", "into", "a", "string" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L405-L409
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.fileGetCSV
final public function fileGetCSV( $delimiter = ',', $enclosure = '"', $escape = '\\' ) { $rows = []; $this->rewind(); while (! $this->feof()) { $row = $this->fgetcsv(0, $delimiter, $enclosure, $escape); if ($row !== false) { array_push($rows, $row); } unset($row); } return $rows; }
php
final public function fileGetCSV( $delimiter = ',', $enclosure = '"', $escape = '\\' ) { $rows = []; $this->rewind(); while (! $this->feof()) { $row = $this->fgetcsv(0, $delimiter, $enclosure, $escape); if ($row !== false) { array_push($rows, $row); } unset($row); } return $rows; }
[ "final", "public", "function", "fileGetCSV", "(", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape", "=", "'\\\\'", ")", "{", "$", "rows", "=", "[", "]", ";", "$", "this", "->", "rewind", "(", ")", ";", "while", "(", "!", "$", "this", "->", "feof", "(", ")", ")", "{", "$", "row", "=", "$", "this", "->", "fgetcsv", "(", "0", ",", "$", "delimiter", ",", "$", "enclosure", ",", "$", "escape", ")", ";", "if", "(", "$", "row", "!==", "false", ")", "{", "array_push", "(", "$", "rows", ",", "$", "row", ")", ";", "}", "unset", "(", "$", "row", ")", ";", "}", "return", "$", "rows", ";", "}" ]
Read an entire file parsed as CSV @param string $delimiter Sets the field delimiter (1 character only) @param string $enclosure Sets the field enclosure (1 character only) @param string $escape Sets the escape character (1 character only) @return array Multi-dimensional indexed array (rows & columns)
[ "Read", "an", "entire", "file", "parsed", "as", "CSV" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L419-L436
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.filePutCSV
final public function filePutCSV( array $fields, $delimiter = ',', $enclosure = '"', $escape_char = '\\' ) { $this->fputcsv($fields, $delimiter, $enclosure, $escape_char); }
php
final public function filePutCSV( array $fields, $delimiter = ',', $enclosure = '"', $escape_char = '\\' ) { $this->fputcsv($fields, $delimiter, $enclosure, $escape_char); }
[ "final", "public", "function", "filePutCSV", "(", "array", "$", "fields", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "escape_char", "=", "'\\\\'", ")", "{", "$", "this", "->", "fputcsv", "(", "$", "fields", ",", "$", "delimiter", ",", "$", "enclosure", ",", "$", "escape_char", ")", ";", "}" ]
Format line as CSV and write to file @param array $fields An array of values. @param string $delimiter Sets the field delimiter (1 character only) @param string $enclosure Sets the field enclosure (1 character only) @param string $escape_char Sets the escape character (1 character only)
[ "Format", "line", "as", "CSV", "and", "write", "to", "file" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L446-L454
shgysk8zer0/core_api
traits/file_resources.php
File_Resources.file
final public function file($flags = 0) { $contents = []; $ignore_nl = $flags & FILE_IGNORE_NEW_LINES; $skip_empty = $flags & FILE_SKIP_EMPTY_LINES; $this->rewind(); while (! $this->feof()) { $line = $this->fgets(); if ($ignore_nl) { $line = rtrim($line, PHP_EOL); } if (! $skip_empty or strlen($line) !== 0) { array_push($contents, $line); } } return $contents; }
php
final public function file($flags = 0) { $contents = []; $ignore_nl = $flags & FILE_IGNORE_NEW_LINES; $skip_empty = $flags & FILE_SKIP_EMPTY_LINES; $this->rewind(); while (! $this->feof()) { $line = $this->fgets(); if ($ignore_nl) { $line = rtrim($line, PHP_EOL); } if (! $skip_empty or strlen($line) !== 0) { array_push($contents, $line); } } return $contents; }
[ "final", "public", "function", "file", "(", "$", "flags", "=", "0", ")", "{", "$", "contents", "=", "[", "]", ";", "$", "ignore_nl", "=", "$", "flags", "&", "FILE_IGNORE_NEW_LINES", ";", "$", "skip_empty", "=", "$", "flags", "&", "FILE_SKIP_EMPTY_LINES", ";", "$", "this", "->", "rewind", "(", ")", ";", "while", "(", "!", "$", "this", "->", "feof", "(", ")", ")", "{", "$", "line", "=", "$", "this", "->", "fgets", "(", ")", ";", "if", "(", "$", "ignore_nl", ")", "{", "$", "line", "=", "rtrim", "(", "$", "line", ",", "PHP_EOL", ")", ";", "}", "if", "(", "!", "$", "skip_empty", "or", "strlen", "(", "$", "line", ")", "!==", "0", ")", "{", "array_push", "(", "$", "contents", ",", "$", "line", ")", ";", "}", "}", "return", "$", "contents", ";", "}" ]
Reads entire file into an array @param int $flags [FILE_IGNORE_NEW_LINES, FILE_SKIP_EMPTY_LINES] @return array Each line of file as an array @see https://php.net/manual/en/function.file.php @todo Make handling of FILE_IGNORE_NEW_LINES match original function
[ "Reads", "entire", "file", "into", "an", "array" ]
train
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/file_resources.php#L476-L493
PenoaksDev/Milky-Framework
src/Milky/Account/Auths/EloquentAuth.php
EloquentAuth.retrieveByCredentials
public function retrieveByCredentials( array $credentials ) { if ( empty( $credentials ) ) return null; // First we will add each credential element to the query as a where clause. // Then we can execute the query and, if we found a user, return it in a // Eloquent User "model" that will be utilized by the Guard instances. $query = $this->createUsrModel()->newQuery(); foreach ( $credentials as $key => $value ) if ( !Str::contains( $key, 'password' ) ) $query->where( $key, $value ); return $query->first(); }
php
public function retrieveByCredentials( array $credentials ) { if ( empty( $credentials ) ) return null; // First we will add each credential element to the query as a where clause. // Then we can execute the query and, if we found a user, return it in a // Eloquent User "model" that will be utilized by the Guard instances. $query = $this->createUsrModel()->newQuery(); foreach ( $credentials as $key => $value ) if ( !Str::contains( $key, 'password' ) ) $query->where( $key, $value ); return $query->first(); }
[ "public", "function", "retrieveByCredentials", "(", "array", "$", "credentials", ")", "{", "if", "(", "empty", "(", "$", "credentials", ")", ")", "return", "null", ";", "// First we will add each credential element to the query as a where clause.", "// Then we can execute the query and, if we found a user, return it in a", "// Eloquent User \"model\" that will be utilized by the Guard instances.", "$", "query", "=", "$", "this", "->", "createUsrModel", "(", ")", "->", "newQuery", "(", ")", ";", "foreach", "(", "$", "credentials", "as", "$", "key", "=>", "$", "value", ")", "if", "(", "!", "Str", "::", "contains", "(", "$", "key", ",", "'password'", ")", ")", "$", "query", "->", "where", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "query", "->", "first", "(", ")", ";", "}" ]
Retrieve a user by the given credentials. @param array $credentials @return User|null
[ "Retrieve", "a", "user", "by", "the", "given", "credentials", "." ]
train
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Auths/EloquentAuth.php#L94-L109
RSQueue/RSQueue
src/RSQueue/Services/Publisher.php
Publisher.publish
public function publish($channelAlias, $payload) { $channel = $this ->queueAliasResolver ->getQueue($channelAlias); $payloadSerialized = $this ->serializer ->apply($payload); $this ->redis ->publish( $channel, $payloadSerialized ); /* * Dispatching publisher event... */ $publisherEvent = new RSQueuePublisherEvent( $payload, $payloadSerialized, $channel, $this->redis ); $this ->eventDispatcher ->dispatch( RSQueueEvents::RSQUEUE_PUBLISHER, $publisherEvent ); return $this; }
php
public function publish($channelAlias, $payload) { $channel = $this ->queueAliasResolver ->getQueue($channelAlias); $payloadSerialized = $this ->serializer ->apply($payload); $this ->redis ->publish( $channel, $payloadSerialized ); /* * Dispatching publisher event... */ $publisherEvent = new RSQueuePublisherEvent( $payload, $payloadSerialized, $channel, $this->redis ); $this ->eventDispatcher ->dispatch( RSQueueEvents::RSQUEUE_PUBLISHER, $publisherEvent ); return $this; }
[ "public", "function", "publish", "(", "$", "channelAlias", ",", "$", "payload", ")", "{", "$", "channel", "=", "$", "this", "->", "queueAliasResolver", "->", "getQueue", "(", "$", "channelAlias", ")", ";", "$", "payloadSerialized", "=", "$", "this", "->", "serializer", "->", "apply", "(", "$", "payload", ")", ";", "$", "this", "->", "redis", "->", "publish", "(", "$", "channel", ",", "$", "payloadSerialized", ")", ";", "/*\n * Dispatching publisher event...\n */", "$", "publisherEvent", "=", "new", "RSQueuePublisherEvent", "(", "$", "payload", ",", "$", "payloadSerialized", ",", "$", "channel", ",", "$", "this", "->", "redis", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "RSQueueEvents", "::", "RSQUEUE_PUBLISHER", ",", "$", "publisherEvent", ")", ";", "return", "$", "this", ";", "}" ]
Enqueues payload inside desired queue. @param string $channelAlias Name of channel to publish payload @param mixed $payload Data to publish @return Producer self Object
[ "Enqueues", "payload", "inside", "desired", "queue", "." ]
train
https://github.com/RSQueue/RSQueue/blob/1a8d72a2b025ed65684644febf9493d4f6ac9333/src/RSQueue/Services/Publisher.php#L37-L72
theopera/framework
src/Component/WebApplication/Router.php
Router.fallBackRoute
private function fallBackRoute(RequestInterface $request) : Route { $parts = explode('/', $request->getPathInfo()); if (count($parts) == 2 && empty($parts[1])) { return $this->getDefaultRoute($request); } $actionName = 'index'; $controllerName = ucfirst($parts[1]); if (count($parts) > 2) { $actionName = $parts[2]; } $endPoint = new RouteEndpoint( $this->context->getControllerNamespace(), $controllerName, $actionName, $request->getMethod()); return new Route('/' . $parts[1] . '/' . $actionName, $endPoint); }
php
private function fallBackRoute(RequestInterface $request) : Route { $parts = explode('/', $request->getPathInfo()); if (count($parts) == 2 && empty($parts[1])) { return $this->getDefaultRoute($request); } $actionName = 'index'; $controllerName = ucfirst($parts[1]); if (count($parts) > 2) { $actionName = $parts[2]; } $endPoint = new RouteEndpoint( $this->context->getControllerNamespace(), $controllerName, $actionName, $request->getMethod()); return new Route('/' . $parts[1] . '/' . $actionName, $endPoint); }
[ "private", "function", "fallBackRoute", "(", "RequestInterface", "$", "request", ")", ":", "Route", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "request", "->", "getPathInfo", "(", ")", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "==", "2", "&&", "empty", "(", "$", "parts", "[", "1", "]", ")", ")", "{", "return", "$", "this", "->", "getDefaultRoute", "(", "$", "request", ")", ";", "}", "$", "actionName", "=", "'index'", ";", "$", "controllerName", "=", "ucfirst", "(", "$", "parts", "[", "1", "]", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "2", ")", "{", "$", "actionName", "=", "$", "parts", "[", "2", "]", ";", "}", "$", "endPoint", "=", "new", "RouteEndpoint", "(", "$", "this", "->", "context", "->", "getControllerNamespace", "(", ")", ",", "$", "controllerName", ",", "$", "actionName", ",", "$", "request", "->", "getMethod", "(", ")", ")", ";", "return", "new", "Route", "(", "'/'", ".", "$", "parts", "[", "1", "]", ".", "'/'", ".", "$", "actionName", ",", "$", "endPoint", ")", ";", "}" ]
If we cannot match a Route with the RouteCollection we will try to find a Controller & Action that matches the uri @param RequestInterface $request @return Route
[ "If", "we", "cannot", "match", "a", "Route", "with", "the", "RouteCollection", "we", "will", "try", "to", "find", "a", "Controller", "&", "Action", "that", "matches", "the", "uri" ]
train
https://github.com/theopera/framework/blob/fa6165d3891a310faa580c81dee49a63c150c711/src/Component/WebApplication/Router.php#L97-L118
essence/dom
src/Tag/Native.php
Native.get
public function get($name, $default = null) { return $this->_Element->hasAttribute($name) ? $this->_Element->getAttribute($name) : $default; }
php
public function get($name, $default = null) { return $this->_Element->hasAttribute($name) ? $this->_Element->getAttribute($name) : $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "_Element", "->", "hasAttribute", "(", "$", "name", ")", "?", "$", "this", "->", "_Element", "->", "getAttribute", "(", "$", "name", ")", ":", "$", "default", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/essence/dom/blob/e5776d2286f4ccbd048d160c28ac77ccc6d68f3a/src/Tag/Native.php#L42-L46
arikaim/container
Container.php
Container.get
public function get($id) { if ($this->has($id) == false) { throw new ServiceNotFoundException($id); } if (\is_object($this->services[$id]) == false || method_exists($this->services[$id], '__invoke') == false) { return $this->services[$id]; } $this->services[$id] = $this->services[$id]($this); return $this->services[$id]; }
php
public function get($id) { if ($this->has($id) == false) { throw new ServiceNotFoundException($id); } if (\is_object($this->services[$id]) == false || method_exists($this->services[$id], '__invoke') == false) { return $this->services[$id]; } $this->services[$id] = $this->services[$id]($this); return $this->services[$id]; }
[ "public", "function", "get", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "id", ")", "==", "false", ")", "{", "throw", "new", "ServiceNotFoundException", "(", "$", "id", ")", ";", "}", "if", "(", "\\", "is_object", "(", "$", "this", "->", "services", "[", "$", "id", "]", ")", "==", "false", "||", "method_exists", "(", "$", "this", "->", "services", "[", "$", "id", "]", ",", "'__invoke'", ")", "==", "false", ")", "{", "return", "$", "this", "->", "services", "[", "$", "id", "]", ";", "}", "$", "this", "->", "services", "[", "$", "id", "]", "=", "$", "this", "->", "services", "[", "$", "id", "]", "(", "$", "this", ")", ";", "return", "$", "this", "->", "services", "[", "$", "id", "]", ";", "}" ]
Get service from container @param string $id Srvice id @throws ServiceNotFoundException; @return mixed Service or null if not exist
[ "Get", "service", "from", "container" ]
train
https://github.com/arikaim/container/blob/aa0e7b62e9a0fd58839610857e466fe4838f72f5/Container.php#L44-L56
arikaim/container
Container.php
Container.add
public function add($id, $service, $replace = false) { if ($this->has($id) == true && $replace == false) { throw new ServiceExistsException($id); } $this->services[$id] = $service; }
php
public function add($id, $service, $replace = false) { if ($this->has($id) == true && $replace == false) { throw new ServiceExistsException($id); } $this->services[$id] = $service; }
[ "public", "function", "add", "(", "$", "id", ",", "$", "service", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "id", ")", "==", "true", "&&", "$", "replace", "==", "false", ")", "{", "throw", "new", "ServiceExistsException", "(", "$", "id", ")", ";", "}", "$", "this", "->", "services", "[", "$", "id", "]", "=", "$", "service", ";", "}" ]
Add service to container @param string $id Service id @param mixed $service Service value @param boolean $replace Replace service if exists @throws ServiceExistsException If replace is false and service exists in container @return void
[ "Add", "service", "to", "container" ]
train
https://github.com/arikaim/container/blob/aa0e7b62e9a0fd58839610857e466fe4838f72f5/Container.php#L78-L84
davewwww/SimpleAccessor
src/Dwo/SimpleAccessor/AccessInfo.php
AccessInfo.readProperty
public static function readProperty($object, $property, array $access) { if (AccessInfo::METHOD === $access['type']) { $value = $object->{$access['name']}(); } elseif (AccessInfo::PROPERTY === $access['type']) { $value = $object->{$access['name']}; } elseif (!$access['has_property'] && property_exists($object, $property)) { $value = $object->$property; } else { throw new \RuntimeException($access['name']); } return $value; }
php
public static function readProperty($object, $property, array $access) { if (AccessInfo::METHOD === $access['type']) { $value = $object->{$access['name']}(); } elseif (AccessInfo::PROPERTY === $access['type']) { $value = $object->{$access['name']}; } elseif (!$access['has_property'] && property_exists($object, $property)) { $value = $object->$property; } else { throw new \RuntimeException($access['name']); } return $value; }
[ "public", "static", "function", "readProperty", "(", "$", "object", ",", "$", "property", ",", "array", "$", "access", ")", "{", "if", "(", "AccessInfo", "::", "METHOD", "===", "$", "access", "[", "'type'", "]", ")", "{", "$", "value", "=", "$", "object", "->", "{", "$", "access", "[", "'name'", "]", "}", "(", ")", ";", "}", "elseif", "(", "AccessInfo", "::", "PROPERTY", "===", "$", "access", "[", "'type'", "]", ")", "{", "$", "value", "=", "$", "object", "->", "{", "$", "access", "[", "'name'", "]", "}", ";", "}", "elseif", "(", "!", "$", "access", "[", "'has_property'", "]", "&&", "property_exists", "(", "$", "object", ",", "$", "property", ")", ")", "{", "$", "value", "=", "$", "object", "->", "$", "property", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "access", "[", "'name'", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
@see PropertyAccessor::readProperty() @param object $object @param string $property @param array $access @return mixed
[ "@see", "PropertyAccessor", "::", "readProperty", "()" ]
train
https://github.com/davewwww/SimpleAccessor/blob/677eb5266ea6d6503e8920ec0db2494b290d1777/src/Dwo/SimpleAccessor/AccessInfo.php#L27-L40
davewwww/SimpleAccessor
src/Dwo/SimpleAccessor/AccessInfo.php
AccessInfo.getReadAccessInfo
public static function getReadAccessInfo(ReflectionClass $reflClass, $property) { $access = array(); $access['has_property'] = $reflClass->hasProperty($property); //method $camelProp = str_replace(' ', '', ucwords(str_replace('_', ' ', $property))); $methods = array('get'.$camelProp, lcfirst($camelProp), 'is'.$camelProp, 'has'.$camelProp); foreach ($methods as $method) { if ($reflClass->hasMethod($method) && $reflClass->getMethod($method)->isPublic()) { $access['type'] = AccessInfo::METHOD; $access['name'] = $method; return $access; } } //property if ($reflClass->hasMethod('__get') && $reflClass->getMethod('__get')->isPublic()) { $access['type'] = AccessInfo::PROPERTY; $access['name'] = $property; $access['ref'] = false; } elseif ($access['has_property'] && $reflClass->getProperty($property)->isPublic()) { $access['type'] = AccessInfo::PROPERTY; $access['name'] = $property; $access['ref'] = true; } else { $access['type'] = 'not_found'; $access['name'] = sprintf( 'Neither the property "%s" nor one of the methods "%s()" '. 'exist and have public access in class "%s".', $property, implode('()", "', array_merge($methods, ['__get'])), $reflClass->name ); } return $access; }
php
public static function getReadAccessInfo(ReflectionClass $reflClass, $property) { $access = array(); $access['has_property'] = $reflClass->hasProperty($property); //method $camelProp = str_replace(' ', '', ucwords(str_replace('_', ' ', $property))); $methods = array('get'.$camelProp, lcfirst($camelProp), 'is'.$camelProp, 'has'.$camelProp); foreach ($methods as $method) { if ($reflClass->hasMethod($method) && $reflClass->getMethod($method)->isPublic()) { $access['type'] = AccessInfo::METHOD; $access['name'] = $method; return $access; } } //property if ($reflClass->hasMethod('__get') && $reflClass->getMethod('__get')->isPublic()) { $access['type'] = AccessInfo::PROPERTY; $access['name'] = $property; $access['ref'] = false; } elseif ($access['has_property'] && $reflClass->getProperty($property)->isPublic()) { $access['type'] = AccessInfo::PROPERTY; $access['name'] = $property; $access['ref'] = true; } else { $access['type'] = 'not_found'; $access['name'] = sprintf( 'Neither the property "%s" nor one of the methods "%s()" '. 'exist and have public access in class "%s".', $property, implode('()", "', array_merge($methods, ['__get'])), $reflClass->name ); } return $access; }
[ "public", "static", "function", "getReadAccessInfo", "(", "ReflectionClass", "$", "reflClass", ",", "$", "property", ")", "{", "$", "access", "=", "array", "(", ")", ";", "$", "access", "[", "'has_property'", "]", "=", "$", "reflClass", "->", "hasProperty", "(", "$", "property", ")", ";", "//method", "$", "camelProp", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "property", ")", ")", ")", ";", "$", "methods", "=", "array", "(", "'get'", ".", "$", "camelProp", ",", "lcfirst", "(", "$", "camelProp", ")", ",", "'is'", ".", "$", "camelProp", ",", "'has'", ".", "$", "camelProp", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "$", "reflClass", "->", "hasMethod", "(", "$", "method", ")", "&&", "$", "reflClass", "->", "getMethod", "(", "$", "method", ")", "->", "isPublic", "(", ")", ")", "{", "$", "access", "[", "'type'", "]", "=", "AccessInfo", "::", "METHOD", ";", "$", "access", "[", "'name'", "]", "=", "$", "method", ";", "return", "$", "access", ";", "}", "}", "//property", "if", "(", "$", "reflClass", "->", "hasMethod", "(", "'__get'", ")", "&&", "$", "reflClass", "->", "getMethod", "(", "'__get'", ")", "->", "isPublic", "(", ")", ")", "{", "$", "access", "[", "'type'", "]", "=", "AccessInfo", "::", "PROPERTY", ";", "$", "access", "[", "'name'", "]", "=", "$", "property", ";", "$", "access", "[", "'ref'", "]", "=", "false", ";", "}", "elseif", "(", "$", "access", "[", "'has_property'", "]", "&&", "$", "reflClass", "->", "getProperty", "(", "$", "property", ")", "->", "isPublic", "(", ")", ")", "{", "$", "access", "[", "'type'", "]", "=", "AccessInfo", "::", "PROPERTY", ";", "$", "access", "[", "'name'", "]", "=", "$", "property", ";", "$", "access", "[", "'ref'", "]", "=", "true", ";", "}", "else", "{", "$", "access", "[", "'type'", "]", "=", "'not_found'", ";", "$", "access", "[", "'name'", "]", "=", "sprintf", "(", "'Neither the property \"%s\" nor one of the methods \"%s()\" '", ".", "'exist and have public access in class \"%s\".'", ",", "$", "property", ",", "implode", "(", "'()\", \"'", ",", "array_merge", "(", "$", "methods", ",", "[", "'__get'", "]", ")", ")", ",", "$", "reflClass", "->", "name", ")", ";", "}", "return", "$", "access", ";", "}" ]
@see PropertyAccessor::getReadAccessInfo() @param ReflectionClass $reflClass @param string $property @return array
[ "@see", "PropertyAccessor", "::", "getReadAccessInfo", "()" ]
train
https://github.com/davewwww/SimpleAccessor/blob/677eb5266ea6d6503e8920ec0db2494b290d1777/src/Dwo/SimpleAccessor/AccessInfo.php#L50-L88
sndsgd/http
src/http/Response.php
Response.setStatus
public function setStatus(int $code): Response { # `Status::getText` will throw an exception for invalid status codes $this->statusText = Status::getText($code); $this->statusCode = $code; return $this; }
php
public function setStatus(int $code): Response { # `Status::getText` will throw an exception for invalid status codes $this->statusText = Status::getText($code); $this->statusCode = $code; return $this; }
[ "public", "function", "setStatus", "(", "int", "$", "code", ")", ":", "Response", "{", "# `Status::getText` will throw an exception for invalid status codes", "$", "this", "->", "statusText", "=", "Status", "::", "getText", "(", "$", "code", ")", ";", "$", "this", "->", "statusCode", "=", "$", "code", ";", "return", "$", "this", ";", "}" ]
Set the status code and text @see \sndsgd\http\Code @param integer $code The http status code @return \sndsgd\http\Response
[ "Set", "the", "status", "code", "and", "text" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/Response.php#L54-L60
sndsgd/http
src/http/Response.php
Response.addHeader
public function addHeader(string $key, string $value): Response { $this->headers->add($key, $value); return $this; }
php
public function addHeader(string $key, string $value): Response { $this->headers->add($key, $value); return $this; }
[ "public", "function", "addHeader", "(", "string", "$", "key", ",", "string", "$", "value", ")", ":", "Response", "{", "$", "this", "->", "headers", "->", "add", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Add a header Allows for adding multiple headers with the same key @param string $key @param string $value @return \sndsgd\http\Response
[ "Add", "a", "header", "Allows", "for", "adding", "multiple", "headers", "with", "the", "same", "key" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/Response.php#L97-L101
sndsgd/http
src/http/Response.php
Response.send
public function send(string $protocol) { header("$protocol {$this->statusCode} {$this->statusText}"); foreach ($this->headers->getStringifiedArray() as $header) { header($header); } echo $this->body; }
php
public function send(string $protocol) { header("$protocol {$this->statusCode} {$this->statusText}"); foreach ($this->headers->getStringifiedArray() as $header) { header($header); } echo $this->body; }
[ "public", "function", "send", "(", "string", "$", "protocol", ")", "{", "header", "(", "\"$protocol {$this->statusCode} {$this->statusText}\"", ")", ";", "foreach", "(", "$", "this", "->", "headers", "->", "getStringifiedArray", "(", ")", "as", "$", "header", ")", "{", "header", "(", "$", "header", ")", ";", "}", "echo", "$", "this", "->", "body", ";", "}" ]
Send the request @param string $protocol The request protocol @return void
[ "Send", "the", "request" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/Response.php#L151-L159
praxigento/mobi_mod_downline
Ui/DataProvider/Grid/Account/Query.php
Query.getMapper
protected function getMapper() { if (is_null($this->mapper)) { /* init parent mapper */ $this->mapper = parent::getMapper(); /* then add own aliases */ $key = self::A_MLM_ID; $value = self::AS_DWNL . '.' . EDownline::A_MLM_ID; $this->mapper->add($key, $value); } $result = $this->mapper; return $result; }
php
protected function getMapper() { if (is_null($this->mapper)) { /* init parent mapper */ $this->mapper = parent::getMapper(); /* then add own aliases */ $key = self::A_MLM_ID; $value = self::AS_DWNL . '.' . EDownline::A_MLM_ID; $this->mapper->add($key, $value); } $result = $this->mapper; return $result; }
[ "protected", "function", "getMapper", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "mapper", ")", ")", "{", "/* init parent mapper */", "$", "this", "->", "mapper", "=", "parent", "::", "getMapper", "(", ")", ";", "/* then add own aliases */", "$", "key", "=", "self", "::", "A_MLM_ID", ";", "$", "value", "=", "self", "::", "AS_DWNL", ".", "'.'", ".", "EDownline", "::", "A_MLM_ID", ";", "$", "this", "->", "mapper", "->", "add", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "result", "=", "$", "this", "->", "mapper", ";", "return", "$", "result", ";", "}" ]
#@-
[ "#" ]
train
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Ui/DataProvider/Grid/Account/Query.php#L28-L40
praxigento/mobi_mod_downline
Ui/DataProvider/Grid/Account/Query.php
Query.getQueryItems
protected function getQueryItems() { /* this is primary query builder, not extender */ $result = parent::getQueryItems(); /* define tables aliases for internal usage (in this method) */ $asDwnl = self::AS_DWNL; $asAcc = self::AS_ACCOUNT; /* LEFT JOIN prxgt_dwnl_customer */ $tbl = $this->resource->getTableName(EDownline::ENTITY_NAME); $as = $asDwnl; $cols = [ self::A_MLM_ID => EDownline::A_MLM_ID ]; $cond = $as . '.' . EDownline::A_CUSTOMER_REF . '=' . $asAcc . '.' . EAccount::A_CUST_ID; $result->joinLeft([$as => $tbl], $cond, $cols); /* return result */ return $result; }
php
protected function getQueryItems() { /* this is primary query builder, not extender */ $result = parent::getQueryItems(); /* define tables aliases for internal usage (in this method) */ $asDwnl = self::AS_DWNL; $asAcc = self::AS_ACCOUNT; /* LEFT JOIN prxgt_dwnl_customer */ $tbl = $this->resource->getTableName(EDownline::ENTITY_NAME); $as = $asDwnl; $cols = [ self::A_MLM_ID => EDownline::A_MLM_ID ]; $cond = $as . '.' . EDownline::A_CUSTOMER_REF . '=' . $asAcc . '.' . EAccount::A_CUST_ID; $result->joinLeft([$as => $tbl], $cond, $cols); /* return result */ return $result; }
[ "protected", "function", "getQueryItems", "(", ")", "{", "/* this is primary query builder, not extender */", "$", "result", "=", "parent", "::", "getQueryItems", "(", ")", ";", "/* define tables aliases for internal usage (in this method) */", "$", "asDwnl", "=", "self", "::", "AS_DWNL", ";", "$", "asAcc", "=", "self", "::", "AS_ACCOUNT", ";", "/* LEFT JOIN prxgt_dwnl_customer */", "$", "tbl", "=", "$", "this", "->", "resource", "->", "getTableName", "(", "EDownline", "::", "ENTITY_NAME", ")", ";", "$", "as", "=", "$", "asDwnl", ";", "$", "cols", "=", "[", "self", "::", "A_MLM_ID", "=>", "EDownline", "::", "A_MLM_ID", "]", ";", "$", "cond", "=", "$", "as", ".", "'.'", ".", "EDownline", "::", "A_CUSTOMER_REF", ".", "'='", ".", "$", "asAcc", ".", "'.'", ".", "EAccount", "::", "A_CUST_ID", ";", "$", "result", "->", "joinLeft", "(", "[", "$", "as", "=>", "$", "tbl", "]", ",", "$", "cond", ",", "$", "cols", ")", ";", "/* return result */", "return", "$", "result", ";", "}" ]
SELECT ... FROM `prxgt_acc_account` AS `paa` LEFT JOIN `prxgt_acc_type_asset` AS `pata` ON pata.id = paa.asset_type_id LEFT JOIN `customer_entity` AS `ce` ON ce.entity_id = paa.customer_id LEFT JOIN `prxgt_dwnl_customer` AS `dwnl` ON dwnl.customer_ref = paa.customer_id
[ "SELECT", "...", "FROM", "prxgt_acc_account", "AS", "paa", "LEFT", "JOIN", "prxgt_acc_type_asset", "AS", "pata", "ON", "pata", ".", "id", "=", "paa", ".", "asset_type_id", "LEFT", "JOIN", "customer_entity", "AS", "ce", "ON", "ce", ".", "entity_id", "=", "paa", ".", "customer_id", "LEFT", "JOIN", "prxgt_dwnl_customer", "AS", "dwnl", "ON", "dwnl", ".", "customer_ref", "=", "paa", ".", "customer_id" ]
train
https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Ui/DataProvider/Grid/Account/Query.php#L54-L74
koolkode/security
src/Authentication/HttpDigestAuthenticationProvider.php
HttpDigestAuthenticationProvider.createNonce
public function createNonce(SecurityContextInterface $context) { if($this->nonceTracker === NULL) { return bin2hex(random_bytes($this->nonceByteCount)); } $this->nonceTracker->initializeTracker(); return $this->nonceTracker->createNonce(); }
php
public function createNonce(SecurityContextInterface $context) { if($this->nonceTracker === NULL) { return bin2hex(random_bytes($this->nonceByteCount)); } $this->nonceTracker->initializeTracker(); return $this->nonceTracker->createNonce(); }
[ "public", "function", "createNonce", "(", "SecurityContextInterface", "$", "context", ")", "{", "if", "(", "$", "this", "->", "nonceTracker", "===", "NULL", ")", "{", "return", "bin2hex", "(", "random_bytes", "(", "$", "this", "->", "nonceByteCount", ")", ")", ";", "}", "$", "this", "->", "nonceTracker", "->", "initializeTracker", "(", ")", ";", "return", "$", "this", "->", "nonceTracker", "->", "createNonce", "(", ")", ";", "}" ]
Create a one-time nonce value (will generate a random nonce when no nonce tracker is being used). @param SecurityContextInterface $context @return string
[ "Create", "a", "one", "-", "time", "nonce", "value", "(", "will", "generate", "a", "random", "nonce", "when", "no", "nonce", "tracker", "is", "being", "used", ")", "." ]
train
https://github.com/koolkode/security/blob/d3d8d42392f520754847d29b6df19aaa38c79e8e/src/Authentication/HttpDigestAuthenticationProvider.php#L115-L125
koolkode/security
src/Authentication/HttpDigestAuthenticationProvider.php
HttpDigestAuthenticationProvider.authenticate
public function authenticate(SecurityContextInterface $context, TokenInterface $token, HttpRequest $request) { if(!$token instanceof HttpDigestToken) { throw new SecurityException(sprintf('Token %s not supported by provider %s', get_class($token), get_class($this))); } if($this->nonceTracker !== NULL) { $this->nonceTracker->initializeTracker(); switch($this->nonceTracker->checkNonce($token->getNonce(), $token->getNonceCount())) { case NonceTrackerInterface::NONCE_OK: // Nonce is OK... break; case NonceTrackerInterface::NONCE_STALE: $token->setStale(true); return; default: return; } } $provider = $this->getPrincipalProvider(); $identity = $token->getUsername(); $ha1 = $provider->findPrincipalHA1($identity, $this->getRealm()); if(!$token->isValidResponse($ha1)) { $provider->notifyPrincipalNotFound($identity); $token->setStatus(TokenInterface::WRONG_CREDENTIALS); return; } $principal = $provider->findPrincipal($identity); if($principal === NULL) { $token->setStatus(TokenInterface::WRONG_CREDENTIALS); return; } $token->setPrincipal($principal); $token->setStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL); $provider->notifyPrinipalFound($principal); }
php
public function authenticate(SecurityContextInterface $context, TokenInterface $token, HttpRequest $request) { if(!$token instanceof HttpDigestToken) { throw new SecurityException(sprintf('Token %s not supported by provider %s', get_class($token), get_class($this))); } if($this->nonceTracker !== NULL) { $this->nonceTracker->initializeTracker(); switch($this->nonceTracker->checkNonce($token->getNonce(), $token->getNonceCount())) { case NonceTrackerInterface::NONCE_OK: // Nonce is OK... break; case NonceTrackerInterface::NONCE_STALE: $token->setStale(true); return; default: return; } } $provider = $this->getPrincipalProvider(); $identity = $token->getUsername(); $ha1 = $provider->findPrincipalHA1($identity, $this->getRealm()); if(!$token->isValidResponse($ha1)) { $provider->notifyPrincipalNotFound($identity); $token->setStatus(TokenInterface::WRONG_CREDENTIALS); return; } $principal = $provider->findPrincipal($identity); if($principal === NULL) { $token->setStatus(TokenInterface::WRONG_CREDENTIALS); return; } $token->setPrincipal($principal); $token->setStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL); $provider->notifyPrinipalFound($principal); }
[ "public", "function", "authenticate", "(", "SecurityContextInterface", "$", "context", ",", "TokenInterface", "$", "token", ",", "HttpRequest", "$", "request", ")", "{", "if", "(", "!", "$", "token", "instanceof", "HttpDigestToken", ")", "{", "throw", "new", "SecurityException", "(", "sprintf", "(", "'Token %s not supported by provider %s'", ",", "get_class", "(", "$", "token", ")", ",", "get_class", "(", "$", "this", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "nonceTracker", "!==", "NULL", ")", "{", "$", "this", "->", "nonceTracker", "->", "initializeTracker", "(", ")", ";", "switch", "(", "$", "this", "->", "nonceTracker", "->", "checkNonce", "(", "$", "token", "->", "getNonce", "(", ")", ",", "$", "token", "->", "getNonceCount", "(", ")", ")", ")", "{", "case", "NonceTrackerInterface", "::", "NONCE_OK", ":", "// Nonce is OK...", "break", ";", "case", "NonceTrackerInterface", "::", "NONCE_STALE", ":", "$", "token", "->", "setStale", "(", "true", ")", ";", "return", ";", "default", ":", "return", ";", "}", "}", "$", "provider", "=", "$", "this", "->", "getPrincipalProvider", "(", ")", ";", "$", "identity", "=", "$", "token", "->", "getUsername", "(", ")", ";", "$", "ha1", "=", "$", "provider", "->", "findPrincipalHA1", "(", "$", "identity", ",", "$", "this", "->", "getRealm", "(", ")", ")", ";", "if", "(", "!", "$", "token", "->", "isValidResponse", "(", "$", "ha1", ")", ")", "{", "$", "provider", "->", "notifyPrincipalNotFound", "(", "$", "identity", ")", ";", "$", "token", "->", "setStatus", "(", "TokenInterface", "::", "WRONG_CREDENTIALS", ")", ";", "return", ";", "}", "$", "principal", "=", "$", "provider", "->", "findPrincipal", "(", "$", "identity", ")", ";", "if", "(", "$", "principal", "===", "NULL", ")", "{", "$", "token", "->", "setStatus", "(", "TokenInterface", "::", "WRONG_CREDENTIALS", ")", ";", "return", ";", "}", "$", "token", "->", "setPrincipal", "(", "$", "principal", ")", ";", "$", "token", "->", "setStatus", "(", "TokenInterface", "::", "AUTHENTICATION_SUCCESSFUL", ")", ";", "$", "provider", "->", "notifyPrinipalFound", "(", "$", "principal", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/koolkode/security/blob/d3d8d42392f520754847d29b6df19aaa38c79e8e/src/Authentication/HttpDigestAuthenticationProvider.php#L130-L180
reliv/rcm-config
src/Factory/ConfigService.php
ConfigService.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); return new \Reliv\RcmConfig\Service\ConfigService( $config, $serviceLocator ); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); return new \Reliv\RcmConfig\Service\ConfigService( $config, $serviceLocator ); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "return", "new", "\\", "Reliv", "\\", "RcmConfig", "\\", "Service", "\\", "ConfigService", "(", "$", "config", ",", "$", "serviceLocator", ")", ";", "}" ]
Creates Service @param ServiceLocatorInterface $serviceLocator Zend Service Locator @return \Reliv\RcmConfig\Service\ConfigService
[ "Creates", "Service" ]
train
https://github.com/reliv/rcm-config/blob/3e8cdea57a8688b06997ce1b167b8410bccac09e/src/Factory/ConfigService.php#L31-L39
t-kanstantsin/fileupload
src/model/ExternalFile.php
ExternalFile.buildFromPath
public static function buildFromPath(?string $path, array $config = []): ?self { // detect if file path actually is url if (preg_match('/^(https?:)?\/\//', $path)) { // TODO: create special file that will not be processed. return null; } if ($path === null) { return null; } $file = new static($config); if ($file->getModelAlias() === null) { throw new InvalidConfigException('Model alias must be defined'); } if ($file->getModelId() === null) { throw new InvalidConfigException('Model id must be defined'); } $file->setActualPath($file->getActualPath() ?? $path); $file->setId($file->generateId()); $file->setHash(crc32($file->getId())); $file->setCreatedAt($file->getCreatedAt() ?? 0); $file->setUpdatedAt($file->getUpdatedAt() ?? 0); if ($file->getMimeType() === null && $file->getExtension() !== null) { $mimeType = (new MimeTypes())->getMimeType($file->getExtension()); if ($mimeType !== null) { $file->setMimeType($mimeType); } } if ($file->getType() === null) { $file->setType(FileType::getByMimeType($file->getMimeType())); } $file->setName(pathinfo($path, PATHINFO_FILENAME)); $extension = pathinfo($path, PATHINFO_EXTENSION); if ($extension !== '') { $file->setExtension($extension); } return $file; }
php
public static function buildFromPath(?string $path, array $config = []): ?self { // detect if file path actually is url if (preg_match('/^(https?:)?\/\//', $path)) { // TODO: create special file that will not be processed. return null; } if ($path === null) { return null; } $file = new static($config); if ($file->getModelAlias() === null) { throw new InvalidConfigException('Model alias must be defined'); } if ($file->getModelId() === null) { throw new InvalidConfigException('Model id must be defined'); } $file->setActualPath($file->getActualPath() ?? $path); $file->setId($file->generateId()); $file->setHash(crc32($file->getId())); $file->setCreatedAt($file->getCreatedAt() ?? 0); $file->setUpdatedAt($file->getUpdatedAt() ?? 0); if ($file->getMimeType() === null && $file->getExtension() !== null) { $mimeType = (new MimeTypes())->getMimeType($file->getExtension()); if ($mimeType !== null) { $file->setMimeType($mimeType); } } if ($file->getType() === null) { $file->setType(FileType::getByMimeType($file->getMimeType())); } $file->setName(pathinfo($path, PATHINFO_FILENAME)); $extension = pathinfo($path, PATHINFO_EXTENSION); if ($extension !== '') { $file->setExtension($extension); } return $file; }
[ "public", "static", "function", "buildFromPath", "(", "?", "string", "$", "path", ",", "array", "$", "config", "=", "[", "]", ")", ":", "?", "self", "{", "// detect if file path actually is url", "if", "(", "preg_match", "(", "'/^(https?:)?\\/\\//'", ",", "$", "path", ")", ")", "{", "// TODO: create special file that will not be processed.", "return", "null", ";", "}", "if", "(", "$", "path", "===", "null", ")", "{", "return", "null", ";", "}", "$", "file", "=", "new", "static", "(", "$", "config", ")", ";", "if", "(", "$", "file", "->", "getModelAlias", "(", ")", "===", "null", ")", "{", "throw", "new", "InvalidConfigException", "(", "'Model alias must be defined'", ")", ";", "}", "if", "(", "$", "file", "->", "getModelId", "(", ")", "===", "null", ")", "{", "throw", "new", "InvalidConfigException", "(", "'Model id must be defined'", ")", ";", "}", "$", "file", "->", "setActualPath", "(", "$", "file", "->", "getActualPath", "(", ")", "??", "$", "path", ")", ";", "$", "file", "->", "setId", "(", "$", "file", "->", "generateId", "(", ")", ")", ";", "$", "file", "->", "setHash", "(", "crc32", "(", "$", "file", "->", "getId", "(", ")", ")", ")", ";", "$", "file", "->", "setCreatedAt", "(", "$", "file", "->", "getCreatedAt", "(", ")", "??", "0", ")", ";", "$", "file", "->", "setUpdatedAt", "(", "$", "file", "->", "getUpdatedAt", "(", ")", "??", "0", ")", ";", "if", "(", "$", "file", "->", "getMimeType", "(", ")", "===", "null", "&&", "$", "file", "->", "getExtension", "(", ")", "!==", "null", ")", "{", "$", "mimeType", "=", "(", "new", "MimeTypes", "(", ")", ")", "->", "getMimeType", "(", "$", "file", "->", "getExtension", "(", ")", ")", ";", "if", "(", "$", "mimeType", "!==", "null", ")", "{", "$", "file", "->", "setMimeType", "(", "$", "mimeType", ")", ";", "}", "}", "if", "(", "$", "file", "->", "getType", "(", ")", "===", "null", ")", "{", "$", "file", "->", "setType", "(", "FileType", "::", "getByMimeType", "(", "$", "file", "->", "getMimeType", "(", ")", ")", ")", ";", "}", "$", "file", "->", "setName", "(", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ")", ";", "$", "extension", "=", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ";", "if", "(", "$", "extension", "!==", "''", ")", "{", "$", "file", "->", "setExtension", "(", "$", "extension", ")", ";", "}", "return", "$", "file", ";", "}" ]
Build IFile object based only on file path, model alias and id @param null|string $path @param array $config Config MUST contain following fields: - modelAlias - modelId @return ExternalFile|null @throws \tkanstantsin\fileupload\config\InvalidConfigException
[ "Build", "IFile", "object", "based", "only", "on", "file", "path", "model", "alias", "and", "id", "@param", "null|string", "$path", "@param", "array", "$config", "Config", "MUST", "contain", "following", "fields", ":", "-", "modelAlias", "-", "modelId" ]
train
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/model/ExternalFile.php#L86-L129
t-kanstantsin/fileupload
src/model/ExternalFile.php
ExternalFile.generateId
protected function generateId(): int { if ($this->getId() !== null) { return $this->getId(); } $maxIdLength = \mb_strlen((string) PHP_INT_MAX) - 1; // try generate unique id for file $id = mb_substr(crc32($this->getModelId()), $maxIdLength - self::ID_PATH_HASH_LENGTH) . mb_substr(crc32($this->getActualPath()), self::ID_PATH_HASH_LENGTH); return (int) $id; }
php
protected function generateId(): int { if ($this->getId() !== null) { return $this->getId(); } $maxIdLength = \mb_strlen((string) PHP_INT_MAX) - 1; // try generate unique id for file $id = mb_substr(crc32($this->getModelId()), $maxIdLength - self::ID_PATH_HASH_LENGTH) . mb_substr(crc32($this->getActualPath()), self::ID_PATH_HASH_LENGTH); return (int) $id; }
[ "protected", "function", "generateId", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "getId", "(", ")", "!==", "null", ")", "{", "return", "$", "this", "->", "getId", "(", ")", ";", "}", "$", "maxIdLength", "=", "\\", "mb_strlen", "(", "(", "string", ")", "PHP_INT_MAX", ")", "-", "1", ";", "// try generate unique id for file", "$", "id", "=", "mb_substr", "(", "crc32", "(", "$", "this", "->", "getModelId", "(", ")", ")", ",", "$", "maxIdLength", "-", "self", "::", "ID_PATH_HASH_LENGTH", ")", ".", "mb_substr", "(", "crc32", "(", "$", "this", "->", "getActualPath", "(", ")", ")", ",", "self", "::", "ID_PATH_HASH_LENGTH", ")", ";", "return", "(", "int", ")", "$", "id", ";", "}" ]
Returns existed id or generate unique id based on model id and file path. @return int
[ "Returns", "existed", "id", "or", "generate", "unique", "id", "based", "on", "model", "id", "and", "file", "path", "." ]
train
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/model/ExternalFile.php#L347-L360
DeimosProject/Helper
src/Helper/Helpers/Arr/Arr.php
Arr.getRequired
public function getRequired(array $storage, $key = null) { return $this->findPath($storage, $this->keys($key)); }
php
public function getRequired(array $storage, $key = null) { return $this->findPath($storage, $this->keys($key)); }
[ "public", "function", "getRequired", "(", "array", "$", "storage", ",", "$", "key", "=", "null", ")", "{", "return", "$", "this", "->", "findPath", "(", "$", "storage", ",", "$", "this", "->", "keys", "(", "$", "key", ")", ")", ";", "}" ]
@param array $storage @param null $key @return array|mixed @throws ExceptionEmpty
[ "@param", "array", "$storage", "@param", "null", "$key" ]
train
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/Arr.php#L147-L150
DeimosProject/Helper
src/Helper/Helpers/Arr/Arr.php
Arr.findPath
protected function findPath(array $storage, array $keys) { if (empty($keys)) { throw new ExceptionEmpty('Not found keys'); } $rows = &$storage; foreach ($keys as $key) { if (!$this->keyExists($rows, $key)) { throw new ExceptionEmpty("Key '{$key}' not found"); } $rows = &$rows[$key]; } return $rows; }
php
protected function findPath(array $storage, array $keys) { if (empty($keys)) { throw new ExceptionEmpty('Not found keys'); } $rows = &$storage; foreach ($keys as $key) { if (!$this->keyExists($rows, $key)) { throw new ExceptionEmpty("Key '{$key}' not found"); } $rows = &$rows[$key]; } return $rows; }
[ "protected", "function", "findPath", "(", "array", "$", "storage", ",", "array", "$", "keys", ")", "{", "if", "(", "empty", "(", "$", "keys", ")", ")", "{", "throw", "new", "ExceptionEmpty", "(", "'Not found keys'", ")", ";", "}", "$", "rows", "=", "&", "$", "storage", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "keyExists", "(", "$", "rows", ",", "$", "key", ")", ")", "{", "throw", "new", "ExceptionEmpty", "(", "\"Key '{$key}' not found\"", ")", ";", "}", "$", "rows", "=", "&", "$", "rows", "[", "$", "key", "]", ";", "}", "return", "$", "rows", ";", "}" ]
@param array $storage @param array $keys @return array|mixed @throws ExceptionEmpty
[ "@param", "array", "$storage", "@param", "array", "$keys" ]
train
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/Arr.php#L159-L179
V8CH/eloquent-model-traits
src/EloquentModelTraits/CreatesUuids.php
CreatesUuids.boot
protected static function boot() { parent::boot(); static::creating(function (Model $model) { $model->{$model->getKeyName()} = Uuid::uuid1()->toString(); }); }
php
protected static function boot() { parent::boot(); static::creating(function (Model $model) { $model->{$model->getKeyName()} = Uuid::uuid1()->toString(); }); }
[ "protected", "static", "function", "boot", "(", ")", "{", "parent", "::", "boot", "(", ")", ";", "static", "::", "creating", "(", "function", "(", "Model", "$", "model", ")", "{", "$", "model", "->", "{", "$", "model", "->", "getKeyName", "(", ")", "}", "=", "Uuid", "::", "uuid1", "(", ")", "->", "toString", "(", ")", ";", "}", ")", ";", "}" ]
Boot function from laravel.
[ "Boot", "function", "from", "laravel", "." ]
train
https://github.com/V8CH/eloquent-model-traits/blob/b8f8aebe748b497c9b058dabe2b0d8011ccf122a/src/EloquentModelTraits/CreatesUuids.php#L18-L25
ekyna/MediaBundle
Model/Import/MediaImport.php
MediaImport.addMedia
public function addMedia(MediaInterface $media) { if (!in_array($media->getKey(), $this->keys)) { throw new \RuntimeException("Key {$media->getKey()} is not selected."); } foreach ($this->medias as $m) { if ($m->getKey() == $media->getKey()) { return $this; } } $media->setFolder($this->folder); $this->medias[] = $media; return $this; }
php
public function addMedia(MediaInterface $media) { if (!in_array($media->getKey(), $this->keys)) { throw new \RuntimeException("Key {$media->getKey()} is not selected."); } foreach ($this->medias as $m) { if ($m->getKey() == $media->getKey()) { return $this; } } $media->setFolder($this->folder); $this->medias[] = $media; return $this; }
[ "public", "function", "addMedia", "(", "MediaInterface", "$", "media", ")", "{", "if", "(", "!", "in_array", "(", "$", "media", "->", "getKey", "(", ")", ",", "$", "this", "->", "keys", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Key {$media->getKey()} is not selected.\"", ")", ";", "}", "foreach", "(", "$", "this", "->", "medias", "as", "$", "m", ")", "{", "if", "(", "$", "m", "->", "getKey", "(", ")", "==", "$", "media", "->", "getKey", "(", ")", ")", "{", "return", "$", "this", ";", "}", "}", "$", "media", "->", "setFolder", "(", "$", "this", "->", "folder", ")", ";", "$", "this", "->", "medias", "[", "]", "=", "$", "media", ";", "return", "$", "this", ";", "}" ]
Adds the media. @param MediaInterface $media @return MediaImport
[ "Adds", "the", "media", "." ]
train
https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Model/Import/MediaImport.php#L106-L122
prolic/HumusMvc
src/HumusMvc/Db/Service/MultiDbManagerFactory.php
MultiDbManagerFactory.setDefaultMetadataCache
protected function setDefaultMetadataCache($cache, ServiceLocatorInterface $serviceLocator) { $metadataCache = null; if (is_string($cache)) { if ($serviceLocator->has($cache)) { $metadataCache = $serviceLocator->get($cache); } } else if ($cache instanceof Zend_Cache_Core) { $metadataCache = $cache; } if ($metadataCache instanceof Zend_Cache_Core) { Zend_Db_Table::setDefaultMetadataCache($metadataCache); } }
php
protected function setDefaultMetadataCache($cache, ServiceLocatorInterface $serviceLocator) { $metadataCache = null; if (is_string($cache)) { if ($serviceLocator->has($cache)) { $metadataCache = $serviceLocator->get($cache); } } else if ($cache instanceof Zend_Cache_Core) { $metadataCache = $cache; } if ($metadataCache instanceof Zend_Cache_Core) { Zend_Db_Table::setDefaultMetadataCache($metadataCache); } }
[ "protected", "function", "setDefaultMetadataCache", "(", "$", "cache", ",", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "metadataCache", "=", "null", ";", "if", "(", "is_string", "(", "$", "cache", ")", ")", "{", "if", "(", "$", "serviceLocator", "->", "has", "(", "$", "cache", ")", ")", "{", "$", "metadataCache", "=", "$", "serviceLocator", "->", "get", "(", "$", "cache", ")", ";", "}", "}", "else", "if", "(", "$", "cache", "instanceof", "Zend_Cache_Core", ")", "{", "$", "metadataCache", "=", "$", "cache", ";", "}", "if", "(", "$", "metadataCache", "instanceof", "Zend_Cache_Core", ")", "{", "Zend_Db_Table", "::", "setDefaultMetadataCache", "(", "$", "metadataCache", ")", ";", "}", "}" ]
Set the default metadata cache @param string|Zend_Cache_Core $cache @return void
[ "Set", "the", "default", "metadata", "cache" ]
train
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Db/Service/MultiDbManagerFactory.php#L81-L97
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.initializeObject
final public function initializeObject(array $options = []) { $this->objectManager = Core::get()->getObjectManager(); $this->checkUnknownOptions($options); $this->checkRequiredOptions($options); $this->options = $this->fillOptionsWithValues($options); }
php
final public function initializeObject(array $options = []) { $this->objectManager = Core::get()->getObjectManager(); $this->checkUnknownOptions($options); $this->checkRequiredOptions($options); $this->options = $this->fillOptionsWithValues($options); }
[ "final", "public", "function", "initializeObject", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "objectManager", "=", "Core", "::", "get", "(", ")", "->", "getObjectManager", "(", ")", ";", "$", "this", "->", "checkUnknownOptions", "(", "$", "options", ")", ";", "$", "this", "->", "checkRequiredOptions", "(", "$", "options", ")", ";", "$", "this", "->", "options", "=", "$", "this", "->", "fillOptionsWithValues", "(", "$", "options", ")", ";", "}" ]
Initializes the service: options are checked and added to the class properties. @inheritdoc
[ "Initializes", "the", "service", ":", "options", "are", "checked", "and", "added", "to", "the", "class", "properties", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L71-L77
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.checkUnknownOptions
protected function checkUnknownOptions(array $options) { $unsupportedOptions = array_diff_key($options, $this->supportedOptions); if ([] !== ($unsupportedOptions)) { throw new InvalidServiceOptionsException( 'Unsupported validation option(s) found: ' . implode(', ', array_keys($unsupportedOptions)), 1456397655 ); } }
php
protected function checkUnknownOptions(array $options) { $unsupportedOptions = array_diff_key($options, $this->supportedOptions); if ([] !== ($unsupportedOptions)) { throw new InvalidServiceOptionsException( 'Unsupported validation option(s) found: ' . implode(', ', array_keys($unsupportedOptions)), 1456397655 ); } }
[ "protected", "function", "checkUnknownOptions", "(", "array", "$", "options", ")", "{", "$", "unsupportedOptions", "=", "array_diff_key", "(", "$", "options", ",", "$", "this", "->", "supportedOptions", ")", ";", "if", "(", "[", "]", "!==", "(", "$", "unsupportedOptions", ")", ")", "{", "throw", "new", "InvalidServiceOptionsException", "(", "'Unsupported validation option(s) found: '", ".", "implode", "(", "', '", ",", "array_keys", "(", "$", "unsupportedOptions", ")", ")", ",", "1456397655", ")", ";", "}", "}" ]
Checks if an unknown option exists in the given options array. @param array $options @throws InvalidServiceOptionsException
[ "Checks", "if", "an", "unknown", "option", "exists", "in", "the", "given", "options", "array", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L85-L95
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.checkRequiredOptions
protected function checkRequiredOptions(array $options) { array_walk( $this->supportedOptions, function ($supportedOptionData, $supportedOptionName, $options) { if (isset($supportedOptionData[1]) && true === $supportedOptionData[1] && empty($supportedOptionData[0]) && !array_key_exists($supportedOptionName, $options) ) { throw new InvalidServiceOptionsException( 'Required validation option not set: ' . $supportedOptionName, 1456397839 ); } }, $options ); }
php
protected function checkRequiredOptions(array $options) { array_walk( $this->supportedOptions, function ($supportedOptionData, $supportedOptionName, $options) { if (isset($supportedOptionData[1]) && true === $supportedOptionData[1] && empty($supportedOptionData[0]) && !array_key_exists($supportedOptionName, $options) ) { throw new InvalidServiceOptionsException( 'Required validation option not set: ' . $supportedOptionName, 1456397839 ); } }, $options ); }
[ "protected", "function", "checkRequiredOptions", "(", "array", "$", "options", ")", "{", "array_walk", "(", "$", "this", "->", "supportedOptions", ",", "function", "(", "$", "supportedOptionData", ",", "$", "supportedOptionName", ",", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "supportedOptionData", "[", "1", "]", ")", "&&", "true", "===", "$", "supportedOptionData", "[", "1", "]", "&&", "empty", "(", "$", "supportedOptionData", "[", "0", "]", ")", "&&", "!", "array_key_exists", "(", "$", "supportedOptionName", ",", "$", "options", ")", ")", "{", "throw", "new", "InvalidServiceOptionsException", "(", "'Required validation option not set: '", ".", "$", "supportedOptionName", ",", "1456397839", ")", ";", "}", "}", ",", "$", "options", ")", ";", "}" ]
Will check if the required options are correctly filled. @param array $options @throws InvalidServiceOptionsException
[ "Will", "check", "if", "the", "required", "options", "are", "correctly", "filled", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L103-L121
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.fillOptionsWithValues
protected function fillOptionsWithValues(array $options) { return array_merge( array_map( function ($value) { if (false === is_array($value)) { throw new InvalidTypeException( 'Supported options of a service must be an array with a value as first entry, and a flag to tell if the option is required in the second entry.', 1459249834 ); } return $value[0]; }, $this->supportedOptions ), $options ); }
php
protected function fillOptionsWithValues(array $options) { return array_merge( array_map( function ($value) { if (false === is_array($value)) { throw new InvalidTypeException( 'Supported options of a service must be an array with a value as first entry, and a flag to tell if the option is required in the second entry.', 1459249834 ); } return $value[0]; }, $this->supportedOptions ), $options ); }
[ "protected", "function", "fillOptionsWithValues", "(", "array", "$", "options", ")", "{", "return", "array_merge", "(", "array_map", "(", "function", "(", "$", "value", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'Supported options of a service must be an array with a value as first entry, and a flag to tell if the option is required in the second entry.'", ",", "1459249834", ")", ";", "}", "return", "$", "value", "[", "0", "]", ";", "}", ",", "$", "this", "->", "supportedOptions", ")", ",", "$", "options", ")", ";", "}" ]
Will fill the options of this service with the given values. @param array $options @return array @throws InvalidTypeException
[ "Will", "fill", "the", "options", "of", "this", "service", "with", "the", "given", "values", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L130-L148
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.delay
protected function delay($priority, callable $callback) { if (false === MathUtility::canBeInterpretedAsInteger($priority)) { throw new InvalidTypeException( 'The priority must be an integer, ' . gettype($priority) . ' was given.', 1457014282 ); } if (false === isset(static::$delayedCallbacks[$priority])) { static::$delayedCallbacks[$priority] = []; } static::$delayedCallbacks[$priority][] = $callback; }
php
protected function delay($priority, callable $callback) { if (false === MathUtility::canBeInterpretedAsInteger($priority)) { throw new InvalidTypeException( 'The priority must be an integer, ' . gettype($priority) . ' was given.', 1457014282 ); } if (false === isset(static::$delayedCallbacks[$priority])) { static::$delayedCallbacks[$priority] = []; } static::$delayedCallbacks[$priority][] = $callback; }
[ "protected", "function", "delay", "(", "$", "priority", ",", "callable", "$", "callback", ")", "{", "if", "(", "false", "===", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "$", "priority", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "'The priority must be an integer, '", ".", "gettype", "(", "$", "priority", ")", ".", "' was given.'", ",", "1457014282", ")", ";", "}", "if", "(", "false", "===", "isset", "(", "static", "::", "$", "delayedCallbacks", "[", "$", "priority", "]", ")", ")", "{", "static", "::", "$", "delayedCallbacks", "[", "$", "priority", "]", "=", "[", "]", ";", "}", "static", "::", "$", "delayedCallbacks", "[", "$", "priority", "]", "[", "]", "=", "$", "callback", ";", "}" ]
Use this function to delay a certain part of the script during an event dispatch. This allows to run parts of the script in a sorted way, based on a priority value. The higher the priority is, the faster the script will run. Please note that the usage of this function is not needed in every event. @param int $priority Priority: the higher it is, the faster the script will run. @param callable $callback Function which will be called later. @throws InvalidTypeException
[ "Use", "this", "function", "to", "delay", "a", "certain", "part", "of", "the", "script", "during", "an", "event", "dispatch", ".", "This", "allows", "to", "run", "parts", "of", "the", "script", "in", "a", "sorted", "way", "based", "on", "a", "priority", "value", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L171-L184
romm/configuration_object
Classes/Service/AbstractService.php
AbstractService.runDelayedCallbacks
public function runDelayedCallbacks(AbstractServiceDTO $dto) { krsort(static::$delayedCallbacks); foreach (static::$delayedCallbacks as $callbacks) { foreach ($callbacks as $callback) { $callback($dto); } } static::$delayedCallbacks = []; }
php
public function runDelayedCallbacks(AbstractServiceDTO $dto) { krsort(static::$delayedCallbacks); foreach (static::$delayedCallbacks as $callbacks) { foreach ($callbacks as $callback) { $callback($dto); } } static::$delayedCallbacks = []; }
[ "public", "function", "runDelayedCallbacks", "(", "AbstractServiceDTO", "$", "dto", ")", "{", "krsort", "(", "static", "::", "$", "delayedCallbacks", ")", ";", "foreach", "(", "static", "::", "$", "delayedCallbacks", "as", "$", "callbacks", ")", "{", "foreach", "(", "$", "callbacks", "as", "$", "callback", ")", "{", "$", "callback", "(", "$", "dto", ")", ";", "}", "}", "static", "::", "$", "delayedCallbacks", "=", "[", "]", ";", "}" ]
Will run every delayed callback which was registered during an event. @see \Romm\ConfigurationObject\Service\AbstractService::delay() @param AbstractServiceDTO $dto The data transfer object sent to the services. @internal This function is reserved for internal usage only, you should not use it in third party applications!
[ "Will", "run", "every", "delayed", "callback", "which", "was", "registered", "during", "an", "event", "." ]
train
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Service/AbstractService.php#L194-L205
ARCANESOFT/Blog
src/Http/Requests/Admin/Posts/CreatePostRequest.php
CreatePostRequest.sanitize
protected function sanitize() { return [ 'slug' => Str::slug($this->get($this->has('slug') ? 'slug' : 'title', '')), 'seo_title' => $this->get(empty($this->get('seo_title')) ? 'title' : 'seo_title'), ]; }
php
protected function sanitize() { return [ 'slug' => Str::slug($this->get($this->has('slug') ? 'slug' : 'title', '')), 'seo_title' => $this->get(empty($this->get('seo_title')) ? 'title' : 'seo_title'), ]; }
[ "protected", "function", "sanitize", "(", ")", "{", "return", "[", "'slug'", "=>", "Str", "::", "slug", "(", "$", "this", "->", "get", "(", "$", "this", "->", "has", "(", "'slug'", ")", "?", "'slug'", ":", "'title'", ",", "''", ")", ")", ",", "'seo_title'", "=>", "$", "this", "->", "get", "(", "empty", "(", "$", "this", "->", "get", "(", "'seo_title'", ")", ")", "?", "'title'", ":", "'seo_title'", ")", ",", "]", ";", "}" ]
Sanitize the inputs. @return array
[ "Sanitize", "the", "inputs", "." ]
train
https://github.com/ARCANESOFT/Blog/blob/2078fdfdcbccda161c02899b9e1f344f011b2859/src/Http/Requests/Admin/Posts/CreatePostRequest.php#L45-L51
Kris-Kuiper/sFire-Framework
src/Validator/Form/Rules/In.php
In.check
private function check($value, $params) { if(true === is_string($value)) { return true === in_array($value, $params[0]); } return false; }
php
private function check($value, $params) { if(true === is_string($value)) { return true === in_array($value, $params[0]); } return false; }
[ "private", "function", "check", "(", "$", "value", ",", "$", "params", ")", "{", "if", "(", "true", "===", "is_string", "(", "$", "value", ")", ")", "{", "return", "true", "===", "in_array", "(", "$", "value", ",", "$", "params", "[", "0", "]", ")", ";", "}", "return", "false", ";", "}" ]
Check if rule passes @param mixed $value @param array $params @return boolean
[ "Check", "if", "rule", "passes" ]
train
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Rules/In.php#L69-L76