repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
valu-digital/valuso
src/ValuSo/Controller/ServiceController.php
ServiceController.fetchOperation
protected function fetchOperation() { $operation = $this->getRouteParam('operation'); if ($operation !== null) { $operation = $this->parseCanonicalName($operation); if (preg_match($this->operationPattern, $operation)) { return $operation; } else { return false; } } else { $operation = $this->getRequest()->getHeader(self::HEADER_OPERATION); if (!$operation) { $operation = 'http-'.$this->getRequest()->getMethod(); } else { $operation = $operation->getFieldValue(); } return $this->parseCanonicalName($operation); } }
php
protected function fetchOperation() { $operation = $this->getRouteParam('operation'); if ($operation !== null) { $operation = $this->parseCanonicalName($operation); if (preg_match($this->operationPattern, $operation)) { return $operation; } else { return false; } } else { $operation = $this->getRequest()->getHeader(self::HEADER_OPERATION); if (!$operation) { $operation = 'http-'.$this->getRequest()->getMethod(); } else { $operation = $operation->getFieldValue(); } return $this->parseCanonicalName($operation); } }
[ "protected", "function", "fetchOperation", "(", ")", "{", "$", "operation", "=", "$", "this", "->", "getRouteParam", "(", "'operation'", ")", ";", "if", "(", "$", "operation", "!==", "null", ")", "{", "$", "operation", "=", "$", "this", "->", "parseCanonicalName", "(", "$", "operation", ")", ";", "if", "(", "preg_match", "(", "$", "this", "->", "operationPattern", ",", "$", "operation", ")", ")", "{", "return", "$", "operation", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "$", "operation", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getHeader", "(", "self", "::", "HEADER_OPERATION", ")", ";", "if", "(", "!", "$", "operation", ")", "{", "$", "operation", "=", "'http-'", ".", "$", "this", "->", "getRequest", "(", ")", "->", "getMethod", "(", ")", ";", "}", "else", "{", "$", "operation", "=", "$", "operation", "->", "getFieldValue", "(", ")", ";", "}", "return", "$", "this", "->", "parseCanonicalName", "(", "$", "operation", ")", ";", "}", "}" ]
Parse operation name from request @return string|boolean
[ "Parse", "operation", "name", "from", "request" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Controller/ServiceController.php#L498-L521
train
valu-digital/valuso
src/ValuSo/Controller/ServiceController.php
ServiceController.fetchParams
protected function fetchParams() { $contentType = $this->getRequest()->getHeaders()->get('Content-Type'); if ($contentType) { $contentTypeParts = explode(';', $contentType->getFieldValue()); $contentType = strtolower(trim($contentTypeParts[0])); } if ($contentType === 'application/json') { $json = $this->getRequest()->getContent(); $params = JsonDecoder::decode($json, JSON::TYPE_ARRAY); } else { // Parse parameters if ($this->getRequest()->isPost()) { $params = $this->getRequest() ->getPost() ->toArray(); $params = array_merge( $params, $this->getRequest() ->getFiles() ->toArray() ); } else { $params = $this->getRequest() ->getQuery() ->toArray(); } } // Use special 'q' parameters instead, if specified if (isset($params['q'])) { $params = Json::decode($params['q'], Json::TYPE_ARRAY); // Files are an exception, as they cannot be passed as part of // the special q parameter foreach ($this->getRequest()->getFiles() as $name => $value) { if (!isset($params[$name])) { $params[$name] = $value; } } } else { // Use route param 'path' and parse its parameters $paramsInRoute = $this->getRouteParam('path'); if ($paramsInRoute && $paramsInRoute !== '/') { $paramsInRoute = explode('/', $paramsInRoute); array_shift($paramsInRoute); $params = array_merge( $params, $paramsInRoute); } } return $params; }
php
protected function fetchParams() { $contentType = $this->getRequest()->getHeaders()->get('Content-Type'); if ($contentType) { $contentTypeParts = explode(';', $contentType->getFieldValue()); $contentType = strtolower(trim($contentTypeParts[0])); } if ($contentType === 'application/json') { $json = $this->getRequest()->getContent(); $params = JsonDecoder::decode($json, JSON::TYPE_ARRAY); } else { // Parse parameters if ($this->getRequest()->isPost()) { $params = $this->getRequest() ->getPost() ->toArray(); $params = array_merge( $params, $this->getRequest() ->getFiles() ->toArray() ); } else { $params = $this->getRequest() ->getQuery() ->toArray(); } } // Use special 'q' parameters instead, if specified if (isset($params['q'])) { $params = Json::decode($params['q'], Json::TYPE_ARRAY); // Files are an exception, as they cannot be passed as part of // the special q parameter foreach ($this->getRequest()->getFiles() as $name => $value) { if (!isset($params[$name])) { $params[$name] = $value; } } } else { // Use route param 'path' and parse its parameters $paramsInRoute = $this->getRouteParam('path'); if ($paramsInRoute && $paramsInRoute !== '/') { $paramsInRoute = explode('/', $paramsInRoute); array_shift($paramsInRoute); $params = array_merge( $params, $paramsInRoute); } } return $params; }
[ "protected", "function", "fetchParams", "(", ")", "{", "$", "contentType", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getHeaders", "(", ")", "->", "get", "(", "'Content-Type'", ")", ";", "if", "(", "$", "contentType", ")", "{", "$", "contentTypeParts", "=", "explode", "(", "';'", ",", "$", "contentType", "->", "getFieldValue", "(", ")", ")", ";", "$", "contentType", "=", "strtolower", "(", "trim", "(", "$", "contentTypeParts", "[", "0", "]", ")", ")", ";", "}", "if", "(", "$", "contentType", "===", "'application/json'", ")", "{", "$", "json", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getContent", "(", ")", ";", "$", "params", "=", "JsonDecoder", "::", "decode", "(", "$", "json", ",", "JSON", "::", "TYPE_ARRAY", ")", ";", "}", "else", "{", "// Parse parameters", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "params", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", ")", "->", "toArray", "(", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "getRequest", "(", ")", "->", "getFiles", "(", ")", "->", "toArray", "(", ")", ")", ";", "}", "else", "{", "$", "params", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getQuery", "(", ")", "->", "toArray", "(", ")", ";", "}", "}", "// Use special 'q' parameters instead, if specified", "if", "(", "isset", "(", "$", "params", "[", "'q'", "]", ")", ")", "{", "$", "params", "=", "Json", "::", "decode", "(", "$", "params", "[", "'q'", "]", ",", "Json", "::", "TYPE_ARRAY", ")", ";", "// Files are an exception, as they cannot be passed as part of", "// the special q parameter", "foreach", "(", "$", "this", "->", "getRequest", "(", ")", "->", "getFiles", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "$", "name", "]", ")", ")", "{", "$", "params", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}", "else", "{", "// Use route param 'path' and parse its parameters", "$", "paramsInRoute", "=", "$", "this", "->", "getRouteParam", "(", "'path'", ")", ";", "if", "(", "$", "paramsInRoute", "&&", "$", "paramsInRoute", "!==", "'/'", ")", "{", "$", "paramsInRoute", "=", "explode", "(", "'/'", ",", "$", "paramsInRoute", ")", ";", "array_shift", "(", "$", "paramsInRoute", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "paramsInRoute", ")", ";", "}", "}", "return", "$", "params", ";", "}" ]
Parse parameters from request @return array
[ "Parse", "parameters", "from", "request" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Controller/ServiceController.php#L528-L585
train
krakphp/cargo
src/Container/AutoWireContainer.php
AutoWireContainer.get
public function get($id, Cargo\Container $container = null) { if ($this->container->has($id) || !class_exists($id)) { return $this->container->get($id, $container ?: $this); } $this->add($id, null); return $this->get($id, $container); }
php
public function get($id, Cargo\Container $container = null) { if ($this->container->has($id) || !class_exists($id)) { return $this->container->get($id, $container ?: $this); } $this->add($id, null); return $this->get($id, $container); }
[ "public", "function", "get", "(", "$", "id", ",", "Cargo", "\\", "Container", "$", "container", "=", "null", ")", "{", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "id", ")", "||", "!", "class_exists", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "id", ",", "$", "container", "?", ":", "$", "this", ")", ";", "}", "$", "this", "->", "add", "(", "$", "id", ",", "null", ")", ";", "return", "$", "this", "->", "get", "(", "$", "id", ",", "$", "container", ")", ";", "}" ]
fetch from container, or if the service is a class name, we'll try to resolve it automatically
[ "fetch", "from", "container", "or", "if", "the", "service", "is", "a", "class", "name", "we", "ll", "try", "to", "resolve", "it", "automatically" ]
ed5ee24dfe4112b33f0fdcf7131d82a2bf96d191
https://github.com/krakphp/cargo/blob/ed5ee24dfe4112b33f0fdcf7131d82a2bf96d191/src/Container/AutoWireContainer.php#L19-L26
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.setOptions
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new \InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value){ $key = strtolower($key); switch ($key) { case 'services': $this->registerServices($value); break; case 'locator': case 'service_locator': $this->setServiceLocator($value); break; case 'service_manager': $this->configureServiceManager($value); break; } } return $this; }
php
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new \InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value){ $key = strtolower($key); switch ($key) { case 'services': $this->registerServices($value); break; case 'locator': case 'service_locator': $this->setServiceLocator($value); break; case 'service_manager': $this->configureServiceManager($value); break; } } return $this; }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", "&&", "!", "$", "options", "instanceof", "Traversable", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected an array or Traversable; received \"%s\"'", ",", "(", "is_object", "(", "$", "options", ")", "?", "get_class", "(", "$", "options", ")", ":", "gettype", "(", "$", "options", ")", ")", ")", ")", ";", "}", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "switch", "(", "$", "key", ")", "{", "case", "'services'", ":", "$", "this", "->", "registerServices", "(", "$", "value", ")", ";", "break", ";", "case", "'locator'", ":", "case", "'service_locator'", ":", "$", "this", "->", "setServiceLocator", "(", "$", "value", ")", ";", "break", ";", "case", "'service_manager'", ":", "$", "this", "->", "configureServiceManager", "(", "$", "value", ")", ";", "break", ";", "}", "}", "return", "$", "this", ";", "}" ]
Configure service loader @param array|\Traversable $options @throws \InvalidArgumentException @return \ValuSo\Broker\ServiceLoader
[ "Configure", "service", "loader" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L66-L94
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.getCommandManager
public function getCommandManager() { if ($this->commandManager === null) { $this->commandManager = new CommandManager(); $this->commandManager->setServiceLoader($this); } return $this->commandManager; }
php
public function getCommandManager() { if ($this->commandManager === null) { $this->commandManager = new CommandManager(); $this->commandManager->setServiceLoader($this); } return $this->commandManager; }
[ "public", "function", "getCommandManager", "(", ")", "{", "if", "(", "$", "this", "->", "commandManager", "===", "null", ")", "{", "$", "this", "->", "commandManager", "=", "new", "CommandManager", "(", ")", ";", "$", "this", "->", "commandManager", "->", "setServiceLoader", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "commandManager", ";", "}" ]
Retrieve command manager @return \ValuSo\Command\CommandManager
[ "Retrieve", "command", "manager" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L158-L166
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.registerServices
public function registerServices($services) { if (!is_array($services) && !($services instanceof Traversable)) { throw new Exception\InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($services) ? get_class($services) : gettype($services)) )); } foreach($services as $key => $impl){ if (is_string($impl)) { $impl = ['name' => $impl]; } $id = isset($impl['id']) ? $impl['id'] : $key; $name = isset($impl['name']) ? $impl['name'] : null; $service = isset($impl['service']) ? $impl['service'] : null; $factory = isset($impl['factory']) ? $impl['factory'] : null; $options = isset($impl['options']) ? $impl['options'] : null; $priority = isset($impl['priority']) ? $impl['priority'] : 1; if (!$service && isset($impl['class'])) { $service = $impl['class']; } if(is_null($options) && isset($impl['config'])){ $options = $impl['config']; } if(!$name){ throw new Exception\InvalidArgumentException('Service name is not defined for service: '.$id); } $this->registerService($id, $name, $service, $options, $priority); if (array_key_exists('enabled', $impl) && !$impl['enabled']) { $this->disableService($id); } if($factory){ $this->getServicePluginManager()->setFactory( $id, $factory); } } return $this; }
php
public function registerServices($services) { if (!is_array($services) && !($services instanceof Traversable)) { throw new Exception\InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($services) ? get_class($services) : gettype($services)) )); } foreach($services as $key => $impl){ if (is_string($impl)) { $impl = ['name' => $impl]; } $id = isset($impl['id']) ? $impl['id'] : $key; $name = isset($impl['name']) ? $impl['name'] : null; $service = isset($impl['service']) ? $impl['service'] : null; $factory = isset($impl['factory']) ? $impl['factory'] : null; $options = isset($impl['options']) ? $impl['options'] : null; $priority = isset($impl['priority']) ? $impl['priority'] : 1; if (!$service && isset($impl['class'])) { $service = $impl['class']; } if(is_null($options) && isset($impl['config'])){ $options = $impl['config']; } if(!$name){ throw new Exception\InvalidArgumentException('Service name is not defined for service: '.$id); } $this->registerService($id, $name, $service, $options, $priority); if (array_key_exists('enabled', $impl) && !$impl['enabled']) { $this->disableService($id); } if($factory){ $this->getServicePluginManager()->setFactory( $id, $factory); } } return $this; }
[ "public", "function", "registerServices", "(", "$", "services", ")", "{", "if", "(", "!", "is_array", "(", "$", "services", ")", "&&", "!", "(", "$", "services", "instanceof", "Traversable", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected an array or Traversable; received \"%s\"'", ",", "(", "is_object", "(", "$", "services", ")", "?", "get_class", "(", "$", "services", ")", ":", "gettype", "(", "$", "services", ")", ")", ")", ")", ";", "}", "foreach", "(", "$", "services", "as", "$", "key", "=>", "$", "impl", ")", "{", "if", "(", "is_string", "(", "$", "impl", ")", ")", "{", "$", "impl", "=", "[", "'name'", "=>", "$", "impl", "]", ";", "}", "$", "id", "=", "isset", "(", "$", "impl", "[", "'id'", "]", ")", "?", "$", "impl", "[", "'id'", "]", ":", "$", "key", ";", "$", "name", "=", "isset", "(", "$", "impl", "[", "'name'", "]", ")", "?", "$", "impl", "[", "'name'", "]", ":", "null", ";", "$", "service", "=", "isset", "(", "$", "impl", "[", "'service'", "]", ")", "?", "$", "impl", "[", "'service'", "]", ":", "null", ";", "$", "factory", "=", "isset", "(", "$", "impl", "[", "'factory'", "]", ")", "?", "$", "impl", "[", "'factory'", "]", ":", "null", ";", "$", "options", "=", "isset", "(", "$", "impl", "[", "'options'", "]", ")", "?", "$", "impl", "[", "'options'", "]", ":", "null", ";", "$", "priority", "=", "isset", "(", "$", "impl", "[", "'priority'", "]", ")", "?", "$", "impl", "[", "'priority'", "]", ":", "1", ";", "if", "(", "!", "$", "service", "&&", "isset", "(", "$", "impl", "[", "'class'", "]", ")", ")", "{", "$", "service", "=", "$", "impl", "[", "'class'", "]", ";", "}", "if", "(", "is_null", "(", "$", "options", ")", "&&", "isset", "(", "$", "impl", "[", "'config'", "]", ")", ")", "{", "$", "options", "=", "$", "impl", "[", "'config'", "]", ";", "}", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Service name is not defined for service: '", ".", "$", "id", ")", ";", "}", "$", "this", "->", "registerService", "(", "$", "id", ",", "$", "name", ",", "$", "service", ",", "$", "options", ",", "$", "priority", ")", ";", "if", "(", "array_key_exists", "(", "'enabled'", ",", "$", "impl", ")", "&&", "!", "$", "impl", "[", "'enabled'", "]", ")", "{", "$", "this", "->", "disableService", "(", "$", "id", ")", ";", "}", "if", "(", "$", "factory", ")", "{", "$", "this", "->", "getServicePluginManager", "(", ")", "->", "setFactory", "(", "$", "id", ",", "$", "factory", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Batch register services @param array|\Traversable $services @throws \InvalidArgumentException @return \ValuSo\Broker\ServiceLoader
[ "Batch", "register", "services" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L175-L223
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.load
public function load($id, $options = null) { $id = $this->normalizeServiceId($id); if(!isset($this->services[$id])){ throw new Exception\ServiceNotFoundException( sprintf('Service ID "%s" does not exist', $id) ); } if($options == null){ $options = $this->services[$id]['options']; } return $this->getServicePluginManager()->get($id, $options, true, true); }
php
public function load($id, $options = null) { $id = $this->normalizeServiceId($id); if(!isset($this->services[$id])){ throw new Exception\ServiceNotFoundException( sprintf('Service ID "%s" does not exist', $id) ); } if($options == null){ $options = $this->services[$id]['options']; } return $this->getServicePluginManager()->get($id, $options, true, true); }
[ "public", "function", "load", "(", "$", "id", ",", "$", "options", "=", "null", ")", "{", "$", "id", "=", "$", "this", "->", "normalizeServiceId", "(", "$", "id", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "services", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ServiceNotFoundException", "(", "sprintf", "(", "'Service ID \"%s\" does not exist'", ",", "$", "id", ")", ")", ";", "}", "if", "(", "$", "options", "==", "null", ")", "{", "$", "options", "=", "$", "this", "->", "services", "[", "$", "id", "]", "[", "'options'", "]", ";", "}", "return", "$", "this", "->", "getServicePluginManager", "(", ")", "->", "get", "(", "$", "id", ",", "$", "options", ",", "true", ",", "true", ")", ";", "}" ]
Loads specific service by ID @param string $name Service name @param array $options Options to apply when first initialized @return ServiceInterface
[ "Loads", "specific", "service", "by", "ID" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L329-L344
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.getServiceOptions
public function getServiceOptions($id) { $id = $this->normalizeServiceId($id); if(!isset($this->services[$id])){ throw new Exception\ServiceNotFoundException( sprintf('Service ID "%s" does not exist', $id) ); } return $this->services[$id]['options']; }
php
public function getServiceOptions($id) { $id = $this->normalizeServiceId($id); if(!isset($this->services[$id])){ throw new Exception\ServiceNotFoundException( sprintf('Service ID "%s" does not exist', $id) ); } return $this->services[$id]['options']; }
[ "public", "function", "getServiceOptions", "(", "$", "id", ")", "{", "$", "id", "=", "$", "this", "->", "normalizeServiceId", "(", "$", "id", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "services", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ServiceNotFoundException", "(", "sprintf", "(", "'Service ID \"%s\" does not exist'", ",", "$", "id", ")", ")", ";", "}", "return", "$", "this", "->", "services", "[", "$", "id", "]", "[", "'options'", "]", ";", "}" ]
Retrieve options for service @param string $id @return array|null @throws Exception\ServiceNotFoundException
[ "Retrieve", "options", "for", "service" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L363-L374
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.exists
public function exists($name) { $name = $this->normalizeServiceName($name); return $this->getCommandManager()->hasListeners($name); }
php
public function exists($name) { $name = $this->normalizeServiceName($name); return $this->getCommandManager()->hasListeners($name); }
[ "public", "function", "exists", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "normalizeServiceName", "(", "$", "name", ")", ";", "return", "$", "this", "->", "getCommandManager", "(", ")", "->", "hasListeners", "(", "$", "name", ")", ";", "}" ]
Test if a service exists Any services that are currently disabled, are not taken into account. @param string $name
[ "Test", "if", "a", "service", "exists" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L404-L408
train
valu-digital/valuso
src/ValuSo/Broker/ServiceLoader.php
ServiceLoader.getServicePluginManager
public function getServicePluginManager() { if($this->servicePluginManager === null){ $this->servicePluginManager = new ServicePluginManager(); $that = $this; $this->servicePluginManager->addInitializer(function ($instance, $serviceManager) use ($that) { $name = $serviceManager->getCreationInstanceName(); $options = $serviceManager->getCreationInstanceOptions(); /** * Configure service */ if($options !== null && sizeof($options) && $instance instanceof Feature\ConfigurableInterface){ $instance->setConfig($options); } }); } return $this->servicePluginManager; }
php
public function getServicePluginManager() { if($this->servicePluginManager === null){ $this->servicePluginManager = new ServicePluginManager(); $that = $this; $this->servicePluginManager->addInitializer(function ($instance, $serviceManager) use ($that) { $name = $serviceManager->getCreationInstanceName(); $options = $serviceManager->getCreationInstanceOptions(); /** * Configure service */ if($options !== null && sizeof($options) && $instance instanceof Feature\ConfigurableInterface){ $instance->setConfig($options); } }); } return $this->servicePluginManager; }
[ "public", "function", "getServicePluginManager", "(", ")", "{", "if", "(", "$", "this", "->", "servicePluginManager", "===", "null", ")", "{", "$", "this", "->", "servicePluginManager", "=", "new", "ServicePluginManager", "(", ")", ";", "$", "that", "=", "$", "this", ";", "$", "this", "->", "servicePluginManager", "->", "addInitializer", "(", "function", "(", "$", "instance", ",", "$", "serviceManager", ")", "use", "(", "$", "that", ")", "{", "$", "name", "=", "$", "serviceManager", "->", "getCreationInstanceName", "(", ")", ";", "$", "options", "=", "$", "serviceManager", "->", "getCreationInstanceOptions", "(", ")", ";", "/**\n\t * Configure service\n\t */", "if", "(", "$", "options", "!==", "null", "&&", "sizeof", "(", "$", "options", ")", "&&", "$", "instance", "instanceof", "Feature", "\\", "ConfigurableInterface", ")", "{", "$", "instance", "->", "setConfig", "(", "$", "options", ")", ";", "}", "}", ")", ";", "}", "return", "$", "this", "->", "servicePluginManager", ";", "}" ]
Retrieve service manager @return \ValuSo\Broker\ServicePluginManager
[ "Retrieve", "service", "manager" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceLoader.php#L415-L438
train
raideer/tweech-framework
src/Tweech/Command/CommandRegistry.php
CommandRegistry.register
public function register(CommandInterface $command) { /* * Gets the name of the command * @var string */ $name = $command->getCommand(); /* * Check if the command isn't already registered * otherwise throw an exception */ if (array_key_exists($name, $this->commands)) { throw new CommandException("Command with name '$name' already registered"); } /* * Adds the command to the array */ $this->commands[$name] = $command; }
php
public function register(CommandInterface $command) { /* * Gets the name of the command * @var string */ $name = $command->getCommand(); /* * Check if the command isn't already registered * otherwise throw an exception */ if (array_key_exists($name, $this->commands)) { throw new CommandException("Command with name '$name' already registered"); } /* * Adds the command to the array */ $this->commands[$name] = $command; }
[ "public", "function", "register", "(", "CommandInterface", "$", "command", ")", "{", "/*\n * Gets the name of the command\n * @var string\n */", "$", "name", "=", "$", "command", "->", "getCommand", "(", ")", ";", "/*\n * Check if the command isn't already registered\n * otherwise throw an exception\n */", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "commands", ")", ")", "{", "throw", "new", "CommandException", "(", "\"Command with name '$name' already registered\"", ")", ";", "}", "/*\n * Adds the command to the array\n */", "$", "this", "->", "commands", "[", "$", "name", "]", "=", "$", "command", ";", "}" ]
Registers a command. @param CommandInterface $command @return void
[ "Registers", "a", "command", "." ]
4aeb5fbf78f96baa67cb62ff676867c4fce1f16c
https://github.com/raideer/tweech-framework/blob/4aeb5fbf78f96baa67cb62ff676867c4fce1f16c/src/Tweech/Command/CommandRegistry.php#L28-L48
train
raideer/tweech-framework
src/Tweech/Command/CommandRegistry.php
CommandRegistry.getCommandIfExists
public function getCommandIfExists($string) { if (starts_with($string, $this->id)) { foreach ($this->commands as $commandName => $command) { if (starts_with($string, $this->id.$commandName)) { return $command; } } } }
php
public function getCommandIfExists($string) { if (starts_with($string, $this->id)) { foreach ($this->commands as $commandName => $command) { if (starts_with($string, $this->id.$commandName)) { return $command; } } } }
[ "public", "function", "getCommandIfExists", "(", "$", "string", ")", "{", "if", "(", "starts_with", "(", "$", "string", ",", "$", "this", "->", "id", ")", ")", "{", "foreach", "(", "$", "this", "->", "commands", "as", "$", "commandName", "=>", "$", "command", ")", "{", "if", "(", "starts_with", "(", "$", "string", ",", "$", "this", "->", "id", ".", "$", "commandName", ")", ")", "{", "return", "$", "command", ";", "}", "}", "}", "}" ]
Check if the given string contains a command if so, return the registered command. @param string $string Received Message @return Command Returns the command or null
[ "Check", "if", "the", "given", "string", "contains", "a", "command", "if", "so", "return", "the", "registered", "command", "." ]
4aeb5fbf78f96baa67cb62ff676867c4fce1f16c
https://github.com/raideer/tweech-framework/blob/4aeb5fbf78f96baa67cb62ff676867c4fce1f16c/src/Tweech/Command/CommandRegistry.php#L68-L77
train
jtallant/skimpy-engine
src/Database/Populator.php
Populator.rebuildDatabase
protected function rebuildDatabase() { # 2. Drop the existing database schema $this->schemaTool->dropDatabase(); # 3. Create the new database schema based on (1) $entityMeta = $this->em->getMetadataFactory()->getAllMetadata(); $this->schemaTool->updateSchema($entityMeta); }
php
protected function rebuildDatabase() { # 2. Drop the existing database schema $this->schemaTool->dropDatabase(); # 3. Create the new database schema based on (1) $entityMeta = $this->em->getMetadataFactory()->getAllMetadata(); $this->schemaTool->updateSchema($entityMeta); }
[ "protected", "function", "rebuildDatabase", "(", ")", "{", "# 2. Drop the existing database schema", "$", "this", "->", "schemaTool", "->", "dropDatabase", "(", ")", ";", "# 3. Create the new database schema based on (1)", "$", "entityMeta", "=", "$", "this", "->", "em", "->", "getMetadataFactory", "(", ")", "->", "getAllMetadata", "(", ")", ";", "$", "this", "->", "schemaTool", "->", "updateSchema", "(", "$", "entityMeta", ")", ";", "}" ]
Builds the DB Schema @return void
[ "Builds", "the", "DB", "Schema" ]
2fce5bc16f8745e54fd66a1c291fcea47fc1b4b2
https://github.com/jtallant/skimpy-engine/blob/2fce5bc16f8745e54fd66a1c291fcea47fc1b4b2/src/Database/Populator.php#L62-L70
train
widoz/template-loader
src/Loader.php
Loader.locateFile
private function locateFile() { // Try to retrieve the theme file path from child or parent for first. // Fallback to Plugin templates path. $filePath = locate_template($this->templatesPath, false, false); // Looking for the file within the plugin if allowed. if (! $filePath) { $filePath = $this->defaultPath; } return $filePath; }
php
private function locateFile() { // Try to retrieve the theme file path from child or parent for first. // Fallback to Plugin templates path. $filePath = locate_template($this->templatesPath, false, false); // Looking for the file within the plugin if allowed. if (! $filePath) { $filePath = $this->defaultPath; } return $filePath; }
[ "private", "function", "locateFile", "(", ")", "{", "// Try to retrieve the theme file path from child or parent for first.", "// Fallback to Plugin templates path.", "$", "filePath", "=", "locate_template", "(", "$", "this", "->", "templatesPath", ",", "false", ",", "false", ")", ";", "// Looking for the file within the plugin if allowed.", "if", "(", "!", "$", "filePath", ")", "{", "$", "filePath", "=", "$", "this", "->", "defaultPath", ";", "}", "return", "$", "filePath", ";", "}" ]
Locate template file Locate the file path for the view, hierarchy try to find the file within the child, parent and last within the plugin. @uses locate_template() To locate the view file within the theme (child or parent). @since 2.1.0 @return string The found file path. Empty string if not found.
[ "Locate", "template", "file" ]
6fa0f74047505fe7f2f37c76b61f4e2058e22868
https://github.com/widoz/template-loader/blob/6fa0f74047505fe7f2f37c76b61f4e2058e22868/src/Loader.php#L222-L234
train
mojopollo/laravel-helpers
src/Mojopollo/Helpers/DateTimeHelper.php
DateTimeHelper.daysOfWeek
public function daysOfWeek($daysOfWeek) { // Check for empty, string or no value if (empty($daysOfWeek) || is_string($daysOfWeek) === false || strlen($daysOfWeek) < 3) { // Return with a null parse return null; } // Separate days of the week by comma $daysOfWeek = explode(',', $daysOfWeek); // Allowed values $allowedValues = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']; // Make sure each day of week foreach ($daysOfWeek as $dayOfWeek) { // Is an allowed value if (in_array($dayOfWeek, $allowedValues) === false) { // Otherwise return with a null parse return null; } } // Return days of the week return $daysOfWeek; }
php
public function daysOfWeek($daysOfWeek) { // Check for empty, string or no value if (empty($daysOfWeek) || is_string($daysOfWeek) === false || strlen($daysOfWeek) < 3) { // Return with a null parse return null; } // Separate days of the week by comma $daysOfWeek = explode(',', $daysOfWeek); // Allowed values $allowedValues = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']; // Make sure each day of week foreach ($daysOfWeek as $dayOfWeek) { // Is an allowed value if (in_array($dayOfWeek, $allowedValues) === false) { // Otherwise return with a null parse return null; } } // Return days of the week return $daysOfWeek; }
[ "public", "function", "daysOfWeek", "(", "$", "daysOfWeek", ")", "{", "// Check for empty, string or no value", "if", "(", "empty", "(", "$", "daysOfWeek", ")", "||", "is_string", "(", "$", "daysOfWeek", ")", "===", "false", "||", "strlen", "(", "$", "daysOfWeek", ")", "<", "3", ")", "{", "// Return with a null parse", "return", "null", ";", "}", "// Separate days of the week by comma", "$", "daysOfWeek", "=", "explode", "(", "','", ",", "$", "daysOfWeek", ")", ";", "// Allowed values", "$", "allowedValues", "=", "[", "'mon'", ",", "'tue'", ",", "'wed'", ",", "'thu'", ",", "'fri'", ",", "'sat'", ",", "'sun'", "]", ";", "// Make sure each day of week", "foreach", "(", "$", "daysOfWeek", "as", "$", "dayOfWeek", ")", "{", "// Is an allowed value", "if", "(", "in_array", "(", "$", "dayOfWeek", ",", "$", "allowedValues", ")", "===", "false", ")", "{", "// Otherwise return with a null parse", "return", "null", ";", "}", "}", "// Return days of the week", "return", "$", "daysOfWeek", ";", "}" ]
Parses a string like "mon,tue,wed,thu,fri,sat,sun" into a array @param string $daysOfWeek example: mon,tue,wed,thu,fri,sat,sun mon,wed,fri @return null|array null if there was a parsing error or a array with parsed days of the week
[ "Parses", "a", "string", "like", "mon", "tue", "wed", "thu", "fri", "sat", "sun", "into", "a", "array" ]
0becb5e0f4202a0f489fb5e384c01dacb8f29dc5
https://github.com/mojopollo/laravel-helpers/blob/0becb5e0f4202a0f489fb5e384c01dacb8f29dc5/src/Mojopollo/Helpers/DateTimeHelper.php#L23-L51
train
phavour/phavour
Phavour/Runnable/View.php
View.setPackage
public function setPackage($package) { if ($package != $this->package) { $this->layoutLocation = null; } $this->package = $this->treatPackageName($package); }
php
public function setPackage($package) { if ($package != $this->package) { $this->layoutLocation = null; } $this->package = $this->treatPackageName($package); }
[ "public", "function", "setPackage", "(", "$", "package", ")", "{", "if", "(", "$", "package", "!=", "$", "this", "->", "package", ")", "{", "$", "this", "->", "layoutLocation", "=", "null", ";", "}", "$", "this", "->", "package", "=", "$", "this", "->", "treatPackageName", "(", "$", "package", ")", ";", "}" ]
Set the package name @param string $package
[ "Set", "the", "package", "name" ]
2246f78203312eb2e23fdb0f776f790e81b4d20f
https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Runnable/View.php#L190-L196
train
phavour/phavour
Phavour/Runnable/View.php
View.setLayout
public function setLayout($file) { if (strstr($file, '::')) { $file = explode('::', $file); $package = $file[0]; $file = $file[1]; } else { $package = $this->package; } $this->assignDeclaredLayout($package, $file); }
php
public function setLayout($file) { if (strstr($file, '::')) { $file = explode('::', $file); $package = $file[0]; $file = $file[1]; } else { $package = $this->package; } $this->assignDeclaredLayout($package, $file); }
[ "public", "function", "setLayout", "(", "$", "file", ")", "{", "if", "(", "strstr", "(", "$", "file", ",", "'::'", ")", ")", "{", "$", "file", "=", "explode", "(", "'::'", ",", "$", "file", ")", ";", "$", "package", "=", "$", "file", "[", "0", "]", ";", "$", "file", "=", "$", "file", "[", "1", "]", ";", "}", "else", "{", "$", "package", "=", "$", "this", "->", "package", ";", "}", "$", "this", "->", "assignDeclaredLayout", "(", "$", "package", ",", "$", "file", ")", ";", "}" ]
Set the layout location @param string $file
[ "Set", "the", "layout", "location" ]
2246f78203312eb2e23fdb0f776f790e81b4d20f
https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Runnable/View.php#L365-L376
train
phavour/phavour
Phavour/Runnable/View.php
View.assignDeclaredLayout
private function assignDeclaredLayout($package, $file) { $file = lcfirst($file); if (substr(strtolower($file), -6) == '.phtml') { $file = substr($file, 0, -6); } $package = $this->app->getPackage($package); $pathPieces = array($package['package_path'], 'res', 'layout', $file); $path = implode(self::DS, $pathPieces) . '.phtml'; if (file_exists($path)) { $this->layoutLocation = $path; return true; } $e = new LayoutFileNotFoundException('Invalid layout file path, expected: "' . $path . '"'); $e->setAdditionalData('Layout Path Checked: ', $path); throw $e; }
php
private function assignDeclaredLayout($package, $file) { $file = lcfirst($file); if (substr(strtolower($file), -6) == '.phtml') { $file = substr($file, 0, -6); } $package = $this->app->getPackage($package); $pathPieces = array($package['package_path'], 'res', 'layout', $file); $path = implode(self::DS, $pathPieces) . '.phtml'; if (file_exists($path)) { $this->layoutLocation = $path; return true; } $e = new LayoutFileNotFoundException('Invalid layout file path, expected: "' . $path . '"'); $e->setAdditionalData('Layout Path Checked: ', $path); throw $e; }
[ "private", "function", "assignDeclaredLayout", "(", "$", "package", ",", "$", "file", ")", "{", "$", "file", "=", "lcfirst", "(", "$", "file", ")", ";", "if", "(", "substr", "(", "strtolower", "(", "$", "file", ")", ",", "-", "6", ")", "==", "'.phtml'", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "0", ",", "-", "6", ")", ";", "}", "$", "package", "=", "$", "this", "->", "app", "->", "getPackage", "(", "$", "package", ")", ";", "$", "pathPieces", "=", "array", "(", "$", "package", "[", "'package_path'", "]", ",", "'res'", ",", "'layout'", ",", "$", "file", ")", ";", "$", "path", "=", "implode", "(", "self", "::", "DS", ",", "$", "pathPieces", ")", ".", "'.phtml'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "layoutLocation", "=", "$", "path", ";", "return", "true", ";", "}", "$", "e", "=", "new", "LayoutFileNotFoundException", "(", "'Invalid layout file path, expected: \"'", ".", "$", "path", ".", "'\"'", ")", ";", "$", "e", "->", "setAdditionalData", "(", "'Layout Path Checked: '", ",", "$", "path", ")", ";", "throw", "$", "e", ";", "}" ]
Assign the path to the layout file @param string $package @param string $file @throws LayoutFileNotFoundException @throws \Phavour\Application\Exception\PackageNotFoundException @return boolean
[ "Assign", "the", "path", "to", "the", "layout", "file" ]
2246f78203312eb2e23fdb0f776f790e81b4d20f
https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Runnable/View.php#L433-L450
train
phavour/phavour
Phavour/Runnable/View.php
View.getPathForView
private function getPathForView() { $methodName = lcfirst($this->method); $className = lcfirst($this->class); $package = $this->app->getPackage($this->package); $pathPieces = array($package['package_path'], 'res', 'view', $className, $methodName); $path = implode(self::DS, $pathPieces) . '.phtml'; if (file_exists($path)) { return $path; } $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $path . '"'); $e->setAdditionalData('View Path Checked: ', $path); throw $e; }
php
private function getPathForView() { $methodName = lcfirst($this->method); $className = lcfirst($this->class); $package = $this->app->getPackage($this->package); $pathPieces = array($package['package_path'], 'res', 'view', $className, $methodName); $path = implode(self::DS, $pathPieces) . '.phtml'; if (file_exists($path)) { return $path; } $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $path . '"'); $e->setAdditionalData('View Path Checked: ', $path); throw $e; }
[ "private", "function", "getPathForView", "(", ")", "{", "$", "methodName", "=", "lcfirst", "(", "$", "this", "->", "method", ")", ";", "$", "className", "=", "lcfirst", "(", "$", "this", "->", "class", ")", ";", "$", "package", "=", "$", "this", "->", "app", "->", "getPackage", "(", "$", "this", "->", "package", ")", ";", "$", "pathPieces", "=", "array", "(", "$", "package", "[", "'package_path'", "]", ",", "'res'", ",", "'view'", ",", "$", "className", ",", "$", "methodName", ")", ";", "$", "path", "=", "implode", "(", "self", "::", "DS", ",", "$", "pathPieces", ")", ".", "'.phtml'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "$", "e", "=", "new", "ViewFileNotFoundException", "(", "'Invalid view file path, expected: \"'", ".", "$", "path", ".", "'\"'", ")", ";", "$", "e", "->", "setAdditionalData", "(", "'View Path Checked: '", ",", "$", "path", ")", ";", "throw", "$", "e", ";", "}" ]
Get the path for a view file. @throws \Phavour\Application\Exception\PackageNotFoundException @throws ViewFileNotFoundException @return string
[ "Get", "the", "path", "for", "a", "view", "file", "." ]
2246f78203312eb2e23fdb0f776f790e81b4d20f
https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Runnable/View.php#L458-L472
train
phavour/phavour
Phavour/Runnable/View.php
View.inflate
private function inflate($filePath) { $currentDirectory = rtrim(dirname($this->currentView), self::DS); $currentDirectory .= self::DS; if (substr($filePath, -6, 6) != '.phtml') { $filePath .= '.phtml'; } $searchPath = realpath($currentDirectory . $filePath); if ($searchPath != false && file_exists($searchPath)) { $content = @include $searchPath; if (!$content) { // @codeCoverageIgnoreStart $e = new ViewFileNotFoundException('Unable to inflate file "' . $searchPath . '"'); $e->setAdditionalData('View Path: ', $searchPath); throw $e; // @codeCoverageIgnoreEnd } return; } // @codeCoverageIgnoreStart $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $currentDirectory . $filePath . '"'); $e->setAdditionalData('View Path Checked: ', $currentDirectory . $filePath); throw $e; // @codeCoverageIgnoreEnd }
php
private function inflate($filePath) { $currentDirectory = rtrim(dirname($this->currentView), self::DS); $currentDirectory .= self::DS; if (substr($filePath, -6, 6) != '.phtml') { $filePath .= '.phtml'; } $searchPath = realpath($currentDirectory . $filePath); if ($searchPath != false && file_exists($searchPath)) { $content = @include $searchPath; if (!$content) { // @codeCoverageIgnoreStart $e = new ViewFileNotFoundException('Unable to inflate file "' . $searchPath . '"'); $e->setAdditionalData('View Path: ', $searchPath); throw $e; // @codeCoverageIgnoreEnd } return; } // @codeCoverageIgnoreStart $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $currentDirectory . $filePath . '"'); $e->setAdditionalData('View Path Checked: ', $currentDirectory . $filePath); throw $e; // @codeCoverageIgnoreEnd }
[ "private", "function", "inflate", "(", "$", "filePath", ")", "{", "$", "currentDirectory", "=", "rtrim", "(", "dirname", "(", "$", "this", "->", "currentView", ")", ",", "self", "::", "DS", ")", ";", "$", "currentDirectory", ".=", "self", "::", "DS", ";", "if", "(", "substr", "(", "$", "filePath", ",", "-", "6", ",", "6", ")", "!=", "'.phtml'", ")", "{", "$", "filePath", ".=", "'.phtml'", ";", "}", "$", "searchPath", "=", "realpath", "(", "$", "currentDirectory", ".", "$", "filePath", ")", ";", "if", "(", "$", "searchPath", "!=", "false", "&&", "file_exists", "(", "$", "searchPath", ")", ")", "{", "$", "content", "=", "@", "include", "$", "searchPath", ";", "if", "(", "!", "$", "content", ")", "{", "// @codeCoverageIgnoreStart", "$", "e", "=", "new", "ViewFileNotFoundException", "(", "'Unable to inflate file \"'", ".", "$", "searchPath", ".", "'\"'", ")", ";", "$", "e", "->", "setAdditionalData", "(", "'View Path: '", ",", "$", "searchPath", ")", ";", "throw", "$", "e", ";", "// @codeCoverageIgnoreEnd", "}", "return", ";", "}", "// @codeCoverageIgnoreStart", "$", "e", "=", "new", "ViewFileNotFoundException", "(", "'Invalid view file path, expected: \"'", ".", "$", "currentDirectory", ".", "$", "filePath", ".", "'\"'", ")", ";", "$", "e", "->", "setAdditionalData", "(", "'View Path Checked: '", ",", "$", "currentDirectory", ".", "$", "filePath", ")", ";", "throw", "$", "e", ";", "// @codeCoverageIgnoreEnd", "}" ]
Inflate a given @param string $filePath @throws \Phavour\Runnable\View\Exception\ViewFileNotFoundException
[ "Inflate", "a", "given" ]
2246f78203312eb2e23fdb0f776f790e81b4d20f
https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Runnable/View.php#L479-L505
train
zbox/UnifiedPush
src/Zbox/UnifiedPush/NotificationService/ServiceCredentialsFactory.php
ServiceCredentialsFactory.getCredentialsByService
public function getCredentialsByService($serviceName) { if (!in_array($serviceName, $this->getInitializedServices())) { throw new DomainException( sprintf("Credentials for service '%s' was not initialized", $serviceName) ); } return $this->serviceCredentials[$serviceName]; }
php
public function getCredentialsByService($serviceName) { if (!in_array($serviceName, $this->getInitializedServices())) { throw new DomainException( sprintf("Credentials for service '%s' was not initialized", $serviceName) ); } return $this->serviceCredentials[$serviceName]; }
[ "public", "function", "getCredentialsByService", "(", "$", "serviceName", ")", "{", "if", "(", "!", "in_array", "(", "$", "serviceName", ",", "$", "this", "->", "getInitializedServices", "(", ")", ")", ")", "{", "throw", "new", "DomainException", "(", "sprintf", "(", "\"Credentials for service '%s' was not initialized\"", ",", "$", "serviceName", ")", ")", ";", "}", "return", "$", "this", "->", "serviceCredentials", "[", "$", "serviceName", "]", ";", "}" ]
Returns credentials for notification service @param string $serviceName @throws DomainException @return CredentialsInterface
[ "Returns", "credentials", "for", "notification", "service" ]
47da2d0577b18ac709cd947c68541014001e1866
https://github.com/zbox/UnifiedPush/blob/47da2d0577b18ac709cd947c68541014001e1866/src/Zbox/UnifiedPush/NotificationService/ServiceCredentialsFactory.php#L76-L85
train
romaricdrigon/OrchestraBundle
Core/Pool/Factory/RepositoryPoolFactory.php
RepositoryPoolFactory.addRepository
public function addRepository($repositoryClass, $serviceId, $entityClass) { $repositoryDefinition = $this->definitionFactory->build($repositoryClass, $serviceId, $entityClass); // this array is not ordered by slug $this->definitions[] = $repositoryDefinition; }
php
public function addRepository($repositoryClass, $serviceId, $entityClass) { $repositoryDefinition = $this->definitionFactory->build($repositoryClass, $serviceId, $entityClass); // this array is not ordered by slug $this->definitions[] = $repositoryDefinition; }
[ "public", "function", "addRepository", "(", "$", "repositoryClass", ",", "$", "serviceId", ",", "$", "entityClass", ")", "{", "$", "repositoryDefinition", "=", "$", "this", "->", "definitionFactory", "->", "build", "(", "$", "repositoryClass", ",", "$", "serviceId", ",", "$", "entityClass", ")", ";", "// this array is not ordered by slug", "$", "this", "->", "definitions", "[", "]", "=", "$", "repositoryDefinition", ";", "}" ]
Add a repository, service from Symfony DIC, to the pool @param string $repositoryClass @param string $serviceId @param string $entityClass
[ "Add", "a", "repository", "service", "from", "Symfony", "DIC", "to", "the", "pool" ]
4abb9736fcb6b23ed08ebd14ab169867339a4785
https://github.com/romaricdrigon/OrchestraBundle/blob/4abb9736fcb6b23ed08ebd14ab169867339a4785/Core/Pool/Factory/RepositoryPoolFactory.php#L48-L54
train
romaricdrigon/OrchestraBundle
Core/Pool/Factory/RepositoryPoolFactory.php
RepositoryPoolFactory.createPool
public function createPool() { $pool = new RepositoryPool(); foreach ($this->definitions as $definition) { $pool->addRepositoryDefinition($definition); } return $pool; }
php
public function createPool() { $pool = new RepositoryPool(); foreach ($this->definitions as $definition) { $pool->addRepositoryDefinition($definition); } return $pool; }
[ "public", "function", "createPool", "(", ")", "{", "$", "pool", "=", "new", "RepositoryPool", "(", ")", ";", "foreach", "(", "$", "this", "->", "definitions", "as", "$", "definition", ")", "{", "$", "pool", "->", "addRepositoryDefinition", "(", "$", "definition", ")", ";", "}", "return", "$", "pool", ";", "}" ]
Factory method for the EntityPool @return RepositoryPoolInterface
[ "Factory", "method", "for", "the", "EntityPool" ]
4abb9736fcb6b23ed08ebd14ab169867339a4785
https://github.com/romaricdrigon/OrchestraBundle/blob/4abb9736fcb6b23ed08ebd14ab169867339a4785/Core/Pool/Factory/RepositoryPoolFactory.php#L61-L70
train
schpill/thin
src/Prototype.php
Prototype.from
static public function from($class) { if (is_object($class)) { $class = get_class($class); } if (empty(self::$prototypes[$class])) { self::$prototypes[$class] = new static($class); } return self::$prototypes[$class]; }
php
static public function from($class) { if (is_object($class)) { $class = get_class($class); } if (empty(self::$prototypes[$class])) { self::$prototypes[$class] = new static($class); } return self::$prototypes[$class]; }
[ "static", "public", "function", "from", "(", "$", "class", ")", "{", "if", "(", "is_object", "(", "$", "class", ")", ")", "{", "$", "class", "=", "get_class", "(", "$", "class", ")", ";", "}", "if", "(", "empty", "(", "self", "::", "$", "prototypes", "[", "$", "class", "]", ")", ")", "{", "self", "::", "$", "prototypes", "[", "$", "class", "]", "=", "new", "static", "(", "$", "class", ")", ";", "}", "return", "self", "::", "$", "prototypes", "[", "$", "class", "]", ";", "}" ]
Returns the prototype associated with the specified class or object. @param string|object $class Class name or instance. @return Prototype
[ "Returns", "the", "prototype", "associated", "with", "the", "specified", "class", "or", "object", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Prototype.php#L27-L38
train
schpill/thin
src/Prototype.php
Prototype.getConsolidatedMethods
protected function getConsolidatedMethods() { if ($this->consolidatedMethods !== null) { return $this->consolidatedMethods; } $methods = $this->methods; if ($this->parent) { $methods += $this->parent->getConsolidatedMethods(); } return $this->consolidatedMethods = $methods; }
php
protected function getConsolidatedMethods() { if ($this->consolidatedMethods !== null) { return $this->consolidatedMethods; } $methods = $this->methods; if ($this->parent) { $methods += $this->parent->getConsolidatedMethods(); } return $this->consolidatedMethods = $methods; }
[ "protected", "function", "getConsolidatedMethods", "(", ")", "{", "if", "(", "$", "this", "->", "consolidatedMethods", "!==", "null", ")", "{", "return", "$", "this", "->", "consolidatedMethods", ";", "}", "$", "methods", "=", "$", "this", "->", "methods", ";", "if", "(", "$", "this", "->", "parent", ")", "{", "$", "methods", "+=", "$", "this", "->", "parent", "->", "getConsolidatedMethods", "(", ")", ";", "}", "return", "$", "this", "->", "consolidatedMethods", "=", "$", "methods", ";", "}" ]
Consolidate the methods of the prototype. The method creates a single array from the prototype methods and those of its parents. @return array[string]callable
[ "Consolidate", "the", "methods", "of", "the", "prototype", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Prototype.php#L110-L123
train
schpill/thin
src/Prototype.php
Prototype.revokeConsolidatedMethods
protected function revokeConsolidatedMethods() { $class = $this->class; foreach (self::$prototypes as $prototype) { if (!is_subclass_of($prototype->class, $class)) { continue; } $prototype->consolidatedMethods = null; } $this->consolidatedMethods = null; }
php
protected function revokeConsolidatedMethods() { $class = $this->class; foreach (self::$prototypes as $prototype) { if (!is_subclass_of($prototype->class, $class)) { continue; } $prototype->consolidatedMethods = null; } $this->consolidatedMethods = null; }
[ "protected", "function", "revokeConsolidatedMethods", "(", ")", "{", "$", "class", "=", "$", "this", "->", "class", ";", "foreach", "(", "self", "::", "$", "prototypes", "as", "$", "prototype", ")", "{", "if", "(", "!", "is_subclass_of", "(", "$", "prototype", "->", "class", ",", "$", "class", ")", ")", "{", "continue", ";", "}", "$", "prototype", "->", "consolidatedMethods", "=", "null", ";", "}", "$", "this", "->", "consolidatedMethods", "=", "null", ";", "}" ]
Revokes the consolidated methods of the prototype. The method must be invoked when prototype methods are modified.
[ "Revokes", "the", "consolidated", "methods", "of", "the", "prototype", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Prototype.php#L130-L143
train
schpill/thin
src/Prototype.php
Prototype.offsetSet
public function offsetSet($method, $callback) { self::$prototypes[$this->class]->methods[$method] = $callback; $this->revokeConsolidatedMethods(); }
php
public function offsetSet($method, $callback) { self::$prototypes[$this->class]->methods[$method] = $callback; $this->revokeConsolidatedMethods(); }
[ "public", "function", "offsetSet", "(", "$", "method", ",", "$", "callback", ")", "{", "self", "::", "$", "prototypes", "[", "$", "this", "->", "class", "]", "->", "methods", "[", "$", "method", "]", "=", "$", "callback", ";", "$", "this", "->", "revokeConsolidatedMethods", "(", ")", ";", "}" ]
Adds or replaces the specified method of the prototype. @param string $method The name of the method. @param callable $callback
[ "Adds", "or", "replaces", "the", "specified", "method", "of", "the", "prototype", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Prototype.php#L152-L157
train
schpill/thin
src/Prototype.php
Prototype.offsetGet
public function offsetGet($method) { $methods = $this->getConsolidatedMethods(); if (!isset($methods[$method])) { throw new Exception("$method, $this->class"); } return $methods[$method]; }
php
public function offsetGet($method) { $methods = $this->getConsolidatedMethods(); if (!isset($methods[$method])) { throw new Exception("$method, $this->class"); } return $methods[$method]; }
[ "public", "function", "offsetGet", "(", "$", "method", ")", "{", "$", "methods", "=", "$", "this", "->", "getConsolidatedMethods", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "methods", "[", "$", "method", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"$method, $this->class\"", ")", ";", "}", "return", "$", "methods", "[", "$", "method", "]", ";", "}" ]
Returns the callback associated with the specified method. @param string $method The name of the method. @throws Exception if the method is not defined. @return callable
[ "Returns", "the", "callback", "associated", "with", "the", "specified", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Prototype.php#L194-L203
train
fxpio/fxp-doctrine-console
Util/ObjectFieldUtil.php
ObjectFieldUtil.addOptions
public static function addOptions(InputDefinition $definition, array $fields, $description) { foreach ($fields as $field => $type) { $mode = 'array' === $type ? InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY : InputOption::VALUE_REQUIRED; if (!$definition->hasOption($field) && !$definition->hasArgument($field)) { $definition->addOption(new InputOption($field, null, $mode, sprintf($description, $field, $type))); } } }
php
public static function addOptions(InputDefinition $definition, array $fields, $description) { foreach ($fields as $field => $type) { $mode = 'array' === $type ? InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY : InputOption::VALUE_REQUIRED; if (!$definition->hasOption($field) && !$definition->hasArgument($field)) { $definition->addOption(new InputOption($field, null, $mode, sprintf($description, $field, $type))); } } }
[ "public", "static", "function", "addOptions", "(", "InputDefinition", "$", "definition", ",", "array", "$", "fields", ",", "$", "description", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", "=>", "$", "type", ")", "{", "$", "mode", "=", "'array'", "===", "$", "type", "?", "InputOption", "::", "VALUE_REQUIRED", "|", "InputOption", "::", "VALUE_IS_ARRAY", ":", "InputOption", "::", "VALUE_REQUIRED", ";", "if", "(", "!", "$", "definition", "->", "hasOption", "(", "$", "field", ")", "&&", "!", "$", "definition", "->", "hasArgument", "(", "$", "field", ")", ")", "{", "$", "definition", "->", "addOption", "(", "new", "InputOption", "(", "$", "field", ",", "null", ",", "$", "mode", ",", "sprintf", "(", "$", "description", ",", "$", "field", ",", "$", "type", ")", ")", ")", ";", "}", "}", "}" ]
Add options in input definition. @param InputDefinition $definition The input definition @param array $fields The fields @param string $description The option description
[ "Add", "options", "in", "input", "definition", "." ]
2fc16d7a4eb0f247075c50de225ec2670ca5479a
https://github.com/fxpio/fxp-doctrine-console/blob/2fc16d7a4eb0f247075c50de225ec2670ca5479a/Util/ObjectFieldUtil.php#L32-L43
train
fxpio/fxp-doctrine-console
Util/ObjectFieldUtil.php
ObjectFieldUtil.getFieldValue
public static function getFieldValue(InputInterface $input, $fieldName) { $value = null; if ($input->hasArgument($fieldName)) { $value = $input->getArgument($fieldName); } elseif ($input->hasOption($fieldName)) { $value = $input->getOption($fieldName); } return $value; }
php
public static function getFieldValue(InputInterface $input, $fieldName) { $value = null; if ($input->hasArgument($fieldName)) { $value = $input->getArgument($fieldName); } elseif ($input->hasOption($fieldName)) { $value = $input->getOption($fieldName); } return $value; }
[ "public", "static", "function", "getFieldValue", "(", "InputInterface", "$", "input", ",", "$", "fieldName", ")", "{", "$", "value", "=", "null", ";", "if", "(", "$", "input", "->", "hasArgument", "(", "$", "fieldName", ")", ")", "{", "$", "value", "=", "$", "input", "->", "getArgument", "(", "$", "fieldName", ")", ";", "}", "elseif", "(", "$", "input", "->", "hasOption", "(", "$", "fieldName", ")", ")", "{", "$", "value", "=", "$", "input", "->", "getOption", "(", "$", "fieldName", ")", ";", "}", "return", "$", "value", ";", "}" ]
Get field value in console input. @param InputInterface $input The console input @param string $fieldName The field name @return mixed|null
[ "Get", "field", "value", "in", "console", "input", "." ]
2fc16d7a4eb0f247075c50de225ec2670ca5479a
https://github.com/fxpio/fxp-doctrine-console/blob/2fc16d7a4eb0f247075c50de225ec2670ca5479a/Util/ObjectFieldUtil.php#L53-L64
train
rbone/phactory
lib/Phactory/Factory.php
Factory.create
public function create($type, $override, $persisted) { $base = $this->factory->blueprint(); $variation = $this->getVariation($type); $blueprint = array_merge($base, $variation, $override); return new Blueprint($this->name, $type, $blueprint, $this->isFixture($type), $persisted); }
php
public function create($type, $override, $persisted) { $base = $this->factory->blueprint(); $variation = $this->getVariation($type); $blueprint = array_merge($base, $variation, $override); return new Blueprint($this->name, $type, $blueprint, $this->isFixture($type), $persisted); }
[ "public", "function", "create", "(", "$", "type", ",", "$", "override", ",", "$", "persisted", ")", "{", "$", "base", "=", "$", "this", "->", "factory", "->", "blueprint", "(", ")", ";", "$", "variation", "=", "$", "this", "->", "getVariation", "(", "$", "type", ")", ";", "$", "blueprint", "=", "array_merge", "(", "$", "base", ",", "$", "variation", ",", "$", "override", ")", ";", "return", "new", "Blueprint", "(", "$", "this", "->", "name", ",", "$", "type", ",", "$", "blueprint", ",", "$", "this", "->", "isFixture", "(", "$", "type", ")", ",", "$", "persisted", ")", ";", "}" ]
Creates a new blueprint @param string $type variation or fixture @param array $override attributes values overrides @param boolean $persisted wether it will save the object or not @return \Phactory\Blueprint
[ "Creates", "a", "new", "blueprint" ]
f1c474084f9b310d171f393fe196e8a2a7aae1ec
https://github.com/rbone/phactory/blob/f1c474084f9b310d171f393fe196e8a2a7aae1ec/lib/Phactory/Factory.php#L40-L48
train
rbone/phactory
lib/Phactory/Factory.php
Factory.getVariation
private function getVariation($type) { if ($type == 'blueprint') { return array(); } elseif (method_exists($this->factory, "{$type}Fixture")) { return call_user_func(array($this->factory, "{$type}Fixture")); } elseif (method_exists($this->factory, "{$type}_fixture")) { // @deprecated Backwards compatibility return call_user_func(array($this->factory, "{$type}_fixture")); } elseif (method_exists($this->factory, $type)) { return call_user_func(array($this->factory, $type)); } else { throw new \BadMethodCallException("No such variation '$type' on " . get_class($this->factory)); } }
php
private function getVariation($type) { if ($type == 'blueprint') { return array(); } elseif (method_exists($this->factory, "{$type}Fixture")) { return call_user_func(array($this->factory, "{$type}Fixture")); } elseif (method_exists($this->factory, "{$type}_fixture")) { // @deprecated Backwards compatibility return call_user_func(array($this->factory, "{$type}_fixture")); } elseif (method_exists($this->factory, $type)) { return call_user_func(array($this->factory, $type)); } else { throw new \BadMethodCallException("No such variation '$type' on " . get_class($this->factory)); } }
[ "private", "function", "getVariation", "(", "$", "type", ")", "{", "if", "(", "$", "type", "==", "'blueprint'", ")", "{", "return", "array", "(", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "factory", ",", "\"{$type}Fixture\"", ")", ")", "{", "return", "call_user_func", "(", "array", "(", "$", "this", "->", "factory", ",", "\"{$type}Fixture\"", ")", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "factory", ",", "\"{$type}_fixture\"", ")", ")", "{", "// @deprecated Backwards compatibility", "return", "call_user_func", "(", "array", "(", "$", "this", "->", "factory", ",", "\"{$type}_fixture\"", ")", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", "->", "factory", ",", "$", "type", ")", ")", "{", "return", "call_user_func", "(", "array", "(", "$", "this", "->", "factory", ",", "$", "type", ")", ")", ";", "}", "else", "{", "throw", "new", "\\", "BadMethodCallException", "(", "\"No such variation '$type' on \"", ".", "get_class", "(", "$", "this", "->", "factory", ")", ")", ";", "}", "}" ]
Applies a variation to the basic blueprint or calls the fixture @param string $type variation or fixture @return array @throws \BadMethodCallException
[ "Applies", "a", "variation", "to", "the", "basic", "blueprint", "or", "calls", "the", "fixture" ]
f1c474084f9b310d171f393fe196e8a2a7aae1ec
https://github.com/rbone/phactory/blob/f1c474084f9b310d171f393fe196e8a2a7aae1ec/lib/Phactory/Factory.php#L56-L69
train
emaphp/omocha
lib/AnnotationBag.php
AnnotationBag.replace
public function replace(array $annotations) { $this->annotations = $annotations; $this->names = []; $index = 0; foreach ($annotations as $annotation) { $name = $annotation->getName(); if (!array_key_exists($name, $this->names)) { $this->names[$name] = []; } $this->names[$name][] = $index++; } }
php
public function replace(array $annotations) { $this->annotations = $annotations; $this->names = []; $index = 0; foreach ($annotations as $annotation) { $name = $annotation->getName(); if (!array_key_exists($name, $this->names)) { $this->names[$name] = []; } $this->names[$name][] = $index++; } }
[ "public", "function", "replace", "(", "array", "$", "annotations", ")", "{", "$", "this", "->", "annotations", "=", "$", "annotations", ";", "$", "this", "->", "names", "=", "[", "]", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "$", "name", "=", "$", "annotation", "->", "getName", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "names", ")", ")", "{", "$", "this", "->", "names", "[", "$", "name", "]", "=", "[", "]", ";", "}", "$", "this", "->", "names", "[", "$", "name", "]", "[", "]", "=", "$", "index", "++", ";", "}", "}" ]
Replaces a set of annotations values @param array $annotations
[ "Replaces", "a", "set", "of", "annotations", "values" ]
6635b2a7d5feeb7c8627a1a50a871220b1861024
https://github.com/emaphp/omocha/blob/6635b2a7d5feeb7c8627a1a50a871220b1861024/lib/AnnotationBag.php#L25-L37
train
emaphp/omocha
lib/AnnotationBag.php
AnnotationBag.get
public function get($key) { if ($this->has($key)) { return $this->annotations[$this->names[$key][0]]; } return null; }
php
public function get($key) { if ($this->has($key)) { return $this->annotations[$this->names[$key][0]]; } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "annotations", "[", "$", "this", "->", "names", "[", "$", "key", "]", "[", "0", "]", "]", ";", "}", "return", "null", ";", "}" ]
Retrieves a single annotation @param string $key @return Annotation|NULL
[ "Retrieves", "a", "single", "annotation" ]
6635b2a7d5feeb7c8627a1a50a871220b1861024
https://github.com/emaphp/omocha/blob/6635b2a7d5feeb7c8627a1a50a871220b1861024/lib/AnnotationBag.php#L61-L66
train
emaphp/omocha
lib/AnnotationBag.php
AnnotationBag.find
public function find($key, $filter = null) { if (!$this->has($key)) { return []; } $annotations = []; foreach ($this->names[$key] as $index) { if (!is_int($filter)) { $annotations[] = $this->annotations[$index]; continue; } $annotation = $this->annotations[$index]; $flags = 0; //match value type if ($filter & Filter::TYPE_ALL) { $value = $annotation->getValue(); if (is_null($value)) { $flags |= Filter::TYPE_NULL; } elseif (is_string($value)) { $flags |= Filter::TYPE_STRING; } elseif (is_int($value)) { $flags |= Filter::TYPE_INTEGER; } elseif (is_float($value)) { $flags |= Filter::TYPE_FLOAT; } elseif (is_bool($value)) { $flags |= Filter::TYPE_BOOLEAN; } elseif (is_array($value)) { $flags |= Filter::TYPE_ARRAY; } elseif (id_object($value)) { $flags |= Filter::TYPE_OBJECT; } } //match argument filter if ($filter & Filter::HAS_ARGUMENT || $filter & Filter::NOT_HAS_ARGUMENT) { if ($annotation->getArgument()) { $flags |= Filter::HAS_ARGUMENT; } else { $flags |= Filter::NOT_HAS_ARGUMENT; } } //add annotation if it meets all requirements if (($flags & $filter) == $flags) { $annotations[] = $annotation; } } return $annotations; }
php
public function find($key, $filter = null) { if (!$this->has($key)) { return []; } $annotations = []; foreach ($this->names[$key] as $index) { if (!is_int($filter)) { $annotations[] = $this->annotations[$index]; continue; } $annotation = $this->annotations[$index]; $flags = 0; //match value type if ($filter & Filter::TYPE_ALL) { $value = $annotation->getValue(); if (is_null($value)) { $flags |= Filter::TYPE_NULL; } elseif (is_string($value)) { $flags |= Filter::TYPE_STRING; } elseif (is_int($value)) { $flags |= Filter::TYPE_INTEGER; } elseif (is_float($value)) { $flags |= Filter::TYPE_FLOAT; } elseif (is_bool($value)) { $flags |= Filter::TYPE_BOOLEAN; } elseif (is_array($value)) { $flags |= Filter::TYPE_ARRAY; } elseif (id_object($value)) { $flags |= Filter::TYPE_OBJECT; } } //match argument filter if ($filter & Filter::HAS_ARGUMENT || $filter & Filter::NOT_HAS_ARGUMENT) { if ($annotation->getArgument()) { $flags |= Filter::HAS_ARGUMENT; } else { $flags |= Filter::NOT_HAS_ARGUMENT; } } //add annotation if it meets all requirements if (($flags & $filter) == $flags) { $annotations[] = $annotation; } } return $annotations; }
[ "public", "function", "find", "(", "$", "key", ",", "$", "filter", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "[", "]", ";", "}", "$", "annotations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "names", "[", "$", "key", "]", "as", "$", "index", ")", "{", "if", "(", "!", "is_int", "(", "$", "filter", ")", ")", "{", "$", "annotations", "[", "]", "=", "$", "this", "->", "annotations", "[", "$", "index", "]", ";", "continue", ";", "}", "$", "annotation", "=", "$", "this", "->", "annotations", "[", "$", "index", "]", ";", "$", "flags", "=", "0", ";", "//match value type", "if", "(", "$", "filter", "&", "Filter", "::", "TYPE_ALL", ")", "{", "$", "value", "=", "$", "annotation", "->", "getValue", "(", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_NULL", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_STRING", ";", "}", "elseif", "(", "is_int", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_INTEGER", ";", "}", "elseif", "(", "is_float", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_FLOAT", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_BOOLEAN", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_ARRAY", ";", "}", "elseif", "(", "id_object", "(", "$", "value", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "TYPE_OBJECT", ";", "}", "}", "//match argument filter", "if", "(", "$", "filter", "&", "Filter", "::", "HAS_ARGUMENT", "||", "$", "filter", "&", "Filter", "::", "NOT_HAS_ARGUMENT", ")", "{", "if", "(", "$", "annotation", "->", "getArgument", "(", ")", ")", "{", "$", "flags", "|=", "Filter", "::", "HAS_ARGUMENT", ";", "}", "else", "{", "$", "flags", "|=", "Filter", "::", "NOT_HAS_ARGUMENT", ";", "}", "}", "//add annotation if it meets all requirements", "if", "(", "(", "$", "flags", "&", "$", "filter", ")", "==", "$", "flags", ")", "{", "$", "annotations", "[", "]", "=", "$", "annotation", ";", "}", "}", "return", "$", "annotations", ";", "}" ]
Retrieves a list of annotations by name @param string $key @param int $filter @return array
[ "Retrieves", "a", "list", "of", "annotations", "by", "name" ]
6635b2a7d5feeb7c8627a1a50a871220b1861024
https://github.com/emaphp/omocha/blob/6635b2a7d5feeb7c8627a1a50a871220b1861024/lib/AnnotationBag.php#L74-L133
train
emaphp/omocha
lib/AnnotationBag.php
AnnotationBag.filter
public function filter(\Closure $callback, $reindex = true) { $result = array_filter($this->annotations, $callback); if ($reindex) { $result = array_values($result); } return $result; }
php
public function filter(\Closure $callback, $reindex = true) { $result = array_filter($this->annotations, $callback); if ($reindex) { $result = array_values($result); } return $result; }
[ "public", "function", "filter", "(", "\\", "Closure", "$", "callback", ",", "$", "reindex", "=", "true", ")", "{", "$", "result", "=", "array_filter", "(", "$", "this", "->", "annotations", ",", "$", "callback", ")", ";", "if", "(", "$", "reindex", ")", "{", "$", "result", "=", "array_values", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Filters elements with the given callback @param \Closure $callback @param boolean $reindex Reset indexes @return array
[ "Filters", "elements", "with", "the", "given", "callback" ]
6635b2a7d5feeb7c8627a1a50a871220b1861024
https://github.com/emaphp/omocha/blob/6635b2a7d5feeb7c8627a1a50a871220b1861024/lib/AnnotationBag.php#L141-L149
train
gplcart/base
Main.php
Main.checkRequiredModules
protected function checkRequiredModules(array $data, &$result) { if ($data['installer'] === 'base' && empty($data['step']) && !$this->getModel()->hasAllRequiredModules()) { $result = array( 'redirect' => '', 'severity' => 'warning', 'message' => gplcart_text('You cannot use this installer because some modules are missed in your distribution') ); } }
php
protected function checkRequiredModules(array $data, &$result) { if ($data['installer'] === 'base' && empty($data['step']) && !$this->getModel()->hasAllRequiredModules()) { $result = array( 'redirect' => '', 'severity' => 'warning', 'message' => gplcart_text('You cannot use this installer because some modules are missed in your distribution') ); } }
[ "protected", "function", "checkRequiredModules", "(", "array", "$", "data", ",", "&", "$", "result", ")", "{", "if", "(", "$", "data", "[", "'installer'", "]", "===", "'base'", "&&", "empty", "(", "$", "data", "[", "'step'", "]", ")", "&&", "!", "$", "this", "->", "getModel", "(", ")", "->", "hasAllRequiredModules", "(", ")", ")", "{", "$", "result", "=", "array", "(", "'redirect'", "=>", "''", ",", "'severity'", "=>", "'warning'", ",", "'message'", "=>", "gplcart_text", "(", "'You cannot use this installer because some modules are missed in your distribution'", ")", ")", ";", "}", "}" ]
Check if all required modules in place @param array $data @param array $result
[ "Check", "if", "all", "required", "modules", "in", "place" ]
bbcd87604d25333a0a1b84d79299fa06ec5dd39e
https://github.com/gplcart/base/blob/bbcd87604d25333a0a1b84d79299fa06ec5dd39e/Main.php#L104-L116
train
factorio-item-browser/api-client
src/Exception/ExceptionFactory.php
ExceptionFactory.create
public static function create( int $statusCode, string $message, string $request, string $response ): ApiClientException { switch ($statusCode) { case 400: $exception = new BadRequestException($message, $request, $response); break; case 401: $exception = new UnauthorizedException($message, $request, $response); break; case 403: $exception = new ForbiddenException($message, $request, $response); break; case 404: $exception = new NotFoundException($message, $request, $response); break; default: $exception = new ApiClientException($message, $statusCode, $request, $response); break; } return $exception; }
php
public static function create( int $statusCode, string $message, string $request, string $response ): ApiClientException { switch ($statusCode) { case 400: $exception = new BadRequestException($message, $request, $response); break; case 401: $exception = new UnauthorizedException($message, $request, $response); break; case 403: $exception = new ForbiddenException($message, $request, $response); break; case 404: $exception = new NotFoundException($message, $request, $response); break; default: $exception = new ApiClientException($message, $statusCode, $request, $response); break; } return $exception; }
[ "public", "static", "function", "create", "(", "int", "$", "statusCode", ",", "string", "$", "message", ",", "string", "$", "request", ",", "string", "$", "response", ")", ":", "ApiClientException", "{", "switch", "(", "$", "statusCode", ")", "{", "case", "400", ":", "$", "exception", "=", "new", "BadRequestException", "(", "$", "message", ",", "$", "request", ",", "$", "response", ")", ";", "break", ";", "case", "401", ":", "$", "exception", "=", "new", "UnauthorizedException", "(", "$", "message", ",", "$", "request", ",", "$", "response", ")", ";", "break", ";", "case", "403", ":", "$", "exception", "=", "new", "ForbiddenException", "(", "$", "message", ",", "$", "request", ",", "$", "response", ")", ";", "break", ";", "case", "404", ":", "$", "exception", "=", "new", "NotFoundException", "(", "$", "message", ",", "$", "request", ",", "$", "response", ")", ";", "break", ";", "default", ":", "$", "exception", "=", "new", "ApiClientException", "(", "$", "message", ",", "$", "statusCode", ",", "$", "request", ",", "$", "response", ")", ";", "break", ";", "}", "return", "$", "exception", ";", "}" ]
Creates the exception corresponding to the specified status code. @param int $statusCode @param string $message @param string $request @param string $response @return ApiClientException
[ "Creates", "the", "exception", "corresponding", "to", "the", "specified", "status", "code", "." ]
ebda897483bd537c310a17ff868ca40c0568f728
https://github.com/factorio-item-browser/api-client/blob/ebda897483bd537c310a17ff868ca40c0568f728/src/Exception/ExceptionFactory.php#L23-L47
train
danhanly/signalert
src/Signalert/Storage/SessionDriver.php
SessionDriver.store
public function store($message, $bucket) { // Get current messages for bucket $messages = $this->fetch($bucket); // Check current message does not exist if (true === in_array($message, $messages)) { // If message already exists, do not add the duplicate return false; } // Add message to stack $messages[] = $message; // Return the message stack to the session $_SESSION[self::ROOT_NODE][$bucket] = $messages; // Report Success return true; }
php
public function store($message, $bucket) { // Get current messages for bucket $messages = $this->fetch($bucket); // Check current message does not exist if (true === in_array($message, $messages)) { // If message already exists, do not add the duplicate return false; } // Add message to stack $messages[] = $message; // Return the message stack to the session $_SESSION[self::ROOT_NODE][$bucket] = $messages; // Report Success return true; }
[ "public", "function", "store", "(", "$", "message", ",", "$", "bucket", ")", "{", "// Get current messages for bucket", "$", "messages", "=", "$", "this", "->", "fetch", "(", "$", "bucket", ")", ";", "// Check current message does not exist", "if", "(", "true", "===", "in_array", "(", "$", "message", ",", "$", "messages", ")", ")", "{", "// If message already exists, do not add the duplicate", "return", "false", ";", "}", "// Add message to stack", "$", "messages", "[", "]", "=", "$", "message", ";", "// Return the message stack to the session", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", "=", "$", "messages", ";", "// Report Success", "return", "true", ";", "}" ]
Store the notifications using the driver @param string $message @param string $bucket @return bool
[ "Store", "the", "notifications", "using", "the", "driver" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Storage/SessionDriver.php#L19-L34
train
danhanly/signalert
src/Signalert/Storage/SessionDriver.php
SessionDriver.fetch
public function fetch($bucket, $flush = true) { // Ensure that the root node exists if (true === empty($_SESSION[self::ROOT_NODE])) { $_SESSION[self::ROOT_NODE] = []; } // Ensure that the bucket exists if (true === empty($_SESSION[self::ROOT_NODE][$bucket])) { $_SESSION[self::ROOT_NODE][$bucket] = []; } // Get the messages for the bucket $messages = $_SESSION[self::ROOT_NODE][$bucket]; // Flush the messages if applicable if (true === $flush) { $this->flush($bucket); } // Return the messages as an array return $messages; }
php
public function fetch($bucket, $flush = true) { // Ensure that the root node exists if (true === empty($_SESSION[self::ROOT_NODE])) { $_SESSION[self::ROOT_NODE] = []; } // Ensure that the bucket exists if (true === empty($_SESSION[self::ROOT_NODE][$bucket])) { $_SESSION[self::ROOT_NODE][$bucket] = []; } // Get the messages for the bucket $messages = $_SESSION[self::ROOT_NODE][$bucket]; // Flush the messages if applicable if (true === $flush) { $this->flush($bucket); } // Return the messages as an array return $messages; }
[ "public", "function", "fetch", "(", "$", "bucket", ",", "$", "flush", "=", "true", ")", "{", "// Ensure that the root node exists", "if", "(", "true", "===", "empty", "(", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", ")", ")", "{", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "=", "[", "]", ";", "}", "// Ensure that the bucket exists", "if", "(", "true", "===", "empty", "(", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", ")", ")", "{", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", "=", "[", "]", ";", "}", "// Get the messages for the bucket", "$", "messages", "=", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", ";", "// Flush the messages if applicable", "if", "(", "true", "===", "$", "flush", ")", "{", "$", "this", "->", "flush", "(", "$", "bucket", ")", ";", "}", "// Return the messages as an array", "return", "$", "messages", ";", "}" ]
Fetch the notifications from the driver @param string $bucket @param bool $flush @return array
[ "Fetch", "the", "notifications", "from", "the", "driver" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Storage/SessionDriver.php#L43-L61
train
danhanly/signalert
src/Signalert/Storage/SessionDriver.php
SessionDriver.flush
public function flush($bucket) { if (false === empty($_SESSION[self::ROOT_NODE][$bucket])) { $_SESSION[self::ROOT_NODE][$bucket] = []; return true; } return false; }
php
public function flush($bucket) { if (false === empty($_SESSION[self::ROOT_NODE][$bucket])) { $_SESSION[self::ROOT_NODE][$bucket] = []; return true; } return false; }
[ "public", "function", "flush", "(", "$", "bucket", ")", "{", "if", "(", "false", "===", "empty", "(", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", ")", ")", "{", "$", "_SESSION", "[", "self", "::", "ROOT_NODE", "]", "[", "$", "bucket", "]", "=", "[", "]", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Flush all notifications from the driver @param string $bucket @return bool
[ "Flush", "all", "notifications", "from", "the", "driver" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Storage/SessionDriver.php#L69-L77
train
brick/validation
src/AbstractValidator.php
AbstractValidator.addFailureMessage
final protected function addFailureMessage(string $messageKey) : void { $messages = $this->getPossibleMessages(); if (! isset($messages[$messageKey])) { throw new \RuntimeException('Unknown message key: ' . $messageKey); } $this->failureMessages[$messageKey] = $messages[$messageKey]; }
php
final protected function addFailureMessage(string $messageKey) : void { $messages = $this->getPossibleMessages(); if (! isset($messages[$messageKey])) { throw new \RuntimeException('Unknown message key: ' . $messageKey); } $this->failureMessages[$messageKey] = $messages[$messageKey]; }
[ "final", "protected", "function", "addFailureMessage", "(", "string", "$", "messageKey", ")", ":", "void", "{", "$", "messages", "=", "$", "this", "->", "getPossibleMessages", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "messages", "[", "$", "messageKey", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Unknown message key: '", ".", "$", "messageKey", ")", ";", "}", "$", "this", "->", "failureMessages", "[", "$", "messageKey", "]", "=", "$", "messages", "[", "$", "messageKey", "]", ";", "}" ]
Adds a failure message. @param string $messageKey The message key. @return void @throws \RuntimeException If the message key is unknown.
[ "Adds", "a", "failure", "message", "." ]
b33593f75df80530417007bde97c4772807563ab
https://github.com/brick/validation/blob/b33593f75df80530417007bde97c4772807563ab/src/AbstractValidator.php#L47-L56
train
alekitto/metadata
lib/Factory/AbstractMetadataFactory.php
AbstractMetadataFactory.dispatchClassMetadataLoadedEvent
protected function dispatchClassMetadataLoadedEvent(ClassMetadataInterface $classMetadata): void { if (null === $this->eventDispatcher) { return; } $this->eventDispatcher->dispatch( ClassMetadataLoadedEvent::LOADED_EVENT, new ClassMetadataLoadedEvent($classMetadata) ); }
php
protected function dispatchClassMetadataLoadedEvent(ClassMetadataInterface $classMetadata): void { if (null === $this->eventDispatcher) { return; } $this->eventDispatcher->dispatch( ClassMetadataLoadedEvent::LOADED_EVENT, new ClassMetadataLoadedEvent($classMetadata) ); }
[ "protected", "function", "dispatchClassMetadataLoadedEvent", "(", "ClassMetadataInterface", "$", "classMetadata", ")", ":", "void", "{", "if", "(", "null", "===", "$", "this", "->", "eventDispatcher", ")", "{", "return", ";", "}", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ClassMetadataLoadedEvent", "::", "LOADED_EVENT", ",", "new", "ClassMetadataLoadedEvent", "(", "$", "classMetadata", ")", ")", ";", "}" ]
Dispatches a class metadata loaded event for the given class. @param ClassMetadataInterface $classMetadata
[ "Dispatches", "a", "class", "metadata", "loaded", "event", "for", "the", "given", "class", "." ]
0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/AbstractMetadataFactory.php#L137-L147
train
alekitto/metadata
lib/Factory/AbstractMetadataFactory.php
AbstractMetadataFactory.getFromCache
private function getFromCache(string $class): ?ClassMetadataInterface { if (null === $this->cache) { return null; } if ($this->cache instanceof Cache) { $cached = $this->cache->fetch($class) ?: null; } else { $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class)); $item = $this->cache->getItem($class); $cached = $item->isHit() ? $item->get() : null; } return $cached; }
php
private function getFromCache(string $class): ?ClassMetadataInterface { if (null === $this->cache) { return null; } if ($this->cache instanceof Cache) { $cached = $this->cache->fetch($class) ?: null; } else { $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class)); $item = $this->cache->getItem($class); $cached = $item->isHit() ? $item->get() : null; } return $cached; }
[ "private", "function", "getFromCache", "(", "string", "$", "class", ")", ":", "?", "ClassMetadataInterface", "{", "if", "(", "null", "===", "$", "this", "->", "cache", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "cache", "instanceof", "Cache", ")", "{", "$", "cached", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "class", ")", "?", ":", "null", ";", "}", "else", "{", "$", "class", "=", "preg_replace", "(", "'#[\\{\\}\\(\\)/\\\\\\\\@:]#'", ",", "'_'", ",", "str_replace", "(", "'_'", ",", "'__'", ",", "$", "class", ")", ")", ";", "$", "item", "=", "$", "this", "->", "cache", "->", "getItem", "(", "$", "class", ")", ";", "$", "cached", "=", "$", "item", "->", "isHit", "(", ")", "?", "$", "item", "->", "get", "(", ")", ":", "null", ";", "}", "return", "$", "cached", ";", "}" ]
Check a cache pool for cached metadata. @param string $class @return null|ClassMetadataInterface
[ "Check", "a", "cache", "pool", "for", "cached", "metadata", "." ]
0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/AbstractMetadataFactory.php#L156-L171
train
alekitto/metadata
lib/Factory/AbstractMetadataFactory.php
AbstractMetadataFactory.saveInCache
private function saveInCache(string $class, ClassMetadataInterface $classMetadata): void { if (null === $this->cache) { return; } if ($this->cache instanceof Cache) { $this->cache->save($class, $classMetadata); } else { $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class)); $item = $this->cache->getItem($class); $item->set($classMetadata); $this->cache->save($item); } }
php
private function saveInCache(string $class, ClassMetadataInterface $classMetadata): void { if (null === $this->cache) { return; } if ($this->cache instanceof Cache) { $this->cache->save($class, $classMetadata); } else { $class = preg_replace('#[\{\}\(\)/\\\\@:]#', '_', str_replace('_', '__', $class)); $item = $this->cache->getItem($class); $item->set($classMetadata); $this->cache->save($item); } }
[ "private", "function", "saveInCache", "(", "string", "$", "class", ",", "ClassMetadataInterface", "$", "classMetadata", ")", ":", "void", "{", "if", "(", "null", "===", "$", "this", "->", "cache", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "cache", "instanceof", "Cache", ")", "{", "$", "this", "->", "cache", "->", "save", "(", "$", "class", ",", "$", "classMetadata", ")", ";", "}", "else", "{", "$", "class", "=", "preg_replace", "(", "'#[\\{\\}\\(\\)/\\\\\\\\@:]#'", ",", "'_'", ",", "str_replace", "(", "'_'", ",", "'__'", ",", "$", "class", ")", ")", ";", "$", "item", "=", "$", "this", "->", "cache", "->", "getItem", "(", "$", "class", ")", ";", "$", "item", "->", "set", "(", "$", "classMetadata", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "item", ")", ";", "}", "}" ]
Saves a metadata into a cache pool. @param string $class @param ClassMetadataInterface $classMetadata
[ "Saves", "a", "metadata", "into", "a", "cache", "pool", "." ]
0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/AbstractMetadataFactory.php#L179-L194
train
alekitto/metadata
lib/Factory/AbstractMetadataFactory.php
AbstractMetadataFactory.getClass
private function getClass($value) { if (! is_object($value) && ! is_string($value)) { return false; } if (is_object($value)) { $value = get_class($value); } return ltrim($value, '\\'); }
php
private function getClass($value) { if (! is_object($value) && ! is_string($value)) { return false; } if (is_object($value)) { $value = get_class($value); } return ltrim($value, '\\'); }
[ "private", "function", "getClass", "(", "$", "value", ")", "{", "if", "(", "!", "is_object", "(", "$", "value", ")", "&&", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "get_class", "(", "$", "value", ")", ";", "}", "return", "ltrim", "(", "$", "value", ",", "'\\\\'", ")", ";", "}" ]
Get the class name from a string or an object. @param string|object $value @return string|bool
[ "Get", "the", "class", "name", "from", "a", "string", "or", "an", "object", "." ]
0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/AbstractMetadataFactory.php#L203-L214
train
easy-system/es-loader
src/ClassLoader.php
ClassLoader.register
public function register() { if (! $this->isRegistered) { spl_autoload_register([$this, 'load'], true, true); $this->isRegistered = true; } return $this; }
php
public function register() { if (! $this->isRegistered) { spl_autoload_register([$this, 'load'], true, true); $this->isRegistered = true; } return $this; }
[ "public", "function", "register", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isRegistered", ")", "{", "spl_autoload_register", "(", "[", "$", "this", ",", "'load'", "]", ",", "true", ",", "true", ")", ";", "$", "this", "->", "isRegistered", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Register the autoloader with spl_autoload. @return self
[ "Register", "the", "autoloader", "with", "spl_autoload", "." ]
4525867ab14e516b7837bbe1e5632ef3cbb3ffff
https://github.com/easy-system/es-loader/blob/4525867ab14e516b7837bbe1e5632ef3cbb3ffff/src/ClassLoader.php#L59-L67
train
easy-system/es-loader
src/ClassLoader.php
ClassLoader.registerPath
public function registerPath($namespace, $path, $prepend = false) { $namespace = Normalizer::ns($namespace, true); $index = substr($namespace, 0, 4); $this->indexes[$index] = true; $path = Normalizer::path($path, true); if (! isset($this->paths[$namespace])) { $this->paths[$namespace] = []; } if ($prepend) { array_unshift($this->paths[$namespace], $path); return $this; } array_push($this->paths[$namespace], $path); return $this; }
php
public function registerPath($namespace, $path, $prepend = false) { $namespace = Normalizer::ns($namespace, true); $index = substr($namespace, 0, 4); $this->indexes[$index] = true; $path = Normalizer::path($path, true); if (! isset($this->paths[$namespace])) { $this->paths[$namespace] = []; } if ($prepend) { array_unshift($this->paths[$namespace], $path); return $this; } array_push($this->paths[$namespace], $path); return $this; }
[ "public", "function", "registerPath", "(", "$", "namespace", ",", "$", "path", ",", "$", "prepend", "=", "false", ")", "{", "$", "namespace", "=", "Normalizer", "::", "ns", "(", "$", "namespace", ",", "true", ")", ";", "$", "index", "=", "substr", "(", "$", "namespace", ",", "0", ",", "4", ")", ";", "$", "this", "->", "indexes", "[", "$", "index", "]", "=", "true", ";", "$", "path", "=", "Normalizer", "::", "path", "(", "$", "path", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "paths", "[", "$", "namespace", "]", ")", ")", "{", "$", "this", "->", "paths", "[", "$", "namespace", "]", "=", "[", "]", ";", "}", "if", "(", "$", "prepend", ")", "{", "array_unshift", "(", "$", "this", "->", "paths", "[", "$", "namespace", "]", ",", "$", "path", ")", ";", "return", "$", "this", ";", "}", "array_push", "(", "$", "this", "->", "paths", "[", "$", "namespace", "]", ",", "$", "path", ")", ";", "return", "$", "this", ";", "}" ]
Registers a PSR-4 directory for a given namespace. @param string $namespace The namespace @param string $path The PSR-4 root directory @param bool $prepend Whether to prepend the directories @return self
[ "Registers", "a", "PSR", "-", "4", "directory", "for", "a", "given", "namespace", "." ]
4525867ab14e516b7837bbe1e5632ef3cbb3ffff
https://github.com/easy-system/es-loader/blob/4525867ab14e516b7837bbe1e5632ef3cbb3ffff/src/ClassLoader.php#L117-L137
train
easy-system/es-loader
src/ClassLoader.php
ClassLoader.addClassMap
public function addClassMap(array $map) { if (empty($this->classMap)) { $this->classMap = $map; return $this; } $this->classMap = array_merge($this->classMap, $map); return $this; }
php
public function addClassMap(array $map) { if (empty($this->classMap)) { $this->classMap = $map; return $this; } $this->classMap = array_merge($this->classMap, $map); return $this; }
[ "public", "function", "addClassMap", "(", "array", "$", "map", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "classMap", ")", ")", "{", "$", "this", "->", "classMap", "=", "$", "map", ";", "return", "$", "this", ";", "}", "$", "this", "->", "classMap", "=", "array_merge", "(", "$", "this", "->", "classMap", ",", "$", "map", ")", ";", "return", "$", "this", ";", "}" ]
Adds the map of classes. @param array $map The map of classes @return self
[ "Adds", "the", "map", "of", "classes", "." ]
4525867ab14e516b7837bbe1e5632ef3cbb3ffff
https://github.com/easy-system/es-loader/blob/4525867ab14e516b7837bbe1e5632ef3cbb3ffff/src/ClassLoader.php#L157-L167
train
easy-system/es-loader
src/ClassLoader.php
ClassLoader.findFile
public function findFile($class) { $class = Normalizer::ns($class, false); if (isset($this->classMap[$class])) { return $this->classMap[$class]; } $index = substr($class, 0, 4); if (isset($this->indexes[$index])) { $namespace = $class; while (false !== $pos = strrpos($namespace, '\\')) { $namespace = substr($class, 0, $pos + 1); if (! isset($this->paths[$namespace])) { $namespace = rtrim($namespace, '\\'); continue; } $subclass = substr($class, $pos + 1); $subpath = Normalizer::path($subclass, false) . '.php'; foreach ($this->paths[$namespace] as $dir) { $path = $dir . $subpath; if (is_readable($path)) { if ($this->classRegistration) { $this->classMap[$class] = $path; } return $path; } } $namespace = rtrim($namespace, '\\'); } } if ($this->classRegistration) { $this->classMap[$class] = false; } return false; }
php
public function findFile($class) { $class = Normalizer::ns($class, false); if (isset($this->classMap[$class])) { return $this->classMap[$class]; } $index = substr($class, 0, 4); if (isset($this->indexes[$index])) { $namespace = $class; while (false !== $pos = strrpos($namespace, '\\')) { $namespace = substr($class, 0, $pos + 1); if (! isset($this->paths[$namespace])) { $namespace = rtrim($namespace, '\\'); continue; } $subclass = substr($class, $pos + 1); $subpath = Normalizer::path($subclass, false) . '.php'; foreach ($this->paths[$namespace] as $dir) { $path = $dir . $subpath; if (is_readable($path)) { if ($this->classRegistration) { $this->classMap[$class] = $path; } return $path; } } $namespace = rtrim($namespace, '\\'); } } if ($this->classRegistration) { $this->classMap[$class] = false; } return false; }
[ "public", "function", "findFile", "(", "$", "class", ")", "{", "$", "class", "=", "Normalizer", "::", "ns", "(", "$", "class", ",", "false", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "classMap", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "classMap", "[", "$", "class", "]", ";", "}", "$", "index", "=", "substr", "(", "$", "class", ",", "0", ",", "4", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "indexes", "[", "$", "index", "]", ")", ")", "{", "$", "namespace", "=", "$", "class", ";", "while", "(", "false", "!==", "$", "pos", "=", "strrpos", "(", "$", "namespace", ",", "'\\\\'", ")", ")", "{", "$", "namespace", "=", "substr", "(", "$", "class", ",", "0", ",", "$", "pos", "+", "1", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "paths", "[", "$", "namespace", "]", ")", ")", "{", "$", "namespace", "=", "rtrim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "continue", ";", "}", "$", "subclass", "=", "substr", "(", "$", "class", ",", "$", "pos", "+", "1", ")", ";", "$", "subpath", "=", "Normalizer", "::", "path", "(", "$", "subclass", ",", "false", ")", ".", "'.php'", ";", "foreach", "(", "$", "this", "->", "paths", "[", "$", "namespace", "]", "as", "$", "dir", ")", "{", "$", "path", "=", "$", "dir", ".", "$", "subpath", ";", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "if", "(", "$", "this", "->", "classRegistration", ")", "{", "$", "this", "->", "classMap", "[", "$", "class", "]", "=", "$", "path", ";", "}", "return", "$", "path", ";", "}", "}", "$", "namespace", "=", "rtrim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "}", "}", "if", "(", "$", "this", "->", "classRegistration", ")", "{", "$", "this", "->", "classMap", "[", "$", "class", "]", "=", "false", ";", "}", "return", "false", ";", "}" ]
Finds the path to the file, that contains the specified class. @param string $class The fully-qualified class name @return string|false The path if found, false otherwise
[ "Finds", "the", "path", "to", "the", "file", "that", "contains", "the", "specified", "class", "." ]
4525867ab14e516b7837bbe1e5632ef3cbb3ffff
https://github.com/easy-system/es-loader/blob/4525867ab14e516b7837bbe1e5632ef3cbb3ffff/src/ClassLoader.php#L204-L240
train
as3io/modlr
src/Rest/RestConfiguration.php
RestConfiguration.setEntityFormat
public function setEntityFormat($format) { $this->validator->isFormatValid($format); $this->entityFormat = $format; return $this; }
php
public function setEntityFormat($format) { $this->validator->isFormatValid($format); $this->entityFormat = $format; return $this; }
[ "public", "function", "setEntityFormat", "(", "$", "format", ")", "{", "$", "this", "->", "validator", "->", "isFormatValid", "(", "$", "format", ")", ";", "$", "this", "->", "entityFormat", "=", "$", "format", ";", "return", "$", "this", ";", "}" ]
Sets the entity type format. @param string $format @return self
[ "Sets", "the", "entity", "type", "format", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestConfiguration.php#L109-L114
train
as3io/modlr
src/Rest/RestConfiguration.php
RestConfiguration.setFieldKeyFormat
public function setFieldKeyFormat($format) { $this->validator->isFormatValid($format); $this->fieldKeyFormat = $format; return $this; }
php
public function setFieldKeyFormat($format) { $this->validator->isFormatValid($format); $this->fieldKeyFormat = $format; return $this; }
[ "public", "function", "setFieldKeyFormat", "(", "$", "format", ")", "{", "$", "this", "->", "validator", "->", "isFormatValid", "(", "$", "format", ")", ";", "$", "this", "->", "fieldKeyFormat", "=", "$", "format", ";", "return", "$", "this", ";", "}" ]
Sets the field key format. @param string $format @return self
[ "Sets", "the", "field", "key", "format", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestConfiguration.php#L132-L137
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.getFeatures
public function getFeatures() { $featuresString = $this->storage->get($this->getFeaturesKey()); $features = explode(',', $featuresString); return $features; }
php
public function getFeatures() { $featuresString = $this->storage->get($this->getFeaturesKey()); $features = explode(',', $featuresString); return $features; }
[ "public", "function", "getFeatures", "(", ")", "{", "$", "featuresString", "=", "$", "this", "->", "storage", "->", "get", "(", "$", "this", "->", "getFeaturesKey", "(", ")", ")", ";", "$", "features", "=", "explode", "(", "','", ",", "$", "featuresString", ")", ";", "return", "$", "features", ";", "}" ]
Get all feature names @return string[]
[ "Get", "all", "feature", "names" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L45-L50
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.saveFeature
protected function saveFeature(RolloutableInterface $feature) { $this->storage->set($this->getKey($feature->getName()), (string)$feature); $features = $this->getFeatures(); if (false === in_array($feature->getName(), $features)) { $features[] = $feature->getName(); } $this->storage->set($this->getFeaturesKey(), implode(',', $features)); }
php
protected function saveFeature(RolloutableInterface $feature) { $this->storage->set($this->getKey($feature->getName()), (string)$feature); $features = $this->getFeatures(); if (false === in_array($feature->getName(), $features)) { $features[] = $feature->getName(); } $this->storage->set($this->getFeaturesKey(), implode(',', $features)); }
[ "protected", "function", "saveFeature", "(", "RolloutableInterface", "$", "feature", ")", "{", "$", "this", "->", "storage", "->", "set", "(", "$", "this", "->", "getKey", "(", "$", "feature", "->", "getName", "(", ")", ")", ",", "(", "string", ")", "$", "feature", ")", ";", "$", "features", "=", "$", "this", "->", "getFeatures", "(", ")", ";", "if", "(", "false", "===", "in_array", "(", "$", "feature", "->", "getName", "(", ")", ",", "$", "features", ")", ")", "{", "$", "features", "[", "]", "=", "$", "feature", "->", "getName", "(", ")", ";", "}", "$", "this", "->", "storage", "->", "set", "(", "$", "this", "->", "getFeaturesKey", "(", ")", ",", "implode", "(", "','", ",", "$", "features", ")", ")", ";", "}" ]
Saves a feature to the storage @param RolloutableInterface $feature
[ "Saves", "a", "feature", "to", "the", "storage" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L56-L64
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.activateRole
public function activateRole($featureName, $roleName) { $feature = $this->getFeature($featureName); $feature->addRole($roleName); $this->saveFeature($feature); }
php
public function activateRole($featureName, $roleName) { $feature = $this->getFeature($featureName); $feature->addRole($roleName); $this->saveFeature($feature); }
[ "public", "function", "activateRole", "(", "$", "featureName", ",", "$", "roleName", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "addRole", "(", "$", "roleName", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Activates a feature for a specific role @param string $featureName @param string $roleName
[ "Activates", "a", "feature", "for", "a", "specific", "role" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L112-L117
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.deactivateRole
public function deactivateRole($featureName, $roleName) { $feature = $this->getFeature($featureName); $feature->removeRole($roleName); $this->saveFeature($feature); }
php
public function deactivateRole($featureName, $roleName) { $feature = $this->getFeature($featureName); $feature->removeRole($roleName); $this->saveFeature($feature); }
[ "public", "function", "deactivateRole", "(", "$", "featureName", ",", "$", "roleName", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "removeRole", "(", "$", "roleName", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Deactivates a feature for a specific role. @param string $featureName @param string $roleName
[ "Deactivates", "a", "feature", "for", "a", "specific", "role", "." ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L124-L129
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.activateGroup
public function activateGroup($featureName, $groupName) { $feature = $this->getFeature($featureName); $feature->addGroup($groupName); $this->saveFeature($feature); }
php
public function activateGroup($featureName, $groupName) { $feature = $this->getFeature($featureName); $feature->addGroup($groupName); $this->saveFeature($feature); }
[ "public", "function", "activateGroup", "(", "$", "featureName", ",", "$", "groupName", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "addGroup", "(", "$", "groupName", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Activates a feature for a specific group @param string $featureName @param string $groupName
[ "Activates", "a", "feature", "for", "a", "specific", "group" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L136-L141
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.deactivateGroup
public function deactivateGroup($featureName, $groupName) { $feature = $this->getFeature($featureName); $feature->removeGroup($groupName); $this->saveFeature($feature); }
php
public function deactivateGroup($featureName, $groupName) { $feature = $this->getFeature($featureName); $feature->removeGroup($groupName); $this->saveFeature($feature); }
[ "public", "function", "deactivateGroup", "(", "$", "featureName", ",", "$", "groupName", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "removeGroup", "(", "$", "groupName", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Deactivates a feature for a specific group. @param string $featureName @param string $groupName
[ "Deactivates", "a", "feature", "for", "a", "specific", "group", "." ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L148-L153
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.activateUser
public function activateUser($featureName, $userId) { $feature = $this->getFeature($featureName); $feature->addUser($userId); $this->saveFeature($feature); }
php
public function activateUser($featureName, $userId) { $feature = $this->getFeature($featureName); $feature->addUser($userId); $this->saveFeature($feature); }
[ "public", "function", "activateUser", "(", "$", "featureName", ",", "$", "userId", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "addUser", "(", "$", "userId", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Activates a feature for a specific user @param string $featureName @param integer $userId
[ "Activates", "a", "feature", "for", "a", "specific", "user" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L160-L165
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.deactivateUser
public function deactivateUser($featureName, $userId) { $feature = $this->getFeature($featureName); $feature->removeUser($userId); $this->saveFeature($feature); }
php
public function deactivateUser($featureName, $userId) { $feature = $this->getFeature($featureName); $feature->removeUser($userId); $this->saveFeature($feature); }
[ "public", "function", "deactivateUser", "(", "$", "featureName", ",", "$", "userId", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "removeUser", "(", "$", "userId", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Deactivates a feature for a specific user @param string $featureName @param integer $userId
[ "Deactivates", "a", "feature", "for", "a", "specific", "user" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L172-L177
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.activatePercentage
public function activatePercentage($featureName, $percentage) { $feature = $this->getFeature($featureName); $feature->setPercentage($percentage); $this->saveFeature($feature); }
php
public function activatePercentage($featureName, $percentage) { $feature = $this->getFeature($featureName); $feature->setPercentage($percentage); $this->saveFeature($feature); }
[ "public", "function", "activatePercentage", "(", "$", "featureName", ",", "$", "percentage", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "setPercentage", "(", "$", "percentage", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Activates a feature for a percentage of users @param string $featureName @param integer $percentage
[ "Activates", "a", "feature", "for", "a", "percentage", "of", "users" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L184-L189
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.deactivatePercentage
public function deactivatePercentage($featureName) { $feature = $this->getFeature($featureName); $feature->setPercentage(0); $this->saveFeature($feature); }
php
public function deactivatePercentage($featureName) { $feature = $this->getFeature($featureName); $feature->setPercentage(0); $this->saveFeature($feature); }
[ "public", "function", "deactivatePercentage", "(", "$", "featureName", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "$", "feature", "->", "setPercentage", "(", "0", ")", ";", "$", "this", "->", "saveFeature", "(", "$", "feature", ")", ";", "}" ]
Deactivates the percentage activation for a feature @param string $featureName
[ "Deactivates", "the", "percentage", "activation", "for", "a", "feature" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L195-L200
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.isActive
public function isActive($featureName, DeterminableUserInterface $user = null) { $feature = $this->getFeature($featureName); return $feature->isActive($this, $user); }
php
public function isActive($featureName, DeterminableUserInterface $user = null) { $feature = $this->getFeature($featureName); return $feature->isActive($this, $user); }
[ "public", "function", "isActive", "(", "$", "featureName", ",", "DeterminableUserInterface", "$", "user", "=", "null", ")", "{", "$", "feature", "=", "$", "this", "->", "getFeature", "(", "$", "featureName", ")", ";", "return", "$", "feature", "->", "isActive", "(", "$", "this", ",", "$", "user", ")", ";", "}" ]
Checks if a feature is active @param string $featureName @param DeterminableUserInterface $user @return bool
[ "Checks", "if", "a", "feature", "is", "active" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L208-L212
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.userHasRole
public function userHasRole($roleName, DeterminableUserInterface $user) { $userHasRole = false; if (true === in_array($roleName, $user->getRoles())) { $userHasRole = true; } return $userHasRole; }
php
public function userHasRole($roleName, DeterminableUserInterface $user) { $userHasRole = false; if (true === in_array($roleName, $user->getRoles())) { $userHasRole = true; } return $userHasRole; }
[ "public", "function", "userHasRole", "(", "$", "roleName", ",", "DeterminableUserInterface", "$", "user", ")", "{", "$", "userHasRole", "=", "false", ";", "if", "(", "true", "===", "in_array", "(", "$", "roleName", ",", "$", "user", "->", "getRoles", "(", ")", ")", ")", "{", "$", "userHasRole", "=", "true", ";", "}", "return", "$", "userHasRole", ";", "}" ]
Checks if a user has the given role @param string $roleName @param DeterminableUserInterface $user @return bool
[ "Checks", "if", "a", "user", "has", "the", "given", "role" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L220-L227
train
DarkGigaByte/rollout
src/DarkGigaByte/Rollout/RolloutAbstract.php
RolloutAbstract.userHasGroup
public function userHasGroup($groupName, DeterminableUserInterface $user) { $userHasGroup = false; if (true === in_array($groupName, $user->getGroups())) { $userHasGroup = true; } return $userHasGroup; }
php
public function userHasGroup($groupName, DeterminableUserInterface $user) { $userHasGroup = false; if (true === in_array($groupName, $user->getGroups())) { $userHasGroup = true; } return $userHasGroup; }
[ "public", "function", "userHasGroup", "(", "$", "groupName", ",", "DeterminableUserInterface", "$", "user", ")", "{", "$", "userHasGroup", "=", "false", ";", "if", "(", "true", "===", "in_array", "(", "$", "groupName", ",", "$", "user", "->", "getGroups", "(", ")", ")", ")", "{", "$", "userHasGroup", "=", "true", ";", "}", "return", "$", "userHasGroup", ";", "}" ]
Checks if a user has the given group @param string $groupName @param DeterminableUserInterface $user @return bool
[ "Checks", "if", "a", "user", "has", "the", "given", "group" ]
bff5f79df2211c9ebcfc35d4cba74daeeca19bcc
https://github.com/DarkGigaByte/rollout/blob/bff5f79df2211c9ebcfc35d4cba74daeeca19bcc/src/DarkGigaByte/Rollout/RolloutAbstract.php#L235-L242
train
pmdevelopment/tool-bundle
Framework/Utilities/CollectionUtility.php
CollectionUtility.isValid
public static function isValid($collection) { if (false === is_array($collection) && false === ($collection instanceof Collection)) { return false; } return true; }
php
public static function isValid($collection) { if (false === is_array($collection) && false === ($collection instanceof Collection)) { return false; } return true; }
[ "public", "static", "function", "isValid", "(", "$", "collection", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "collection", ")", "&&", "false", "===", "(", "$", "collection", "instanceof", "Collection", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is Valid Collection @param mixed $collection @return bool
[ "Is", "Valid", "Collection" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/Utilities/CollectionUtility.php#L28-L35
train
pmdevelopment/tool-bundle
Framework/Utilities/CollectionUtility.php
CollectionUtility.find
public static function find($collection, $id) { $id = intval($id); foreach ($collection as $entity) { if ($id === $entity->getId()) { return $entity; } } return null; }
php
public static function find($collection, $id) { $id = intval($id); foreach ($collection as $entity) { if ($id === $entity->getId()) { return $entity; } } return null; }
[ "public", "static", "function", "find", "(", "$", "collection", ",", "$", "id", ")", "{", "$", "id", "=", "intval", "(", "$", "id", ")", ";", "foreach", "(", "$", "collection", "as", "$", "entity", ")", "{", "if", "(", "$", "id", "===", "$", "entity", "->", "getId", "(", ")", ")", "{", "return", "$", "entity", ";", "}", "}", "return", "null", ";", "}" ]
Find By Id @param Collection|array $collection @param int $id @return null|object
[ "Find", "By", "Id" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/Utilities/CollectionUtility.php#L136-L146
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.directoryAction
public function directoryAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if ($dbfile->isFile()) { return $this->fileAction($this->getPath()); } $readme_content = $dir_content = ''; $index = $dbfile->findIndex(); if (file_exists($index)) { return $this->fileAction($index); } $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'dirscan' => $dbfile->getWDBScanStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $readme = $dbfile->findReadme(); if (file_exists($readme)) { $this->wdb->setInputFile($readme); $readme_dbfile = new WDBFile($readme); $readme_content = $readme_dbfile->viewFileInfos(); } $tpl_params['inpage_menu'] = !empty($readme_content) ? 'true' : 'false'; $dir_content = $this->wdb ->display('', 'dirindex', $tpl_params); return array('default', $dir_content.$readme_content, $tpl_params); }
php
public function directoryAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if ($dbfile->isFile()) { return $this->fileAction($this->getPath()); } $readme_content = $dir_content = ''; $index = $dbfile->findIndex(); if (file_exists($index)) { return $this->fileAction($index); } $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'dirscan' => $dbfile->getWDBScanStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $readme = $dbfile->findReadme(); if (file_exists($readme)) { $this->wdb->setInputFile($readme); $readme_dbfile = new WDBFile($readme); $readme_content = $readme_dbfile->viewFileInfos(); } $tpl_params['inpage_menu'] = !empty($readme_content) ? 'true' : 'false'; $dir_content = $this->wdb ->display('', 'dirindex', $tpl_params); return array('default', $dir_content.$readme_content, $tpl_params); }
[ "public", "function", "directoryAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "if", "(", "$", "dbfile", "->", "isFile", "(", ")", ")", "{", "return", "$", "this", "->", "fileAction", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "}", "$", "readme_content", "=", "$", "dir_content", "=", "''", ";", "$", "index", "=", "$", "dbfile", "->", "findIndex", "(", ")", ";", "if", "(", "file_exists", "(", "$", "index", ")", ")", "{", "return", "$", "this", "->", "fileAction", "(", "$", "index", ")", ";", "}", "$", "tpl_params", "=", "array", "(", "'page'", "=>", "$", "dbfile", "->", "getWDBFullStack", "(", ")", ",", "'dirscan'", "=>", "$", "dbfile", "->", "getWDBScanStack", "(", ")", ",", "'breadcrumbs'", "=>", "TemplateHelper", "::", "getBreadcrumbs", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", "'title'", "=>", "TemplateHelper", "::", "buildPageTitle", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", ")", ";", "if", "(", "empty", "(", "$", "tpl_params", "[", "'title'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", "{", "$", "tpl_params", "[", "'title'", "]", "=", "TemplateHelper", "::", "buildPageTitle", "(", "end", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", ";", "}", "else", "{", "$", "tpl_params", "[", "'title'", "]", "=", "_T", "(", "'Home'", ")", ";", "}", "}", "$", "readme", "=", "$", "dbfile", "->", "findReadme", "(", ")", ";", "if", "(", "file_exists", "(", "$", "readme", ")", ")", "{", "$", "this", "->", "wdb", "->", "setInputFile", "(", "$", "readme", ")", ";", "$", "readme_dbfile", "=", "new", "WDBFile", "(", "$", "readme", ")", ";", "$", "readme_content", "=", "$", "readme_dbfile", "->", "viewFileInfos", "(", ")", ";", "}", "$", "tpl_params", "[", "'inpage_menu'", "]", "=", "!", "empty", "(", "$", "readme_content", ")", "?", "'true'", ":", "'false'", ";", "$", "dir_content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'dirindex'", ",", "$", "tpl_params", ")", ";", "return", "array", "(", "'default'", ",", "$", "dir_content", ".", "$", "readme_content", ",", "$", "tpl_params", ")", ";", "}" ]
Directory path action @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "Directory", "path", "action" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L64-L110
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.fileAction
public function fileAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getPath()); if ($dbfile->isDir()) { return $this->directoryAction($this->getPath()); } $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $content = $dbfile->viewFileInfos($tpl_params); return array('default', $content, $tpl_params); }
php
public function fileAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getPath()); if ($dbfile->isDir()) { return $this->directoryAction($this->getPath()); } $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $content = $dbfile->viewFileInfos($tpl_params); return array('default', $content, $tpl_params); }
[ "public", "function", "fileAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "if", "(", "$", "dbfile", "->", "isDir", "(", ")", ")", "{", "return", "$", "this", "->", "directoryAction", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "}", "$", "tpl_params", "=", "array", "(", "'page'", "=>", "$", "dbfile", "->", "getWDBFullStack", "(", ")", ",", "'breadcrumbs'", "=>", "TemplateHelper", "::", "getBreadcrumbs", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", "'title'", "=>", "TemplateHelper", "::", "buildPageTitle", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", ")", ";", "if", "(", "empty", "(", "$", "tpl_params", "[", "'title'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", "{", "$", "tpl_params", "[", "'title'", "]", "=", "TemplateHelper", "::", "buildPageTitle", "(", "end", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", ";", "}", "else", "{", "$", "tpl_params", "[", "'title'", "]", "=", "_T", "(", "'Home'", ")", ";", "}", "}", "$", "content", "=", "$", "dbfile", "->", "viewFileInfos", "(", "$", "tpl_params", ")", ";", "return", "array", "(", "'default'", ",", "$", "content", ",", "$", "tpl_params", ")", ";", "}" ]
File path action @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "File", "path", "action" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L119-L149
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.rssFeedAction
public function rssFeedAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); $contents = array(); $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $this->wdb->getResponse()->setContentType('xml'); $page = $dbfile->getWDBStack(); if ($dbfile->isDir()) { $contents = Helper::getFlatDirscans($dbfile->getWDBScanStack(true), true); foreach ($contents['dirscan'] as $i=>$item) { if ($item['type']!=='dir' && file_exists($item['path'])) { $dbfile = new WDBFile($item['path']); $contents['dirscan'][$i]['content'] = $dbfile->viewIntroduction(4000, false); } } } else { $page['content'] = $dbfile->viewIntroduction(4000, false); } $rss_content = $this->wdb->display('', 'rss', array( 'page' => $page, 'contents' => $contents )); return array('layout_empty_xml', $rss_content); }
php
public function rssFeedAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); $contents = array(); $tpl_params = array( 'page' => $dbfile->getWDBFullStack(), 'breadcrumbs' => TemplateHelper::getBreadcrumbs($this->getPath()), 'title' => TemplateHelper::buildPageTitle($this->getPath()), ); if (empty($tpl_params['title'])) { if (!empty($tpl_params['breadcrumbs'])) { $tpl_params['title'] = TemplateHelper::buildPageTitle(end($tpl_params['breadcrumbs'])); } else { $tpl_params['title'] = _T('Home'); } } $this->wdb->getResponse()->setContentType('xml'); $page = $dbfile->getWDBStack(); if ($dbfile->isDir()) { $contents = Helper::getFlatDirscans($dbfile->getWDBScanStack(true), true); foreach ($contents['dirscan'] as $i=>$item) { if ($item['type']!=='dir' && file_exists($item['path'])) { $dbfile = new WDBFile($item['path']); $contents['dirscan'][$i]['content'] = $dbfile->viewIntroduction(4000, false); } } } else { $page['content'] = $dbfile->viewIntroduction(4000, false); } $rss_content = $this->wdb->display('', 'rss', array( 'page' => $page, 'contents' => $contents )); return array('layout_empty_xml', $rss_content); }
[ "public", "function", "rssFeedAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "$", "contents", "=", "array", "(", ")", ";", "$", "tpl_params", "=", "array", "(", "'page'", "=>", "$", "dbfile", "->", "getWDBFullStack", "(", ")", ",", "'breadcrumbs'", "=>", "TemplateHelper", "::", "getBreadcrumbs", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", "'title'", "=>", "TemplateHelper", "::", "buildPageTitle", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", ")", ";", "if", "(", "empty", "(", "$", "tpl_params", "[", "'title'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", "{", "$", "tpl_params", "[", "'title'", "]", "=", "TemplateHelper", "::", "buildPageTitle", "(", "end", "(", "$", "tpl_params", "[", "'breadcrumbs'", "]", ")", ")", ";", "}", "else", "{", "$", "tpl_params", "[", "'title'", "]", "=", "_T", "(", "'Home'", ")", ";", "}", "}", "$", "this", "->", "wdb", "->", "getResponse", "(", ")", "->", "setContentType", "(", "'xml'", ")", ";", "$", "page", "=", "$", "dbfile", "->", "getWDBStack", "(", ")", ";", "if", "(", "$", "dbfile", "->", "isDir", "(", ")", ")", "{", "$", "contents", "=", "Helper", "::", "getFlatDirscans", "(", "$", "dbfile", "->", "getWDBScanStack", "(", "true", ")", ",", "true", ")", ";", "foreach", "(", "$", "contents", "[", "'dirscan'", "]", "as", "$", "i", "=>", "$", "item", ")", "{", "if", "(", "$", "item", "[", "'type'", "]", "!==", "'dir'", "&&", "file_exists", "(", "$", "item", "[", "'path'", "]", ")", ")", "{", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "item", "[", "'path'", "]", ")", ";", "$", "contents", "[", "'dirscan'", "]", "[", "$", "i", "]", "[", "'content'", "]", "=", "$", "dbfile", "->", "viewIntroduction", "(", "4000", ",", "false", ")", ";", "}", "}", "}", "else", "{", "$", "page", "[", "'content'", "]", "=", "$", "dbfile", "->", "viewIntroduction", "(", "4000", ",", "false", ")", ";", "}", "$", "rss_content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'rss'", ",", "array", "(", "'page'", "=>", "$", "page", ",", "'contents'", "=>", "$", "contents", ")", ")", ";", "return", "array", "(", "'layout_empty_xml'", ",", "$", "rss_content", ")", ";", "}" ]
RSS action for concerned path @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "RSS", "action", "for", "concerned", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L158-L202
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.sitemapAction
public function sitemapAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isDir()) { throw new NotFoundException( 'Can not build a sitemap from a single file!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $this->wdb->getResponse()->setContentType('xml'); $contents = Helper::getFlatDirscans($dbfile->getWDBScanStack(true)); $rss_content = $this->wdb->display('', 'sitemap', array( 'page' => $dbfile->getWDBStack(), 'contents' => $contents )); return array('layout_empty_xml', $rss_content); }
php
public function sitemapAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isDir()) { throw new NotFoundException( 'Can not build a sitemap from a single file!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $this->wdb->getResponse()->setContentType('xml'); $contents = Helper::getFlatDirscans($dbfile->getWDBScanStack(true)); $rss_content = $this->wdb->display('', 'sitemap', array( 'page' => $dbfile->getWDBStack(), 'contents' => $contents )); return array('layout_empty_xml', $rss_content); }
[ "public", "function", "sitemapAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "if", "(", "!", "$", "dbfile", "->", "isDir", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Can not build a sitemap from a single file!'", ",", "0", ",", "null", ",", "TemplateHelper", "::", "getRoute", "(", "$", "dbfile", "->", "getWDBPath", "(", ")", ")", ")", ";", "}", "$", "this", "->", "wdb", "->", "getResponse", "(", ")", "->", "setContentType", "(", "'xml'", ")", ";", "$", "contents", "=", "Helper", "::", "getFlatDirscans", "(", "$", "dbfile", "->", "getWDBScanStack", "(", "true", ")", ")", ";", "$", "rss_content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'sitemap'", ",", "array", "(", "'page'", "=>", "$", "dbfile", "->", "getWDBStack", "(", ")", ",", "'contents'", "=>", "$", "contents", ")", ")", ";", "return", "array", "(", "'layout_empty_xml'", ",", "$", "rss_content", ")", ";", "}" ]
Sitemap action for a path @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "Sitemap", "action", "for", "a", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L211-L235
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.htmlOnlyAction
public function htmlOnlyAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $md_parser = $this->wdb->getMarkdownParser(); $md_content = $md_parser->transformSource($this->getPath()); return array('layout_empty_html', $md_content->getBody(), array('page_notes' => $md_content->getNotesToString()) ); }
php
public function htmlOnlyAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $md_parser = $this->wdb->getMarkdownParser(); $md_content = $md_parser->transformSource($this->getPath()); return array('layout_empty_html', $md_content->getBody(), array('page_notes' => $md_content->getNotesToString()) ); }
[ "public", "function", "htmlOnlyAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "if", "(", "!", "$", "dbfile", "->", "isFile", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Can not send raw content of a directory!'", ",", "0", ",", "null", ",", "TemplateHelper", "::", "getRoute", "(", "$", "dbfile", "->", "getWDBPath", "(", ")", ")", ")", ";", "}", "$", "md_parser", "=", "$", "this", "->", "wdb", "->", "getMarkdownParser", "(", ")", ";", "$", "md_content", "=", "$", "md_parser", "->", "transformSource", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "return", "array", "(", "'layout_empty_html'", ",", "$", "md_content", "->", "getBody", "(", ")", ",", "array", "(", "'page_notes'", "=>", "$", "md_content", "->", "getNotesToString", "(", ")", ")", ")", ";", "}" ]
HTML only version of a path @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "HTML", "only", "version", "of", "a", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L244-L266
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.plainTextAction
public function plainTextAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $response = $this->wdb->getResponse(); // mime header $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $this->getPath()); if ( ! in_array($mime, $response::$content_types)) { $mime = 'text/plain'; } finfo_close($finfo); // content $ctt = $response->flush(file_get_contents($this->getPath()), $mime); return array('layout_empty_txt', $ctt); }
php
public function plainTextAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $response = $this->wdb->getResponse(); // mime header $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $this->getPath()); if ( ! in_array($mime, $response::$content_types)) { $mime = 'text/plain'; } finfo_close($finfo); // content $ctt = $response->flush(file_get_contents($this->getPath()), $mime); return array('layout_empty_txt', $ctt); }
[ "public", "function", "plainTextAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "if", "(", "!", "$", "dbfile", "->", "isFile", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Can not send raw content of a directory!'", ",", "0", ",", "null", ",", "TemplateHelper", "::", "getRoute", "(", "$", "dbfile", "->", "getWDBPath", "(", ")", ")", ")", ";", "}", "$", "response", "=", "$", "this", "->", "wdb", "->", "getResponse", "(", ")", ";", "// mime header", "$", "finfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "mime", "=", "finfo_file", "(", "$", "finfo", ",", "$", "this", "->", "getPath", "(", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "mime", ",", "$", "response", "::", "$", "content_types", ")", ")", "{", "$", "mime", "=", "'text/plain'", ";", "}", "finfo_close", "(", "$", "finfo", ")", ";", "// content", "$", "ctt", "=", "$", "response", "->", "flush", "(", "file_get_contents", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", "$", "mime", ")", ";", "return", "array", "(", "'layout_empty_txt'", ",", "$", "ctt", ")", ";", "}" ]
Raw plain text action of a path @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "Raw", "plain", "text", "action", "of", "a", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L275-L304
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.downloadAction
public function downloadAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $this->wdb->getResponse() ->download($path, 'text/plain'); exit(0); }
php
public function downloadAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $dbfile = new WDBFile($this->getpath()); if (!$dbfile->isFile()) { throw new NotFoundException( 'Can not send raw content of a directory!', 0, null, TemplateHelper::getRoute($dbfile->getWDBPath()) ); } $this->wdb->getResponse() ->download($path, 'text/plain'); exit(0); }
[ "public", "function", "downloadAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "if", "(", "!", "$", "dbfile", "->", "isFile", "(", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Can not send raw content of a directory!'", ",", "0", ",", "null", ",", "TemplateHelper", "::", "getRoute", "(", "$", "dbfile", "->", "getWDBPath", "(", ")", ")", ")", ";", "}", "$", "this", "->", "wdb", "->", "getResponse", "(", ")", "->", "download", "(", "$", "path", ",", "'text/plain'", ")", ";", "exit", "(", "0", ")", ";", "}" ]
Download action of a path @param string $path @throws \WebDocBook\Exception\NotFoundException
[ "Download", "action", "of", "a", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L312-L331
train
wdbo/webdocbook
src/WebDocBook/Controller/DefaultController.php
DefaultController.searchAction
public function searchAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $search = $this->wdb->getRequest()->getArgument('s'); if (empty($search)) { return $this->indexAction($path); } $_s = Helper::makeSearch($search, $this->getPath()); $title = _T('Search for "%search_str%"', array('search_str'=>$search)); $breadcrumbs = TemplateHelper::getBreadcrumbs($this->getPath()); $breadcrumbs[] = $title; $dbfile = new WDBFile($this->getpath()); $page = $dbfile->getWDBStack(); $page['type'] = 'search'; $tpl_params = array( 'page' => $page, 'breadcrumbs' => $breadcrumbs, 'title' => $title, ); $search_content = $this->wdb->display($_s, 'search', array( 'search_str' => $search, 'path' => TemplateHelper::buildPageTitle($this->getPath()), )); return array('default', $search_content, $tpl_params); }
php
public function searchAction($path) { try { $this->setPath($path); } catch (NotFoundException $e) { throw $e; } $search = $this->wdb->getRequest()->getArgument('s'); if (empty($search)) { return $this->indexAction($path); } $_s = Helper::makeSearch($search, $this->getPath()); $title = _T('Search for "%search_str%"', array('search_str'=>$search)); $breadcrumbs = TemplateHelper::getBreadcrumbs($this->getPath()); $breadcrumbs[] = $title; $dbfile = new WDBFile($this->getpath()); $page = $dbfile->getWDBStack(); $page['type'] = 'search'; $tpl_params = array( 'page' => $page, 'breadcrumbs' => $breadcrumbs, 'title' => $title, ); $search_content = $this->wdb->display($_s, 'search', array( 'search_str' => $search, 'path' => TemplateHelper::buildPageTitle($this->getPath()), )); return array('default', $search_content, $tpl_params); }
[ "public", "function", "searchAction", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "catch", "(", "NotFoundException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "$", "search", "=", "$", "this", "->", "wdb", "->", "getRequest", "(", ")", "->", "getArgument", "(", "'s'", ")", ";", "if", "(", "empty", "(", "$", "search", ")", ")", "{", "return", "$", "this", "->", "indexAction", "(", "$", "path", ")", ";", "}", "$", "_s", "=", "Helper", "::", "makeSearch", "(", "$", "search", ",", "$", "this", "->", "getPath", "(", ")", ")", ";", "$", "title", "=", "_T", "(", "'Search for \"%search_str%\"'", ",", "array", "(", "'search_str'", "=>", "$", "search", ")", ")", ";", "$", "breadcrumbs", "=", "TemplateHelper", "::", "getBreadcrumbs", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "$", "breadcrumbs", "[", "]", "=", "$", "title", ";", "$", "dbfile", "=", "new", "WDBFile", "(", "$", "this", "->", "getpath", "(", ")", ")", ";", "$", "page", "=", "$", "dbfile", "->", "getWDBStack", "(", ")", ";", "$", "page", "[", "'type'", "]", "=", "'search'", ";", "$", "tpl_params", "=", "array", "(", "'page'", "=>", "$", "page", ",", "'breadcrumbs'", "=>", "$", "breadcrumbs", ",", "'title'", "=>", "$", "title", ",", ")", ";", "$", "search_content", "=", "$", "this", "->", "wdb", "->", "display", "(", "$", "_s", ",", "'search'", ",", "array", "(", "'search_str'", "=>", "$", "search", ",", "'path'", "=>", "TemplateHelper", "::", "buildPageTitle", "(", "$", "this", "->", "getPath", "(", ")", ")", ",", ")", ")", ";", "return", "array", "(", "'default'", ",", "$", "search_content", ",", "$", "tpl_params", ")", ";", "}" ]
Global search action of a path @param string $path @return array @throws \WebDocBook\Exception\NotFoundException
[ "Global", "search", "action", "of", "a", "path" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/DefaultController.php#L340-L372
train
PhoxPHP/Glider
src/Console/Command/Seed.php
Seed.createSeed
protected function createSeed() { $templateTags = []; $seedsDirectory = $this->cmd->getConfigOpt('seeds_storage'); $filename = trim($this->cmd->question('Seed filename?')); $templateTags['phx:class'] = Helper::getQualifiedClassName($filename); $path = $seedsDirectory . '/' . $filename . '.php'; if (file_exists($path)) { throw new SeedFileInvalidException( sprintf( 'Seed file [%s] exists.', $filename ) ); } $builder = new TemplateBuilder($this->cmd, $this->env); $builder->createClassTemplate('seed', $filename, $seedsDirectory, $templateTags); }
php
protected function createSeed() { $templateTags = []; $seedsDirectory = $this->cmd->getConfigOpt('seeds_storage'); $filename = trim($this->cmd->question('Seed filename?')); $templateTags['phx:class'] = Helper::getQualifiedClassName($filename); $path = $seedsDirectory . '/' . $filename . '.php'; if (file_exists($path)) { throw new SeedFileInvalidException( sprintf( 'Seed file [%s] exists.', $filename ) ); } $builder = new TemplateBuilder($this->cmd, $this->env); $builder->createClassTemplate('seed', $filename, $seedsDirectory, $templateTags); }
[ "protected", "function", "createSeed", "(", ")", "{", "$", "templateTags", "=", "[", "]", ";", "$", "seedsDirectory", "=", "$", "this", "->", "cmd", "->", "getConfigOpt", "(", "'seeds_storage'", ")", ";", "$", "filename", "=", "trim", "(", "$", "this", "->", "cmd", "->", "question", "(", "'Seed filename?'", ")", ")", ";", "$", "templateTags", "[", "'phx:class'", "]", "=", "Helper", "::", "getQualifiedClassName", "(", "$", "filename", ")", ";", "$", "path", "=", "$", "seedsDirectory", ".", "'/'", ".", "$", "filename", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "SeedFileInvalidException", "(", "sprintf", "(", "'Seed file [%s] exists.'", ",", "$", "filename", ")", ")", ";", "}", "$", "builder", "=", "new", "TemplateBuilder", "(", "$", "this", "->", "cmd", ",", "$", "this", "->", "env", ")", ";", "$", "builder", "->", "createClassTemplate", "(", "'seed'", ",", "$", "filename", ",", "$", "seedsDirectory", ",", "$", "templateTags", ")", ";", "}" ]
Create new seed class. @access protected @return <void>
[ "Create", "new", "seed", "class", "." ]
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Seed.php#L110-L131
train
PhoxPHP/Glider
src/Console/Command/Seed.php
Seed.runSeeds
protected function runSeeds() { foreach($this->getSeeders() as $file) { require_once $file; $className = basename($file, '.php'); $this->runSeed($className); } }
php
protected function runSeeds() { foreach($this->getSeeders() as $file) { require_once $file; $className = basename($file, '.php'); $this->runSeed($className); } }
[ "protected", "function", "runSeeds", "(", ")", "{", "foreach", "(", "$", "this", "->", "getSeeders", "(", ")", "as", "$", "file", ")", "{", "require_once", "$", "file", ";", "$", "className", "=", "basename", "(", "$", "file", ",", "'.php'", ")", ";", "$", "this", "->", "runSeed", "(", "$", "className", ")", ";", "}", "}" ]
Runs all seeders. @access protected @return <void>
[ "Runs", "all", "seeders", "." ]
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Seed.php#L139-L146
train
PhoxPHP/Glider
src/Console/Command/Seed.php
Seed.runSeed
protected function runSeed(String $className) { if (!class_exists($className)) { throw new SeederNotFoundException( sprintf( '[%s] seeder class not found.', $className ) ); } $seeder = new $className(); return $seeder->run(); }
php
protected function runSeed(String $className) { if (!class_exists($className)) { throw new SeederNotFoundException( sprintf( '[%s] seeder class not found.', $className ) ); } $seeder = new $className(); return $seeder->run(); }
[ "protected", "function", "runSeed", "(", "String", "$", "className", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "throw", "new", "SeederNotFoundException", "(", "sprintf", "(", "'[%s] seeder class not found.'", ",", "$", "className", ")", ")", ";", "}", "$", "seeder", "=", "new", "$", "className", "(", ")", ";", "return", "$", "seeder", "->", "run", "(", ")", ";", "}" ]
Runs a single seeder. @param $className <String> @access protected @return <void>
[ "Runs", "a", "single", "seeder", "." ]
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Seed.php#L155-L168
train
PhoxPHP/Glider
src/Console/Command/Seed.php
Seed.getSeeders
protected function getSeeders() : Array { $seeders = []; $seedsDirectory = $this->cmd->getConfigOpt('seeds_storage'); foreach(glob($seedsDirectory . '/*' . '.php') as $file) { $seeders[] = $file; } return $seeders; }
php
protected function getSeeders() : Array { $seeders = []; $seedsDirectory = $this->cmd->getConfigOpt('seeds_storage'); foreach(glob($seedsDirectory . '/*' . '.php') as $file) { $seeders[] = $file; } return $seeders; }
[ "protected", "function", "getSeeders", "(", ")", ":", "Array", "{", "$", "seeders", "=", "[", "]", ";", "$", "seedsDirectory", "=", "$", "this", "->", "cmd", "->", "getConfigOpt", "(", "'seeds_storage'", ")", ";", "foreach", "(", "glob", "(", "$", "seedsDirectory", ".", "'/*'", ".", "'.php'", ")", "as", "$", "file", ")", "{", "$", "seeders", "[", "]", "=", "$", "file", ";", "}", "return", "$", "seeders", ";", "}" ]
Returns an array of seeder files. @access protected @return <Array>
[ "Returns", "an", "array", "of", "seeder", "files", "." ]
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Console/Command/Seed.php#L176-L185
train
slickframework/form
src/Renderer/Checkbox.php
Checkbox.getLabelAttributes
public function getLabelAttributes() { $result = []; $label = $this->element->getLabel(); foreach ($label->getAttributes() as $attribute => $value) { if (null === $value) { $result[] = $attribute; continue; } $result[] = "{$attribute}=\"{$value}\""; } return implode(' ', $result); }
php
public function getLabelAttributes() { $result = []; $label = $this->element->getLabel(); foreach ($label->getAttributes() as $attribute => $value) { if (null === $value) { $result[] = $attribute; continue; } $result[] = "{$attribute}=\"{$value}\""; } return implode(' ', $result); }
[ "public", "function", "getLabelAttributes", "(", ")", "{", "$", "result", "=", "[", "]", ";", "$", "label", "=", "$", "this", "->", "element", "->", "getLabel", "(", ")", ";", "foreach", "(", "$", "label", "->", "getAttributes", "(", ")", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "$", "result", "[", "]", "=", "$", "attribute", ";", "continue", ";", "}", "$", "result", "[", "]", "=", "\"{$attribute}=\\\"{$value}\\\"\"", ";", "}", "return", "implode", "(", "' '", ",", "$", "result", ")", ";", "}" ]
Returns the elements's label attributes as a string @return string
[ "Returns", "the", "elements", "s", "label", "attributes", "as", "a", "string" ]
e7d536b3bad49194e246ff93587da2589e31a003
https://github.com/slickframework/form/blob/e7d536b3bad49194e246ff93587da2589e31a003/src/Renderer/Checkbox.php#L37-L50
train
gisostallenberg/correct-horse-battery-staple
src/CorrectHorseBatteryStaple.php
CorrectHorseBatteryStaple.verifyCommand
private function verifyCommand() { $process = new Process('which cracklib-check'); $process->setTimeout(10); $process->run(); if ($process->isSuccessful()) { return trim($process->getOutput() ); } $process = new Process('whereis cracklib-check'); $process->setTimeout(10); $process->run(); if ($process->isSuccessful()) { return preg_replace('/cracklib-check: ([^ ]*) .*/', '$1', trim($process->getOutput() ) ); } throw new RuntimeException('Unable to find cracklib-check command, please install cracklib-check'); }
php
private function verifyCommand() { $process = new Process('which cracklib-check'); $process->setTimeout(10); $process->run(); if ($process->isSuccessful()) { return trim($process->getOutput() ); } $process = new Process('whereis cracklib-check'); $process->setTimeout(10); $process->run(); if ($process->isSuccessful()) { return preg_replace('/cracklib-check: ([^ ]*) .*/', '$1', trim($process->getOutput() ) ); } throw new RuntimeException('Unable to find cracklib-check command, please install cracklib-check'); }
[ "private", "function", "verifyCommand", "(", ")", "{", "$", "process", "=", "new", "Process", "(", "'which cracklib-check'", ")", ";", "$", "process", "->", "setTimeout", "(", "10", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}", "$", "process", "=", "new", "Process", "(", "'whereis cracklib-check'", ")", ";", "$", "process", "->", "setTimeout", "(", "10", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "preg_replace", "(", "'/cracklib-check: ([^ ]*) .*/'", ",", "'$1'", ",", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ")", ";", "}", "throw", "new", "RuntimeException", "(", "'Unable to find cracklib-check command, please install cracklib-check'", ")", ";", "}" ]
Verify the command to be available @return string @throws RuntimeException
[ "Verify", "the", "command", "to", "be", "available" ]
5be41f0bcba23d25e173e49117e30a738b75a353
https://github.com/gisostallenberg/correct-horse-battery-staple/blob/5be41f0bcba23d25e173e49117e30a738b75a353/src/CorrectHorseBatteryStaple.php#L54-L72
train
gisostallenberg/correct-horse-battery-staple
src/CorrectHorseBatteryStaple.php
CorrectHorseBatteryStaple.check
public function check($password) { if (empty($password) ) { throw new InvalidArgumentException('The password cannot be empty'); } $process = new Process($this->command); $process->setInput($password); $process->mustRun(); return $this->verifyOutput($process->getOutput() ); }
php
public function check($password) { if (empty($password) ) { throw new InvalidArgumentException('The password cannot be empty'); } $process = new Process($this->command); $process->setInput($password); $process->mustRun(); return $this->verifyOutput($process->getOutput() ); }
[ "public", "function", "check", "(", "$", "password", ")", "{", "if", "(", "empty", "(", "$", "password", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The password cannot be empty'", ")", ";", "}", "$", "process", "=", "new", "Process", "(", "$", "this", "->", "command", ")", ";", "$", "process", "->", "setInput", "(", "$", "password", ")", ";", "$", "process", "->", "mustRun", "(", ")", ";", "return", "$", "this", "->", "verifyOutput", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}" ]
Performs an obscure check with the given password @param string $password @throws ProcessFailedException
[ "Performs", "an", "obscure", "check", "with", "the", "given", "password" ]
5be41f0bcba23d25e173e49117e30a738b75a353
https://github.com/gisostallenberg/correct-horse-battery-staple/blob/5be41f0bcba23d25e173e49117e30a738b75a353/src/CorrectHorseBatteryStaple.php#L80-L89
train
gisostallenberg/correct-horse-battery-staple
src/CorrectHorseBatteryStaple.php
CorrectHorseBatteryStaple.verifyOutput
private function verifyOutput($output) { $output = trim($output); $result = 'unknown'; if (preg_match('/: ([^:]+)$/', $output, $matches) ) { $result = $matches[1]; } $this->message = $result; if (array_key_exists($result, $this->messageStatus) ) { $this->status = $this->messageStatus[$result]; } else { $this->status = $this->messageStatus['unknown']; } return ($this->status === 0); }
php
private function verifyOutput($output) { $output = trim($output); $result = 'unknown'; if (preg_match('/: ([^:]+)$/', $output, $matches) ) { $result = $matches[1]; } $this->message = $result; if (array_key_exists($result, $this->messageStatus) ) { $this->status = $this->messageStatus[$result]; } else { $this->status = $this->messageStatus['unknown']; } return ($this->status === 0); }
[ "private", "function", "verifyOutput", "(", "$", "output", ")", "{", "$", "output", "=", "trim", "(", "$", "output", ")", ";", "$", "result", "=", "'unknown'", ";", "if", "(", "preg_match", "(", "'/: ([^:]+)$/'", ",", "$", "output", ",", "$", "matches", ")", ")", "{", "$", "result", "=", "$", "matches", "[", "1", "]", ";", "}", "$", "this", "->", "message", "=", "$", "result", ";", "if", "(", "array_key_exists", "(", "$", "result", ",", "$", "this", "->", "messageStatus", ")", ")", "{", "$", "this", "->", "status", "=", "$", "this", "->", "messageStatus", "[", "$", "result", "]", ";", "}", "else", "{", "$", "this", "->", "status", "=", "$", "this", "->", "messageStatus", "[", "'unknown'", "]", ";", "}", "return", "(", "$", "this", "->", "status", "===", "0", ")", ";", "}" ]
Checks the result of the password check @param string $output
[ "Checks", "the", "result", "of", "the", "password", "check" ]
5be41f0bcba23d25e173e49117e30a738b75a353
https://github.com/gisostallenberg/correct-horse-battery-staple/blob/5be41f0bcba23d25e173e49117e30a738b75a353/src/CorrectHorseBatteryStaple.php#L96-L113
train
bruno-barros/w.eloquent-framework
src/weloquent/Support/Navigation/BootstrapMenuWalker.php
BootstrapMenuWalker.start_lvl
public function start_lvl( &$output, $depth = 0, $args = array() ) { // depth dependent classes $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent $display_depth = ( $depth + 1); // because it counts the first submenu as 0 $classes = array( 'sub-menu', ( $display_depth == 0 ? 'dropdown' : '' ), ( $display_depth > 0 ? 'dropdown-menu' : '' ), ); $class_names = implode( ' ', $classes ); // build html $output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n"; }
php
public function start_lvl( &$output, $depth = 0, $args = array() ) { // depth dependent classes $indent = ( $depth > 0 ? str_repeat( "\t", $depth ) : '' ); // code indent $display_depth = ( $depth + 1); // because it counts the first submenu as 0 $classes = array( 'sub-menu', ( $display_depth == 0 ? 'dropdown' : '' ), ( $display_depth > 0 ? 'dropdown-menu' : '' ), ); $class_names = implode( ' ', $classes ); // build html $output .= "\n" . $indent . '<ul class="' . $class_names . '">' . "\n"; }
[ "public", "function", "start_lvl", "(", "&", "$", "output", ",", "$", "depth", "=", "0", ",", "$", "args", "=", "array", "(", ")", ")", "{", "// depth dependent classes", "$", "indent", "=", "(", "$", "depth", ">", "0", "?", "str_repeat", "(", "\"\\t\"", ",", "$", "depth", ")", ":", "''", ")", ";", "// code indent", "$", "display_depth", "=", "(", "$", "depth", "+", "1", ")", ";", "// because it counts the first submenu as 0", "$", "classes", "=", "array", "(", "'sub-menu'", ",", "(", "$", "display_depth", "==", "0", "?", "'dropdown'", ":", "''", ")", ",", "(", "$", "display_depth", ">", "0", "?", "'dropdown-menu'", ":", "''", ")", ",", ")", ";", "$", "class_names", "=", "implode", "(", "' '", ",", "$", "classes", ")", ";", "// build html", "$", "output", ".=", "\"\\n\"", ".", "$", "indent", ".", "'<ul class=\"'", ".", "$", "class_names", ".", "'\">'", ".", "\"\\n\"", ";", "}" ]
Starts the list before the elements are added. add classes to ul sub-menus @param string $output @param int $depth @param array $args @return string
[ "Starts", "the", "list", "before", "the", "elements", "are", "added", ".", "add", "classes", "to", "ul", "sub", "-", "menus" ]
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Support/Navigation/BootstrapMenuWalker.php#L20-L34
train
Synapse-Cmf/synapse-cmf
src/Synapse/Cmf/Framework/Engine/Resolver/ThemeResolver.php
ThemeResolver.resolve
public function resolve($themeName = null) { switch (true) { // given theme name case $themeName: if (!$theme = $this->themeLoader->retrieveByName($themeName)) { throw new InvalidThemeException(sprintf( 'No themes registered under for "%s" theme name. Did you mean one of these themes : %s ?', $themeName, $this->themeLoader->retrieveAll()->display('name') )); } break; // // default theme - not yet implemented // case $theme = $this->themeLoader->retrieveOne(array( // 'default' => true // )): // break; // first theme defined if there is only one activated case ($themes = $this->themeLoader->retrieveAll()) && $themes->count() == 1: $theme = $themes->first(); break; default: throw new InvalidThemeException( 'Unavailable to determine which theme to use, if you are using more than one you have to call one explicitely. See online documentation at https://synapse-cmf.github.io/documentation/fr/3_book/1_decorator/2_themes.html for more informations.' ); } return $theme; }
php
public function resolve($themeName = null) { switch (true) { // given theme name case $themeName: if (!$theme = $this->themeLoader->retrieveByName($themeName)) { throw new InvalidThemeException(sprintf( 'No themes registered under for "%s" theme name. Did you mean one of these themes : %s ?', $themeName, $this->themeLoader->retrieveAll()->display('name') )); } break; // // default theme - not yet implemented // case $theme = $this->themeLoader->retrieveOne(array( // 'default' => true // )): // break; // first theme defined if there is only one activated case ($themes = $this->themeLoader->retrieveAll()) && $themes->count() == 1: $theme = $themes->first(); break; default: throw new InvalidThemeException( 'Unavailable to determine which theme to use, if you are using more than one you have to call one explicitely. See online documentation at https://synapse-cmf.github.io/documentation/fr/3_book/1_decorator/2_themes.html for more informations.' ); } return $theme; }
[ "public", "function", "resolve", "(", "$", "themeName", "=", "null", ")", "{", "switch", "(", "true", ")", "{", "// given theme name", "case", "$", "themeName", ":", "if", "(", "!", "$", "theme", "=", "$", "this", "->", "themeLoader", "->", "retrieveByName", "(", "$", "themeName", ")", ")", "{", "throw", "new", "InvalidThemeException", "(", "sprintf", "(", "'No themes registered under for \"%s\" theme name. Did you mean one of these themes : %s ?'", ",", "$", "themeName", ",", "$", "this", "->", "themeLoader", "->", "retrieveAll", "(", ")", "->", "display", "(", "'name'", ")", ")", ")", ";", "}", "break", ";", "// // default theme - not yet implemented", "// case $theme = $this->themeLoader->retrieveOne(array(", "// 'default' => true", "// )):", "// break;", "// first theme defined if there is only one activated", "case", "(", "$", "themes", "=", "$", "this", "->", "themeLoader", "->", "retrieveAll", "(", ")", ")", "&&", "$", "themes", "->", "count", "(", ")", "==", "1", ":", "$", "theme", "=", "$", "themes", "->", "first", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidThemeException", "(", "'Unavailable to determine which theme to use, if you are using more than one you have to call one explicitely. See online documentation at https://synapse-cmf.github.io/documentation/fr/3_book/1_decorator/2_themes.html for more informations.'", ")", ";", "}", "return", "$", "theme", ";", "}" ]
Select Theme to use from given parameters and return it. @param string $themeName optional theme name to use @return Theme @throws InvalidThemeException If no theme found for given theme name
[ "Select", "Theme", "to", "use", "from", "given", "parameters", "and", "return", "it", "." ]
d8122a4150a83d5607289724425cf35c56a5e880
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Engine/Resolver/ThemeResolver.php#L35-L69
train
noizu/fragmented-keys
src/NoizuLabs/FragmentedKeys/Tag.php
Tag.Increment
public function Increment() { if($this->version == null) { $this->_getVersion(); } $this->version += .1; $this->_StoreVersion(); }
php
public function Increment() { if($this->version == null) { $this->_getVersion(); } $this->version += .1; $this->_StoreVersion(); }
[ "public", "function", "Increment", "(", ")", "{", "if", "(", "$", "this", "->", "version", "==", "null", ")", "{", "$", "this", "->", "_getVersion", "(", ")", ";", "}", "$", "this", "->", "version", "+=", ".1", ";", "$", "this", "->", "_StoreVersion", "(", ")", ";", "}" ]
Increment version number.
[ "Increment", "version", "number", "." ]
5eccc8553ba11920d6d84e20e89b50c28d941b45
https://github.com/noizu/fragmented-keys/blob/5eccc8553ba11920d6d84e20e89b50c28d941b45/src/NoizuLabs/FragmentedKeys/Tag.php#L144-L151
train
noizu/fragmented-keys
src/NoizuLabs/FragmentedKeys/Tag.php
Tag._getVersion
protected function _getVersion() { if(empty($this->version)) { $result = $this->cacheHandler->get($this->getTagName()); if(empty($result)) { $this->ResetTagVersion(); } else { $this->version = $result; } } return $this->version; }
php
protected function _getVersion() { if(empty($this->version)) { $result = $this->cacheHandler->get($this->getTagName()); if(empty($result)) { $this->ResetTagVersion(); } else { $this->version = $result; } } return $this->version; }
[ "protected", "function", "_getVersion", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "version", ")", ")", "{", "$", "result", "=", "$", "this", "->", "cacheHandler", "->", "get", "(", "$", "this", "->", "getTagName", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "ResetTagVersion", "(", ")", ";", "}", "else", "{", "$", "this", "->", "version", "=", "$", "result", ";", "}", "}", "return", "$", "this", "->", "version", ";", "}" ]
return current version number of tag-instance @return int
[ "return", "current", "version", "number", "of", "tag", "-", "instance" ]
5eccc8553ba11920d6d84e20e89b50c28d941b45
https://github.com/noizu/fragmented-keys/blob/5eccc8553ba11920d6d84e20e89b50c28d941b45/src/NoizuLabs/FragmentedKeys/Tag.php#L167-L179
train
phPoirot/Client-OAuth2
mod/Authenticate/IdentifierTokenAssertion.php
IdentifierTokenAssertion.getOwnerId
function getOwnerId() { if ($this->withIdentity() instanceof iIdentityOfUser) { /** @var IdentityOAuthToken|iIdentityOfUser $identity */ $identity = $this->withIdentity(); $userId = $identity->getOwnerId(); } else { $userInfo = $this->getAuthInfo(); $userId = $userInfo['user']['uid']; } return $userId; }
php
function getOwnerId() { if ($this->withIdentity() instanceof iIdentityOfUser) { /** @var IdentityOAuthToken|iIdentityOfUser $identity */ $identity = $this->withIdentity(); $userId = $identity->getOwnerId(); } else { $userInfo = $this->getAuthInfo(); $userId = $userInfo['user']['uid']; } return $userId; }
[ "function", "getOwnerId", "(", ")", "{", "if", "(", "$", "this", "->", "withIdentity", "(", ")", "instanceof", "iIdentityOfUser", ")", "{", "/** @var IdentityOAuthToken|iIdentityOfUser $identity */", "$", "identity", "=", "$", "this", "->", "withIdentity", "(", ")", ";", "$", "userId", "=", "$", "identity", "->", "getOwnerId", "(", ")", ";", "}", "else", "{", "$", "userInfo", "=", "$", "this", "->", "getAuthInfo", "(", ")", ";", "$", "userId", "=", "$", "userInfo", "[", "'user'", "]", "[", "'uid'", "]", ";", "}", "return", "$", "userId", ";", "}" ]
Get Owner Identifier @return mixed
[ "Get", "Owner", "Identifier" ]
8745fd54afbbb185669b9e38b1241ecc8ffc7268
https://github.com/phPoirot/Client-OAuth2/blob/8745fd54afbbb185669b9e38b1241ecc8ffc7268/mod/Authenticate/IdentifierTokenAssertion.php#L30-L46
train
phPoirot/Client-OAuth2
mod/Authenticate/IdentifierTokenAssertion.php
IdentifierTokenAssertion.getAuthInfo
function getAuthInfo($grants = false) { if ($this->_c_info) return $this->_c_info; $options = null; if ( $grants ) $options['include_grants'] = true; try { $info = $this->federation()->getMyAccountInfo($options); } catch (exOAuthAccessDenied $e) { throw new exAccessDenied($e->getMessage(), $e->getCode(), $e); } return $this->_c_info = $info; }
php
function getAuthInfo($grants = false) { if ($this->_c_info) return $this->_c_info; $options = null; if ( $grants ) $options['include_grants'] = true; try { $info = $this->federation()->getMyAccountInfo($options); } catch (exOAuthAccessDenied $e) { throw new exAccessDenied($e->getMessage(), $e->getCode(), $e); } return $this->_c_info = $info; }
[ "function", "getAuthInfo", "(", "$", "grants", "=", "false", ")", "{", "if", "(", "$", "this", "->", "_c_info", ")", "return", "$", "this", "->", "_c_info", ";", "$", "options", "=", "null", ";", "if", "(", "$", "grants", ")", "$", "options", "[", "'include_grants'", "]", "=", "true", ";", "try", "{", "$", "info", "=", "$", "this", "->", "federation", "(", ")", "->", "getMyAccountInfo", "(", "$", "options", ")", ";", "}", "catch", "(", "exOAuthAccessDenied", "$", "e", ")", "{", "throw", "new", "exAccessDenied", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "return", "$", "this", "->", "_c_info", "=", "$", "info", ";", "}" ]
Retrieve User Info From OAuth Server @param bool $grants @return array
[ "Retrieve", "User", "Info", "From", "OAuth", "Server" ]
8745fd54afbbb185669b9e38b1241ecc8ffc7268
https://github.com/phPoirot/Client-OAuth2/blob/8745fd54afbbb185669b9e38b1241ecc8ffc7268/mod/Authenticate/IdentifierTokenAssertion.php#L56-L74
train
phPoirot/Client-OAuth2
mod/Authenticate/IdentifierTokenAssertion.php
IdentifierTokenAssertion.federation
function federation() { if ($this->_c_federation) return $this->_c_federation; $federation = clone $this->federation; $federation->setTokenProvider( $this->insTokenProvider() ); return $this->_c_federation = $federation; }
php
function federation() { if ($this->_c_federation) return $this->_c_federation; $federation = clone $this->federation; $federation->setTokenProvider( $this->insTokenProvider() ); return $this->_c_federation = $federation; }
[ "function", "federation", "(", ")", "{", "if", "(", "$", "this", "->", "_c_federation", ")", "return", "$", "this", "->", "_c_federation", ";", "$", "federation", "=", "clone", "$", "this", "->", "federation", ";", "$", "federation", "->", "setTokenProvider", "(", "$", "this", "->", "insTokenProvider", "(", ")", ")", ";", "return", "$", "this", "->", "_c_federation", "=", "$", "federation", ";", "}" ]
Access Federation Commands Of Identified User @return Federation
[ "Access", "Federation", "Commands", "Of", "Identified", "User" ]
8745fd54afbbb185669b9e38b1241ecc8ffc7268
https://github.com/phPoirot/Client-OAuth2/blob/8745fd54afbbb185669b9e38b1241ecc8ffc7268/mod/Authenticate/IdentifierTokenAssertion.php#L82-L94
train
phPoirot/Client-OAuth2
mod/Authenticate/IdentifierTokenAssertion.php
IdentifierTokenAssertion.insTokenProvider
function insTokenProvider() { if ($this->_tokenProvider) return $this->_tokenProvider; /** @var IdentityOAuthToken|iIdentityAccTokenProvider $identity */ $identity = $this->withIdentity(); $tokenProvider = new TokenProviderSolid( $identity->getAccessToken() ); return $tokenProvider; }
php
function insTokenProvider() { if ($this->_tokenProvider) return $this->_tokenProvider; /** @var IdentityOAuthToken|iIdentityAccTokenProvider $identity */ $identity = $this->withIdentity(); $tokenProvider = new TokenProviderSolid( $identity->getAccessToken() ); return $tokenProvider; }
[ "function", "insTokenProvider", "(", ")", "{", "if", "(", "$", "this", "->", "_tokenProvider", ")", "return", "$", "this", "->", "_tokenProvider", ";", "/** @var IdentityOAuthToken|iIdentityAccTokenProvider $identity */", "$", "identity", "=", "$", "this", "->", "withIdentity", "(", ")", ";", "$", "tokenProvider", "=", "new", "TokenProviderSolid", "(", "$", "identity", "->", "getAccessToken", "(", ")", ")", ";", "return", "$", "tokenProvider", ";", "}" ]
Token Provider Help Call API`s Behalf Of User with given token [code] $federation = clone \Module\OAuth2Client\Services::OAuthFederate(); $federation->setTokenProvider($tokenProvider); $info = $federation->getMyAccountInfo(); [/code] @return TokenProviderSolid
[ "Token", "Provider", "Help", "Call", "API", "s", "Behalf", "Of", "User", "with", "given", "token" ]
8745fd54afbbb185669b9e38b1241ecc8ffc7268
https://github.com/phPoirot/Client-OAuth2/blob/8745fd54afbbb185669b9e38b1241ecc8ffc7268/mod/Authenticate/IdentifierTokenAssertion.php#L111-L124
train
praxisnetau/silverware-navigation
src/Components/BarNavigation.php
BarNavigation.getCollapseClassNames
public function getCollapseClassNames() { $classes = $this->styles('navbar.collapse', 'collapse'); if ($this->hasRows()) { $classes[] = $this->style('navbar.column'); } if ($align = $this->ItemAlign) { $classes[] = $this->style(sprintf('navbar.item-align-%s', $align)); } if ($justify = $this->ItemJustify) { $classes[] = $this->style(sprintf('navbar.item-justify-%s', $justify)); } $this->extend('updateCollapseClassNames', $classes); return $classes; }
php
public function getCollapseClassNames() { $classes = $this->styles('navbar.collapse', 'collapse'); if ($this->hasRows()) { $classes[] = $this->style('navbar.column'); } if ($align = $this->ItemAlign) { $classes[] = $this->style(sprintf('navbar.item-align-%s', $align)); } if ($justify = $this->ItemJustify) { $classes[] = $this->style(sprintf('navbar.item-justify-%s', $justify)); } $this->extend('updateCollapseClassNames', $classes); return $classes; }
[ "public", "function", "getCollapseClassNames", "(", ")", "{", "$", "classes", "=", "$", "this", "->", "styles", "(", "'navbar.collapse'", ",", "'collapse'", ")", ";", "if", "(", "$", "this", "->", "hasRows", "(", ")", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'navbar.column'", ")", ";", "}", "if", "(", "$", "align", "=", "$", "this", "->", "ItemAlign", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "sprintf", "(", "'navbar.item-align-%s'", ",", "$", "align", ")", ")", ";", "}", "if", "(", "$", "justify", "=", "$", "this", "->", "ItemJustify", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "sprintf", "(", "'navbar.item-justify-%s'", ",", "$", "justify", ")", ")", ";", "}", "$", "this", "->", "extend", "(", "'updateCollapseClassNames'", ",", "$", "classes", ")", ";", "return", "$", "classes", ";", "}" ]
Answers an array of collapse class names for the HTML template. @return array
[ "Answers", "an", "array", "of", "collapse", "class", "names", "for", "the", "HTML", "template", "." ]
04e6f3003c2871348d5bba7869d4fc273641627e
https://github.com/praxisnetau/silverware-navigation/blob/04e6f3003c2871348d5bba7869d4fc273641627e/src/Components/BarNavigation.php#L589-L608
train
praxisnetau/silverware-navigation
src/Components/BarNavigation.php
BarNavigation.getLogoDimensions
public function getLogoDimensions() { // Initialise: $data = []; // Obtain Dimensions: $widths = $this->dbObject('BrandLogoWidth'); $heights = $this->dbObject('BrandLogoHeight'); // Iterate Width Viewports: foreach ($widths->getViewports() as $viewport) { if ($value = $widths->getField($viewport)) { $data[$viewport]['Width'] = $value; $data[$viewport]['Breakpoint'] = $widths->getBreakpoint($viewport); } } // Iterate Height Viewports: foreach ($heights->getViewports() as $viewport) { if ($value = $heights->getField($viewport)) { $data[$viewport]['Height'] = $value; $data[$viewport]['Breakpoint'] = $heights->getBreakpoint($viewport); } } // Create Items List: $items = ArrayList::create(); // Create Data Items: foreach ($data as $item) { $items->push(ArrayData::create($item)); } // Answer Items List: return $items; }
php
public function getLogoDimensions() { // Initialise: $data = []; // Obtain Dimensions: $widths = $this->dbObject('BrandLogoWidth'); $heights = $this->dbObject('BrandLogoHeight'); // Iterate Width Viewports: foreach ($widths->getViewports() as $viewport) { if ($value = $widths->getField($viewport)) { $data[$viewport]['Width'] = $value; $data[$viewport]['Breakpoint'] = $widths->getBreakpoint($viewport); } } // Iterate Height Viewports: foreach ($heights->getViewports() as $viewport) { if ($value = $heights->getField($viewport)) { $data[$viewport]['Height'] = $value; $data[$viewport]['Breakpoint'] = $heights->getBreakpoint($viewport); } } // Create Items List: $items = ArrayList::create(); // Create Data Items: foreach ($data as $item) { $items->push(ArrayData::create($item)); } // Answer Items List: return $items; }
[ "public", "function", "getLogoDimensions", "(", ")", "{", "// Initialise:", "$", "data", "=", "[", "]", ";", "// Obtain Dimensions:", "$", "widths", "=", "$", "this", "->", "dbObject", "(", "'BrandLogoWidth'", ")", ";", "$", "heights", "=", "$", "this", "->", "dbObject", "(", "'BrandLogoHeight'", ")", ";", "// Iterate Width Viewports:", "foreach", "(", "$", "widths", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "value", "=", "$", "widths", "->", "getField", "(", "$", "viewport", ")", ")", "{", "$", "data", "[", "$", "viewport", "]", "[", "'Width'", "]", "=", "$", "value", ";", "$", "data", "[", "$", "viewport", "]", "[", "'Breakpoint'", "]", "=", "$", "widths", "->", "getBreakpoint", "(", "$", "viewport", ")", ";", "}", "}", "// Iterate Height Viewports:", "foreach", "(", "$", "heights", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "value", "=", "$", "heights", "->", "getField", "(", "$", "viewport", ")", ")", "{", "$", "data", "[", "$", "viewport", "]", "[", "'Height'", "]", "=", "$", "value", ";", "$", "data", "[", "$", "viewport", "]", "[", "'Breakpoint'", "]", "=", "$", "heights", "->", "getBreakpoint", "(", "$", "viewport", ")", ";", "}", "}", "// Create Items List:", "$", "items", "=", "ArrayList", "::", "create", "(", ")", ";", "// Create Data Items:", "foreach", "(", "$", "data", "as", "$", "item", ")", "{", "$", "items", "->", "push", "(", "ArrayData", "::", "create", "(", "$", "item", ")", ")", ";", "}", "// Answer Items List:", "return", "$", "items", ";", "}" ]
Answers a list of logo dimensions for the custom CSS template. @return ArrayList
[ "Answers", "a", "list", "of", "logo", "dimensions", "for", "the", "custom", "CSS", "template", "." ]
04e6f3003c2871348d5bba7869d4fc273641627e
https://github.com/praxisnetau/silverware-navigation/blob/04e6f3003c2871348d5bba7869d4fc273641627e/src/Components/BarNavigation.php#L709-L755
train
praxisnetau/silverware-navigation
src/Components/BarNavigation.php
BarNavigation.getBackgroundOptions
public function getBackgroundOptions() { return [ self::BG_PRIMARY => _t(__CLASS__ . '.PRIMARY', 'Primary'), self::BG_LIGHT => _t(__CLASS__ . '.LIGHT', 'Light'), self::BG_DARK => _t(__CLASS__ . '.DARK', 'Dark') ]; }
php
public function getBackgroundOptions() { return [ self::BG_PRIMARY => _t(__CLASS__ . '.PRIMARY', 'Primary'), self::BG_LIGHT => _t(__CLASS__ . '.LIGHT', 'Light'), self::BG_DARK => _t(__CLASS__ . '.DARK', 'Dark') ]; }
[ "public", "function", "getBackgroundOptions", "(", ")", "{", "return", "[", "self", "::", "BG_PRIMARY", "=>", "_t", "(", "__CLASS__", ".", "'.PRIMARY'", ",", "'Primary'", ")", ",", "self", "::", "BG_LIGHT", "=>", "_t", "(", "__CLASS__", ".", "'.LIGHT'", ",", "'Light'", ")", ",", "self", "::", "BG_DARK", "=>", "_t", "(", "__CLASS__", ".", "'.DARK'", ",", "'Dark'", ")", "]", ";", "}" ]
Answers an array of options for the background field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "background", "field", "." ]
04e6f3003c2871348d5bba7869d4fc273641627e
https://github.com/praxisnetau/silverware-navigation/blob/04e6f3003c2871348d5bba7869d4fc273641627e/src/Components/BarNavigation.php#L762-L769
train
praxisnetau/silverware-navigation
src/Components/BarNavigation.php
BarNavigation.getItemAlignOptions
public function getItemAlignOptions() { return [ self::ITEM_ALIGN_START => _t(__CLASS__ . '.START', 'Start'), self::ITEM_ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ITEM_ALIGN_END => _t(__CLASS__ . '.END', 'End'), self::ITEM_ALIGN_BETWEEN => _t(__CLASS__ . '.BETWEEN', 'Between'), self::ITEM_ALIGN_AROUND => _t(__CLASS__ . '.AROUND', 'Around') ]; }
php
public function getItemAlignOptions() { return [ self::ITEM_ALIGN_START => _t(__CLASS__ . '.START', 'Start'), self::ITEM_ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ITEM_ALIGN_END => _t(__CLASS__ . '.END', 'End'), self::ITEM_ALIGN_BETWEEN => _t(__CLASS__ . '.BETWEEN', 'Between'), self::ITEM_ALIGN_AROUND => _t(__CLASS__ . '.AROUND', 'Around') ]; }
[ "public", "function", "getItemAlignOptions", "(", ")", "{", "return", "[", "self", "::", "ITEM_ALIGN_START", "=>", "_t", "(", "__CLASS__", ".", "'.START'", ",", "'Start'", ")", ",", "self", "::", "ITEM_ALIGN_CENTER", "=>", "_t", "(", "__CLASS__", ".", "'.CENTER'", ",", "'Center'", ")", ",", "self", "::", "ITEM_ALIGN_END", "=>", "_t", "(", "__CLASS__", ".", "'.END'", ",", "'End'", ")", ",", "self", "::", "ITEM_ALIGN_BETWEEN", "=>", "_t", "(", "__CLASS__", ".", "'.BETWEEN'", ",", "'Between'", ")", ",", "self", "::", "ITEM_ALIGN_AROUND", "=>", "_t", "(", "__CLASS__", ".", "'.AROUND'", ",", "'Around'", ")", "]", ";", "}" ]
Answers an array of options for the item align field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "item", "align", "field", "." ]
04e6f3003c2871348d5bba7869d4fc273641627e
https://github.com/praxisnetau/silverware-navigation/blob/04e6f3003c2871348d5bba7869d4fc273641627e/src/Components/BarNavigation.php#L802-L811
train
praxisnetau/silverware-navigation
src/Components/BarNavigation.php
BarNavigation.getItemJustifyOptions
public function getItemJustifyOptions() { return [ self::ITEM_ALIGN_START => _t(__CLASS__ . '.START', 'Start'), self::ITEM_ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ITEM_ALIGN_END => _t(__CLASS__ . '.END', 'End'), self::ITEM_ALIGN_BASELINE => _t(__CLASS__ . '.BASELINE', 'Baseline'), self::ITEM_ALIGN_STRETCH => _t(__CLASS__ . '.STRETCH', 'Stretch') ]; }
php
public function getItemJustifyOptions() { return [ self::ITEM_ALIGN_START => _t(__CLASS__ . '.START', 'Start'), self::ITEM_ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ITEM_ALIGN_END => _t(__CLASS__ . '.END', 'End'), self::ITEM_ALIGN_BASELINE => _t(__CLASS__ . '.BASELINE', 'Baseline'), self::ITEM_ALIGN_STRETCH => _t(__CLASS__ . '.STRETCH', 'Stretch') ]; }
[ "public", "function", "getItemJustifyOptions", "(", ")", "{", "return", "[", "self", "::", "ITEM_ALIGN_START", "=>", "_t", "(", "__CLASS__", ".", "'.START'", ",", "'Start'", ")", ",", "self", "::", "ITEM_ALIGN_CENTER", "=>", "_t", "(", "__CLASS__", ".", "'.CENTER'", ",", "'Center'", ")", ",", "self", "::", "ITEM_ALIGN_END", "=>", "_t", "(", "__CLASS__", ".", "'.END'", ",", "'End'", ")", ",", "self", "::", "ITEM_ALIGN_BASELINE", "=>", "_t", "(", "__CLASS__", ".", "'.BASELINE'", ",", "'Baseline'", ")", ",", "self", "::", "ITEM_ALIGN_STRETCH", "=>", "_t", "(", "__CLASS__", ".", "'.STRETCH'", ",", "'Stretch'", ")", "]", ";", "}" ]
Answers an array of options for the item justify field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "item", "justify", "field", "." ]
04e6f3003c2871348d5bba7869d4fc273641627e
https://github.com/praxisnetau/silverware-navigation/blob/04e6f3003c2871348d5bba7869d4fc273641627e/src/Components/BarNavigation.php#L818-L827
train
selikhovleonid/nadir
src/core/WebCtrlResolver.php
WebCtrlResolver.createCtrl
protected function createCtrl() { $oView = ViewFactory::createView( $this->ctrlName, str_replace('action', '', $this->actionName) ); $aComponentsRootMap = AppHelper::getInstance()->getConfig('componentsRootMap'); if (!isset($aComponentsRootMap['controllers'])) { throw new Exception("The field 'componentsRootMap.controllers' must be " ."presented in the main configuration file."); } $sCtrlNamespace = str_replace( \DIRECTORY_SEPARATOR, '\\', $aComponentsRootMap['controllers'] ); $sCtrlNameFull = $sCtrlNamespace.'\\'.$this->ctrlName; if (!is_null($oView)) { $sLayoutName = AppHelper::getInstance()->getConfig('defaultLayout'); if (!is_null($sLayoutName)) { $oLayout = ViewFactory::createLayout($sLayoutName, $oView); $oCtrl = new $sCtrlNameFull($this->request, $oLayout); } else { $oCtrl = new $sCtrlNameFull($this->request, $oView); } } else { $oCtrl = new $sCtrlNameFull($this->request); } return $oCtrl; }
php
protected function createCtrl() { $oView = ViewFactory::createView( $this->ctrlName, str_replace('action', '', $this->actionName) ); $aComponentsRootMap = AppHelper::getInstance()->getConfig('componentsRootMap'); if (!isset($aComponentsRootMap['controllers'])) { throw new Exception("The field 'componentsRootMap.controllers' must be " ."presented in the main configuration file."); } $sCtrlNamespace = str_replace( \DIRECTORY_SEPARATOR, '\\', $aComponentsRootMap['controllers'] ); $sCtrlNameFull = $sCtrlNamespace.'\\'.$this->ctrlName; if (!is_null($oView)) { $sLayoutName = AppHelper::getInstance()->getConfig('defaultLayout'); if (!is_null($sLayoutName)) { $oLayout = ViewFactory::createLayout($sLayoutName, $oView); $oCtrl = new $sCtrlNameFull($this->request, $oLayout); } else { $oCtrl = new $sCtrlNameFull($this->request, $oView); } } else { $oCtrl = new $sCtrlNameFull($this->request); } return $oCtrl; }
[ "protected", "function", "createCtrl", "(", ")", "{", "$", "oView", "=", "ViewFactory", "::", "createView", "(", "$", "this", "->", "ctrlName", ",", "str_replace", "(", "'action'", ",", "''", ",", "$", "this", "->", "actionName", ")", ")", ";", "$", "aComponentsRootMap", "=", "AppHelper", "::", "getInstance", "(", ")", "->", "getConfig", "(", "'componentsRootMap'", ")", ";", "if", "(", "!", "isset", "(", "$", "aComponentsRootMap", "[", "'controllers'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"The field 'componentsRootMap.controllers' must be \"", ".", "\"presented in the main configuration file.\"", ")", ";", "}", "$", "sCtrlNamespace", "=", "str_replace", "(", "\\", "DIRECTORY_SEPARATOR", ",", "'\\\\'", ",", "$", "aComponentsRootMap", "[", "'controllers'", "]", ")", ";", "$", "sCtrlNameFull", "=", "$", "sCtrlNamespace", ".", "'\\\\'", ".", "$", "this", "->", "ctrlName", ";", "if", "(", "!", "is_null", "(", "$", "oView", ")", ")", "{", "$", "sLayoutName", "=", "AppHelper", "::", "getInstance", "(", ")", "->", "getConfig", "(", "'defaultLayout'", ")", ";", "if", "(", "!", "is_null", "(", "$", "sLayoutName", ")", ")", "{", "$", "oLayout", "=", "ViewFactory", "::", "createLayout", "(", "$", "sLayoutName", ",", "$", "oView", ")", ";", "$", "oCtrl", "=", "new", "$", "sCtrlNameFull", "(", "$", "this", "->", "request", ",", "$", "oLayout", ")", ";", "}", "else", "{", "$", "oCtrl", "=", "new", "$", "sCtrlNameFull", "(", "$", "this", "->", "request", ",", "$", "oView", ")", ";", "}", "}", "else", "{", "$", "oCtrl", "=", "new", "$", "sCtrlNameFull", "(", "$", "this", "->", "request", ")", ";", "}", "return", "$", "oCtrl", ";", "}" ]
It creates the controller object, assignes it with default view and layout objects. @return \nadir\core\AWebController.
[ "It", "creates", "the", "controller", "object", "assignes", "it", "with", "default", "view", "and", "layout", "objects", "." ]
47545fccd8516c8f0a20c02ba62f68269c7199da
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/WebCtrlResolver.php#L30-L59
train
octris/sqlbuilder
libs/Sqlbuilder/Template.php
Template.resolveSql
public function resolveSql(array $parameters = array()) { // sql statement from template $sql = preg_replace_callback('|/\*\*(.+?)\*\*/|', function($match) use (&$parameters) { $name = trim($match[1]); $snippet = $this->builder->resolveSnippet($name, $parameters); return $snippet; }, $this->sql); // resolve parameters $types = ''; $values = []; $sql = preg_replace_callback('/@(?P<type>.):(?P<name>.+?)@/', function($match) use (&$types, &$values, $parameters) { $types .= $match['type']; $values[] = $parameters[$match['name']]; return $this->builder->resolveParameter(count($values), $match['type'], $match['name']); }, $sql); return (object)['sql' => $sql, 'types' => $types, 'parameters' => $values]; }
php
public function resolveSql(array $parameters = array()) { // sql statement from template $sql = preg_replace_callback('|/\*\*(.+?)\*\*/|', function($match) use (&$parameters) { $name = trim($match[1]); $snippet = $this->builder->resolveSnippet($name, $parameters); return $snippet; }, $this->sql); // resolve parameters $types = ''; $values = []; $sql = preg_replace_callback('/@(?P<type>.):(?P<name>.+?)@/', function($match) use (&$types, &$values, $parameters) { $types .= $match['type']; $values[] = $parameters[$match['name']]; return $this->builder->resolveParameter(count($values), $match['type'], $match['name']); }, $sql); return (object)['sql' => $sql, 'types' => $types, 'parameters' => $values]; }
[ "public", "function", "resolveSql", "(", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "// sql statement from template", "$", "sql", "=", "preg_replace_callback", "(", "'|/\\*\\*(.+?)\\*\\*/|'", ",", "function", "(", "$", "match", ")", "use", "(", "&", "$", "parameters", ")", "{", "$", "name", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "$", "snippet", "=", "$", "this", "->", "builder", "->", "resolveSnippet", "(", "$", "name", ",", "$", "parameters", ")", ";", "return", "$", "snippet", ";", "}", ",", "$", "this", "->", "sql", ")", ";", "// resolve parameters", "$", "types", "=", "''", ";", "$", "values", "=", "[", "]", ";", "$", "sql", "=", "preg_replace_callback", "(", "'/@(?P<type>.):(?P<name>.+?)@/'", ",", "function", "(", "$", "match", ")", "use", "(", "&", "$", "types", ",", "&", "$", "values", ",", "$", "parameters", ")", "{", "$", "types", ".=", "$", "match", "[", "'type'", "]", ";", "$", "values", "[", "]", "=", "$", "parameters", "[", "$", "match", "[", "'name'", "]", "]", ";", "return", "$", "this", "->", "builder", "->", "resolveParameter", "(", "count", "(", "$", "values", ")", ",", "$", "match", "[", "'type'", "]", ",", "$", "match", "[", "'name'", "]", ")", ";", "}", ",", "$", "sql", ")", ";", "return", "(", "object", ")", "[", "'sql'", "=>", "$", "sql", ",", "'types'", "=>", "$", "types", ",", "'parameters'", "=>", "$", "values", "]", ";", "}" ]
Resolve SQL statement. @param array $parameters Optional parameters for forming SQL statement. @return string Resolved SQL statement.
[ "Resolve", "SQL", "statement", "." ]
d22a494fd4814b3245fce20b4076eec1b382ffd3
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder/Template.php#L54-L77
train
ben-gibson/foursquare-venue-client
src/Factory/ContactFactory.php
ContactFactory.create
public function create(Description $description) { return new ContactEntity( $description->getOptionalProperty('phone'), $description->getOptionalProperty('twitter'), $description->getOptionalProperty('facebook') ); }
php
public function create(Description $description) { return new ContactEntity( $description->getOptionalProperty('phone'), $description->getOptionalProperty('twitter'), $description->getOptionalProperty('facebook') ); }
[ "public", "function", "create", "(", "Description", "$", "description", ")", "{", "return", "new", "ContactEntity", "(", "$", "description", "->", "getOptionalProperty", "(", "'phone'", ")", ",", "$", "description", "->", "getOptionalProperty", "(", "'twitter'", ")", ",", "$", "description", "->", "getOptionalProperty", "(", "'facebook'", ")", ")", ";", "}" ]
Create contact information from a description. @param Description $description The contact description. @return ContactEntity
[ "Create", "contact", "information", "from", "a", "description", "." ]
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Factory/ContactFactory.php#L19-L26
train
alphacomm/alpharpc
src/AlphaRPC/Manager/WorkerHandler/Action.php
Action.addWorker
public function addWorker($worker) { if (!$worker instanceof Worker) { throw new \Exception('$worker is not an instance of Worker'); } $this->workerList[$worker->getId()] = $worker; return $this; }
php
public function addWorker($worker) { if (!$worker instanceof Worker) { throw new \Exception('$worker is not an instance of Worker'); } $this->workerList[$worker->getId()] = $worker; return $this; }
[ "public", "function", "addWorker", "(", "$", "worker", ")", "{", "if", "(", "!", "$", "worker", "instanceof", "Worker", ")", "{", "throw", "new", "\\", "Exception", "(", "'$worker is not an instance of Worker'", ")", ";", "}", "$", "this", "->", "workerList", "[", "$", "worker", "->", "getId", "(", ")", "]", "=", "$", "worker", ";", "return", "$", "this", ";", "}" ]
Adds a worker to the action. @param Worker $worker @return Action @throws \Exception
[ "Adds", "a", "worker", "to", "the", "action", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Action.php#L76-L84
train