id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
4,700
quantaphp/class-names
src/Psr4Namespace.php
Psr4Namespace.fqcn
private function fqcn(): \Generator { foreach ($this->paths() as $root => $path) { $x = substr($path, strlen($root) + 1, -4); $fqcn = implode('', [$this->namespace, '\\', str_replace('/', '\\', $x)]); yield $fqcn => $fqcn; } }
php
private function fqcn(): \Generator { foreach ($this->paths() as $root => $path) { $x = substr($path, strlen($root) + 1, -4); $fqcn = implode('', [$this->namespace, '\\', str_replace('/', '\\', $x)]); yield $fqcn => $fqcn; } }
[ "private", "function", "fqcn", "(", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "paths", "(", ")", "as", "$", "root", "=>", "$", "path", ")", "{", "$", "x", "=", "substr", "(", "$", "path", ",", "strlen", "(", "$", "root", ")", "+", "1", ",", "-", "4", ")", ";", "$", "fqcn", "=", "implode", "(", "''", ",", "[", "$", "this", "->", "namespace", ",", "'\\\\'", ",", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "x", ")", "]", ")", ";", "yield", "$", "fqcn", "=>", "$", "fqcn", ";", "}", "}" ]
Yield the non redundant fully qualified class name of the classes. @return \Generator
[ "Yield", "the", "non", "redundant", "fully", "qualified", "class", "name", "of", "the", "classes", "." ]
2c0aea13ff82aa70df0fe6f78247415d15a994d1
https://github.com/quantaphp/class-names/blob/2c0aea13ff82aa70df0fe6f78247415d15a994d1/src/Psr4Namespace.php#L94-L103
4,701
mattjmattj/maybe
src/Maybe.php
Maybe.initProphecyReturnValues
private function initProphecyReturnValues() { $reflection = new \Maybe\Util\Reflection($this->classname); $returnTypes = $reflection->getReturnTypes(); foreach ($returnTypes as $method => $type) { $this->initProphecyReturnValueForMethod($method, $type); } }
php
private function initProphecyReturnValues() { $reflection = new \Maybe\Util\Reflection($this->classname); $returnTypes = $reflection->getReturnTypes(); foreach ($returnTypes as $method => $type) { $this->initProphecyReturnValueForMethod($method, $type); } }
[ "private", "function", "initProphecyReturnValues", "(", ")", "{", "$", "reflection", "=", "new", "\\", "Maybe", "\\", "Util", "\\", "Reflection", "(", "$", "this", "->", "classname", ")", ";", "$", "returnTypes", "=", "$", "reflection", "->", "getReturnTypes", "(", ")", ";", "foreach", "(", "$", "returnTypes", "as", "$", "method", "=>", "$", "type", ")", "{", "$", "this", "->", "initProphecyReturnValueForMethod", "(", "$", "method", ",", "$", "type", ")", ";", "}", "}" ]
Tries to set a coherent return value for each of the faked method, using Reflection API.
[ "Tries", "to", "set", "a", "coherent", "return", "value", "for", "each", "of", "the", "faked", "method", "using", "Reflection", "API", "." ]
a58f5676cad4dfde7738829002e059452c98c042
https://github.com/mattjmattj/maybe/blob/a58f5676cad4dfde7738829002e059452c98c042/src/Maybe.php#L87-L94
4,702
chenwenzhang/initially-rpc
src/Initially/Rpc/Core/Web/App.php
App.handle
public function handle() { $action = isset($_GET["action"]) ? trim($_GET["action"]) : "list"; $control = new Control(); switch ($action) { case "detail": $control->detailAction(); break; default: $control->listAction(); } }
php
public function handle() { $action = isset($_GET["action"]) ? trim($_GET["action"]) : "list"; $control = new Control(); switch ($action) { case "detail": $control->detailAction(); break; default: $control->listAction(); } }
[ "public", "function", "handle", "(", ")", "{", "$", "action", "=", "isset", "(", "$", "_GET", "[", "\"action\"", "]", ")", "?", "trim", "(", "$", "_GET", "[", "\"action\"", "]", ")", ":", "\"list\"", ";", "$", "control", "=", "new", "Control", "(", ")", ";", "switch", "(", "$", "action", ")", "{", "case", "\"detail\"", ":", "$", "control", "->", "detailAction", "(", ")", ";", "break", ";", "default", ":", "$", "control", "->", "listAction", "(", ")", ";", "}", "}" ]
Web app handle
[ "Web", "app", "handle" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Core/Web/App.php#L10-L21
4,703
headzoo/core
src/Headzoo/Core/Errors.php
Errors.toInteger
public static function toInteger($error) { if (is_string($error) && isset(self::$errors[$error])) { $error = self::$errors[$error]; } if (!is_int($error) || !in_array($error, self::$errors)) { self::toss( "InvalidArgument", "The value {0} is not a valid E_ERROR constant value.", $error ); } return $error; }
php
public static function toInteger($error) { if (is_string($error) && isset(self::$errors[$error])) { $error = self::$errors[$error]; } if (!is_int($error) || !in_array($error, self::$errors)) { self::toss( "InvalidArgument", "The value {0} is not a valid E_ERROR constant value.", $error ); } return $error; }
[ "public", "static", "function", "toInteger", "(", "$", "error", ")", "{", "if", "(", "is_string", "(", "$", "error", ")", "&&", "isset", "(", "self", "::", "$", "errors", "[", "$", "error", "]", ")", ")", "{", "$", "error", "=", "self", "::", "$", "errors", "[", "$", "error", "]", ";", "}", "if", "(", "!", "is_int", "(", "$", "error", ")", "||", "!", "in_array", "(", "$", "error", ",", "self", "::", "$", "errors", ")", ")", "{", "self", "::", "toss", "(", "\"InvalidArgument\"", ",", "\"The value {0} is not a valid E_ERROR constant value.\"", ",", "$", "error", ")", ";", "}", "return", "$", "error", ";", "}" ]
Returns the value of the error as an integer The value of $error may be either one of the E_ERROR constants, or a string naming one of the constants. The integer value of the constant is returned, or an exception is thrown when $error is not valid. The $error argument may be either an integer (one of the E_ERROR values) or a string with the name of an E_ERROR constant. Examples: ```php echo Errors::toInteger("E_STRICT"); // Outputs: 2048 echo Errors::toInteger(E_WARNING); // Outputs: 2 ``` @param string|int $error The error to convert @throws Exceptions\InvalidArgumentException When $error is not a valid E_ERROR constant @return int
[ "Returns", "the", "value", "of", "the", "error", "as", "an", "integer" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/Errors.php#L120-L134
4,704
headzoo/core
src/Headzoo/Core/Errors.php
Errors.toString
public static function toString($error) { if (is_int($error) && in_array($error, self::$errors)) { $error = array_search($error, self::$errors); } if (!is_string($error) || !isset(self::$errors[$error])) { self::toss( "InvalidArgument", "The value {0} is not a valid E_ERROR constant value.", $error ); } return $error; }
php
public static function toString($error) { if (is_int($error) && in_array($error, self::$errors)) { $error = array_search($error, self::$errors); } if (!is_string($error) || !isset(self::$errors[$error])) { self::toss( "InvalidArgument", "The value {0} is not a valid E_ERROR constant value.", $error ); } return $error; }
[ "public", "static", "function", "toString", "(", "$", "error", ")", "{", "if", "(", "is_int", "(", "$", "error", ")", "&&", "in_array", "(", "$", "error", ",", "self", "::", "$", "errors", ")", ")", "{", "$", "error", "=", "array_search", "(", "$", "error", ",", "self", "::", "$", "errors", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "error", ")", "||", "!", "isset", "(", "self", "::", "$", "errors", "[", "$", "error", "]", ")", ")", "{", "self", "::", "toss", "(", "\"InvalidArgument\"", ",", "\"The value {0} is not a valid E_ERROR constant value.\"", ",", "$", "error", ")", ";", "}", "return", "$", "error", ";", "}" ]
Returns the value of the error as a string Returns the string representation of the given error. For example when given an E_WARNING, the method returns "E_WARNING". The $error argument may be either an integer (one of the E_ERROR values) or a string with the name of an E_ERROR constant. Examples: ```php echo Errors::toString(E_WARNING); // Outputs: "E_WARNING" echo Errors::toString("E_CORE_ERROR"); // Outputs: "E_CORE_ERROR" ``` @param int|string $error The error to convert @throws Exceptions\InvalidArgumentException When $error is not a valid E_ERROR constant @return int
[ "Returns", "the", "value", "of", "the", "error", "as", "a", "string" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/Errors.php#L160-L174
4,705
headzoo/core
src/Headzoo/Core/Errors.php
Errors.toUser
public static function toUser(&$error) { $error_int = self::toInteger($error); switch($error_int) { case E_ERROR: $error = E_USER_ERROR; break; case E_WARNING: $error = E_USER_WARNING; break; case E_NOTICE: $error = E_USER_NOTICE; break; case E_DEPRECATED: $error = E_USER_DEPRECATED; break; } return self::isTrueUser($error); }
php
public static function toUser(&$error) { $error_int = self::toInteger($error); switch($error_int) { case E_ERROR: $error = E_USER_ERROR; break; case E_WARNING: $error = E_USER_WARNING; break; case E_NOTICE: $error = E_USER_NOTICE; break; case E_DEPRECATED: $error = E_USER_DEPRECATED; break; } return self::isTrueUser($error); }
[ "public", "static", "function", "toUser", "(", "&", "$", "error", ")", "{", "$", "error_int", "=", "self", "::", "toInteger", "(", "$", "error", ")", ";", "switch", "(", "$", "error_int", ")", "{", "case", "E_ERROR", ":", "$", "error", "=", "E_USER_ERROR", ";", "break", ";", "case", "E_WARNING", ":", "$", "error", "=", "E_USER_WARNING", ";", "break", ";", "case", "E_NOTICE", ":", "$", "error", "=", "E_USER_NOTICE", ";", "break", ";", "case", "E_DEPRECATED", ":", "$", "error", "=", "E_USER_DEPRECATED", ";", "break", ";", "}", "return", "self", "::", "isTrueUser", "(", "$", "error", ")", ";", "}" ]
Converts an E_ERROR constant to the E_USER_ERROR equivalent For example when given an E_WARNING constant value, the error is converted into an E_USER_WARNING value. Not all E_ERROR constants have E_USER_ERROR equivalents. In those cases the error remains unchanged, and the method returns false. Returns whether the error is an E_USER_ERROR. Either before or after converting. Examples: ```php $error = E_ERROR; $is_user = Errors::toUser($error); var_dump($error); var_dump($is_user); // Outputs: // 256 (E_USER_ERROR) // bool(true) $error = E_USER_WARNING; $is_user = Errors::toUser($error); var_dump($error); var_dump($is_user); // Outputs: // 512 (E_USER_WARNING) // bool(true) $error = E_CORE_ERROR; $is_user = Errors::toUser($error); var_dump($error); var_dump($is_user); // Outputs: // 16 (E_CORE_ERROR) // bool(false) ``` @param int $error The error to convert @return bool
[ "Converts", "an", "E_ERROR", "constant", "to", "the", "E_USER_ERROR", "equivalent" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/Errors.php#L219-L238
4,706
phlexible/media-manager
Upload/TempStorage.php
TempStorage.store
public function store(UploadedFileSource $file, $folderId, $userId, $originalFileId, $useWizard) { $tempId = uniqid(); $tempDir = $this->tempDir.'/'.$tempId.'/'; $tempName = $tempDir.basename($file->getPath()); if (!file_exists($tempDir) && !mkdir($tempDir, 0777, true)) { throw new StoreUploadedFileException('Error occured while creating temp upload folder.'); } if (!move_uploaded_file($file->getPath(), $tempName)) { throw new StoreUploadedFileException('Error occured during uploaded file move.'); } $tempFile = new TempFile( $tempId, $file->getName(), $tempName, $file->getMimeType(), $file->getSize(), $this->hasher->fromPath($tempName), $originalFileId, $folderId, $userId, $useWizard ); /* $event = new BeforeStoreUploadEvent($this, $tempFile); if ($this->dispatcher->dispatch(MediaSiteEvents::BEFORE_STORE_UPLOAD, $event)->isPropagationStopped()) { return null; } */ $tempFiles = $this->session->get('mediamanager.temp_files'); $tempFiles[$tempId] = $tempFile; $this->session->set('mediamanager.temp_files', $tempFiles); /* $event = new StoreUploadEvent($this, $tempFile); $this->dispatcher->dispatch(MediaSiteEvents::STORE_UPLOAD, $event); */ return $tempFile; }
php
public function store(UploadedFileSource $file, $folderId, $userId, $originalFileId, $useWizard) { $tempId = uniqid(); $tempDir = $this->tempDir.'/'.$tempId.'/'; $tempName = $tempDir.basename($file->getPath()); if (!file_exists($tempDir) && !mkdir($tempDir, 0777, true)) { throw new StoreUploadedFileException('Error occured while creating temp upload folder.'); } if (!move_uploaded_file($file->getPath(), $tempName)) { throw new StoreUploadedFileException('Error occured during uploaded file move.'); } $tempFile = new TempFile( $tempId, $file->getName(), $tempName, $file->getMimeType(), $file->getSize(), $this->hasher->fromPath($tempName), $originalFileId, $folderId, $userId, $useWizard ); /* $event = new BeforeStoreUploadEvent($this, $tempFile); if ($this->dispatcher->dispatch(MediaSiteEvents::BEFORE_STORE_UPLOAD, $event)->isPropagationStopped()) { return null; } */ $tempFiles = $this->session->get('mediamanager.temp_files'); $tempFiles[$tempId] = $tempFile; $this->session->set('mediamanager.temp_files', $tempFiles); /* $event = new StoreUploadEvent($this, $tempFile); $this->dispatcher->dispatch(MediaSiteEvents::STORE_UPLOAD, $event); */ return $tempFile; }
[ "public", "function", "store", "(", "UploadedFileSource", "$", "file", ",", "$", "folderId", ",", "$", "userId", ",", "$", "originalFileId", ",", "$", "useWizard", ")", "{", "$", "tempId", "=", "uniqid", "(", ")", ";", "$", "tempDir", "=", "$", "this", "->", "tempDir", ".", "'/'", ".", "$", "tempId", ".", "'/'", ";", "$", "tempName", "=", "$", "tempDir", ".", "basename", "(", "$", "file", "->", "getPath", "(", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "tempDir", ")", "&&", "!", "mkdir", "(", "$", "tempDir", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "StoreUploadedFileException", "(", "'Error occured while creating temp upload folder.'", ")", ";", "}", "if", "(", "!", "move_uploaded_file", "(", "$", "file", "->", "getPath", "(", ")", ",", "$", "tempName", ")", ")", "{", "throw", "new", "StoreUploadedFileException", "(", "'Error occured during uploaded file move.'", ")", ";", "}", "$", "tempFile", "=", "new", "TempFile", "(", "$", "tempId", ",", "$", "file", "->", "getName", "(", ")", ",", "$", "tempName", ",", "$", "file", "->", "getMimeType", "(", ")", ",", "$", "file", "->", "getSize", "(", ")", ",", "$", "this", "->", "hasher", "->", "fromPath", "(", "$", "tempName", ")", ",", "$", "originalFileId", ",", "$", "folderId", ",", "$", "userId", ",", "$", "useWizard", ")", ";", "/*\n $event = new BeforeStoreUploadEvent($this, $tempFile);\n if ($this->dispatcher->dispatch(MediaSiteEvents::BEFORE_STORE_UPLOAD, $event)->isPropagationStopped()) {\n return null;\n }\n */", "$", "tempFiles", "=", "$", "this", "->", "session", "->", "get", "(", "'mediamanager.temp_files'", ")", ";", "$", "tempFiles", "[", "$", "tempId", "]", "=", "$", "tempFile", ";", "$", "this", "->", "session", "->", "set", "(", "'mediamanager.temp_files'", ",", "$", "tempFiles", ")", ";", "/*\n $event = new StoreUploadEvent($this, $tempFile);\n $this->dispatcher->dispatch(MediaSiteEvents::STORE_UPLOAD, $event);\n */", "return", "$", "tempFile", ";", "}" ]
Store upload. @param UploadedFileSource $file @param string $folderId @param int $userId @param string $originalFileId @param bool $useWizard @return TempFile @throws \Exception
[ "Store", "upload", "." ]
e4835062c9be575fc0e5ab67f25f02a50a85a7f6
https://github.com/phlexible/media-manager/blob/e4835062c9be575fc0e5ab67f25f02a50a85a7f6/Upload/TempStorage.php#L164-L208
4,707
slickframework/i18n
src/Language.php
Language.parseLanguage
private static function parseLanguage($code) { $lang = substr($code, 0, 2); foreach (self::codes() as $code) { if ($code['code'] == strtolower($lang)) { return [strtolower($lang), $code['description']]; } } throw new UnknownLanguageCodeException( "The language code '{$code}'' is unknown." ); }
php
private static function parseLanguage($code) { $lang = substr($code, 0, 2); foreach (self::codes() as $code) { if ($code['code'] == strtolower($lang)) { return [strtolower($lang), $code['description']]; } } throw new UnknownLanguageCodeException( "The language code '{$code}'' is unknown." ); }
[ "private", "static", "function", "parseLanguage", "(", "$", "code", ")", "{", "$", "lang", "=", "substr", "(", "$", "code", ",", "0", ",", "2", ")", ";", "foreach", "(", "self", "::", "codes", "(", ")", "as", "$", "code", ")", "{", "if", "(", "$", "code", "[", "'code'", "]", "==", "strtolower", "(", "$", "lang", ")", ")", "{", "return", "[", "strtolower", "(", "$", "lang", ")", ",", "$", "code", "[", "'description'", "]", "]", ";", "}", "}", "throw", "new", "UnknownLanguageCodeException", "(", "\"The language code '{$code}'' is unknown.\"", ")", ";", "}" ]
Get language code @param string $code @return array
[ "Get", "language", "code" ]
3d6d9bad8e0f7ac02f6e9919821cf49371fc9353
https://github.com/slickframework/i18n/blob/3d6d9bad8e0f7ac02f6e9919821cf49371fc9353/src/Language.php#L131-L143
4,708
slickframework/i18n
src/Language.php
Language.parseRegion
private static function parseRegion($code) { $lang = substr($code, 0, 2); $reg = strtoupper(substr($code, 3, 2)); $needle = "{$lang}-{$reg}"; foreach (self::codes() as $code) { if ($code['code'] == $needle) { return [$reg, $code['description']]; } } throw new UnknownLanguageCodeException( "The region code '{$code}'' is unknown." ); }
php
private static function parseRegion($code) { $lang = substr($code, 0, 2); $reg = strtoupper(substr($code, 3, 2)); $needle = "{$lang}-{$reg}"; foreach (self::codes() as $code) { if ($code['code'] == $needle) { return [$reg, $code['description']]; } } throw new UnknownLanguageCodeException( "The region code '{$code}'' is unknown." ); }
[ "private", "static", "function", "parseRegion", "(", "$", "code", ")", "{", "$", "lang", "=", "substr", "(", "$", "code", ",", "0", ",", "2", ")", ";", "$", "reg", "=", "strtoupper", "(", "substr", "(", "$", "code", ",", "3", ",", "2", ")", ")", ";", "$", "needle", "=", "\"{$lang}-{$reg}\"", ";", "foreach", "(", "self", "::", "codes", "(", ")", "as", "$", "code", ")", "{", "if", "(", "$", "code", "[", "'code'", "]", "==", "$", "needle", ")", "{", "return", "[", "$", "reg", ",", "$", "code", "[", "'description'", "]", "]", ";", "}", "}", "throw", "new", "UnknownLanguageCodeException", "(", "\"The region code '{$code}'' is unknown.\"", ")", ";", "}" ]
Get regina name and code @param string $code @return array
[ "Get", "regina", "name", "and", "code" ]
3d6d9bad8e0f7ac02f6e9919821cf49371fc9353
https://github.com/slickframework/i18n/blob/3d6d9bad8e0f7ac02f6e9919821cf49371fc9353/src/Language.php#L152-L166
4,709
sndatabase/core
src/DB.php
DB.register
final public static function register(Factory $factory) { if(!isset(self::$factories[$factory->driver])) self::$factories[$factory->driver] = $factory; }
php
final public static function register(Factory $factory) { if(!isset(self::$factories[$factory->driver])) self::$factories[$factory->driver] = $factory; }
[ "final", "public", "static", "function", "register", "(", "Factory", "$", "factory", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "factories", "[", "$", "factory", "->", "driver", "]", ")", ")", "self", "::", "$", "factories", "[", "$", "factory", "->", "driver", "]", "=", "$", "factory", ";", "}" ]
Registers a driver, based on its factory @param Factory $factory
[ "Registers", "a", "driver", "based", "on", "its", "factory" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/DB.php#L81-L84
4,710
sndatabase/core
src/DB.php
DB.getFactory
final private static function getFactory($driver) { $key = array_search(strtolower($driver), array_map('strtolower', array_keys(self::$factories))); if($key === false) throw new DriverException('Driver not found'); $factories = array_values(self::$factories); return $factories[$key]; }
php
final private static function getFactory($driver) { $key = array_search(strtolower($driver), array_map('strtolower', array_keys(self::$factories))); if($key === false) throw new DriverException('Driver not found'); $factories = array_values(self::$factories); return $factories[$key]; }
[ "final", "private", "static", "function", "getFactory", "(", "$", "driver", ")", "{", "$", "key", "=", "array_search", "(", "strtolower", "(", "$", "driver", ")", ",", "array_map", "(", "'strtolower'", ",", "array_keys", "(", "self", "::", "$", "factories", ")", ")", ")", ";", "if", "(", "$", "key", "===", "false", ")", "throw", "new", "DriverException", "(", "'Driver not found'", ")", ";", "$", "factories", "=", "array_values", "(", "self", "::", "$", "factories", ")", ";", "return", "$", "factories", "[", "$", "key", "]", ";", "}" ]
Get a factory for the requested driver @param string $driver Driver name. Case insensitive. @return Factory Matching factory. @throws DriverException
[ "Get", "a", "factory", "for", "the", "requested", "driver" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/DB.php#L100-L105
4,711
sndatabase/core
src/DB.php
DB.getConnection
final public static function getConnection($cnxString) { $factory = self::getFactory(parse_url($cnxString, PHP_URL_SCHEME)); return $factory->getConnection($cnxString); }
php
final public static function getConnection($cnxString) { $factory = self::getFactory(parse_url($cnxString, PHP_URL_SCHEME)); return $factory->getConnection($cnxString); }
[ "final", "public", "static", "function", "getConnection", "(", "$", "cnxString", ")", "{", "$", "factory", "=", "self", "::", "getFactory", "(", "parse_url", "(", "$", "cnxString", ",", "PHP_URL_SCHEME", ")", ")", ";", "return", "$", "factory", "->", "getConnection", "(", "$", "cnxString", ")", ";", "}" ]
Get connection from connection string @param string $cnxString Connection string @return Connection Connection instance @throws ConnectionFailedException @throws DriverException
[ "Get", "connection", "from", "connection", "string" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/DB.php#L114-L117
4,712
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/parser/classes/twig/fuel/extension.php
Twig_Fuel_Extension.getFunctions
public function getFunctions() { return array( 'fuel_version' => new Twig_Function_Method($this, 'fuel_version'), 'url' => new Twig_Function_Method($this, 'url'), 'base_url' => new Twig_Function_Function('Uri::base'), 'current_url' => new Twig_Function_Function('Uri::current'), 'uri_segment' => new Twig_Function_Function('Uri::segment'), 'uri_segments' => new Twig_Function_Function('Uri::segments'), 'config' => new Twig_Function_Function('Config::get'), 'lang' => new Twig_Function_Function('Lang::get'), 'form_open' => new Twig_Function_Function('Form::open'), 'form_close' => new Twig_Function_Function('Form::close'), 'form_input' => new Twig_Function_Function('Form::input'), 'form_password' => new Twig_Function_Function('Form::password'), 'form_hidden' => new Twig_Function_Function('Form::hidden'), 'form_radio' => new Twig_Function_Function('Form::radio'), 'form_checkbox' => new Twig_Function_Function('Form::checkbox'), 'form_textarea' => new Twig_Function_Function('Form::textarea'), 'form_file' => new Twig_Function_Function('Form::file'), 'form_button' => new Twig_Function_Function('Form::button'), 'form_reset' => new Twig_Function_Function('Form::reset'), 'form_submit' => new Twig_Function_Function('Form::submit'), 'form_select' => new Twig_Function_Function('Form::select'), 'form_label' => new Twig_Function_Function('Form::label'), 'form_val' => new Twig_Function_Function('Input::param'), 'input_get' => new Twig_Function_Function('Input::get'), 'input_post' => new Twig_Function_Function('Input::post'), 'asset_add_path' => new Twig_Function_Function('Asset::add_path'), 'asset_css' => new Twig_Function_Function('Asset::css'), 'asset_js' => new Twig_Function_Function('Asset::js'), 'asset_img' => new Twig_Function_Function('Asset::img'), 'asset_render' => new Twig_Function_Function('Asset::render'), 'asset_find_file' => new Twig_Function_Function('Asset::find_file'), 'html_anchor' => new Twig_Function_Function('Html::anchor'), 'session_get' => new Twig_Function_Function('Session::get'), 'session_get_flash' => new Twig_Function_Function('Session::get_flash'), 'markdown_parse' => new Twig_Function_Function('Markdown::parse'), 'auth_has_access' => new Twig_Function_Function('Auth::has_access'), 'auth_check' => new Twig_Function_Function('Auth::check') ); }
php
public function getFunctions() { return array( 'fuel_version' => new Twig_Function_Method($this, 'fuel_version'), 'url' => new Twig_Function_Method($this, 'url'), 'base_url' => new Twig_Function_Function('Uri::base'), 'current_url' => new Twig_Function_Function('Uri::current'), 'uri_segment' => new Twig_Function_Function('Uri::segment'), 'uri_segments' => new Twig_Function_Function('Uri::segments'), 'config' => new Twig_Function_Function('Config::get'), 'lang' => new Twig_Function_Function('Lang::get'), 'form_open' => new Twig_Function_Function('Form::open'), 'form_close' => new Twig_Function_Function('Form::close'), 'form_input' => new Twig_Function_Function('Form::input'), 'form_password' => new Twig_Function_Function('Form::password'), 'form_hidden' => new Twig_Function_Function('Form::hidden'), 'form_radio' => new Twig_Function_Function('Form::radio'), 'form_checkbox' => new Twig_Function_Function('Form::checkbox'), 'form_textarea' => new Twig_Function_Function('Form::textarea'), 'form_file' => new Twig_Function_Function('Form::file'), 'form_button' => new Twig_Function_Function('Form::button'), 'form_reset' => new Twig_Function_Function('Form::reset'), 'form_submit' => new Twig_Function_Function('Form::submit'), 'form_select' => new Twig_Function_Function('Form::select'), 'form_label' => new Twig_Function_Function('Form::label'), 'form_val' => new Twig_Function_Function('Input::param'), 'input_get' => new Twig_Function_Function('Input::get'), 'input_post' => new Twig_Function_Function('Input::post'), 'asset_add_path' => new Twig_Function_Function('Asset::add_path'), 'asset_css' => new Twig_Function_Function('Asset::css'), 'asset_js' => new Twig_Function_Function('Asset::js'), 'asset_img' => new Twig_Function_Function('Asset::img'), 'asset_render' => new Twig_Function_Function('Asset::render'), 'asset_find_file' => new Twig_Function_Function('Asset::find_file'), 'html_anchor' => new Twig_Function_Function('Html::anchor'), 'session_get' => new Twig_Function_Function('Session::get'), 'session_get_flash' => new Twig_Function_Function('Session::get_flash'), 'markdown_parse' => new Twig_Function_Function('Markdown::parse'), 'auth_has_access' => new Twig_Function_Function('Auth::has_access'), 'auth_check' => new Twig_Function_Function('Auth::check') ); }
[ "public", "function", "getFunctions", "(", ")", "{", "return", "array", "(", "'fuel_version'", "=>", "new", "Twig_Function_Method", "(", "$", "this", ",", "'fuel_version'", ")", ",", "'url'", "=>", "new", "Twig_Function_Method", "(", "$", "this", ",", "'url'", ")", ",", "'base_url'", "=>", "new", "Twig_Function_Function", "(", "'Uri::base'", ")", ",", "'current_url'", "=>", "new", "Twig_Function_Function", "(", "'Uri::current'", ")", ",", "'uri_segment'", "=>", "new", "Twig_Function_Function", "(", "'Uri::segment'", ")", ",", "'uri_segments'", "=>", "new", "Twig_Function_Function", "(", "'Uri::segments'", ")", ",", "'config'", "=>", "new", "Twig_Function_Function", "(", "'Config::get'", ")", ",", "'lang'", "=>", "new", "Twig_Function_Function", "(", "'Lang::get'", ")", ",", "'form_open'", "=>", "new", "Twig_Function_Function", "(", "'Form::open'", ")", ",", "'form_close'", "=>", "new", "Twig_Function_Function", "(", "'Form::close'", ")", ",", "'form_input'", "=>", "new", "Twig_Function_Function", "(", "'Form::input'", ")", ",", "'form_password'", "=>", "new", "Twig_Function_Function", "(", "'Form::password'", ")", ",", "'form_hidden'", "=>", "new", "Twig_Function_Function", "(", "'Form::hidden'", ")", ",", "'form_radio'", "=>", "new", "Twig_Function_Function", "(", "'Form::radio'", ")", ",", "'form_checkbox'", "=>", "new", "Twig_Function_Function", "(", "'Form::checkbox'", ")", ",", "'form_textarea'", "=>", "new", "Twig_Function_Function", "(", "'Form::textarea'", ")", ",", "'form_file'", "=>", "new", "Twig_Function_Function", "(", "'Form::file'", ")", ",", "'form_button'", "=>", "new", "Twig_Function_Function", "(", "'Form::button'", ")", ",", "'form_reset'", "=>", "new", "Twig_Function_Function", "(", "'Form::reset'", ")", ",", "'form_submit'", "=>", "new", "Twig_Function_Function", "(", "'Form::submit'", ")", ",", "'form_select'", "=>", "new", "Twig_Function_Function", "(", "'Form::select'", ")", ",", "'form_label'", "=>", "new", "Twig_Function_Function", "(", "'Form::label'", ")", ",", "'form_val'", "=>", "new", "Twig_Function_Function", "(", "'Input::param'", ")", ",", "'input_get'", "=>", "new", "Twig_Function_Function", "(", "'Input::get'", ")", ",", "'input_post'", "=>", "new", "Twig_Function_Function", "(", "'Input::post'", ")", ",", "'asset_add_path'", "=>", "new", "Twig_Function_Function", "(", "'Asset::add_path'", ")", ",", "'asset_css'", "=>", "new", "Twig_Function_Function", "(", "'Asset::css'", ")", ",", "'asset_js'", "=>", "new", "Twig_Function_Function", "(", "'Asset::js'", ")", ",", "'asset_img'", "=>", "new", "Twig_Function_Function", "(", "'Asset::img'", ")", ",", "'asset_render'", "=>", "new", "Twig_Function_Function", "(", "'Asset::render'", ")", ",", "'asset_find_file'", "=>", "new", "Twig_Function_Function", "(", "'Asset::find_file'", ")", ",", "'html_anchor'", "=>", "new", "Twig_Function_Function", "(", "'Html::anchor'", ")", ",", "'session_get'", "=>", "new", "Twig_Function_Function", "(", "'Session::get'", ")", ",", "'session_get_flash'", "=>", "new", "Twig_Function_Function", "(", "'Session::get_flash'", ")", ",", "'markdown_parse'", "=>", "new", "Twig_Function_Function", "(", "'Markdown::parse'", ")", ",", "'auth_has_access'", "=>", "new", "Twig_Function_Function", "(", "'Auth::has_access'", ")", ",", "'auth_check'", "=>", "new", "Twig_Function_Function", "(", "'Auth::check'", ")", ")", ";", "}" ]
Sets up all of the functions this extension makes available. @return array
[ "Sets", "up", "all", "of", "the", "functions", "this", "extension", "makes", "available", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/parser/classes/twig/fuel/extension.php#L43-L94
4,713
webriq/core
module/User/src/Grid/User/Authentication/Service.php
Service.onLogin
public function onLogin( Event $event ) { $adapter = $this->getAuthenticationAdapterFactory() ->factory( $event->getParams() ); $result = $event->getAuthenticationService() ->authenticate( $adapter ); $event->setResult( $result ); return $result; }
php
public function onLogin( Event $event ) { $adapter = $this->getAuthenticationAdapterFactory() ->factory( $event->getParams() ); $result = $event->getAuthenticationService() ->authenticate( $adapter ); $event->setResult( $result ); return $result; }
[ "public", "function", "onLogin", "(", "Event", "$", "event", ")", "{", "$", "adapter", "=", "$", "this", "->", "getAuthenticationAdapterFactory", "(", ")", "->", "factory", "(", "$", "event", "->", "getParams", "(", ")", ")", ";", "$", "result", "=", "$", "event", "->", "getAuthenticationService", "(", ")", "->", "authenticate", "(", "$", "adapter", ")", ";", "$", "event", "->", "setResult", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Default action on login @param \User\Authentication\Event $event @return \Zend\Authentication\Result
[ "Default", "action", "on", "login" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/Authentication/Service.php#L92-L100
4,714
Sowapps/orpheus-inputcontroller
src/InputController/CLIController/CLIArgument.php
CLIArgument.make
public static function make($name, $config) { $required = false; if( $config[0] === '+' ) { $required = true; $config = substr($config, 1); } list($shortName, $type) = explodeList(':', $config, 2); return new static($name, $shortName, $type, $required); }
php
public static function make($name, $config) { $required = false; if( $config[0] === '+' ) { $required = true; $config = substr($config, 1); } list($shortName, $type) = explodeList(':', $config, 2); return new static($name, $shortName, $type, $required); }
[ "public", "static", "function", "make", "(", "$", "name", ",", "$", "config", ")", "{", "$", "required", "=", "false", ";", "if", "(", "$", "config", "[", "0", "]", "===", "'+'", ")", "{", "$", "required", "=", "true", ";", "$", "config", "=", "substr", "(", "$", "config", ",", "1", ")", ";", "}", "list", "(", "$", "shortName", ",", "$", "type", ")", "=", "explodeList", "(", "':'", ",", "$", "config", ",", "2", ")", ";", "return", "new", "static", "(", "$", "name", ",", "$", "shortName", ",", "$", "type", ",", "$", "required", ")", ";", "}" ]
Make a CLIArgument from config @param string $name @param string $config @return \Orpheus\InputController\CLIArgument
[ "Make", "a", "CLIArgument", "from", "config" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/CLIController/CLIArgument.php#L79-L87
4,715
teeebor/decoy-framework
utils/httpBody/FormBody.php
FormBody.parse
private function parse(){ $inputs = explode('&',$this->input); foreach($inputs as $input){ $exp = explode('=',$input); if(count($exp)==2) $this->content[urldecode($exp[0])] = urldecode($exp[1]); } }
php
private function parse(){ $inputs = explode('&',$this->input); foreach($inputs as $input){ $exp = explode('=',$input); if(count($exp)==2) $this->content[urldecode($exp[0])] = urldecode($exp[1]); } }
[ "private", "function", "parse", "(", ")", "{", "$", "inputs", "=", "explode", "(", "'&'", ",", "$", "this", "->", "input", ")", ";", "foreach", "(", "$", "inputs", "as", "$", "input", ")", "{", "$", "exp", "=", "explode", "(", "'='", ",", "$", "input", ")", ";", "if", "(", "count", "(", "$", "exp", ")", "==", "2", ")", "$", "this", "->", "content", "[", "urldecode", "(", "$", "exp", "[", "0", "]", ")", "]", "=", "urldecode", "(", "$", "exp", "[", "1", "]", ")", ";", "}", "}" ]
Parsing the sent input
[ "Parsing", "the", "sent", "input" ]
3881ae63a7d13088efda5afd3932c1af1fc18b23
https://github.com/teeebor/decoy-framework/blob/3881ae63a7d13088efda5afd3932c1af1fc18b23/utils/httpBody/FormBody.php#L29-L36
4,716
apitude/apitude
src/Validator/Constraints/NotBlankOrWhitespaceValidator.php
NotBlankOrWhitespaceValidator.validate
public function validate($value, Constraint $constraint) { $value = trim($value); parent::validate($value, $constraint); }
php
public function validate($value, Constraint $constraint) { $value = trim($value); parent::validate($value, $constraint); }
[ "public", "function", "validate", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "parent", "::", "validate", "(", "$", "value", ",", "$", "constraint", ")", ";", "}" ]
Trim value before passing to NotBlankValidator {@inheritdoc} @param string $value Value to validate @param Constraint $constraint Constraint object
[ "Trim", "value", "before", "passing", "to", "NotBlankValidator" ]
ccf503e42214184f96cd73b4e0fc5d06c377bce5
https://github.com/apitude/apitude/blob/ccf503e42214184f96cd73b4e0fc5d06c377bce5/src/Validator/Constraints/NotBlankOrWhitespaceValidator.php#L18-L23
4,717
erikkubica/netlime-theme-image
ThemeImage.php
ThemeImage.registerImageSizes
protected function registerImageSizes() { do_action("before_theme_register_image-sizes"); foreach ($this->getConfig("image-sizes") as $id => $data): add_image_size($id, $data["width"], $data["height"], $data["crop"]); endforeach; do_action("after_theme_register_image-sizes"); }
php
protected function registerImageSizes() { do_action("before_theme_register_image-sizes"); foreach ($this->getConfig("image-sizes") as $id => $data): add_image_size($id, $data["width"], $data["height"], $data["crop"]); endforeach; do_action("after_theme_register_image-sizes"); }
[ "protected", "function", "registerImageSizes", "(", ")", "{", "do_action", "(", "\"before_theme_register_image-sizes\"", ")", ";", "foreach", "(", "$", "this", "->", "getConfig", "(", "\"image-sizes\"", ")", "as", "$", "id", "=>", "$", "data", ")", ":", "add_image_size", "(", "$", "id", ",", "$", "data", "[", "\"width\"", "]", ",", "$", "data", "[", "\"height\"", "]", ",", "$", "data", "[", "\"crop\"", "]", ")", ";", "endforeach", ";", "do_action", "(", "\"after_theme_register_image-sizes\"", ")", ";", "}" ]
Registers image sizes from config
[ "Registers", "image", "sizes", "from", "config" ]
8795c429b79a2869bea49bc899d5653300d41323
https://github.com/erikkubica/netlime-theme-image/blob/8795c429b79a2869bea49bc899d5653300d41323/ThemeImage.php#L17-L26
4,718
erikkubica/netlime-theme-image
ThemeImage.php
ThemeImage.getImage
public function getImage($attachment_id, $size = "post-thumbnail", $placeholder = true) { $sizes = $this->getConfig("image-sizes"); if (isset($sizes[$size]) && $placeholder) { $image = "//placehold.it/" . $sizes[$size]["width"] . "x" . $sizes[$size]["height"]; } else { $image = false; } $imgData = wp_get_attachment_image_src($attachment_id, $size); if ($imgData && is_array($imgData) && isset($imgData[0]) && $imgData[0]): $image = $imgData[0]; endif; return $image; }
php
public function getImage($attachment_id, $size = "post-thumbnail", $placeholder = true) { $sizes = $this->getConfig("image-sizes"); if (isset($sizes[$size]) && $placeholder) { $image = "//placehold.it/" . $sizes[$size]["width"] . "x" . $sizes[$size]["height"]; } else { $image = false; } $imgData = wp_get_attachment_image_src($attachment_id, $size); if ($imgData && is_array($imgData) && isset($imgData[0]) && $imgData[0]): $image = $imgData[0]; endif; return $image; }
[ "public", "function", "getImage", "(", "$", "attachment_id", ",", "$", "size", "=", "\"post-thumbnail\"", ",", "$", "placeholder", "=", "true", ")", "{", "$", "sizes", "=", "$", "this", "->", "getConfig", "(", "\"image-sizes\"", ")", ";", "if", "(", "isset", "(", "$", "sizes", "[", "$", "size", "]", ")", "&&", "$", "placeholder", ")", "{", "$", "image", "=", "\"//placehold.it/\"", ".", "$", "sizes", "[", "$", "size", "]", "[", "\"width\"", "]", ".", "\"x\"", ".", "$", "sizes", "[", "$", "size", "]", "[", "\"height\"", "]", ";", "}", "else", "{", "$", "image", "=", "false", ";", "}", "$", "imgData", "=", "wp_get_attachment_image_src", "(", "$", "attachment_id", ",", "$", "size", ")", ";", "if", "(", "$", "imgData", "&&", "is_array", "(", "$", "imgData", ")", "&&", "isset", "(", "$", "imgData", "[", "0", "]", ")", "&&", "$", "imgData", "[", "0", "]", ")", ":", "$", "image", "=", "$", "imgData", "[", "0", "]", ";", "endif", ";", "return", "$", "image", ";", "}" ]
Get image url by ID and size @param $attachment_id @param string $size @param bool $placeholder @return bool|mixed
[ "Get", "image", "url", "by", "ID", "and", "size" ]
8795c429b79a2869bea49bc899d5653300d41323
https://github.com/erikkubica/netlime-theme-image/blob/8795c429b79a2869bea49bc899d5653300d41323/ThemeImage.php#L36-L52
4,719
bugadani/ORMiny
src/EntityManager.php
EntityManager.commit
public function commit() { $this->driver->inTransaction( function (Driver $driver, array $pendingQueries) { /** @var PendingQuery[] $pendingQueries */ foreach ($pendingQueries as $item) { $item->execute(); } }, $this->pendingQueries ); $this->pendingQueries = []; }
php
public function commit() { $this->driver->inTransaction( function (Driver $driver, array $pendingQueries) { /** @var PendingQuery[] $pendingQueries */ foreach ($pendingQueries as $item) { $item->execute(); } }, $this->pendingQueries ); $this->pendingQueries = []; }
[ "public", "function", "commit", "(", ")", "{", "$", "this", "->", "driver", "->", "inTransaction", "(", "function", "(", "Driver", "$", "driver", ",", "array", "$", "pendingQueries", ")", "{", "/** @var PendingQuery[] $pendingQueries */", "foreach", "(", "$", "pendingQueries", "as", "$", "item", ")", "{", "$", "item", "->", "execute", "(", ")", ";", "}", "}", ",", "$", "this", "->", "pendingQueries", ")", ";", "$", "this", "->", "pendingQueries", "=", "[", "]", ";", "}" ]
Executes pending queries
[ "Executes", "pending", "queries" ]
3701e617c64f6a648e180954ea1562136a856e33
https://github.com/bugadani/ORMiny/blob/3701e617c64f6a648e180954ea1562136a856e33/src/EntityManager.php#L201-L213
4,720
Ocelot-Framework/ocelot-mvc
src/Util/Ant/AntPathStringMatcher.php
AntPathStringMatcher.quote
protected function quote($s, $start, $end) { if ($start == $end) { return ""; } return preg_quote(substr($s, $start, $end), '#'); }
php
protected function quote($s, $start, $end) { if ($start == $end) { return ""; } return preg_quote(substr($s, $start, $end), '#'); }
[ "protected", "function", "quote", "(", "$", "s", ",", "$", "start", ",", "$", "end", ")", "{", "if", "(", "$", "start", "==", "$", "end", ")", "{", "return", "\"\"", ";", "}", "return", "preg_quote", "(", "substr", "(", "$", "s", ",", "$", "start", ",", "$", "end", ")", ",", "'#'", ")", ";", "}" ]
Returns a part of the string and quotes it. @param string $s The string to use @param integer $start The start index @param integer $end The end index @return string
[ "Returns", "a", "part", "of", "the", "string", "and", "quotes", "it", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Util/Ant/AntPathStringMatcher.php#L97-L103
4,721
Ocelot-Framework/ocelot-mvc
src/Util/Ant/AntPathStringMatcher.php
AntPathStringMatcher.matchStrings
public function matchStrings($str, &$uriTemplateVariables) { $matches = array(); if (preg_match_all($this->pattern, $str, $matches, PREG_PATTERN_ORDER)) { if ($uriTemplateVariables !== null) { array_shift($matches); if (count($this->variableNames) != count($matches)) { throw new \Exception( "The number of capturing groups in the pattern segment ".$this->pattern . " does not match the number of URI template variables it defines, which can occur if" . " capturing groups are used in a URI template regex. Use non-capturing groups instead." ); } for ($i = 0; $i < count($matches); $i++) { $uriTemplateVariables[$this->variableNames[$i]] = $matches[$i][0]; } } return true; } else { return false; } }
php
public function matchStrings($str, &$uriTemplateVariables) { $matches = array(); if (preg_match_all($this->pattern, $str, $matches, PREG_PATTERN_ORDER)) { if ($uriTemplateVariables !== null) { array_shift($matches); if (count($this->variableNames) != count($matches)) { throw new \Exception( "The number of capturing groups in the pattern segment ".$this->pattern . " does not match the number of URI template variables it defines, which can occur if" . " capturing groups are used in a URI template regex. Use non-capturing groups instead." ); } for ($i = 0; $i < count($matches); $i++) { $uriTemplateVariables[$this->variableNames[$i]] = $matches[$i][0]; } } return true; } else { return false; } }
[ "public", "function", "matchStrings", "(", "$", "str", ",", "&", "$", "uriTemplateVariables", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match_all", "(", "$", "this", "->", "pattern", ",", "$", "str", ",", "$", "matches", ",", "PREG_PATTERN_ORDER", ")", ")", "{", "if", "(", "$", "uriTemplateVariables", "!==", "null", ")", "{", "array_shift", "(", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "this", "->", "variableNames", ")", "!=", "count", "(", "$", "matches", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"The number of capturing groups in the pattern segment \"", ".", "$", "this", "->", "pattern", ".", "\" does not match the number of URI template variables it defines, which can occur if\"", ".", "\" capturing groups are used in a URI template regex. Use non-capturing groups instead.\"", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "matches", ")", ";", "$", "i", "++", ")", "{", "$", "uriTemplateVariables", "[", "$", "this", "->", "variableNames", "[", "$", "i", "]", "]", "=", "$", "matches", "[", "$", "i", "]", "[", "0", "]", ";", "}", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Main entry point of the AntPathStringMatcher. @param string $str The string to match @param array $uriTemplateVariables The array in which to write the matched variables @throws \Exception @return boolean {@code true} if the string matches against the pattern, or {@code false} otherwise
[ "Main", "entry", "point", "of", "the", "AntPathStringMatcher", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Util/Ant/AntPathStringMatcher.php#L112-L133
4,722
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.getSysCcmpBaseCurrency
public function getSysCcmpBaseCurrency($date){ if(!preg_match('#\A\d\d\d\d#',$date,$match)){ throw new CHttpException(400, 'invalid date in getSysCcmpBaseCurrency(): ' . $date); } $year = (int)$match[0]; foreach($this->_base_currencies as $bc){ if($bc['fcbc_year_from'] <= $year && (empty($bc['fcbc_year_to']) || $bc['fcbc_year_to'] >= $year) ){ return $bc['fcbc_fcrn_id']; } } throw new CHttpException(400, 'Please define for ' . $date . ' base currency! SysCcmpId = ' . Yii::app()->sysCompany->getActiveCompany()); }
php
public function getSysCcmpBaseCurrency($date){ if(!preg_match('#\A\d\d\d\d#',$date,$match)){ throw new CHttpException(400, 'invalid date in getSysCcmpBaseCurrency(): ' . $date); } $year = (int)$match[0]; foreach($this->_base_currencies as $bc){ if($bc['fcbc_year_from'] <= $year && (empty($bc['fcbc_year_to']) || $bc['fcbc_year_to'] >= $year) ){ return $bc['fcbc_fcrn_id']; } } throw new CHttpException(400, 'Please define for ' . $date . ' base currency! SysCcmpId = ' . Yii::app()->sysCompany->getActiveCompany()); }
[ "public", "function", "getSysCcmpBaseCurrency", "(", "$", "date", ")", "{", "if", "(", "!", "preg_match", "(", "'#\\A\\d\\d\\d\\d#'", ",", "$", "date", ",", "$", "match", ")", ")", "{", "throw", "new", "CHttpException", "(", "400", ",", "'invalid date in getSysCcmpBaseCurrency(): '", ".", "$", "date", ")", ";", "}", "$", "year", "=", "(", "int", ")", "$", "match", "[", "0", "]", ";", "foreach", "(", "$", "this", "->", "_base_currencies", "as", "$", "bc", ")", "{", "if", "(", "$", "bc", "[", "'fcbc_year_from'", "]", "<=", "$", "year", "&&", "(", "empty", "(", "$", "bc", "[", "'fcbc_year_to'", "]", ")", "||", "$", "bc", "[", "'fcbc_year_to'", "]", ">=", "$", "year", ")", ")", "{", "return", "$", "bc", "[", "'fcbc_fcrn_id'", "]", ";", "}", "}", "throw", "new", "CHttpException", "(", "400", ",", "'Please define for '", ".", "$", "date", ".", "' base currency! SysCcmpId = '", ".", "Yii", "::", "app", "(", ")", "->", "sysCompany", "->", "getActiveCompany", "(", ")", ")", ";", "}" ]
Look for base currency on date @param char $date YYYY..... @return int @throws CHttpException
[ "Look", "for", "base", "currency", "on", "date" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L49-L62
4,723
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.getSourceBaseCurrency
public function getSourceBaseCurrency($source) { if ($this->_source === FALSE) { $this->_loadSources(); } return $this->_source[$source]['fcsr_base_fcrn_id']; }
php
public function getSourceBaseCurrency($source) { if ($this->_source === FALSE) { $this->_loadSources(); } return $this->_source[$source]['fcsr_base_fcrn_id']; }
[ "public", "function", "getSourceBaseCurrency", "(", "$", "source", ")", "{", "if", "(", "$", "this", "->", "_source", "===", "FALSE", ")", "{", "$", "this", "->", "_loadSources", "(", ")", ";", "}", "return", "$", "this", "->", "_source", "[", "$", "source", "]", "[", "'fcsr_base_fcrn_id'", "]", ";", "}" ]
get source base currency @param int $source @return int base currency id fcrn_id
[ "get", "source", "base", "currency" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L109-L116
4,724
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.getCurrencyIdByCode
public function getCurrencyIdByCode($code) { $this->sError = FALSE; if ($this->_currencyCode2Id === FALSE) { $this->_loadCurrencyCodes(); } if (!isset($this->_currencyCode2Id[$code])) { $this->sError = 'Incorect currency code: ' . $code; return FALSE; } return $this->_currencyCode2Id[$code]; }
php
public function getCurrencyIdByCode($code) { $this->sError = FALSE; if ($this->_currencyCode2Id === FALSE) { $this->_loadCurrencyCodes(); } if (!isset($this->_currencyCode2Id[$code])) { $this->sError = 'Incorect currency code: ' . $code; return FALSE; } return $this->_currencyCode2Id[$code]; }
[ "public", "function", "getCurrencyIdByCode", "(", "$", "code", ")", "{", "$", "this", "->", "sError", "=", "FALSE", ";", "if", "(", "$", "this", "->", "_currencyCode2Id", "===", "FALSE", ")", "{", "$", "this", "->", "_loadCurrencyCodes", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "_currencyCode2Id", "[", "$", "code", "]", ")", ")", "{", "$", "this", "->", "sError", "=", "'Incorect currency code: '", ".", "$", "code", ";", "return", "FALSE", ";", "}", "return", "$", "this", "->", "_currencyCode2Id", "[", "$", "code", "]", ";", "}" ]
Get cyrrency id by currency code @param char $sCode currency code @return boolean|int - currency id
[ "Get", "cyrrency", "id", "by", "currency", "code" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L151-L164
4,725
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.isValidCurrencyId
public function isValidCurrencyId($id) { $this->sError = FALSE; if (!$this->getCurrencyId2Code($id)) { $this->sError = 'Incorect currency id: ' . $id; return FALSE; } return TRUE; }
php
public function isValidCurrencyId($id) { $this->sError = FALSE; if (!$this->getCurrencyId2Code($id)) { $this->sError = 'Incorect currency id: ' . $id; return FALSE; } return TRUE; }
[ "public", "function", "isValidCurrencyId", "(", "$", "id", ")", "{", "$", "this", "->", "sError", "=", "FALSE", ";", "if", "(", "!", "$", "this", "->", "getCurrencyId2Code", "(", "$", "id", ")", ")", "{", "$", "this", "->", "sError", "=", "'Incorect currency id: '", ".", "$", "id", ";", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
Validate currency ID @param char $id currency id @return boolean
[ "Validate", "currency", "ID" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L171-L180
4,726
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.isValidSourceId
public function isValidSourceId($source) { $this->sError = FALSE; if ($this->_source === FALSE) { $this->_loadSources(); } if (!isset($this->_source[$source])) { $this->sError = 'Incorect source id: ' . $source; return FALSE; } return TRUE; }
php
public function isValidSourceId($source) { $this->sError = FALSE; if ($this->_source === FALSE) { $this->_loadSources(); } if (!isset($this->_source[$source])) { $this->sError = 'Incorect source id: ' . $source; return FALSE; } return TRUE; }
[ "public", "function", "isValidSourceId", "(", "$", "source", ")", "{", "$", "this", "->", "sError", "=", "FALSE", ";", "if", "(", "$", "this", "->", "_source", "===", "FALSE", ")", "{", "$", "this", "->", "_loadSources", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "_source", "[", "$", "source", "]", ")", ")", "{", "$", "this", "->", "sError", "=", "'Incorect source id: '", ".", "$", "source", ";", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
Validate SOURCE ID @param char $id source id @return boolean
[ "Validate", "SOURCE", "ID" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L187-L199
4,727
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.convertToBase
public function convertToBase($amt, $fcrn_id, $date,$round = 6) { $source = $this->getSysCcmpCurrencySource($date); $rate = $this->getCurrencyRate($fcrn_id, $date,$source); if ($rate === FALSE) { return FALSE; } /** * @todo add convert type to fcsr_courrency_source as definition */ if ($source == 2){ return round($rate * $amt, $round); } return round($amt/$rate, $round); }
php
public function convertToBase($amt, $fcrn_id, $date,$round = 6) { $source = $this->getSysCcmpCurrencySource($date); $rate = $this->getCurrencyRate($fcrn_id, $date,$source); if ($rate === FALSE) { return FALSE; } /** * @todo add convert type to fcsr_courrency_source as definition */ if ($source == 2){ return round($rate * $amt, $round); } return round($amt/$rate, $round); }
[ "public", "function", "convertToBase", "(", "$", "amt", ",", "$", "fcrn_id", ",", "$", "date", ",", "$", "round", "=", "6", ")", "{", "$", "source", "=", "$", "this", "->", "getSysCcmpCurrencySource", "(", "$", "date", ")", ";", "$", "rate", "=", "$", "this", "->", "getCurrencyRate", "(", "$", "fcrn_id", ",", "$", "date", ",", "$", "source", ")", ";", "if", "(", "$", "rate", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "/**\n * @todo add convert type to fcsr_courrency_source as definition\n */", "if", "(", "$", "source", "==", "2", ")", "{", "return", "round", "(", "$", "rate", "*", "$", "amt", ",", "$", "round", ")", ";", "}", "return", "round", "(", "$", "amt", "/", "$", "rate", ",", "$", "round", ")", ";", "}" ]
convert to base currency @param decimal $amt @param int $fcrn_id @param date $date @return boolean/amt
[ "convert", "to", "base", "currency" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L569-L585
4,728
DBRisinajumi/fcrn
components/FcrnRate.php
FcrnRate.convertFromTo
public function convertFromTo($from_fcrn_id,$to_fcrn_id,$amt, $date,$round = 6, $source = false) { Yii::log("Converting from ".$this->convId2Code($from_fcrn_id)." to ".$this->convId2Code($to_fcrn_id)); //default source - syscompany source if(!$source){ $source = $this->getSysCcmpCurrencySource($date); } $from_rate = $this->getCurrencyRate($from_fcrn_id, $date,$source); if ($from_rate === FALSE) { return FALSE; } $to_rate = $this->getCurrencyRate($to_fcrn_id, $date,$source); if ($to_rate === FALSE) { return FALSE; } /** * @todo add convert type to fcsr_courrency_source as definition */ if ($source == self::SOURCE_BANK_RU){ return round($to_rate*$from_rate * $amt, $round); } else { return round($to_rate/$from_rate * $amt, $round); } }
php
public function convertFromTo($from_fcrn_id,$to_fcrn_id,$amt, $date,$round = 6, $source = false) { Yii::log("Converting from ".$this->convId2Code($from_fcrn_id)." to ".$this->convId2Code($to_fcrn_id)); //default source - syscompany source if(!$source){ $source = $this->getSysCcmpCurrencySource($date); } $from_rate = $this->getCurrencyRate($from_fcrn_id, $date,$source); if ($from_rate === FALSE) { return FALSE; } $to_rate = $this->getCurrencyRate($to_fcrn_id, $date,$source); if ($to_rate === FALSE) { return FALSE; } /** * @todo add convert type to fcsr_courrency_source as definition */ if ($source == self::SOURCE_BANK_RU){ return round($to_rate*$from_rate * $amt, $round); } else { return round($to_rate/$from_rate * $amt, $round); } }
[ "public", "function", "convertFromTo", "(", "$", "from_fcrn_id", ",", "$", "to_fcrn_id", ",", "$", "amt", ",", "$", "date", ",", "$", "round", "=", "6", ",", "$", "source", "=", "false", ")", "{", "Yii", "::", "log", "(", "\"Converting from \"", ".", "$", "this", "->", "convId2Code", "(", "$", "from_fcrn_id", ")", ".", "\" to \"", ".", "$", "this", "->", "convId2Code", "(", "$", "to_fcrn_id", ")", ")", ";", "//default source - syscompany source", "if", "(", "!", "$", "source", ")", "{", "$", "source", "=", "$", "this", "->", "getSysCcmpCurrencySource", "(", "$", "date", ")", ";", "}", "$", "from_rate", "=", "$", "this", "->", "getCurrencyRate", "(", "$", "from_fcrn_id", ",", "$", "date", ",", "$", "source", ")", ";", "if", "(", "$", "from_rate", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "$", "to_rate", "=", "$", "this", "->", "getCurrencyRate", "(", "$", "to_fcrn_id", ",", "$", "date", ",", "$", "source", ")", ";", "if", "(", "$", "to_rate", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "/**\n * @todo add convert type to fcsr_courrency_source as definition\n */", "if", "(", "$", "source", "==", "self", "::", "SOURCE_BANK_RU", ")", "{", "return", "round", "(", "$", "to_rate", "*", "$", "from_rate", "*", "$", "amt", ",", "$", "round", ")", ";", "}", "else", "{", "return", "round", "(", "$", "to_rate", "/", "$", "from_rate", "*", "$", "amt", ",", "$", "round", ")", ";", "}", "}" ]
convert from one currency to other @param int $from_fcrn_id @param int $to_fcrn_id @param decimal $amt @param date $date @return boolean/amt
[ "convert", "from", "one", "currency", "to", "other" ]
900845417217304e8959077c4b371e9ff6c46d4d
https://github.com/DBRisinajumi/fcrn/blob/900845417217304e8959077c4b371e9ff6c46d4d/components/FcrnRate.php#L595-L624
4,729
konservs/brilliant.framework
libraries/Items/BItemsRTree.php
BItemsRTree.itemsFilterHash
public function itemsFilterHash($params) { $itemshash = parent::itemsFilterHash($params); //Select items only with some group if (isset($params['group'])) { $itemshash .= ':group=' . $params['group']; } //Select categories only with some level if (isset($params['level'])) { $itemshash .= ':level=' . $params['level']; } //Select categories only with parentid=$params['parent']. if (isset($params['parent'])) { $itemshash .= ':parent=' . $params['parent']; } //Select categories only with parentid=$params['parent']. if (isset($params['parentisnull'])) { $itemshash .= ':parentisnull=' . empty($params['parentisnull'])?'N':'Y'; } //Entire parents tree. if (isset($params['parenttree'])) { $itemid = (int)$params['parenttree']; $item = $this->itemGet($itemid); if (empty($item)) { return false; } $itemshash .= ':parenttree-' . $item->lft . '-' . $item->rgt; } //Entire parents tree, second version. if ((isset($params['parenttree_lft'])) && (isset($params['parenttree_rgt']))) { $lft = $params['parenttree_lft']; $rgt = $params['parenttree_rgt']; if (($lft < 1) || ($rgt < 1) || ($lft >= $rgt)) { return false; } $itemshash .= ':parenttree-' . $lft . '-' . $rgt; } //Entire parents chain. if (isset($params['parentchain'])) { $itemid = (int)$params['parentchain']; $item = $this->itemGet($itemid); if (empty($item)) { return false; } $itemshash .= ':parentchain-' . $item->lft . '-' . $item->rgt; } //Entire parents chain, second version. if ((isset($params['parentchain_lft'])) && (isset($params['parentchain_rgt']))) { $lft = $params['parentchain_lft']; $rgt = $params['parentchain_rgt']; if (($lft < 1) || ($rgt < 1) || ($lft >= $rgt)) { return false; } $itemshash .= ':parentchain-' . $lft . '-' . $rgt; } return $itemshash; }
php
public function itemsFilterHash($params) { $itemshash = parent::itemsFilterHash($params); //Select items only with some group if (isset($params['group'])) { $itemshash .= ':group=' . $params['group']; } //Select categories only with some level if (isset($params['level'])) { $itemshash .= ':level=' . $params['level']; } //Select categories only with parentid=$params['parent']. if (isset($params['parent'])) { $itemshash .= ':parent=' . $params['parent']; } //Select categories only with parentid=$params['parent']. if (isset($params['parentisnull'])) { $itemshash .= ':parentisnull=' . empty($params['parentisnull'])?'N':'Y'; } //Entire parents tree. if (isset($params['parenttree'])) { $itemid = (int)$params['parenttree']; $item = $this->itemGet($itemid); if (empty($item)) { return false; } $itemshash .= ':parenttree-' . $item->lft . '-' . $item->rgt; } //Entire parents tree, second version. if ((isset($params['parenttree_lft'])) && (isset($params['parenttree_rgt']))) { $lft = $params['parenttree_lft']; $rgt = $params['parenttree_rgt']; if (($lft < 1) || ($rgt < 1) || ($lft >= $rgt)) { return false; } $itemshash .= ':parenttree-' . $lft . '-' . $rgt; } //Entire parents chain. if (isset($params['parentchain'])) { $itemid = (int)$params['parentchain']; $item = $this->itemGet($itemid); if (empty($item)) { return false; } $itemshash .= ':parentchain-' . $item->lft . '-' . $item->rgt; } //Entire parents chain, second version. if ((isset($params['parentchain_lft'])) && (isset($params['parentchain_rgt']))) { $lft = $params['parentchain_lft']; $rgt = $params['parentchain_rgt']; if (($lft < 1) || ($rgt < 1) || ($lft >= $rgt)) { return false; } $itemshash .= ':parentchain-' . $lft . '-' . $rgt; } return $itemshash; }
[ "public", "function", "itemsFilterHash", "(", "$", "params", ")", "{", "$", "itemshash", "=", "parent", "::", "itemsFilterHash", "(", "$", "params", ")", ";", "//Select items only with some group", "if", "(", "isset", "(", "$", "params", "[", "'group'", "]", ")", ")", "{", "$", "itemshash", ".=", "':group='", ".", "$", "params", "[", "'group'", "]", ";", "}", "//Select categories only with some level", "if", "(", "isset", "(", "$", "params", "[", "'level'", "]", ")", ")", "{", "$", "itemshash", ".=", "':level='", ".", "$", "params", "[", "'level'", "]", ";", "}", "//Select categories only with parentid=$params['parent'].", "if", "(", "isset", "(", "$", "params", "[", "'parent'", "]", ")", ")", "{", "$", "itemshash", ".=", "':parent='", ".", "$", "params", "[", "'parent'", "]", ";", "}", "//Select categories only with parentid=$params['parent'].", "if", "(", "isset", "(", "$", "params", "[", "'parentisnull'", "]", ")", ")", "{", "$", "itemshash", ".=", "':parentisnull='", ".", "empty", "(", "$", "params", "[", "'parentisnull'", "]", ")", "?", "'N'", ":", "'Y'", ";", "}", "//Entire parents tree. ", "if", "(", "isset", "(", "$", "params", "[", "'parenttree'", "]", ")", ")", "{", "$", "itemid", "=", "(", "int", ")", "$", "params", "[", "'parenttree'", "]", ";", "$", "item", "=", "$", "this", "->", "itemGet", "(", "$", "itemid", ")", ";", "if", "(", "empty", "(", "$", "item", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parenttree-'", ".", "$", "item", "->", "lft", ".", "'-'", ".", "$", "item", "->", "rgt", ";", "}", "//Entire parents tree, second version. ", "if", "(", "(", "isset", "(", "$", "params", "[", "'parenttree_lft'", "]", ")", ")", "&&", "(", "isset", "(", "$", "params", "[", "'parenttree_rgt'", "]", ")", ")", ")", "{", "$", "lft", "=", "$", "params", "[", "'parenttree_lft'", "]", ";", "$", "rgt", "=", "$", "params", "[", "'parenttree_rgt'", "]", ";", "if", "(", "(", "$", "lft", "<", "1", ")", "||", "(", "$", "rgt", "<", "1", ")", "||", "(", "$", "lft", ">=", "$", "rgt", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parenttree-'", ".", "$", "lft", ".", "'-'", ".", "$", "rgt", ";", "}", "//Entire parents chain. ", "if", "(", "isset", "(", "$", "params", "[", "'parentchain'", "]", ")", ")", "{", "$", "itemid", "=", "(", "int", ")", "$", "params", "[", "'parentchain'", "]", ";", "$", "item", "=", "$", "this", "->", "itemGet", "(", "$", "itemid", ")", ";", "if", "(", "empty", "(", "$", "item", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parentchain-'", ".", "$", "item", "->", "lft", ".", "'-'", ".", "$", "item", "->", "rgt", ";", "}", "//Entire parents chain, second version. ", "if", "(", "(", "isset", "(", "$", "params", "[", "'parentchain_lft'", "]", ")", ")", "&&", "(", "isset", "(", "$", "params", "[", "'parentchain_rgt'", "]", ")", ")", ")", "{", "$", "lft", "=", "$", "params", "[", "'parentchain_lft'", "]", ";", "$", "rgt", "=", "$", "params", "[", "'parentchain_rgt'", "]", ";", "if", "(", "(", "$", "lft", "<", "1", ")", "||", "(", "$", "rgt", "<", "1", ")", "||", "(", "$", "lft", ">=", "$", "rgt", ")", ")", "{", "return", "false", ";", "}", "$", "itemshash", ".=", "':parentchain-'", ".", "$", "lft", ".", "'-'", ".", "$", "rgt", ";", "}", "return", "$", "itemshash", ";", "}" ]
Get items hash for caching @param $params @return string
[ "Get", "items", "hash", "for", "caching" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Items/BItemsRTree.php#L125-L181
4,730
TOGoS/TPFetcher
lib/TOGoS/Fetcher.php
TOGoS_Fetcher.cache
public function cache( $urn ) { $base32Sha1 = TOGoS_Fetcher_HashUtil::extractBase32Sha1($urn); $psp = substr($base32Sha1,0,2)."/".$base32Sha1; $dataDir = "{$this->cacheRepoDir}/data"; if( is_dir($dataDir) ) { foreach( scandir($dataDir) as $sector ) { if( $sector[0] == '.' ) continue; $existing = "{$dataDir}/{$sector}/{$psp}"; if( file_exists($existing) ) return $existing; } // For compatibility with some buggy systems... $existing = "{$dataDir}/{$psp}"; if( file_exists($existing) ) return $existing; } $destFile = "{$dataDir}/{$this->cacheSector}/{$psp}"; $tempFile = $this->tempFile($destFile); try { $size = $this->download( $urn, $tempFile ); } catch( Exception $e ) { unlink($tempFile); throw $e; } return $this->completeDownload( $tempFile, $destFile, $size ); }
php
public function cache( $urn ) { $base32Sha1 = TOGoS_Fetcher_HashUtil::extractBase32Sha1($urn); $psp = substr($base32Sha1,0,2)."/".$base32Sha1; $dataDir = "{$this->cacheRepoDir}/data"; if( is_dir($dataDir) ) { foreach( scandir($dataDir) as $sector ) { if( $sector[0] == '.' ) continue; $existing = "{$dataDir}/{$sector}/{$psp}"; if( file_exists($existing) ) return $existing; } // For compatibility with some buggy systems... $existing = "{$dataDir}/{$psp}"; if( file_exists($existing) ) return $existing; } $destFile = "{$dataDir}/{$this->cacheSector}/{$psp}"; $tempFile = $this->tempFile($destFile); try { $size = $this->download( $urn, $tempFile ); } catch( Exception $e ) { unlink($tempFile); throw $e; } return $this->completeDownload( $tempFile, $destFile, $size ); }
[ "public", "function", "cache", "(", "$", "urn", ")", "{", "$", "base32Sha1", "=", "TOGoS_Fetcher_HashUtil", "::", "extractBase32Sha1", "(", "$", "urn", ")", ";", "$", "psp", "=", "substr", "(", "$", "base32Sha1", ",", "0", ",", "2", ")", ".", "\"/\"", ".", "$", "base32Sha1", ";", "$", "dataDir", "=", "\"{$this->cacheRepoDir}/data\"", ";", "if", "(", "is_dir", "(", "$", "dataDir", ")", ")", "{", "foreach", "(", "scandir", "(", "$", "dataDir", ")", "as", "$", "sector", ")", "{", "if", "(", "$", "sector", "[", "0", "]", "==", "'.'", ")", "continue", ";", "$", "existing", "=", "\"{$dataDir}/{$sector}/{$psp}\"", ";", "if", "(", "file_exists", "(", "$", "existing", ")", ")", "return", "$", "existing", ";", "}", "// For compatibility with some buggy systems...", "$", "existing", "=", "\"{$dataDir}/{$psp}\"", ";", "if", "(", "file_exists", "(", "$", "existing", ")", ")", "return", "$", "existing", ";", "}", "$", "destFile", "=", "\"{$dataDir}/{$this->cacheSector}/{$psp}\"", ";", "$", "tempFile", "=", "$", "this", "->", "tempFile", "(", "$", "destFile", ")", ";", "try", "{", "$", "size", "=", "$", "this", "->", "download", "(", "$", "urn", ",", "$", "tempFile", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "unlink", "(", "$", "tempFile", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "this", "->", "completeDownload", "(", "$", "tempFile", ",", "$", "destFile", ",", "$", "size", ")", ";", "}" ]
Returns the path of the file, if successfully cached
[ "Returns", "the", "path", "of", "the", "file", "if", "successfully", "cached" ]
2fff6eb55a9c8700260b330b9954e2f15068fe85
https://github.com/TOGoS/TPFetcher/blob/2fff6eb55a9c8700260b330b9954e2f15068fe85/lib/TOGoS/Fetcher.php#L164-L189
4,731
Beth3346/wp-admin
src/Admin.php
Admin.metaCustomColumn
public function metaCustomColumn($column_name, $meta_field, $id) { if ($column_name === $column_name) { $column_name = get_post_meta($id, $meta_field, true); echo $column_name; } }
php
public function metaCustomColumn($column_name, $meta_field, $id) { if ($column_name === $column_name) { $column_name = get_post_meta($id, $meta_field, true); echo $column_name; } }
[ "public", "function", "metaCustomColumn", "(", "$", "column_name", ",", "$", "meta_field", ",", "$", "id", ")", "{", "if", "(", "$", "column_name", "===", "$", "column_name", ")", "{", "$", "column_name", "=", "get_post_meta", "(", "$", "id", ",", "$", "meta_field", ",", "true", ")", ";", "echo", "$", "column_name", ";", "}", "}" ]
Displays post meta field in custom column on post admin view @since 1.0.0 @access public @param column_name, meta_field, id @return void
[ "Displays", "post", "meta", "field", "in", "custom", "column", "on", "post", "admin", "view" ]
41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1
https://github.com/Beth3346/wp-admin/blob/41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1/src/Admin.php#L32-L38
4,732
Beth3346/wp-admin
src/Admin.php
Admin.dashboardCpts
public function dashboardCpts() { $args = array( 'public' => true , '_builtin' => false ); $output = 'object'; $operator = 'and'; $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $post_type) { $num_posts = wp_count_posts($post_type->name); $num = number_format_i18n($num_posts->publish); $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type=$post_type->name'>$num"; $text = "$text</a>"; } echo '<li class="post-count">' . $num . ' ' . $text . '</li>'; } }
php
public function dashboardCpts() { $args = array( 'public' => true , '_builtin' => false ); $output = 'object'; $operator = 'and'; $post_types = get_post_types($args, $output, $operator); foreach ($post_types as $post_type) { $num_posts = wp_count_posts($post_type->name); $num = number_format_i18n($num_posts->publish); $text = _n($post_type->labels->singular_name, $post_type->labels->name, intval($num_posts->publish)); if (current_user_can('edit_posts')) { $num = "<a href='edit.php?post_type=$post_type->name'>$num"; $text = "$text</a>"; } echo '<li class="post-count">' . $num . ' ' . $text . '</li>'; } }
[ "public", "function", "dashboardCpts", "(", ")", "{", "$", "args", "=", "array", "(", "'public'", "=>", "true", ",", "'_builtin'", "=>", "false", ")", ";", "$", "output", "=", "'object'", ";", "$", "operator", "=", "'and'", ";", "$", "post_types", "=", "get_post_types", "(", "$", "args", ",", "$", "output", ",", "$", "operator", ")", ";", "foreach", "(", "$", "post_types", "as", "$", "post_type", ")", "{", "$", "num_posts", "=", "wp_count_posts", "(", "$", "post_type", "->", "name", ")", ";", "$", "num", "=", "number_format_i18n", "(", "$", "num_posts", "->", "publish", ")", ";", "$", "text", "=", "_n", "(", "$", "post_type", "->", "labels", "->", "singular_name", ",", "$", "post_type", "->", "labels", "->", "name", ",", "intval", "(", "$", "num_posts", "->", "publish", ")", ")", ";", "if", "(", "current_user_can", "(", "'edit_posts'", ")", ")", "{", "$", "num", "=", "\"<a href='edit.php?post_type=$post_type->name'>$num\"", ";", "$", "text", "=", "\"$text</a>\"", ";", "}", "echo", "'<li class=\"post-count\">'", ".", "$", "num", ".", "' '", ".", "$", "text", ".", "'</li>'", ";", "}", "}" ]
Add custom post types to right now dashboard @since 1.0.0 @access public @param @return void
[ "Add", "custom", "post", "types", "to", "right", "now", "dashboard" ]
41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1
https://github.com/Beth3346/wp-admin/blob/41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1/src/Admin.php#L81-L105
4,733
Beth3346/wp-admin
src/Admin.php
Admin.dashboardTaxonomies
public function dashboardTaxonomies() { $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num"; $text = "$text</a>"; } echo '<li class="post-count">' . $num . ' ' . $text . '</li>'; } }
php
public function dashboardTaxonomies() { $taxonomies = get_taxonomies($args, $output, $operator); foreach ($taxonomies as $taxonomy) { $num_terms = wp_count_terms($taxonomy->name); $num = number_format_i18n($num_terms); $text = _n($taxonomy->labels->singular_name, $taxonomy->labels->name, intval($num_terms)); if (current_user_can('manage_categories')) { $num = "<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num"; $text = "$text</a>"; } echo '<li class="post-count">' . $num . ' ' . $text . '</li>'; } }
[ "public", "function", "dashboardTaxonomies", "(", ")", "{", "$", "taxonomies", "=", "get_taxonomies", "(", "$", "args", ",", "$", "output", ",", "$", "operator", ")", ";", "foreach", "(", "$", "taxonomies", "as", "$", "taxonomy", ")", "{", "$", "num_terms", "=", "wp_count_terms", "(", "$", "taxonomy", "->", "name", ")", ";", "$", "num", "=", "number_format_i18n", "(", "$", "num_terms", ")", ";", "$", "text", "=", "_n", "(", "$", "taxonomy", "->", "labels", "->", "singular_name", ",", "$", "taxonomy", "->", "labels", "->", "name", ",", "intval", "(", "$", "num_terms", ")", ")", ";", "if", "(", "current_user_can", "(", "'manage_categories'", ")", ")", "{", "$", "num", "=", "\"<a href='edit-tags.php?taxonomy=$taxonomy->name'>$num\"", ";", "$", "text", "=", "\"$text</a>\"", ";", "}", "echo", "'<li class=\"post-count\">'", ".", "$", "num", ".", "' '", ".", "$", "text", ".", "'</li>'", ";", "}", "}" ]
Adds taxonomies to the Right Now dashboard @since 1.0.0 @access public @param @return void
[ "Adds", "taxonomies", "to", "the", "Right", "Now", "dashboard" ]
41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1
https://github.com/Beth3346/wp-admin/blob/41c7c6a9cf7ba7d53dd775c03eec7912039d8ed1/src/Admin.php#L116-L132
4,734
RhubarbPHP/Module.Leaf.CommonControls
src/SelectionControls/SelectionControl.php
SelectionControl.setSelectionItems
public function setSelectionItems(array $items) { $this->selectionItems = $items; $this->model->selectionItems = $this->getCurrentlyAvailableSelectionItems(); return $this; }
php
public function setSelectionItems(array $items) { $this->selectionItems = $items; $this->model->selectionItems = $this->getCurrentlyAvailableSelectionItems(); return $this; }
[ "public", "function", "setSelectionItems", "(", "array", "$", "items", ")", "{", "$", "this", "->", "selectionItems", "=", "$", "items", ";", "$", "this", "->", "model", "->", "selectionItems", "=", "$", "this", "->", "getCurrentlyAvailableSelectionItems", "(", ")", ";", "return", "$", "this", ";", "}" ]
Receives an array specifying the item sources for this control. @param array $items @return $this
[ "Receives", "an", "array", "specifying", "the", "item", "sources", "for", "this", "control", "." ]
fd12390c470304a436ebd78f315e29af7552cc15
https://github.com/RhubarbPHP/Module.Leaf.CommonControls/blob/fd12390c470304a436ebd78f315e29af7552cc15/src/SelectionControls/SelectionControl.php#L151-L158
4,735
RhubarbPHP/Module.Leaf.CommonControls
src/SelectionControls/SelectionControl.php
SelectionControl.makeItem
protected final function makeItem($value, $label, $data = []) { $item = new \stdClass(); $item->value = $value; $item->label = $label; $item->data = $data; return $item; }
php
protected final function makeItem($value, $label, $data = []) { $item = new \stdClass(); $item->value = $value; $item->label = $label; $item->data = $data; return $item; }
[ "protected", "final", "function", "makeItem", "(", "$", "value", ",", "$", "label", ",", "$", "data", "=", "[", "]", ")", "{", "$", "item", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "item", "->", "value", "=", "$", "value", ";", "$", "item", "->", "label", "=", "$", "label", ";", "$", "item", "->", "data", "=", "$", "data", ";", "return", "$", "item", ";", "}" ]
Makes a stdClass to represent an item. This will make a standard object with the following properties: Value: The value of the item Label: A text display value for the item Data: Any other associated item data Note that these properties are UpperCamelCase as these objects are often converted directly into Javascript objects and that best matches our current javascript styles. @param $value @param $label @param $data @return \stdClass
[ "Makes", "a", "stdClass", "to", "represent", "an", "item", "." ]
fd12390c470304a436ebd78f315e29af7552cc15
https://github.com/RhubarbPHP/Module.Leaf.CommonControls/blob/fd12390c470304a436ebd78f315e29af7552cc15/src/SelectionControls/SelectionControl.php#L290-L298
4,736
atompulse/domain
Data/DataContainer.php
DataContainer.defineProperty
public function defineProperty(string $property, $constraints = [], $defaultValue = null) { $this->validProperties[$property] = $constraints; if (!is_null($defaultValue)) { $this->defaultValues[$property] = $defaultValue; } }
php
public function defineProperty(string $property, $constraints = [], $defaultValue = null) { $this->validProperties[$property] = $constraints; if (!is_null($defaultValue)) { $this->defaultValues[$property] = $defaultValue; } }
[ "public", "function", "defineProperty", "(", "string", "$", "property", ",", "$", "constraints", "=", "[", "]", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "this", "->", "validProperties", "[", "$", "property", "]", "=", "$", "constraints", ";", "if", "(", "!", "is_null", "(", "$", "defaultValue", ")", ")", "{", "$", "this", "->", "defaultValues", "[", "$", "property", "]", "=", "$", "defaultValue", ";", "}", "}" ]
Define a property on data container @param string $property @param array $constraints @param null $defaultValue @throws PropertyNotValidException
[ "Define", "a", "property", "on", "data", "container" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L144-L151
4,737
atompulse/domain
Data/DataContainer.php
DataContainer.isValidProperty
public function isValidProperty(string $property) { if (!empty($this->validProperties) && !array_key_exists($property, $this->validProperties)) { return false; } return true; }
php
public function isValidProperty(string $property) { if (!empty($this->validProperties) && !array_key_exists($property, $this->validProperties)) { return false; } return true; }
[ "public", "function", "isValidProperty", "(", "string", "$", "property", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "validProperties", ")", "&&", "!", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "validProperties", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if a property is valid @param string $property @return bool
[ "Check", "if", "a", "property", "is", "valid" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L158-L165
4,738
atompulse/domain
Data/DataContainer.php
DataContainer.normalizeValue
protected function normalizeValue($value) { $normalizedValue = $value; // object value if (is_object($value)) { if (get_class($value) === "DateTime") { $normalizedValue = $value->format("Y-m-d\TH:i:s.u\Z"); } elseif ($value instanceof DataContainerInterface || method_exists($value, 'normalizeData')) { $normalizedValue = $value->normalizeData(); } else { throw new PropertyValueNormalizationException( "Value error: object of type [" . get_class($value) . "] does not implement DataContainerInterface nor have a [normalizeData] method" ); } } elseif (is_array($value)) { foreach ($value as $arrProperty => $arrValue) { $normalizedValue[$arrProperty] = $this->normalizeValue($arrValue); } } return $normalizedValue; }
php
protected function normalizeValue($value) { $normalizedValue = $value; // object value if (is_object($value)) { if (get_class($value) === "DateTime") { $normalizedValue = $value->format("Y-m-d\TH:i:s.u\Z"); } elseif ($value instanceof DataContainerInterface || method_exists($value, 'normalizeData')) { $normalizedValue = $value->normalizeData(); } else { throw new PropertyValueNormalizationException( "Value error: object of type [" . get_class($value) . "] does not implement DataContainerInterface nor have a [normalizeData] method" ); } } elseif (is_array($value)) { foreach ($value as $arrProperty => $arrValue) { $normalizedValue[$arrProperty] = $this->normalizeValue($arrValue); } } return $normalizedValue; }
[ "protected", "function", "normalizeValue", "(", "$", "value", ")", "{", "$", "normalizedValue", "=", "$", "value", ";", "// object value", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "get_class", "(", "$", "value", ")", "===", "\"DateTime\"", ")", "{", "$", "normalizedValue", "=", "$", "value", "->", "format", "(", "\"Y-m-d\\TH:i:s.u\\Z\"", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "DataContainerInterface", "||", "method_exists", "(", "$", "value", ",", "'normalizeData'", ")", ")", "{", "$", "normalizedValue", "=", "$", "value", "->", "normalizeData", "(", ")", ";", "}", "else", "{", "throw", "new", "PropertyValueNormalizationException", "(", "\"Value error: object of type [\"", ".", "get_class", "(", "$", "value", ")", ".", "\"]\n does not implement DataContainerInterface nor have a [normalizeData] method\"", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "arrProperty", "=>", "$", "arrValue", ")", "{", "$", "normalizedValue", "[", "$", "arrProperty", "]", "=", "$", "this", "->", "normalizeValue", "(", "$", "arrValue", ")", ";", "}", "}", "return", "$", "normalizedValue", ";", "}" ]
Normalize a property value @param $value @return mixed @throws PropertyValueNormalizationException
[ "Normalize", "a", "property", "value" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L353-L375
4,739
atompulse/domain
Data/DataContainer.php
DataContainer.checkTypes
private function checkTypes(string $property, $value) { $integrityConstraints = $this->getIntegritySpecification($property); $actualValueType = gettype($value); if ($actualValueType == 'double') { $actualValueType = is_int($value) ? 'integer' : 'number'; } else { if ($actualValueType == 'NULL') { $actualValueType = 'null'; } } if (count($integrityConstraints)) { // object check if ($actualValueType == 'object') { if (!in_array(get_class($value), $integrityConstraints)) { throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints).'], but given value is instance of : [' . get_class($value).']'); } } else { // primitive type value $isValidType = false; foreach ($integrityConstraints as $type) { if ($type === 'object' && is_object($value)) { $isValidType = true; break; } elseif ($type == 'array' && is_array($value)) { $isValidType = true; break; } elseif ($type == 'string' && is_string($value)) { $isValidType = true; break; } elseif ($type == 'number' && is_numeric($value)) { $isValidType = true; break; } elseif (($type == 'integer' || $type == 'int') && is_int($value)) { $isValidType = true; break; } elseif (($type == 'boolean' || $type == 'bool') && is_bool($value)) { $isValidType = true; break; } elseif ($type == 'null' && $value === null) { $isValidType = true; break; } } if (!$isValidType) { throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints)."], but given value is: [$actualValueType]"); } } } return true; }
php
private function checkTypes(string $property, $value) { $integrityConstraints = $this->getIntegritySpecification($property); $actualValueType = gettype($value); if ($actualValueType == 'double') { $actualValueType = is_int($value) ? 'integer' : 'number'; } else { if ($actualValueType == 'NULL') { $actualValueType = 'null'; } } if (count($integrityConstraints)) { // object check if ($actualValueType == 'object') { if (!in_array(get_class($value), $integrityConstraints)) { throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints).'], but given value is instance of : [' . get_class($value).']'); } } else { // primitive type value $isValidType = false; foreach ($integrityConstraints as $type) { if ($type === 'object' && is_object($value)) { $isValidType = true; break; } elseif ($type == 'array' && is_array($value)) { $isValidType = true; break; } elseif ($type == 'string' && is_string($value)) { $isValidType = true; break; } elseif ($type == 'number' && is_numeric($value)) { $isValidType = true; break; } elseif (($type == 'integer' || $type == 'int') && is_int($value)) { $isValidType = true; break; } elseif (($type == 'boolean' || $type == 'bool') && is_bool($value)) { $isValidType = true; break; } elseif ($type == 'null' && $value === null) { $isValidType = true; break; } } if (!$isValidType) { throw new PropertyValueNotValidException("Type error: Property [$property] accepts only [".implode(',', $integrityConstraints)."], but given value is: [$actualValueType]"); } } } return true; }
[ "private", "function", "checkTypes", "(", "string", "$", "property", ",", "$", "value", ")", "{", "$", "integrityConstraints", "=", "$", "this", "->", "getIntegritySpecification", "(", "$", "property", ")", ";", "$", "actualValueType", "=", "gettype", "(", "$", "value", ")", ";", "if", "(", "$", "actualValueType", "==", "'double'", ")", "{", "$", "actualValueType", "=", "is_int", "(", "$", "value", ")", "?", "'integer'", ":", "'number'", ";", "}", "else", "{", "if", "(", "$", "actualValueType", "==", "'NULL'", ")", "{", "$", "actualValueType", "=", "'null'", ";", "}", "}", "if", "(", "count", "(", "$", "integrityConstraints", ")", ")", "{", "// object check", "if", "(", "$", "actualValueType", "==", "'object'", ")", "{", "if", "(", "!", "in_array", "(", "get_class", "(", "$", "value", ")", ",", "$", "integrityConstraints", ")", ")", "{", "throw", "new", "PropertyValueNotValidException", "(", "\"Type error: Property [$property] accepts only [\"", ".", "implode", "(", "','", ",", "$", "integrityConstraints", ")", ".", "'], but given value is instance of : ['", ".", "get_class", "(", "$", "value", ")", ".", "']'", ")", ";", "}", "}", "else", "{", "// primitive type value", "$", "isValidType", "=", "false", ";", "foreach", "(", "$", "integrityConstraints", "as", "$", "type", ")", "{", "if", "(", "$", "type", "===", "'object'", "&&", "is_object", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "$", "type", "==", "'array'", "&&", "is_array", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "$", "type", "==", "'string'", "&&", "is_string", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "$", "type", "==", "'number'", "&&", "is_numeric", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "(", "$", "type", "==", "'integer'", "||", "$", "type", "==", "'int'", ")", "&&", "is_int", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "(", "$", "type", "==", "'boolean'", "||", "$", "type", "==", "'bool'", ")", "&&", "is_bool", "(", "$", "value", ")", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "elseif", "(", "$", "type", "==", "'null'", "&&", "$", "value", "===", "null", ")", "{", "$", "isValidType", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "isValidType", ")", "{", "throw", "new", "PropertyValueNotValidException", "(", "\"Type error: Property [$property] accepts only [\"", ".", "implode", "(", "','", ",", "$", "integrityConstraints", ")", ".", "\"], but given value is: [$actualValueType]\"", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check property value type @param string $property @param mixed $value @return bool @throws PropertyValueNotValidException
[ "Check", "property", "value", "type" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L384-L438
4,740
atompulse/domain
Data/DataContainer.php
DataContainer.getIntegritySpecification
private function getIntegritySpecification(string $property) { $constraints = $this->validProperties[$property]; if (!is_array($constraints)) { $constraints = $this->parseIntegritySpecification($this->validProperties[$property]); } return $constraints; }
php
private function getIntegritySpecification(string $property) { $constraints = $this->validProperties[$property]; if (!is_array($constraints)) { $constraints = $this->parseIntegritySpecification($this->validProperties[$property]); } return $constraints; }
[ "private", "function", "getIntegritySpecification", "(", "string", "$", "property", ")", "{", "$", "constraints", "=", "$", "this", "->", "validProperties", "[", "$", "property", "]", ";", "if", "(", "!", "is_array", "(", "$", "constraints", ")", ")", "{", "$", "constraints", "=", "$", "this", "->", "parseIntegritySpecification", "(", "$", "this", "->", "validProperties", "[", "$", "property", "]", ")", ";", "}", "return", "$", "constraints", ";", "}" ]
Get defined integrity check type|value for a property @param string $property @return array
[ "Get", "defined", "integrity", "check", "type|value", "for", "a", "property" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L445-L454
4,741
atompulse/domain
Data/DataContainer.php
DataContainer.parseIntegritySpecification
private function parseIntegritySpecification(string $integritySpecification) { $parsedIntegritySpecification = []; if (strpos($integritySpecification, '|') !== false) { $parsedIntegritySpecification = explode('|', $integritySpecification); } elseif (!empty($integritySpecification)) { $parsedIntegritySpecification = [$integritySpecification]; } return $parsedIntegritySpecification; }
php
private function parseIntegritySpecification(string $integritySpecification) { $parsedIntegritySpecification = []; if (strpos($integritySpecification, '|') !== false) { $parsedIntegritySpecification = explode('|', $integritySpecification); } elseif (!empty($integritySpecification)) { $parsedIntegritySpecification = [$integritySpecification]; } return $parsedIntegritySpecification; }
[ "private", "function", "parseIntegritySpecification", "(", "string", "$", "integritySpecification", ")", "{", "$", "parsedIntegritySpecification", "=", "[", "]", ";", "if", "(", "strpos", "(", "$", "integritySpecification", ",", "'|'", ")", "!==", "false", ")", "{", "$", "parsedIntegritySpecification", "=", "explode", "(", "'|'", ",", "$", "integritySpecification", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "integritySpecification", ")", ")", "{", "$", "parsedIntegritySpecification", "=", "[", "$", "integritySpecification", "]", ";", "}", "return", "$", "parsedIntegritySpecification", ";", "}" ]
Parse integrity specification "array|null" @param string $integritySpecification @return array
[ "Parse", "integrity", "specification", "array|null" ]
01aa2ce5f18da2ef5a3310b7f1285379056d3c7d
https://github.com/atompulse/domain/blob/01aa2ce5f18da2ef5a3310b7f1285379056d3c7d/Data/DataContainer.php#L461-L472
4,742
dendevs/plpadaptability
src/Adaptability.php
Adaptability.log
public function log( $log_name, $level, $message, $context ) { $service_name = $this->get_service_metas( 'service_name' ); return $this->_krl->log( $service_name, $log_name, $level, $message, $context ); }
php
public function log( $log_name, $level, $message, $context ) { $service_name = $this->get_service_metas( 'service_name' ); return $this->_krl->log( $service_name, $log_name, $level, $message, $context ); }
[ "public", "function", "log", "(", "$", "log_name", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", "{", "$", "service_name", "=", "$", "this", "->", "get_service_metas", "(", "'service_name'", ")", ";", "return", "$", "this", "->", "_krl", "->", "log", "(", "$", "service_name", ",", "$", "log_name", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}" ]
Ecriture de log basique ou via service du kernel @param string $log_name nom du logger, si service de base alors non fichier @param string $level niveau du message ( info, debug, ... ) @param string $message message a logger @param array $context informations supplementaires @return bool true si ecriture ok
[ "Ecriture", "de", "log", "basique", "ou", "via", "service", "du", "kernel" ]
9e1af2912c5b6ee7e409af487279d529e56ecbe1
https://github.com/dendevs/plpadaptability/blob/9e1af2912c5b6ee7e409af487279d529e56ecbe1/src/Adaptability.php#L95-L99
4,743
DevGroup-ru/yii2-admin-utils
src/traits/AdminResponse.php
AdminResponse.renderResponse
public function renderResponse($view, $params = []) { /** @var \DevGroup\AdminUtils\controllers\BaseController $context */ $context = $this instanceof Action ? $this->controller : $this; if (Yii::$app->request->isAjax === true) { Yii::$app->response->format = Response::FORMAT_JSON; $content = $context->renderAjax($view, $params); return new AjaxResponse($content, false, Yii::$app->session->getAllFlashes(true)); } else { return $context->render($view, $params); } }
php
public function renderResponse($view, $params = []) { /** @var \DevGroup\AdminUtils\controllers\BaseController $context */ $context = $this instanceof Action ? $this->controller : $this; if (Yii::$app->request->isAjax === true) { Yii::$app->response->format = Response::FORMAT_JSON; $content = $context->renderAjax($view, $params); return new AjaxResponse($content, false, Yii::$app->session->getAllFlashes(true)); } else { return $context->render($view, $params); } }
[ "public", "function", "renderResponse", "(", "$", "view", ",", "$", "params", "=", "[", "]", ")", "{", "/** @var \\DevGroup\\AdminUtils\\controllers\\BaseController $context */", "$", "context", "=", "$", "this", "instanceof", "Action", "?", "$", "this", "->", "controller", ":", "$", "this", ";", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", "===", "true", ")", "{", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "content", "=", "$", "context", "->", "renderAjax", "(", "$", "view", ",", "$", "params", ")", ";", "return", "new", "AjaxResponse", "(", "$", "content", ",", "false", ",", "Yii", "::", "$", "app", "->", "session", "->", "getAllFlashes", "(", "true", ")", ")", ";", "}", "else", "{", "return", "$", "context", "->", "render", "(", "$", "view", ",", "$", "params", ")", ";", "}", "}" ]
Generates response for current request based on it's type @param string $view @param array $params @return \DevGroup\AdminUtils\response\AjaxResponse|string
[ "Generates", "response", "for", "current", "request", "based", "on", "it", "s", "type" ]
15c1853a5ec264602de3ad82dbf70f85de66adff
https://github.com/DevGroup-ru/yii2-admin-utils/blob/15c1853a5ec264602de3ad82dbf70f85de66adff/src/traits/AdminResponse.php#L27-L39
4,744
webriq/core
module/Core/src/Grid/Core/View/Helper/Markdown.php
Markdown.transform
public function transform( $text, $options = null ) { if ( null !== $options ) { $this->setOptions( $options ); } $parser = $this->extraEnabled ? new MarkdownExtraParser : new MarkdownParser; $parsed = $parser->transformMarkdown( $text ); if ( ! empty( $this->linkTarget ) ) { $parsed = preg_replace( '#<(a|form)((\s[^>]*)?)>(.*?)</\\1>#', '<$1 target="' . htmlspecialchars( $this->linkTarget ) . '"$2>$4</$1>', $parsed ); } if ( $this->stripScripts ) { $parsed = preg_replace( '#<script(\s[^>]*)?>.*?</script>#', '', $parsed ); } return $parsed; }
php
public function transform( $text, $options = null ) { if ( null !== $options ) { $this->setOptions( $options ); } $parser = $this->extraEnabled ? new MarkdownExtraParser : new MarkdownParser; $parsed = $parser->transformMarkdown( $text ); if ( ! empty( $this->linkTarget ) ) { $parsed = preg_replace( '#<(a|form)((\s[^>]*)?)>(.*?)</\\1>#', '<$1 target="' . htmlspecialchars( $this->linkTarget ) . '"$2>$4</$1>', $parsed ); } if ( $this->stripScripts ) { $parsed = preg_replace( '#<script(\s[^>]*)?>.*?</script>#', '', $parsed ); } return $parsed; }
[ "public", "function", "transform", "(", "$", "text", ",", "$", "options", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "options", ")", "{", "$", "this", "->", "setOptions", "(", "$", "options", ")", ";", "}", "$", "parser", "=", "$", "this", "->", "extraEnabled", "?", "new", "MarkdownExtraParser", ":", "new", "MarkdownParser", ";", "$", "parsed", "=", "$", "parser", "->", "transformMarkdown", "(", "$", "text", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "linkTarget", ")", ")", "{", "$", "parsed", "=", "preg_replace", "(", "'#<(a|form)((\\s[^>]*)?)>(.*?)</\\\\1>#'", ",", "'<$1 target=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "linkTarget", ")", ".", "'\"$2>$4</$1>'", ",", "$", "parsed", ")", ";", "}", "if", "(", "$", "this", "->", "stripScripts", ")", "{", "$", "parsed", "=", "preg_replace", "(", "'#<script(\\s[^>]*)?>.*?</script>#'", ",", "''", ",", "$", "parsed", ")", ";", "}", "return", "$", "parsed", ";", "}" ]
Transform text from markdown to html @param string $text @param array $options @return string
[ "Transform", "text", "from", "markdown", "to", "html" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/View/Helper/Markdown.php#L70-L101
4,745
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Service/ProductOrderService.php
ProductOrderService.findAll
public function findAll($page = 1, $max = 50) { $offset = (($page - 1) * $max); $productOrders = $this->productOrderRepository->findBy(array(), array(), $max, $offset); return $productOrders; }
php
public function findAll($page = 1, $max = 50) { $offset = (($page - 1) * $max); $productOrders = $this->productOrderRepository->findBy(array(), array(), $max, $offset); return $productOrders; }
[ "public", "function", "findAll", "(", "$", "page", "=", "1", ",", "$", "max", "=", "50", ")", "{", "$", "offset", "=", "(", "(", "$", "page", "-", "1", ")", "*", "$", "max", ")", ";", "$", "productOrders", "=", "$", "this", "->", "productOrderRepository", "->", "findBy", "(", "array", "(", ")", ",", "array", "(", ")", ",", "$", "max", ",", "$", "offset", ")", ";", "return", "$", "productOrders", ";", "}" ]
Find al ProductOrders with pagination options. @param integer $page [description] @param integer $max [description] @return ArrayCollection ProductOrders.
[ "Find", "al", "ProductOrders", "with", "pagination", "options", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderService.php#L56-L61
4,746
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Service/ProductOrderService.php
ProductOrderService.create
public function create(ProductOrder $productOrder) { $this->getEm()->persist($productOrder); $this->getEm()->flush(); return $productOrder; }
php
public function create(ProductOrder $productOrder) { $this->getEm()->persist($productOrder); $this->getEm()->flush(); return $productOrder; }
[ "public", "function", "create", "(", "ProductOrder", "$", "productOrder", ")", "{", "$", "this", "->", "getEm", "(", ")", "->", "persist", "(", "$", "productOrder", ")", ";", "$", "this", "->", "getEm", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "productOrder", ";", "}" ]
Create a new productOrder. @param ProductOrder $productOrder the productOrder instance. @return ProductOrder the productOrder instance.
[ "Create", "a", "new", "productOrder", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderService.php#L88-L94
4,747
flowcode/AmulenShopBundle
src/Flowcode/ShopBundle/Service/ProductOrderService.php
ProductOrderService.clearDrafts
public function clearDrafts() { $interval = new \DateInterval('P1D'); $dateTo = new \DateTime(); $dateTo->sub($interval); $orders = $this->productOrderRepository->getDraftsBetween(null, $dateTo); $processedCount = 0; /** @var ProductOrder $productOrder */ foreach ($orders as $productOrder) { $productOrder->setEnabled(false); $processedCount++; } $this->getEm()->flush(); return [ 'processed' => $processedCount ]; }
php
public function clearDrafts() { $interval = new \DateInterval('P1D'); $dateTo = new \DateTime(); $dateTo->sub($interval); $orders = $this->productOrderRepository->getDraftsBetween(null, $dateTo); $processedCount = 0; /** @var ProductOrder $productOrder */ foreach ($orders as $productOrder) { $productOrder->setEnabled(false); $processedCount++; } $this->getEm()->flush(); return [ 'processed' => $processedCount ]; }
[ "public", "function", "clearDrafts", "(", ")", "{", "$", "interval", "=", "new", "\\", "DateInterval", "(", "'P1D'", ")", ";", "$", "dateTo", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "dateTo", "->", "sub", "(", "$", "interval", ")", ";", "$", "orders", "=", "$", "this", "->", "productOrderRepository", "->", "getDraftsBetween", "(", "null", ",", "$", "dateTo", ")", ";", "$", "processedCount", "=", "0", ";", "/** @var ProductOrder $productOrder */", "foreach", "(", "$", "orders", "as", "$", "productOrder", ")", "{", "$", "productOrder", "->", "setEnabled", "(", "false", ")", ";", "$", "processedCount", "++", ";", "}", "$", "this", "->", "getEm", "(", ")", "->", "flush", "(", ")", ";", "return", "[", "'processed'", "=>", "$", "processedCount", "]", ";", "}" ]
Disable old draft orders. @return array
[ "Disable", "old", "draft", "orders", "." ]
500aaf4364be3c42fca69ecd10a449da03993814
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Service/ProductOrderService.php#L389-L410
4,748
Thuata/ComponentBundle
SoftDelete/SoftDeletableTrait.php
SoftDeletableTrait.setDeleted
public function setDeleted(bool $deleted) { if(!is_bool($deleted)) { throw new InvalidParameterTypeException(get_class($this), __METHOD__, 1, 'boolean', gettype($deleted)); } $this->deleted = $deleted; return $this; }
php
public function setDeleted(bool $deleted) { if(!is_bool($deleted)) { throw new InvalidParameterTypeException(get_class($this), __METHOD__, 1, 'boolean', gettype($deleted)); } $this->deleted = $deleted; return $this; }
[ "public", "function", "setDeleted", "(", "bool", "$", "deleted", ")", "{", "if", "(", "!", "is_bool", "(", "$", "deleted", ")", ")", "{", "throw", "new", "InvalidParameterTypeException", "(", "get_class", "(", "$", "this", ")", ",", "__METHOD__", ",", "1", ",", "'boolean'", ",", "gettype", "(", "$", "deleted", ")", ")", ";", "}", "$", "this", "->", "deleted", "=", "$", "deleted", ";", "return", "$", "this", ";", "}" ]
Sets Instance to deleted or not deleted @param boolean $deleted @return \Thuata\ComponentBundle\SoftDelete\SoftDeleteInterface @throws \Thuata\ComponentBundle\Exception\InvalidParameterTypeException
[ "Sets", "Instance", "to", "deleted", "or", "not", "deleted" ]
1001aaf585d177daa4b2fef4989c530ff5963df0
https://github.com/Thuata/ComponentBundle/blob/1001aaf585d177daa4b2fef4989c530ff5963df0/SoftDelete/SoftDeletableTrait.php#L64-L73
4,749
eureka-framework/Eurekon
Style.php
Style.get
public function get() { if ($this->argument instanceof Argument && ! $this->argument->has('color')) { return $this->text; } $text = ''; if ($this->foregroundColor !== '') { //~ Highlight $highlight = $this->hasHighlightedForeground ? static::HIGH_FOREGROUND : static::REGULAR_FOREGROUND; //~ Decoration $decoration = $this->isBold ? static::DECORATION_BOLD : ''; $decoration .= $this->isUnderline ? static::DECORATION_UNDERLINE : ''; $decoration = ! empty($decoration) ? $decoration : static::DECORATION_NONE; //~ Apply style $text .= self::BEGIN . $decoration . $highlight . $this->foregroundColor . self::END; } if ($this->backgroundColor !== '') { $highlight = $this->hasHighlightedBackground ? static::HIGH_BACKGROUND : static::REGULAR_BACKGROUND; $text .= self::BEGIN . $highlight . $this->backgroundColor . self::END; } $text .= $this->text . self::DESACTIVATE; return $text; }
php
public function get() { if ($this->argument instanceof Argument && ! $this->argument->has('color')) { return $this->text; } $text = ''; if ($this->foregroundColor !== '') { //~ Highlight $highlight = $this->hasHighlightedForeground ? static::HIGH_FOREGROUND : static::REGULAR_FOREGROUND; //~ Decoration $decoration = $this->isBold ? static::DECORATION_BOLD : ''; $decoration .= $this->isUnderline ? static::DECORATION_UNDERLINE : ''; $decoration = ! empty($decoration) ? $decoration : static::DECORATION_NONE; //~ Apply style $text .= self::BEGIN . $decoration . $highlight . $this->foregroundColor . self::END; } if ($this->backgroundColor !== '') { $highlight = $this->hasHighlightedBackground ? static::HIGH_BACKGROUND : static::REGULAR_BACKGROUND; $text .= self::BEGIN . $highlight . $this->backgroundColor . self::END; } $text .= $this->text . self::DESACTIVATE; return $text; }
[ "public", "function", "get", "(", ")", "{", "if", "(", "$", "this", "->", "argument", "instanceof", "Argument", "&&", "!", "$", "this", "->", "argument", "->", "has", "(", "'color'", ")", ")", "{", "return", "$", "this", "->", "text", ";", "}", "$", "text", "=", "''", ";", "if", "(", "$", "this", "->", "foregroundColor", "!==", "''", ")", "{", "//~ Highlight", "$", "highlight", "=", "$", "this", "->", "hasHighlightedForeground", "?", "static", "::", "HIGH_FOREGROUND", ":", "static", "::", "REGULAR_FOREGROUND", ";", "//~ Decoration", "$", "decoration", "=", "$", "this", "->", "isBold", "?", "static", "::", "DECORATION_BOLD", ":", "''", ";", "$", "decoration", ".=", "$", "this", "->", "isUnderline", "?", "static", "::", "DECORATION_UNDERLINE", ":", "''", ";", "$", "decoration", "=", "!", "empty", "(", "$", "decoration", ")", "?", "$", "decoration", ":", "static", "::", "DECORATION_NONE", ";", "//~ Apply style", "$", "text", ".=", "self", "::", "BEGIN", ".", "$", "decoration", ".", "$", "highlight", ".", "$", "this", "->", "foregroundColor", ".", "self", "::", "END", ";", "}", "if", "(", "$", "this", "->", "backgroundColor", "!==", "''", ")", "{", "$", "highlight", "=", "$", "this", "->", "hasHighlightedBackground", "?", "static", "::", "HIGH_BACKGROUND", ":", "static", "::", "REGULAR_BACKGROUND", ";", "$", "text", ".=", "self", "::", "BEGIN", ".", "$", "highlight", ".", "$", "this", "->", "backgroundColor", ".", "self", "::", "END", ";", "}", "$", "text", ".=", "$", "this", "->", "text", ".", "self", "::", "DESACTIVATE", ";", "return", "$", "text", ";", "}" ]
Get text with styles. @return string
[ "Get", "text", "with", "styles", "." ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Style.php#L281-L310
4,750
eureka-framework/Eurekon
Style.php
Style.reset
public function reset() { $this->isBold = false; $this->isUnderline = false; $this->hasHighlightedBackground = false; $this->hasHighlightedForeground = false; $this->backgroundColor = Style::COLOR_BLACK; $this->foregroundColor = Style::COLOR_WHITE; return $this; }
php
public function reset() { $this->isBold = false; $this->isUnderline = false; $this->hasHighlightedBackground = false; $this->hasHighlightedForeground = false; $this->backgroundColor = Style::COLOR_BLACK; $this->foregroundColor = Style::COLOR_WHITE; return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "isBold", "=", "false", ";", "$", "this", "->", "isUnderline", "=", "false", ";", "$", "this", "->", "hasHighlightedBackground", "=", "false", ";", "$", "this", "->", "hasHighlightedForeground", "=", "false", ";", "$", "this", "->", "backgroundColor", "=", "Style", "::", "COLOR_BLACK", ";", "$", "this", "->", "foregroundColor", "=", "Style", "::", "COLOR_WHITE", ";", "return", "$", "this", ";", "}" ]
Reset styles. @return Style Class instance
[ "Reset", "styles", "." ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Style.php#L317-L327
4,751
dlabas/DlcDoctrine
src/DlcDoctrine/Event/FinishListener.php
FinishListener.getObjectManager
public function getObjectManager() { if (!$this->objectManager instanceof ObjectManager) { $this->setObjectManager($this->getServiceManager()->get('doctrine.entitymanager.orm_default')); } return $this->objectManager; }
php
public function getObjectManager() { if (!$this->objectManager instanceof ObjectManager) { $this->setObjectManager($this->getServiceManager()->get('doctrine.entitymanager.orm_default')); } return $this->objectManager; }
[ "public", "function", "getObjectManager", "(", ")", "{", "if", "(", "!", "$", "this", "->", "objectManager", "instanceof", "ObjectManager", ")", "{", "$", "this", "->", "setObjectManager", "(", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "'doctrine.entitymanager.orm_default'", ")", ")", ";", "}", "return", "$", "this", "->", "objectManager", ";", "}" ]
Get the object manager @return ObjectManager
[ "Get", "the", "object", "manager" ]
1e754c208197e9aa7a9d58efcc726e109aaa6edf
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Event/FinishListener.php#L26-L32
4,752
dlabas/DlcDoctrine
src/DlcDoctrine/Event/FinishListener.php
FinishListener.onFinish
public function onFinish($event) { $objectManager = $this->getObjectManager(); $unitOfWork = $objectManager->getUnitOfWork(); if ($unitOfWork->size() > 0) { $objectManager->flush(); } }
php
public function onFinish($event) { $objectManager = $this->getObjectManager(); $unitOfWork = $objectManager->getUnitOfWork(); if ($unitOfWork->size() > 0) { $objectManager->flush(); } }
[ "public", "function", "onFinish", "(", "$", "event", ")", "{", "$", "objectManager", "=", "$", "this", "->", "getObjectManager", "(", ")", ";", "$", "unitOfWork", "=", "$", "objectManager", "->", "getUnitOfWork", "(", ")", ";", "if", "(", "$", "unitOfWork", "->", "size", "(", ")", ">", "0", ")", "{", "$", "objectManager", "->", "flush", "(", ")", ";", "}", "}" ]
Listen to the "finish" event and attempt to flush changes @param MvcEvent $e
[ "Listen", "to", "the", "finish", "event", "and", "attempt", "to", "flush", "changes" ]
1e754c208197e9aa7a9d58efcc726e109aaa6edf
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Event/FinishListener.php#L77-L85
4,753
FiveLab/AuthorizeActionBundle
src/Request/ParamConverter/AuthorizeActionParamConverter.php
AuthorizeActionParamConverter.setPropertyValuesToObject
private function setPropertyValuesToObject(Request $request, $object, array $fields): void { $objectClass = get_class($object); foreach ($fields as $propertyName => $attributeName) { $value = $request->attributes->get($attributeName); $propertyTypes = $this->propertyTypeExtractor->getTypes($objectClass, $propertyName); $propertyType = null; if ($propertyTypes) { $propertyType = array_pop($propertyTypes); } if (!$value) { // The value is empty. Throw exception if value cannot be nullable. if ($propertyType && !$propertyType->isNullable()) { throw new MissingAttributeException(sprintf( 'Missing the attribute with name "%s" in request.', $attributeName )); } // We cannot get the type of property or property can be nullable. continue; } if ($propertyType->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) { // The property should be an object. Try denormalize. $value = $this->denormalizer->denormalize($value, $propertyType->getClassName()); } $refProperty = new \ReflectionProperty($object, $propertyName); $refProperty->setAccessible(true); $refProperty->setValue($object, $value); } }
php
private function setPropertyValuesToObject(Request $request, $object, array $fields): void { $objectClass = get_class($object); foreach ($fields as $propertyName => $attributeName) { $value = $request->attributes->get($attributeName); $propertyTypes = $this->propertyTypeExtractor->getTypes($objectClass, $propertyName); $propertyType = null; if ($propertyTypes) { $propertyType = array_pop($propertyTypes); } if (!$value) { // The value is empty. Throw exception if value cannot be nullable. if ($propertyType && !$propertyType->isNullable()) { throw new MissingAttributeException(sprintf( 'Missing the attribute with name "%s" in request.', $attributeName )); } // We cannot get the type of property or property can be nullable. continue; } if ($propertyType->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) { // The property should be an object. Try denormalize. $value = $this->denormalizer->denormalize($value, $propertyType->getClassName()); } $refProperty = new \ReflectionProperty($object, $propertyName); $refProperty->setAccessible(true); $refProperty->setValue($object, $value); } }
[ "private", "function", "setPropertyValuesToObject", "(", "Request", "$", "request", ",", "$", "object", ",", "array", "$", "fields", ")", ":", "void", "{", "$", "objectClass", "=", "get_class", "(", "$", "object", ")", ";", "foreach", "(", "$", "fields", "as", "$", "propertyName", "=>", "$", "attributeName", ")", "{", "$", "value", "=", "$", "request", "->", "attributes", "->", "get", "(", "$", "attributeName", ")", ";", "$", "propertyTypes", "=", "$", "this", "->", "propertyTypeExtractor", "->", "getTypes", "(", "$", "objectClass", ",", "$", "propertyName", ")", ";", "$", "propertyType", "=", "null", ";", "if", "(", "$", "propertyTypes", ")", "{", "$", "propertyType", "=", "array_pop", "(", "$", "propertyTypes", ")", ";", "}", "if", "(", "!", "$", "value", ")", "{", "// The value is empty. Throw exception if value cannot be nullable.", "if", "(", "$", "propertyType", "&&", "!", "$", "propertyType", "->", "isNullable", "(", ")", ")", "{", "throw", "new", "MissingAttributeException", "(", "sprintf", "(", "'Missing the attribute with name \"%s\" in request.'", ",", "$", "attributeName", ")", ")", ";", "}", "// We cannot get the type of property or property can be nullable.", "continue", ";", "}", "if", "(", "$", "propertyType", "->", "getBuiltinType", "(", ")", "===", "Type", "::", "BUILTIN_TYPE_OBJECT", ")", "{", "// The property should be an object. Try denormalize.", "$", "value", "=", "$", "this", "->", "denormalizer", "->", "denormalize", "(", "$", "value", ",", "$", "propertyType", "->", "getClassName", "(", ")", ")", ";", "}", "$", "refProperty", "=", "new", "\\", "ReflectionProperty", "(", "$", "object", ",", "$", "propertyName", ")", ";", "$", "refProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "refProperty", "->", "setValue", "(", "$", "object", ",", "$", "value", ")", ";", "}", "}" ]
Set the values to object @param Request $request @param object $object @param array $fields @throws MissingAttributeException @throws \InvalidArgumentException @throws \ReflectionException
[ "Set", "the", "values", "to", "object" ]
7613923022180a0f3e9ec455b3bf06806fb10887
https://github.com/FiveLab/AuthorizeActionBundle/blob/7613923022180a0f3e9ec455b3bf06806fb10887/src/Request/ParamConverter/AuthorizeActionParamConverter.php#L94-L129
4,754
gocom/eien
src/Rah/Eien/Base.php
Rah_Eien_Base.tmpFile
protected function tmpFile() { if (($this->temp = tempnam($this->config->tmp, $this->config->prefix)) === false) { throw new Rah_Eien_Exception('Unable to create a temporary file, check the configured tmp directory.'); } if ($this->config->extension) { if (rename($this->temp, $this->temp.'.'.$this->config->extension) === false) { throw new Rah_Eien_Exception('Unable to add "'.$this->config->extension.'" extension to "'.$this->temp.'".'); } $this->temp .= '.'.$this->config->extension; } }
php
protected function tmpFile() { if (($this->temp = tempnam($this->config->tmp, $this->config->prefix)) === false) { throw new Rah_Eien_Exception('Unable to create a temporary file, check the configured tmp directory.'); } if ($this->config->extension) { if (rename($this->temp, $this->temp.'.'.$this->config->extension) === false) { throw new Rah_Eien_Exception('Unable to add "'.$this->config->extension.'" extension to "'.$this->temp.'".'); } $this->temp .= '.'.$this->config->extension; } }
[ "protected", "function", "tmpFile", "(", ")", "{", "if", "(", "(", "$", "this", "->", "temp", "=", "tempnam", "(", "$", "this", "->", "config", "->", "tmp", ",", "$", "this", "->", "config", "->", "prefix", ")", ")", "===", "false", ")", "{", "throw", "new", "Rah_Eien_Exception", "(", "'Unable to create a temporary file, check the configured tmp directory.'", ")", ";", "}", "if", "(", "$", "this", "->", "config", "->", "extension", ")", "{", "if", "(", "rename", "(", "$", "this", "->", "temp", ",", "$", "this", "->", "temp", ".", "'.'", ".", "$", "this", "->", "config", "->", "extension", ")", "===", "false", ")", "{", "throw", "new", "Rah_Eien_Exception", "(", "'Unable to add \"'", ".", "$", "this", "->", "config", "->", "extension", ".", "'\" extension to \"'", ".", "$", "this", "->", "temp", ".", "'\".'", ")", ";", "}", "$", "this", "->", "temp", ".=", "'.'", ".", "$", "this", "->", "config", "->", "extension", ";", "}", "}" ]
Gets a path to a temporary file. @throws Rah_Eien_Exception
[ "Gets", "a", "path", "to", "a", "temporary", "file", "." ]
e711ff12a8f4304381dcb4e502f71cb74bfb9dd0
https://github.com/gocom/eien/blob/e711ff12a8f4304381dcb4e502f71cb74bfb9dd0/src/Rah/Eien/Base.php#L157-L173
4,755
gocom/eien
src/Rah/Eien/Base.php
Rah_Eien_Base.tmpDirectory
protected function tmpDirectory() { $this->tmpFile(); unlink($this->temp); $this->temp .= '.d'; if (mkdir($this->temp) === false) { throw new Rah_Eien_Exception('Unable to create a temporary directory, check the configured tmp directory.'); } }
php
protected function tmpDirectory() { $this->tmpFile(); unlink($this->temp); $this->temp .= '.d'; if (mkdir($this->temp) === false) { throw new Rah_Eien_Exception('Unable to create a temporary directory, check the configured tmp directory.'); } }
[ "protected", "function", "tmpDirectory", "(", ")", "{", "$", "this", "->", "tmpFile", "(", ")", ";", "unlink", "(", "$", "this", "->", "temp", ")", ";", "$", "this", "->", "temp", ".=", "'.d'", ";", "if", "(", "mkdir", "(", "$", "this", "->", "temp", ")", "===", "false", ")", "{", "throw", "new", "Rah_Eien_Exception", "(", "'Unable to create a temporary directory, check the configured tmp directory.'", ")", ";", "}", "}" ]
Gets a path to a temporary directory. @throws Rah_Eien_Exception
[ "Gets", "a", "path", "to", "a", "temporary", "directory", "." ]
e711ff12a8f4304381dcb4e502f71cb74bfb9dd0
https://github.com/gocom/eien/blob/e711ff12a8f4304381dcb4e502f71cb74bfb9dd0/src/Rah/Eien/Base.php#L181-L191
4,756
gocom/eien
src/Rah/Eien/Base.php
Rah_Eien_Base.clean
protected function clean() { if ($this->temp) { new Rah_Eien_Action_Stat($this->temp, 'wf'); if (unlink($this->temp) === false) { throw new Rah_Eien_Exception('Unable to remove the temporary trash.'); } } }
php
protected function clean() { if ($this->temp) { new Rah_Eien_Action_Stat($this->temp, 'wf'); if (unlink($this->temp) === false) { throw new Rah_Eien_Exception('Unable to remove the temporary trash.'); } } }
[ "protected", "function", "clean", "(", ")", "{", "if", "(", "$", "this", "->", "temp", ")", "{", "new", "Rah_Eien_Action_Stat", "(", "$", "this", "->", "temp", ",", "'wf'", ")", ";", "if", "(", "unlink", "(", "$", "this", "->", "temp", ")", "===", "false", ")", "{", "throw", "new", "Rah_Eien_Exception", "(", "'Unable to remove the temporary trash.'", ")", ";", "}", "}", "}" ]
Clean temporary trash. @throws Rah_Eien_Exception
[ "Clean", "temporary", "trash", "." ]
e711ff12a8f4304381dcb4e502f71cb74bfb9dd0
https://github.com/gocom/eien/blob/e711ff12a8f4304381dcb4e502f71cb74bfb9dd0/src/Rah/Eien/Base.php#L199-L210
4,757
webriq/core
module/Paragraph/src/Grid/Paragraph/View/Model/CreateWizard/StartStep.php
StartStep.getNextStep
public function getNextStep() { $next = parent::getNextStep(); if ( empty( $next ) ) { $form = $this->getStepForm(); if ( ! empty( $form ) ) { $type = $form->get( 'type' ); if ( ! empty( $type ) ) { $next = $type->getValue(); } } } return $next; }
php
public function getNextStep() { $next = parent::getNextStep(); if ( empty( $next ) ) { $form = $this->getStepForm(); if ( ! empty( $form ) ) { $type = $form->get( 'type' ); if ( ! empty( $type ) ) { $next = $type->getValue(); } } } return $next; }
[ "public", "function", "getNextStep", "(", ")", "{", "$", "next", "=", "parent", "::", "getNextStep", "(", ")", ";", "if", "(", "empty", "(", "$", "next", ")", ")", "{", "$", "form", "=", "$", "this", "->", "getStepForm", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "form", ")", ")", "{", "$", "type", "=", "$", "form", "->", "get", "(", "'type'", ")", ";", "if", "(", "!", "empty", "(", "$", "type", ")", ")", "{", "$", "next", "=", "$", "type", "->", "getValue", "(", ")", ";", "}", "}", "}", "return", "$", "next", ";", "}" ]
Get next step @return string|null
[ "Get", "next", "step" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/View/Model/CreateWizard/StartStep.php#L20-L40
4,758
helionogueir/database
core/routine/database/MySql.class.php
MySql.connect
public function connect(Info $info): PDO { try { $mysql = new PDO("{$info->getDsn()}:host={$info->getHost()};dbname={$info->getDbname()};port={$info->getPort()};charset={$info->getCharset()}", $info->getUser(), $info->getPassword(), array( PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_PERSISTENT => false, PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_TIMEOUT => 1800, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES {$info->getCharset()}" )); } catch (Exception $ex) { $mysql = null; throw $ex; } return $mysql; }
php
public function connect(Info $info): PDO { try { $mysql = new PDO("{$info->getDsn()}:host={$info->getHost()};dbname={$info->getDbname()};port={$info->getPort()};charset={$info->getCharset()}", $info->getUser(), $info->getPassword(), array( PDO::ATTR_AUTOCOMMIT => false, PDO::ATTR_PERSISTENT => false, PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_TIMEOUT => 1800, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES {$info->getCharset()}" )); } catch (Exception $ex) { $mysql = null; throw $ex; } return $mysql; }
[ "public", "function", "connect", "(", "Info", "$", "info", ")", ":", "PDO", "{", "try", "{", "$", "mysql", "=", "new", "PDO", "(", "\"{$info->getDsn()}:host={$info->getHost()};dbname={$info->getDbname()};port={$info->getPort()};charset={$info->getCharset()}\"", ",", "$", "info", "->", "getUser", "(", ")", ",", "$", "info", "->", "getPassword", "(", ")", ",", "array", "(", "PDO", "::", "ATTR_AUTOCOMMIT", "=>", "false", ",", "PDO", "::", "ATTR_PERSISTENT", "=>", "false", ",", "PDO", "::", "ATTR_EMULATE_PREPARES", "=>", "true", ",", "PDO", "::", "ATTR_TIMEOUT", "=>", "1800", ",", "PDO", "::", "ATTR_ERRMODE", "=>", "PDO", "::", "ERRMODE_EXCEPTION", ",", "PDO", "::", "MYSQL_ATTR_USE_BUFFERED_QUERY", "=>", "true", ",", "PDO", "::", "ATTR_DEFAULT_FETCH_MODE", "=>", "PDO", "::", "FETCH_OBJ", ",", "PDO", "::", "MYSQL_ATTR_INIT_COMMAND", "=>", "\"SET NAMES {$info->getCharset()}\"", ")", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "$", "mysql", "=", "null", ";", "throw", "$", "ex", ";", "}", "return", "$", "mysql", ";", "}" ]
- Connect in MySQL database @param helionogueir\database\routine\database\Info $info Database information @return PDO Return PDO MySQL connection
[ "-", "Connect", "in", "MySQL", "database" ]
685606726cd90cc730c419681383e2cb6c4150f3
https://github.com/helionogueir/database/blob/685606726cd90cc730c419681383e2cb6c4150f3/core/routine/database/MySql.class.php#L21-L38
4,759
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.prepareTableRegistry
protected function prepareTableRegistry(DOMElement $table, $bundle) { if (($tableName = $table->getAttribute('name')) !== '') { $tmpTableClass = null; if (!empty($tableClass = $table->getAttribute('tableClass'))) { $tmpTableClass = "'" . $tableClass . "'"; } $tmpEntityClass = null; if (!empty($entityClass = $table->getAttribute('entityClass'))) { $tmpEntityClass = "'" . $entityClass . "'"; } $tmpAlias = null; if (!empty($alias = $table->getAttribute('alias'))) { $tmpAlias = "'" . $alias . "'"; } $code = <<<PHP Cake\ORM\TableRegistry::config( '$bundle.$alias', [ 'table' => '$tableName', 'alias' => $tmpAlias, 'className' => $tmpTableClass, 'entityClass' => $tmpEntityClass, ] ); PHP; $this->tablesModel[$bundle][] = [ 'tableClass' => $tableClass, 'entityClass' => $entityClass, 'alias' => $alias ]; $this->tableRegistryCode[$bundle][] = $code; } }
php
protected function prepareTableRegistry(DOMElement $table, $bundle) { if (($tableName = $table->getAttribute('name')) !== '') { $tmpTableClass = null; if (!empty($tableClass = $table->getAttribute('tableClass'))) { $tmpTableClass = "'" . $tableClass . "'"; } $tmpEntityClass = null; if (!empty($entityClass = $table->getAttribute('entityClass'))) { $tmpEntityClass = "'" . $entityClass . "'"; } $tmpAlias = null; if (!empty($alias = $table->getAttribute('alias'))) { $tmpAlias = "'" . $alias . "'"; } $code = <<<PHP Cake\ORM\TableRegistry::config( '$bundle.$alias', [ 'table' => '$tableName', 'alias' => $tmpAlias, 'className' => $tmpTableClass, 'entityClass' => $tmpEntityClass, ] ); PHP; $this->tablesModel[$bundle][] = [ 'tableClass' => $tableClass, 'entityClass' => $entityClass, 'alias' => $alias ]; $this->tableRegistryCode[$bundle][] = $code; } }
[ "protected", "function", "prepareTableRegistry", "(", "DOMElement", "$", "table", ",", "$", "bundle", ")", "{", "if", "(", "(", "$", "tableName", "=", "$", "table", "->", "getAttribute", "(", "'name'", ")", ")", "!==", "''", ")", "{", "$", "tmpTableClass", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "tableClass", "=", "$", "table", "->", "getAttribute", "(", "'tableClass'", ")", ")", ")", "{", "$", "tmpTableClass", "=", "\"'\"", ".", "$", "tableClass", ".", "\"'\"", ";", "}", "$", "tmpEntityClass", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "entityClass", "=", "$", "table", "->", "getAttribute", "(", "'entityClass'", ")", ")", ")", "{", "$", "tmpEntityClass", "=", "\"'\"", ".", "$", "entityClass", ".", "\"'\"", ";", "}", "$", "tmpAlias", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "alias", "=", "$", "table", "->", "getAttribute", "(", "'alias'", ")", ")", ")", "{", "$", "tmpAlias", "=", "\"'\"", ".", "$", "alias", ".", "\"'\"", ";", "}", "$", "code", "=", " <<<PHP\nCake\\ORM\\TableRegistry::config(\n '$bundle.$alias',\n [\n 'table' => '$tableName',\n 'alias' => $tmpAlias,\n 'className' => $tmpTableClass,\n 'entityClass' => $tmpEntityClass,\n ]\n);\nPHP", ";", "$", "this", "->", "tablesModel", "[", "$", "bundle", "]", "[", "]", "=", "[", "'tableClass'", "=>", "$", "tableClass", ",", "'entityClass'", "=>", "$", "entityClass", ",", "'alias'", "=>", "$", "alias", "]", ";", "$", "this", "->", "tableRegistryCode", "[", "$", "bundle", "]", "[", "]", "=", "$", "code", ";", "}", "}" ]
Prepare table registry @param DOMElement $table @param string $bundle Bundle name
[ "Prepare", "table", "registry" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L99-L136
4,760
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.dumpTableRegistry
protected function dumpTableRegistry(CLImate $climate, $bundle) { $mapDirPath = Bundles::getPath($bundle) . DS . 'Domain' . DS . 'map'; $tableRegistryConfigFile = $mapDirPath . DS . 'table_registry_config.php'; if (!is_dir($mapDirPath)) { mkdir($mapDirPath, 0777, true); } if (is_array($this->tableRegistryCode[$bundle])) { file_put_contents( $tableRegistryConfigFile, '<?php' . "\n\n" . implode("\n\n", $this->tableRegistryCode[$bundle]) ); } }
php
protected function dumpTableRegistry(CLImate $climate, $bundle) { $mapDirPath = Bundles::getPath($bundle) . DS . 'Domain' . DS . 'map'; $tableRegistryConfigFile = $mapDirPath . DS . 'table_registry_config.php'; if (!is_dir($mapDirPath)) { mkdir($mapDirPath, 0777, true); } if (is_array($this->tableRegistryCode[$bundle])) { file_put_contents( $tableRegistryConfigFile, '<?php' . "\n\n" . implode("\n\n", $this->tableRegistryCode[$bundle]) ); } }
[ "protected", "function", "dumpTableRegistry", "(", "CLImate", "$", "climate", ",", "$", "bundle", ")", "{", "$", "mapDirPath", "=", "Bundles", "::", "getPath", "(", "$", "bundle", ")", ".", "DS", ".", "'Domain'", ".", "DS", ".", "'map'", ";", "$", "tableRegistryConfigFile", "=", "$", "mapDirPath", ".", "DS", ".", "'table_registry_config.php'", ";", "if", "(", "!", "is_dir", "(", "$", "mapDirPath", ")", ")", "{", "mkdir", "(", "$", "mapDirPath", ",", "0777", ",", "true", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "tableRegistryCode", "[", "$", "bundle", "]", ")", ")", "{", "file_put_contents", "(", "$", "tableRegistryConfigFile", ",", "'<?php'", ".", "\"\\n\\n\"", ".", "implode", "(", "\"\\n\\n\"", ",", "$", "this", "->", "tableRegistryCode", "[", "$", "bundle", "]", ")", ")", ";", "}", "}" ]
Dump table registry @param CLImate $climate @param string $bundle @throws \Rad\Core\Exception\MissingBundleException
[ "Dump", "table", "registry" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L146-L161
4,761
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.dumpModelClasses
protected function dumpModelClasses(CLImate $climate, $bundle) { if (is_array($this->tablesModel[$bundle])) { foreach ($this->tablesModel[$bundle] as $tableSpec) { $alias = $tableSpec['alias']; if ($tableSpec['tableClass']) { $tableClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['tableClass']) . '.php'; $tableClassDir = dirname($tableClassPath); $tableClassName = trim( substr($tableSpec['tableClass'], strrpos($tableSpec['tableClass'], '\\')), '\\' ); $tableClassNamespace = trim( substr($tableSpec['tableClass'], 0, strrpos($tableSpec['tableClass'], '\\')), '\\' ); if (!is_file($tableClassPath)) { if (!is_dir($tableClassDir)) { mkdir($tableClassDir, 0777, true); } ob_start(); echo '<?php'; include Bundles::getPath('CakeOrm') . '/Resource/config/table_template.php'; $content = ob_get_contents(); ob_end_clean(); file_put_contents($tableClassPath, $content); $climate->lightGray(sprintf('Create table class "%s".', $tableSpec['tableClass'])); } else { $climate->lightMagenta(sprintf('Table class "%s" exists.', $tableSpec['tableClass'])); } } //if ($tableSpec['entityClass']) { // $entityClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['entityClass']); // $entityClassName = trim( // substr($tableSpec['entityClass'], strrpos($tableSpec['entityClass'], '\\')), // '\\' // ); //} } } }
php
protected function dumpModelClasses(CLImate $climate, $bundle) { if (is_array($this->tablesModel[$bundle])) { foreach ($this->tablesModel[$bundle] as $tableSpec) { $alias = $tableSpec['alias']; if ($tableSpec['tableClass']) { $tableClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['tableClass']) . '.php'; $tableClassDir = dirname($tableClassPath); $tableClassName = trim( substr($tableSpec['tableClass'], strrpos($tableSpec['tableClass'], '\\')), '\\' ); $tableClassNamespace = trim( substr($tableSpec['tableClass'], 0, strrpos($tableSpec['tableClass'], '\\')), '\\' ); if (!is_file($tableClassPath)) { if (!is_dir($tableClassDir)) { mkdir($tableClassDir, 0777, true); } ob_start(); echo '<?php'; include Bundles::getPath('CakeOrm') . '/Resource/config/table_template.php'; $content = ob_get_contents(); ob_end_clean(); file_put_contents($tableClassPath, $content); $climate->lightGray(sprintf('Create table class "%s".', $tableSpec['tableClass'])); } else { $climate->lightMagenta(sprintf('Table class "%s" exists.', $tableSpec['tableClass'])); } } //if ($tableSpec['entityClass']) { // $entityClassPath = SRC_DIR . DS . str_replace('\\', '/', $tableSpec['entityClass']); // $entityClassName = trim( // substr($tableSpec['entityClass'], strrpos($tableSpec['entityClass'], '\\')), // '\\' // ); //} } } }
[ "protected", "function", "dumpModelClasses", "(", "CLImate", "$", "climate", ",", "$", "bundle", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "tablesModel", "[", "$", "bundle", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "tablesModel", "[", "$", "bundle", "]", "as", "$", "tableSpec", ")", "{", "$", "alias", "=", "$", "tableSpec", "[", "'alias'", "]", ";", "if", "(", "$", "tableSpec", "[", "'tableClass'", "]", ")", "{", "$", "tableClassPath", "=", "SRC_DIR", ".", "DS", ".", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "tableSpec", "[", "'tableClass'", "]", ")", ".", "'.php'", ";", "$", "tableClassDir", "=", "dirname", "(", "$", "tableClassPath", ")", ";", "$", "tableClassName", "=", "trim", "(", "substr", "(", "$", "tableSpec", "[", "'tableClass'", "]", ",", "strrpos", "(", "$", "tableSpec", "[", "'tableClass'", "]", ",", "'\\\\'", ")", ")", ",", "'\\\\'", ")", ";", "$", "tableClassNamespace", "=", "trim", "(", "substr", "(", "$", "tableSpec", "[", "'tableClass'", "]", ",", "0", ",", "strrpos", "(", "$", "tableSpec", "[", "'tableClass'", "]", ",", "'\\\\'", ")", ")", ",", "'\\\\'", ")", ";", "if", "(", "!", "is_file", "(", "$", "tableClassPath", ")", ")", "{", "if", "(", "!", "is_dir", "(", "$", "tableClassDir", ")", ")", "{", "mkdir", "(", "$", "tableClassDir", ",", "0777", ",", "true", ")", ";", "}", "ob_start", "(", ")", ";", "echo", "'<?php'", ";", "include", "Bundles", "::", "getPath", "(", "'CakeOrm'", ")", ".", "'/Resource/config/table_template.php'", ";", "$", "content", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "file_put_contents", "(", "$", "tableClassPath", ",", "$", "content", ")", ";", "$", "climate", "->", "lightGray", "(", "sprintf", "(", "'Create table class \"%s\".'", ",", "$", "tableSpec", "[", "'tableClass'", "]", ")", ")", ";", "}", "else", "{", "$", "climate", "->", "lightMagenta", "(", "sprintf", "(", "'Table class \"%s\" exists.'", ",", "$", "tableSpec", "[", "'tableClass'", "]", ")", ")", ";", "}", "}", "//if ($tableSpec['entityClass']) {", "// $entityClassPath = SRC_DIR . DS . str_replace('\\\\', '/', $tableSpec['entityClass']);", "// $entityClassName = trim(", "// substr($tableSpec['entityClass'], strrpos($tableSpec['entityClass'], '\\\\')),", "// '\\\\'", "// );", "//}", "}", "}", "}" ]
Dump model classes @param CLImate $climate @param string $bundle
[ "Dump", "model", "classes" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L169-L213
4,762
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.prepareForeignConstraint
protected function prepareForeignConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $foreignKeys = $xpath->query(sprintf('/database/table[@name="%s"]/foreign', $table->getAttribute('name'))); /** @var DOMElement $foreignKey */ foreach ($foreignKeys as $foreignKey) { $foreignTable = $foreignKey->getAttribute('foreignTable'); $references = $foreignKey->getElementsByTagName('reference'); /** @var DOMElement $reference */ foreach ($references as $reference) { $localColumn = $reference->getAttribute('local'); $foreignColumn = $reference->getAttribute('foreign'); $constraintName = sprintf( '%s_%s_%s_%s_foreign', $table->getAttribute('name'), $foreignTable, $localColumn, $foreignColumn ); $schemaTable->addConstraint( $constraintName, [ 'type' => 'foreign', 'columns' => [$localColumn], 'references' => [$foreignTable, $foreignColumn], 'update' => $foreignKey->getAttribute('onUpdate'), 'delete' => $foreignKey->getAttribute('onDelete') ] ); } } }
php
protected function prepareForeignConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $foreignKeys = $xpath->query(sprintf('/database/table[@name="%s"]/foreign', $table->getAttribute('name'))); /** @var DOMElement $foreignKey */ foreach ($foreignKeys as $foreignKey) { $foreignTable = $foreignKey->getAttribute('foreignTable'); $references = $foreignKey->getElementsByTagName('reference'); /** @var DOMElement $reference */ foreach ($references as $reference) { $localColumn = $reference->getAttribute('local'); $foreignColumn = $reference->getAttribute('foreign'); $constraintName = sprintf( '%s_%s_%s_%s_foreign', $table->getAttribute('name'), $foreignTable, $localColumn, $foreignColumn ); $schemaTable->addConstraint( $constraintName, [ 'type' => 'foreign', 'columns' => [$localColumn], 'references' => [$foreignTable, $foreignColumn], 'update' => $foreignKey->getAttribute('onUpdate'), 'delete' => $foreignKey->getAttribute('onDelete') ] ); } } }
[ "protected", "function", "prepareForeignConstraint", "(", "DOMElement", "$", "table", ",", "DOMXPath", "$", "xpath", ",", "Table", "$", "schemaTable", ")", "{", "$", "foreignKeys", "=", "$", "xpath", "->", "query", "(", "sprintf", "(", "'/database/table[@name=\"%s\"]/foreign'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ")", ")", ";", "/** @var DOMElement $foreignKey */", "foreach", "(", "$", "foreignKeys", "as", "$", "foreignKey", ")", "{", "$", "foreignTable", "=", "$", "foreignKey", "->", "getAttribute", "(", "'foreignTable'", ")", ";", "$", "references", "=", "$", "foreignKey", "->", "getElementsByTagName", "(", "'reference'", ")", ";", "/** @var DOMElement $reference */", "foreach", "(", "$", "references", "as", "$", "reference", ")", "{", "$", "localColumn", "=", "$", "reference", "->", "getAttribute", "(", "'local'", ")", ";", "$", "foreignColumn", "=", "$", "reference", "->", "getAttribute", "(", "'foreign'", ")", ";", "$", "constraintName", "=", "sprintf", "(", "'%s_%s_%s_%s_foreign'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ",", "$", "foreignTable", ",", "$", "localColumn", ",", "$", "foreignColumn", ")", ";", "$", "schemaTable", "->", "addConstraint", "(", "$", "constraintName", ",", "[", "'type'", "=>", "'foreign'", ",", "'columns'", "=>", "[", "$", "localColumn", "]", ",", "'references'", "=>", "[", "$", "foreignTable", ",", "$", "foreignColumn", "]", ",", "'update'", "=>", "$", "foreignKey", "->", "getAttribute", "(", "'onUpdate'", ")", ",", "'delete'", "=>", "$", "foreignKey", "->", "getAttribute", "(", "'onDelete'", ")", "]", ")", ";", "}", "}", "}" ]
Prepare foreign key constraint @param DOMElement $table @param DOMXPath $xpath @param Table $schemaTable
[ "Prepare", "foreign", "key", "constraint" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L253-L286
4,763
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.prepareUniqueConstraint
protected function prepareUniqueConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $uniqueTags = $xpath->query(sprintf('/database/table[@name="%s"]/unique', $table->getAttribute('name'))); /** @var DOMElement $uniqueTag */ foreach ($uniqueTags as $uniqueTag) { $uniqueColumns = $uniqueTag->getElementsByTagName('unique-column'); $constraintName = $uniqueTag->getAttribute('name'); $tmpUniqueColumn = []; /** @var DOMElement $uniqueColumn */ foreach ($uniqueColumns as $uniqueColumn) { $tmpUniqueColumn[] = $uniqueColumn->getAttribute('name'); } if (empty(trim($constraintName))) { $constraintName = sprintf( '%s_%s_%s', $table->getAttribute('name'), implode('_', $tmpUniqueColumn), 'unique' ); } $schemaTable->addConstraint( $constraintName, [ 'type' => 'unique', 'columns' => $tmpUniqueColumn ] ); } }
php
protected function prepareUniqueConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $uniqueTags = $xpath->query(sprintf('/database/table[@name="%s"]/unique', $table->getAttribute('name'))); /** @var DOMElement $uniqueTag */ foreach ($uniqueTags as $uniqueTag) { $uniqueColumns = $uniqueTag->getElementsByTagName('unique-column'); $constraintName = $uniqueTag->getAttribute('name'); $tmpUniqueColumn = []; /** @var DOMElement $uniqueColumn */ foreach ($uniqueColumns as $uniqueColumn) { $tmpUniqueColumn[] = $uniqueColumn->getAttribute('name'); } if (empty(trim($constraintName))) { $constraintName = sprintf( '%s_%s_%s', $table->getAttribute('name'), implode('_', $tmpUniqueColumn), 'unique' ); } $schemaTable->addConstraint( $constraintName, [ 'type' => 'unique', 'columns' => $tmpUniqueColumn ] ); } }
[ "protected", "function", "prepareUniqueConstraint", "(", "DOMElement", "$", "table", ",", "DOMXPath", "$", "xpath", ",", "Table", "$", "schemaTable", ")", "{", "$", "uniqueTags", "=", "$", "xpath", "->", "query", "(", "sprintf", "(", "'/database/table[@name=\"%s\"]/unique'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ")", ")", ";", "/** @var DOMElement $uniqueTag */", "foreach", "(", "$", "uniqueTags", "as", "$", "uniqueTag", ")", "{", "$", "uniqueColumns", "=", "$", "uniqueTag", "->", "getElementsByTagName", "(", "'unique-column'", ")", ";", "$", "constraintName", "=", "$", "uniqueTag", "->", "getAttribute", "(", "'name'", ")", ";", "$", "tmpUniqueColumn", "=", "[", "]", ";", "/** @var DOMElement $uniqueColumn */", "foreach", "(", "$", "uniqueColumns", "as", "$", "uniqueColumn", ")", "{", "$", "tmpUniqueColumn", "[", "]", "=", "$", "uniqueColumn", "->", "getAttribute", "(", "'name'", ")", ";", "}", "if", "(", "empty", "(", "trim", "(", "$", "constraintName", ")", ")", ")", "{", "$", "constraintName", "=", "sprintf", "(", "'%s_%s_%s'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ",", "implode", "(", "'_'", ",", "$", "tmpUniqueColumn", ")", ",", "'unique'", ")", ";", "}", "$", "schemaTable", "->", "addConstraint", "(", "$", "constraintName", ",", "[", "'type'", "=>", "'unique'", ",", "'columns'", "=>", "$", "tmpUniqueColumn", "]", ")", ";", "}", "}" ]
Prepare unique constraint @param DOMElement $table @param DOMXPath $xpath @param Table $schemaTable
[ "Prepare", "unique", "constraint" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L295-L327
4,764
radphp/cake-orm-bundle
Action/BuildAction.php
BuildAction.preparePrimaryConstraint
protected function preparePrimaryConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $primaryTags = $xpath->query(sprintf('/database/table[@name="%s"]/primary', $table->getAttribute('name'))); /** @var DOMElement $primaryTag */ foreach ($primaryTags as $primaryTag) { $primaryColumns = $primaryTag->getElementsByTagName('primary-column'); $constraintName = $primaryTag->getAttribute('name'); $tmpPrimaryColumn = []; /** @var DOMElement $primaryColumn */ foreach ($primaryColumns as $primaryColumn) { $tmpPrimaryColumn[] = $primaryColumn->getAttribute('name'); } if (empty(trim($constraintName))) { $constraintName = sprintf( '%s_%s_%s', $table->getAttribute('name'), implode('_', $tmpPrimaryColumn), 'primary' ); } $schemaTable->addConstraint( $constraintName, [ 'type' => 'primary', 'columns' => $tmpPrimaryColumn ] ); } }
php
protected function preparePrimaryConstraint(DOMElement $table, DOMXPath $xpath, Table $schemaTable) { $primaryTags = $xpath->query(sprintf('/database/table[@name="%s"]/primary', $table->getAttribute('name'))); /** @var DOMElement $primaryTag */ foreach ($primaryTags as $primaryTag) { $primaryColumns = $primaryTag->getElementsByTagName('primary-column'); $constraintName = $primaryTag->getAttribute('name'); $tmpPrimaryColumn = []; /** @var DOMElement $primaryColumn */ foreach ($primaryColumns as $primaryColumn) { $tmpPrimaryColumn[] = $primaryColumn->getAttribute('name'); } if (empty(trim($constraintName))) { $constraintName = sprintf( '%s_%s_%s', $table->getAttribute('name'), implode('_', $tmpPrimaryColumn), 'primary' ); } $schemaTable->addConstraint( $constraintName, [ 'type' => 'primary', 'columns' => $tmpPrimaryColumn ] ); } }
[ "protected", "function", "preparePrimaryConstraint", "(", "DOMElement", "$", "table", ",", "DOMXPath", "$", "xpath", ",", "Table", "$", "schemaTable", ")", "{", "$", "primaryTags", "=", "$", "xpath", "->", "query", "(", "sprintf", "(", "'/database/table[@name=\"%s\"]/primary'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ")", ")", ";", "/** @var DOMElement $primaryTag */", "foreach", "(", "$", "primaryTags", "as", "$", "primaryTag", ")", "{", "$", "primaryColumns", "=", "$", "primaryTag", "->", "getElementsByTagName", "(", "'primary-column'", ")", ";", "$", "constraintName", "=", "$", "primaryTag", "->", "getAttribute", "(", "'name'", ")", ";", "$", "tmpPrimaryColumn", "=", "[", "]", ";", "/** @var DOMElement $primaryColumn */", "foreach", "(", "$", "primaryColumns", "as", "$", "primaryColumn", ")", "{", "$", "tmpPrimaryColumn", "[", "]", "=", "$", "primaryColumn", "->", "getAttribute", "(", "'name'", ")", ";", "}", "if", "(", "empty", "(", "trim", "(", "$", "constraintName", ")", ")", ")", "{", "$", "constraintName", "=", "sprintf", "(", "'%s_%s_%s'", ",", "$", "table", "->", "getAttribute", "(", "'name'", ")", ",", "implode", "(", "'_'", ",", "$", "tmpPrimaryColumn", ")", ",", "'primary'", ")", ";", "}", "$", "schemaTable", "->", "addConstraint", "(", "$", "constraintName", ",", "[", "'type'", "=>", "'primary'", ",", "'columns'", "=>", "$", "tmpPrimaryColumn", "]", ")", ";", "}", "}" ]
Prepare primary constraint @param DOMElement $table @param DOMXPath $xpath @param Table $schemaTable
[ "Prepare", "primary", "constraint" ]
bb0c917ece97910739badc54a9020e0216e98820
https://github.com/radphp/cake-orm-bundle/blob/bb0c917ece97910739badc54a9020e0216e98820/Action/BuildAction.php#L336-L368
4,765
apnet/bootstrap
app/src/Apnet/Dev/Factory/Importer/BootstrapImporter.php
BootstrapImporter.getBootstrapSassJavascripts
protected function getBootstrapSassJavascripts() { $process = new Process("gem which bootstrap-sass"); $process->run(); if (!$process->isSuccessful()) { throw new WatcherCompileException( "`bootstrap-sass` gem was not found\n\n" . $process->getOutput() ); } $gemPath = trim($process->getOutput()); $bjsRootPath = dirname(dirname($gemPath)) . "/assets/javascripts"; $bjsPath = $bjsRootPath . "/bootstrap-sprockets.js"; $bjs = file_get_contents($bjsPath); $inputs = array(); $matches = array(); if (preg_match_all("/\/\/= require (.*)/i", $bjs, $matches)) { foreach ($matches[1] as $asset) { $inputs[] = $bjsRootPath . "/" . $asset . ".js"; } } else { $inputs[] = $bjsPath; } return $inputs; }
php
protected function getBootstrapSassJavascripts() { $process = new Process("gem which bootstrap-sass"); $process->run(); if (!$process->isSuccessful()) { throw new WatcherCompileException( "`bootstrap-sass` gem was not found\n\n" . $process->getOutput() ); } $gemPath = trim($process->getOutput()); $bjsRootPath = dirname(dirname($gemPath)) . "/assets/javascripts"; $bjsPath = $bjsRootPath . "/bootstrap-sprockets.js"; $bjs = file_get_contents($bjsPath); $inputs = array(); $matches = array(); if (preg_match_all("/\/\/= require (.*)/i", $bjs, $matches)) { foreach ($matches[1] as $asset) { $inputs[] = $bjsRootPath . "/" . $asset . ".js"; } } else { $inputs[] = $bjsPath; } return $inputs; }
[ "protected", "function", "getBootstrapSassJavascripts", "(", ")", "{", "$", "process", "=", "new", "Process", "(", "\"gem which bootstrap-sass\"", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "WatcherCompileException", "(", "\"`bootstrap-sass` gem was not found\\n\\n\"", ".", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}", "$", "gemPath", "=", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "$", "bjsRootPath", "=", "dirname", "(", "dirname", "(", "$", "gemPath", ")", ")", ".", "\"/assets/javascripts\"", ";", "$", "bjsPath", "=", "$", "bjsRootPath", ".", "\"/bootstrap-sprockets.js\"", ";", "$", "bjs", "=", "file_get_contents", "(", "$", "bjsPath", ")", ";", "$", "inputs", "=", "array", "(", ")", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match_all", "(", "\"/\\/\\/= require (.*)/i\"", ",", "$", "bjs", ",", "$", "matches", ")", ")", "{", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "asset", ")", "{", "$", "inputs", "[", "]", "=", "$", "bjsRootPath", ".", "\"/\"", ".", "$", "asset", ".", "\".js\"", ";", "}", "}", "else", "{", "$", "inputs", "[", "]", "=", "$", "bjsPath", ";", "}", "return", "$", "inputs", ";", "}" ]
Get a list of js files @throws WatcherCompileException @return array
[ "Get", "a", "list", "of", "js", "files" ]
76260df0522659db2d8ed05ce7fc1438aa83cf13
https://github.com/apnet/bootstrap/blob/76260df0522659db2d8ed05ce7fc1438aa83cf13/app/src/Apnet/Dev/Factory/Importer/BootstrapImporter.php#L51-L76
4,766
flextype-components/event
Event.php
Event.addListener
public static function addListener(string $event, $function, int $priority = 10, array $args = null) : void { Event::$listeners[$event][$priority][] = [ 'function' => $function, 'args' => $args ]; }
php
public static function addListener(string $event, $function, int $priority = 10, array $args = null) : void { Event::$listeners[$event][$priority][] = [ 'function' => $function, 'args' => $args ]; }
[ "public", "static", "function", "addListener", "(", "string", "$", "event", ",", "$", "function", ",", "int", "$", "priority", "=", "10", ",", "array", "$", "args", "=", "null", ")", ":", "void", "{", "Event", "::", "$", "listeners", "[", "$", "event", "]", "[", "$", "priority", "]", "[", "]", "=", "[", "'function'", "=>", "$", "function", ",", "'args'", "=>", "$", "args", "]", ";", "}" ]
Add new listener Event::addListener('event_name', function() { echo 'Test Event 1'; }, 1); Event::addListener('event_name', function() { echo 'Test Event 2'; }, 2); @access public @param string $event Event name @param mixed $function Function to add @param integer $priority Priority. Default is 10 @param array $args Function aguments @return void
[ "Add", "new", "listener" ]
0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93
https://github.com/flextype-components/event/blob/0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93/Event.php#L38-L44
4,767
flextype-components/event
Event.php
Event.removeAllListeners
public static function removeAllListeners(string $event) : void { if (Event::hasListeners($event)) { unset(Event::$listeners[$event]); } }
php
public static function removeAllListeners(string $event) : void { if (Event::hasListeners($event)) { unset(Event::$listeners[$event]); } }
[ "public", "static", "function", "removeAllListeners", "(", "string", "$", "event", ")", ":", "void", "{", "if", "(", "Event", "::", "hasListeners", "(", "$", "event", ")", ")", "{", "unset", "(", "Event", "::", "$", "listeners", "[", "$", "event", "]", ")", ";", "}", "}" ]
Remove all listeners for current event. Event::removeAllListeners('event_name'); @access public @param string $event Event name @return void
[ "Remove", "all", "listeners", "for", "current", "event", "." ]
0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93
https://github.com/flextype-components/event/blob/0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93/Event.php#L68-L73
4,768
flextype-components/event
Event.php
Event.hasListeners
public static function hasListeners(string $event) : bool { if (! isset(Event::$listeners[$event]) || count(Event::$listeners[$event]) === 0) { return false; } return true; }
php
public static function hasListeners(string $event) : bool { if (! isset(Event::$listeners[$event]) || count(Event::$listeners[$event]) === 0) { return false; } return true; }
[ "public", "static", "function", "hasListeners", "(", "string", "$", "event", ")", ":", "bool", "{", "if", "(", "!", "isset", "(", "Event", "::", "$", "listeners", "[", "$", "event", "]", ")", "||", "count", "(", "Event", "::", "$", "listeners", "[", "$", "event", "]", ")", "===", "0", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check is listeners exists for current event. if (Event::hasListeners('event_name')) { // do something... } @access public @param string $event Event name @return bool $return Return data or not. Default is false
[ "Check", "is", "listeners", "exists", "for", "current", "event", "." ]
0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93
https://github.com/flextype-components/event/blob/0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93/Event.php#L86-L93
4,769
flextype-components/event
Event.php
Event.dispatch
public static function dispatch(string $event, array $args = [], bool $return = false) { // is there some registered $listeners ? if (isset(Event::$listeners[$event]) && count(Event::$listeners[$event]) > 0) { // Get all listeners for given event. $listeners = Event::$listeners[$event]; // Sort by priority krsort($listeners); // Loop through $listeners array foreach ($listeners as $listener) { // Loop through $_listener array foreach ($listener as $_listener) { // Return or Render specific $_listener results ? if ($return) { return call_user_func_array($_listener['function'], (isset($args) ? $args : $_listener['args'])); } else { call_user_func_array($_listener['function'], (isset($args) ? $args : $_listener['args'])); } } } } }
php
public static function dispatch(string $event, array $args = [], bool $return = false) { // is there some registered $listeners ? if (isset(Event::$listeners[$event]) && count(Event::$listeners[$event]) > 0) { // Get all listeners for given event. $listeners = Event::$listeners[$event]; // Sort by priority krsort($listeners); // Loop through $listeners array foreach ($listeners as $listener) { // Loop through $_listener array foreach ($listener as $_listener) { // Return or Render specific $_listener results ? if ($return) { return call_user_func_array($_listener['function'], (isset($args) ? $args : $_listener['args'])); } else { call_user_func_array($_listener['function'], (isset($args) ? $args : $_listener['args'])); } } } } }
[ "public", "static", "function", "dispatch", "(", "string", "$", "event", ",", "array", "$", "args", "=", "[", "]", ",", "bool", "$", "return", "=", "false", ")", "{", "// is there some registered $listeners ?", "if", "(", "isset", "(", "Event", "::", "$", "listeners", "[", "$", "event", "]", ")", "&&", "count", "(", "Event", "::", "$", "listeners", "[", "$", "event", "]", ")", ">", "0", ")", "{", "// Get all listeners for given event.", "$", "listeners", "=", "Event", "::", "$", "listeners", "[", "$", "event", "]", ";", "// Sort by priority", "krsort", "(", "$", "listeners", ")", ";", "// Loop through $listeners array", "foreach", "(", "$", "listeners", "as", "$", "listener", ")", "{", "// Loop through $_listener array", "foreach", "(", "$", "listener", "as", "$", "_listener", ")", "{", "// Return or Render specific $_listener results ?", "if", "(", "$", "return", ")", "{", "return", "call_user_func_array", "(", "$", "_listener", "[", "'function'", "]", ",", "(", "isset", "(", "$", "args", ")", "?", "$", "args", ":", "$", "_listener", "[", "'args'", "]", ")", ")", ";", "}", "else", "{", "call_user_func_array", "(", "$", "_listener", "[", "'function'", "]", ",", "(", "isset", "(", "$", "args", ")", "?", "$", "args", ":", "$", "_listener", "[", "'args'", "]", ")", ")", ";", "}", "}", "}", "}", "}" ]
Dispatch all listeners of the given event. Event::dispatch('event_name'); @access public @param string $event Event name @param array $args Arguments @param bool $return Return data or not. Default is false @return mixed
[ "Dispatch", "all", "listeners", "of", "the", "given", "event", "." ]
0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93
https://github.com/flextype-components/event/blob/0600ec80ddbdf7a392f4d3ca32fb9f8d568b4b93/Event.php#L106-L132
4,770
funkeye/console
src/JsonRpc.php
JsonRpc.setErrorHandle
public function setErrorHandle($err, $message, $file, $line) { $oJsonRpc = JsonRpc::getInstance(); $content = explode("\n", file_get_contents($file)); header('Content-Type: application/json'); $id = $oJsonRpc->extractId(); $error = array( "code" => 100, "message" => "Server error", "error" => array( "name" => "PHPErorr", "code" => $err, "message" => $message, "file" => $file, "at" => $line, "line" => $content[$line-1])); ob_end_clean(); echo $oJsonRpc->response(null, $id, $error); exit(); }
php
public function setErrorHandle($err, $message, $file, $line) { $oJsonRpc = JsonRpc::getInstance(); $content = explode("\n", file_get_contents($file)); header('Content-Type: application/json'); $id = $oJsonRpc->extractId(); $error = array( "code" => 100, "message" => "Server error", "error" => array( "name" => "PHPErorr", "code" => $err, "message" => $message, "file" => $file, "at" => $line, "line" => $content[$line-1])); ob_end_clean(); echo $oJsonRpc->response(null, $id, $error); exit(); }
[ "public", "function", "setErrorHandle", "(", "$", "err", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "$", "oJsonRpc", "=", "JsonRpc", "::", "getInstance", "(", ")", ";", "$", "content", "=", "explode", "(", "\"\\n\"", ",", "file_get_contents", "(", "$", "file", ")", ")", ";", "header", "(", "'Content-Type: application/json'", ")", ";", "$", "id", "=", "$", "oJsonRpc", "->", "extractId", "(", ")", ";", "$", "error", "=", "array", "(", "\"code\"", "=>", "100", ",", "\"message\"", "=>", "\"Server error\"", ",", "\"error\"", "=>", "array", "(", "\"name\"", "=>", "\"PHPErorr\"", ",", "\"code\"", "=>", "$", "err", ",", "\"message\"", "=>", "$", "message", ",", "\"file\"", "=>", "$", "file", ",", "\"at\"", "=>", "$", "line", ",", "\"line\"", "=>", "$", "content", "[", "$", "line", "-", "1", "]", ")", ")", ";", "ob_end_clean", "(", ")", ";", "echo", "$", "oJsonRpc", "->", "response", "(", "null", ",", "$", "id", ",", "$", "error", ")", ";", "exit", "(", ")", ";", "}" ]
set error handler @param int $err @param string $message @param string $file @param string $line
[ "set", "error", "handler" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L56-L74
4,771
funkeye/console
src/JsonRpc.php
JsonRpc.response
public function response($result, $id, $error) { if ($error) { $error['name'] = 'JSONRPCError'; } return json_encode(array("jsonrpc" => "2.0", 'result' => $result, 'id' => $id, 'error'=> $error)); }
php
public function response($result, $id, $error) { if ($error) { $error['name'] = 'JSONRPCError'; } return json_encode(array("jsonrpc" => "2.0", 'result' => $result, 'id' => $id, 'error'=> $error)); }
[ "public", "function", "response", "(", "$", "result", ",", "$", "id", ",", "$", "error", ")", "{", "if", "(", "$", "error", ")", "{", "$", "error", "[", "'name'", "]", "=", "'JSONRPCError'", ";", "}", "return", "json_encode", "(", "array", "(", "\"jsonrpc\"", "=>", "\"2.0\"", ",", "'result'", "=>", "$", "result", ",", "'id'", "=>", "$", "id", ",", "'error'", "=>", "$", "error", ")", ")", ";", "}" ]
make the response @param string $result @param int $id @param string $error @return json string
[ "make", "the", "response" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L138-L146
4,772
funkeye/console
src/JsonRpc.php
JsonRpc.extractId
public function extractId() { $regex = '/[\'"]id[\'"] *: *([0-9]*)/'; $rawData = $this->getRawPostData(); if (preg_match($regex, $rawData, $m)) { return intval($m[1]); } else { return null; } }
php
public function extractId() { $regex = '/[\'"]id[\'"] *: *([0-9]*)/'; $rawData = $this->getRawPostData(); if (preg_match($regex, $rawData, $m)) { return intval($m[1]); } else { return null; } }
[ "public", "function", "extractId", "(", ")", "{", "$", "regex", "=", "'/[\\'\"]id[\\'\"] *: *([0-9]*)/'", ";", "$", "rawData", "=", "$", "this", "->", "getRawPostData", "(", ")", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "rawData", ",", "$", "m", ")", ")", "{", "return", "intval", "(", "$", "m", "[", "1", "]", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
try to extract id from broken json @return int
[ "try", "to", "extract", "id", "from", "broken", "json" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L152-L160
4,773
funkeye/console
src/JsonRpc.php
JsonRpc.currentURL
private function currentURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; }
php
private function currentURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; }
[ "private", "function", "currentURL", "(", ")", "{", "$", "pageURL", "=", "'http'", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "\"HTTPS\"", "]", ")", "&&", "$", "_SERVER", "[", "\"HTTPS\"", "]", "==", "\"on\"", ")", "{", "$", "pageURL", ".=", "\"s\"", ";", "}", "$", "pageURL", ".=", "\"://\"", ";", "if", "(", "$", "_SERVER", "[", "\"SERVER_PORT\"", "]", "!=", "\"80\"", ")", "{", "$", "pageURL", ".=", "$", "_SERVER", "[", "\"SERVER_NAME\"", "]", ".", "\":\"", ".", "$", "_SERVER", "[", "\"SERVER_PORT\"", "]", ".", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ";", "}", "else", "{", "$", "pageURL", ".=", "$", "_SERVER", "[", "\"SERVER_NAME\"", "]", ".", "$", "_SERVER", "[", "\"REQUEST_URI\"", "]", ";", "}", "return", "$", "pageURL", ";", "}" ]
get the current URL @return string
[ "get", "the", "current", "URL" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L166-L178
4,774
funkeye/console
src/JsonRpc.php
JsonRpc.serviceDescription
private function serviceDescription($object) { $class_name = get_class($object); $methods = get_class_methods($class_name); $service = ["sdversion" => "1.0", "name" => "DemoService", "address" => $this->currentURL(), "id" => "urn:md5:" . md5($this->currentURL())]; $static = get_class_vars($class_name); foreach ($methods as $method_name) { $proc = array("name" => $method_name); $method = new \ReflectionMethod($class_name, $method_name); $params = array(); foreach ($method->getParameters() as $param) { $params[] = $param->name; } $proc['params'] = $params; $help_str_name = $method_name . "_documentation"; if (array_key_exists($help_str_name, $static)) { $proc['help'] = $static[$help_str_name]; } $service['procs'][] = $proc; } return $service; }
php
private function serviceDescription($object) { $class_name = get_class($object); $methods = get_class_methods($class_name); $service = ["sdversion" => "1.0", "name" => "DemoService", "address" => $this->currentURL(), "id" => "urn:md5:" . md5($this->currentURL())]; $static = get_class_vars($class_name); foreach ($methods as $method_name) { $proc = array("name" => $method_name); $method = new \ReflectionMethod($class_name, $method_name); $params = array(); foreach ($method->getParameters() as $param) { $params[] = $param->name; } $proc['params'] = $params; $help_str_name = $method_name . "_documentation"; if (array_key_exists($help_str_name, $static)) { $proc['help'] = $static[$help_str_name]; } $service['procs'][] = $proc; } return $service; }
[ "private", "function", "serviceDescription", "(", "$", "object", ")", "{", "$", "class_name", "=", "get_class", "(", "$", "object", ")", ";", "$", "methods", "=", "get_class_methods", "(", "$", "class_name", ")", ";", "$", "service", "=", "[", "\"sdversion\"", "=>", "\"1.0\"", ",", "\"name\"", "=>", "\"DemoService\"", ",", "\"address\"", "=>", "$", "this", "->", "currentURL", "(", ")", ",", "\"id\"", "=>", "\"urn:md5:\"", ".", "md5", "(", "$", "this", "->", "currentURL", "(", ")", ")", "]", ";", "$", "static", "=", "get_class_vars", "(", "$", "class_name", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method_name", ")", "{", "$", "proc", "=", "array", "(", "\"name\"", "=>", "$", "method_name", ")", ";", "$", "method", "=", "new", "\\", "ReflectionMethod", "(", "$", "class_name", ",", "$", "method_name", ")", ";", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "method", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "params", "[", "]", "=", "$", "param", "->", "name", ";", "}", "$", "proc", "[", "'params'", "]", "=", "$", "params", ";", "$", "help_str_name", "=", "$", "method_name", ".", "\"_documentation\"", ";", "if", "(", "array_key_exists", "(", "$", "help_str_name", ",", "$", "static", ")", ")", "{", "$", "proc", "[", "'help'", "]", "=", "$", "static", "[", "$", "help_str_name", "]", ";", "}", "$", "service", "[", "'procs'", "]", "[", "]", "=", "$", "proc", ";", "}", "return", "$", "service", ";", "}" ]
get service description of the class @param object $object @return array
[ "get", "service", "description", "of", "the", "class" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L185-L208
4,775
funkeye/console
src/JsonRpc.php
JsonRpc.getJsonRequest
private function getJsonRequest() { $request = $this->getRawPostData(); if ($request == "") { throw new JsonRpcExeption(101, "Parse Error: no data"); } $encoding = mb_detect_encoding($request, 'auto'); if ($encoding != 'UTF-8') { $request = iconv($encoding, 'UTF-8', $request); } $request = json_decode($request); if ($request == NULL) { // parse error $error = $this->getJsonError(); throw new JsonRpcExeption(101, "Parse Error: $error"); } return $request; }
php
private function getJsonRequest() { $request = $this->getRawPostData(); if ($request == "") { throw new JsonRpcExeption(101, "Parse Error: no data"); } $encoding = mb_detect_encoding($request, 'auto'); if ($encoding != 'UTF-8') { $request = iconv($encoding, 'UTF-8', $request); } $request = json_decode($request); if ($request == NULL) { // parse error $error = $this->getJsonError(); throw new JsonRpcExeption(101, "Parse Error: $error"); } return $request; }
[ "private", "function", "getJsonRequest", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRawPostData", "(", ")", ";", "if", "(", "$", "request", "==", "\"\"", ")", "{", "throw", "new", "JsonRpcExeption", "(", "101", ",", "\"Parse Error: no data\"", ")", ";", "}", "$", "encoding", "=", "mb_detect_encoding", "(", "$", "request", ",", "'auto'", ")", ";", "if", "(", "$", "encoding", "!=", "'UTF-8'", ")", "{", "$", "request", "=", "iconv", "(", "$", "encoding", ",", "'UTF-8'", ",", "$", "request", ")", ";", "}", "$", "request", "=", "json_decode", "(", "$", "request", ")", ";", "if", "(", "$", "request", "==", "NULL", ")", "{", "// parse error", "$", "error", "=", "$", "this", "->", "getJsonError", "(", ")", ";", "throw", "new", "JsonRpcExeption", "(", "101", ",", "\"Parse Error: $error\"", ")", ";", "}", "return", "$", "request", ";", "}" ]
get the json request @return array @throws JsonRpcExeption
[ "get", "the", "json", "request" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/JsonRpc.php#L215-L230
4,776
synapsestudios/synapse-base
src/Synapse/User/UserServiceProvider.php
UserServiceProvider.setFirewallsAndAccessRules
protected function setFirewallsAndAccessRules(Application $app) { $app->extend('security.firewalls', function ($firewalls, $app) { $createUser = new RequestMatcher('^/users$', null, ['POST']); $verifyRegistration = new RequestMatcher('^/users/[0-9]+/verify-registration$', null, ['POST']); $userFirewalls = [ 'create-users' => [ 'pattern' => $createUser, // User registration endpoint is public 'anonymous' => true, ], 'verify-registration' => [ 'pattern' => $verifyRegistration, // User registration endpoint is public 'anonymous' => true, ], 'reset-password' => [ 'pattern' => '^/user/reset-password$', 'anonymous' => true, ], ]; return array_merge($userFirewalls, $firewalls); }); $app->extend('security.access_rules', function ($rules, $app) { $usersAdminFunctionRequestMatcher = new RequestMatcher('^/users/\d+$', null, ['GET']); $newRules = [ [$usersAdminFunctionRequestMatcher, 'ROLE_ADMIN'] ]; return array_merge($newRules, $rules); }); }
php
protected function setFirewallsAndAccessRules(Application $app) { $app->extend('security.firewalls', function ($firewalls, $app) { $createUser = new RequestMatcher('^/users$', null, ['POST']); $verifyRegistration = new RequestMatcher('^/users/[0-9]+/verify-registration$', null, ['POST']); $userFirewalls = [ 'create-users' => [ 'pattern' => $createUser, // User registration endpoint is public 'anonymous' => true, ], 'verify-registration' => [ 'pattern' => $verifyRegistration, // User registration endpoint is public 'anonymous' => true, ], 'reset-password' => [ 'pattern' => '^/user/reset-password$', 'anonymous' => true, ], ]; return array_merge($userFirewalls, $firewalls); }); $app->extend('security.access_rules', function ($rules, $app) { $usersAdminFunctionRequestMatcher = new RequestMatcher('^/users/\d+$', null, ['GET']); $newRules = [ [$usersAdminFunctionRequestMatcher, 'ROLE_ADMIN'] ]; return array_merge($newRules, $rules); }); }
[ "protected", "function", "setFirewallsAndAccessRules", "(", "Application", "$", "app", ")", "{", "$", "app", "->", "extend", "(", "'security.firewalls'", ",", "function", "(", "$", "firewalls", ",", "$", "app", ")", "{", "$", "createUser", "=", "new", "RequestMatcher", "(", "'^/users$'", ",", "null", ",", "[", "'POST'", "]", ")", ";", "$", "verifyRegistration", "=", "new", "RequestMatcher", "(", "'^/users/[0-9]+/verify-registration$'", ",", "null", ",", "[", "'POST'", "]", ")", ";", "$", "userFirewalls", "=", "[", "'create-users'", "=>", "[", "'pattern'", "=>", "$", "createUser", ",", "// User registration endpoint is public", "'anonymous'", "=>", "true", ",", "]", ",", "'verify-registration'", "=>", "[", "'pattern'", "=>", "$", "verifyRegistration", ",", "// User registration endpoint is public", "'anonymous'", "=>", "true", ",", "]", ",", "'reset-password'", "=>", "[", "'pattern'", "=>", "'^/user/reset-password$'", ",", "'anonymous'", "=>", "true", ",", "]", ",", "]", ";", "return", "array_merge", "(", "$", "userFirewalls", ",", "$", "firewalls", ")", ";", "}", ")", ";", "$", "app", "->", "extend", "(", "'security.access_rules'", ",", "function", "(", "$", "rules", ",", "$", "app", ")", "{", "$", "usersAdminFunctionRequestMatcher", "=", "new", "RequestMatcher", "(", "'^/users/\\d+$'", ",", "null", ",", "[", "'GET'", "]", ")", ";", "$", "newRules", "=", "[", "[", "$", "usersAdminFunctionRequestMatcher", ",", "'ROLE_ADMIN'", "]", "]", ";", "return", "array_merge", "(", "$", "newRules", ",", "$", "rules", ")", ";", "}", ")", ";", "}" ]
Set user related firewalls @param Application $app
[ "Set", "user", "related", "firewalls" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/UserServiceProvider.php#L136-L167
4,777
phossa2/libs
src/Phossa2/Cache/CachePool.php
CachePool.driverAction
protected function driverAction(/*# string */ $action, $item)/*# : bool */ { if (is_null($item)) { return $this->getDriver()->{$action}(); } else { return $this->getDriver()->{$action}($item); } }
php
protected function driverAction(/*# string */ $action, $item)/*# : bool */ { if (is_null($item)) { return $this->getDriver()->{$action}(); } else { return $this->getDriver()->{$action}($item); } }
[ "protected", "function", "driverAction", "(", "/*# string */", "$", "action", ",", "$", "item", ")", "/*# : bool */", "{", "if", "(", "is_null", "(", "$", "item", ")", ")", "{", "return", "$", "this", "->", "getDriver", "(", ")", "->", "{", "$", "action", "}", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getDriver", "(", ")", "->", "{", "$", "action", "}", "(", "$", "item", ")", ";", "}", "}" ]
Execute an action with the driver @param string $action @param CacheItemInterface|null $item @access protected
[ "Execute", "an", "action", "with", "the", "driver" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/CachePool.php#L245-L252
4,778
xpl-php/Common
src/Storage/Collection.php
Collection.merge
public function merge($data) { if (! is_array($data)) { $data = $this->makeArray($data); } $this->_data = array_merge($this->_data, $data); }
php
public function merge($data) { if (! is_array($data)) { $data = $this->makeArray($data); } $this->_data = array_merge($this->_data, $data); }
[ "public", "function", "merge", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "makeArray", "(", "$", "data", ")", ";", "}", "$", "this", "->", "_data", "=", "array_merge", "(", "$", "this", "->", "_data", ",", "$", "data", ")", ";", "}" ]
Merges the given items into the collection. @param array|Arrayable $data @return void
[ "Merges", "the", "given", "items", "into", "the", "collection", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Collection.php#L26-L33
4,779
xpl-php/Common
src/Storage/Collection.php
Collection.replace
public function replace($data) { if (! is_array($data)) { $data = $this->makeArray($data); } $this->_data = array_replace($this->_data, $data); }
php
public function replace($data) { if (! is_array($data)) { $data = $this->makeArray($data); } $this->_data = array_replace($this->_data, $data); }
[ "public", "function", "replace", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "makeArray", "(", "$", "data", ")", ";", "}", "$", "this", "->", "_data", "=", "array_replace", "(", "$", "this", "->", "_data", ",", "$", "data", ")", ";", "}" ]
Replaces items in the collection with those given. @param array|Arrayable $data @return void
[ "Replaces", "items", "in", "the", "collection", "with", "those", "given", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Collection.php#L41-L48
4,780
xpl-php/Common
src/Storage/Collection.php
Collection.intersect
public function intersect($data) { if (! is_array($data)) { $data = $this->makeArray($data); } return new static(array_intersect_assoc($this->_data, $data)); }
php
public function intersect($data) { if (! is_array($data)) { $data = $this->makeArray($data); } return new static(array_intersect_assoc($this->_data, $data)); }
[ "public", "function", "intersect", "(", "$", "data", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "makeArray", "(", "$", "data", ")", ";", "}", "return", "new", "static", "(", "array_intersect_assoc", "(", "$", "this", "->", "_data", ",", "$", "data", ")", ")", ";", "}" ]
Computes the intersection with the given array and returns a new collection. @param array|\xpl\Common\Arrayable $data @return \xpl\Common\Storage\Collection
[ "Computes", "the", "intersection", "with", "the", "given", "array", "and", "returns", "a", "new", "collection", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Collection.php#L86-L93
4,781
xpl-php/Common
src/Storage/Collection.php
Collection.keyFilter
public function keyFilter($func) { $filtered = array_filter($this->keys(), $func); return new static(array_intersect_key($this->_data, array_flip($filtered))); }
php
public function keyFilter($func) { $filtered = array_filter($this->keys(), $func); return new static(array_intersect_key($this->_data, array_flip($filtered))); }
[ "public", "function", "keyFilter", "(", "$", "func", ")", "{", "$", "filtered", "=", "array_filter", "(", "$", "this", "->", "keys", "(", ")", ",", "$", "func", ")", ";", "return", "new", "static", "(", "array_intersect_key", "(", "$", "this", "->", "_data", ",", "array_flip", "(", "$", "filtered", ")", ")", ")", ";", "}" ]
Filters the items by key and returns a new collection. @param callable $func @return \xpl\Common\Storage\Collection
[ "Filters", "the", "items", "by", "key", "and", "returns", "a", "new", "collection", "." ]
0669bdcca29f1f8835297c2397c62fee3be5dce3
https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Collection.php#L131-L136
4,782
unimatrix/cake
src/Shell/Helper/CronHelper.php
CronHelper.addJob
public function addJob($job = []) { if(!isset($job['msg'])) throw new RuntimeException('Job without a message'); if(!isset($job['schedule'])) throw new RuntimeException('Job without a CRON expression'); if(!isset($job['function'])) throw new RuntimeException('Job without a function'); if($this->isDue($job['schedule'])) $this->jobs[] = $job; }
php
public function addJob($job = []) { if(!isset($job['msg'])) throw new RuntimeException('Job without a message'); if(!isset($job['schedule'])) throw new RuntimeException('Job without a CRON expression'); if(!isset($job['function'])) throw new RuntimeException('Job without a function'); if($this->isDue($job['schedule'])) $this->jobs[] = $job; }
[ "public", "function", "addJob", "(", "$", "job", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "job", "[", "'msg'", "]", ")", ")", "throw", "new", "RuntimeException", "(", "'Job without a message'", ")", ";", "if", "(", "!", "isset", "(", "$", "job", "[", "'schedule'", "]", ")", ")", "throw", "new", "RuntimeException", "(", "'Job without a CRON expression'", ")", ";", "if", "(", "!", "isset", "(", "$", "job", "[", "'function'", "]", ")", ")", "throw", "new", "RuntimeException", "(", "'Job without a function'", ")", ";", "if", "(", "$", "this", "->", "isDue", "(", "$", "job", "[", "'schedule'", "]", ")", ")", "$", "this", "->", "jobs", "[", "]", "=", "$", "job", ";", "}" ]
Load the cron jobs that should be runned and register them into the jobs array.
[ "Load", "the", "cron", "jobs", "that", "should", "be", "runned", "and", "register", "them", "into", "the", "jobs", "array", "." ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Shell/Helper/CronHelper.php#L48-L60
4,783
unimatrix/cake
src/Shell/Helper/CronHelper.php
CronHelper.getJob
public function getJob($msg) { $found = false; foreach($this->jobs as $job) { if($job['msg'] === $msg) { $found = $job; break; } } return $found; }
php
public function getJob($msg) { $found = false; foreach($this->jobs as $job) { if($job['msg'] === $msg) { $found = $job; break; } } return $found; }
[ "public", "function", "getJob", "(", "$", "msg", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "$", "this", "->", "jobs", "as", "$", "job", ")", "{", "if", "(", "$", "job", "[", "'msg'", "]", "===", "$", "msg", ")", "{", "$", "found", "=", "$", "job", ";", "break", ";", "}", "}", "return", "$", "found", ";", "}" ]
Get a particular job by msg @param string $msg Job message @return boolean|array
[ "Get", "a", "particular", "job", "by", "msg" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Shell/Helper/CronHelper.php#L106-L116
4,784
unimatrix/cake
src/Shell/Helper/CronHelper.php
CronHelper.output
public function output($args = null) { $i = 0; foreach ($this->jobs as $job) if($job['function']($job['msg']) === TRUE) $i++; $this->jobs = []; return $i; }
php
public function output($args = null) { $i = 0; foreach ($this->jobs as $job) if($job['function']($job['msg']) === TRUE) $i++; $this->jobs = []; return $i; }
[ "public", "function", "output", "(", "$", "args", "=", "null", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "this", "->", "jobs", "as", "$", "job", ")", "if", "(", "$", "job", "[", "'function'", "]", "(", "$", "job", "[", "'msg'", "]", ")", "===", "TRUE", ")", "$", "i", "++", ";", "$", "this", "->", "jobs", "=", "[", "]", ";", "return", "$", "i", ";", "}" ]
Load the cron jobs to run and execute them. @return int Number of runned tasks
[ "Load", "the", "cron", "jobs", "to", "run", "and", "execute", "them", "." ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Shell/Helper/CronHelper.php#L122-L130
4,785
litert/core
lib/TEventListener.php
TEventListener.removeListener
public function removeListener( string $event, callable $listener ) { if ($this->_events[$event] ?? false) { $key = array_search( $listener, $this->_events[$event], true ); if ($key !== false) { array_splice( $this->_events[$event], $key, 1 ); } } return $this; }
php
public function removeListener( string $event, callable $listener ) { if ($this->_events[$event] ?? false) { $key = array_search( $listener, $this->_events[$event], true ); if ($key !== false) { array_splice( $this->_events[$event], $key, 1 ); } } return $this; }
[ "public", "function", "removeListener", "(", "string", "$", "event", ",", "callable", "$", "listener", ")", "{", "if", "(", "$", "this", "->", "_events", "[", "$", "event", "]", "??", "false", ")", "{", "$", "key", "=", "array_search", "(", "$", "listener", ",", "$", "this", "->", "_events", "[", "$", "event", "]", ",", "true", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "array_splice", "(", "$", "this", "->", "_events", "[", "$", "event", "]", ",", "$", "key", ",", "1", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove specific listener of an event. @param string $event @param callable $listener @return static
[ "Remove", "specific", "listener", "of", "an", "event", "." ]
a494f03ef919d67d48c990d03eeac8dfae7c996a
https://github.com/litert/core/blob/a494f03ef919d67d48c990d03eeac8dfae7c996a/lib/TEventListener.php#L71-L95
4,786
roydejong/Enlighten
lib/Http/Response.php
Response.setResponseCode
public function setResponseCode($code) { if (!ResponseCode::isValid($code)) { throw new \InvalidArgumentException('setResponseCode(): Invalid HTTP response code given of value ' . strval($code)); } $this->statusCode = $code; return $this; }
php
public function setResponseCode($code) { if (!ResponseCode::isValid($code)) { throw new \InvalidArgumentException('setResponseCode(): Invalid HTTP response code given of value ' . strval($code)); } $this->statusCode = $code; return $this; }
[ "public", "function", "setResponseCode", "(", "$", "code", ")", "{", "if", "(", "!", "ResponseCode", "::", "isValid", "(", "$", "code", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'setResponseCode(): Invalid HTTP response code given of value '", ".", "strval", "(", "$", "code", ")", ")", ";", "}", "$", "this", "->", "statusCode", "=", "$", "code", ";", "return", "$", "this", ";", "}" ]
Sets the HTTP response code. @param int $code @return $this
[ "Sets", "the", "HTTP", "response", "code", "." ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L65-L73
4,787
roydejong/Enlighten
lib/Http/Response.php
Response.doRedirect
public function doRedirect($url, $permanent = false) { $this->setResponseCode($permanent ? ResponseCode::HTTP_MOVED_PERMANENTLY : ResponseCode::HTTP_FOUND); $this->setHeader('Location', $url); return $this; }
php
public function doRedirect($url, $permanent = false) { $this->setResponseCode($permanent ? ResponseCode::HTTP_MOVED_PERMANENTLY : ResponseCode::HTTP_FOUND); $this->setHeader('Location', $url); return $this; }
[ "public", "function", "doRedirect", "(", "$", "url", ",", "$", "permanent", "=", "false", ")", "{", "$", "this", "->", "setResponseCode", "(", "$", "permanent", "?", "ResponseCode", "::", "HTTP_MOVED_PERMANENTLY", ":", "ResponseCode", "::", "HTTP_FOUND", ")", ";", "$", "this", "->", "setHeader", "(", "'Location'", ",", "$", "url", ")", ";", "return", "$", "this", ";", "}" ]
Redirect the user to a specific URL. Performs a HTTP 301 or HTTP 302 redirect. @param string $url @param bool $permanent If true, a 301 Moved Permanently will be issued; otherwise a 307 Temporary Redirect. @return $this
[ "Redirect", "the", "user", "to", "a", "specific", "URL", ".", "Performs", "a", "HTTP", "301", "or", "HTTP", "302", "redirect", "." ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L93-L98
4,788
roydejong/Enlighten
lib/Http/Response.php
Response.setHeader
public function setHeader($key, $value) { $this->headers[strval($key)] = strval($value); return $this; }
php
public function setHeader($key, $value) { $this->headers[strval($key)] = strval($value); return $this; }
[ "public", "function", "setHeader", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "headers", "[", "strval", "(", "$", "key", ")", "]", "=", "strval", "(", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Sets a HTTP header to a certain value. @param string $key @param string $value @return $this
[ "Sets", "a", "HTTP", "header", "to", "a", "certain", "value", "." ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L107-L111
4,789
roydejong/Enlighten
lib/Http/Response.php
Response.setCookie
public function setCookie($name, $value, $expire = 0, $path = null, $domain = null, $secure = false, $httpOnly = false) { return $this->addCookie((new Cookie()) ->setName($name) ->setValue($value) ->setExpireTimestamp($expire) ->setPath($path) ->setDomain($domain) ->setSecure($secure) ->setHttpOnly($httpOnly)); }
php
public function setCookie($name, $value, $expire = 0, $path = null, $domain = null, $secure = false, $httpOnly = false) { return $this->addCookie((new Cookie()) ->setName($name) ->setValue($value) ->setExpireTimestamp($expire) ->setPath($path) ->setDomain($domain) ->setSecure($secure) ->setHttpOnly($httpOnly)); }
[ "public", "function", "setCookie", "(", "$", "name", ",", "$", "value", ",", "$", "expire", "=", "0", ",", "$", "path", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "false", ")", "{", "return", "$", "this", "->", "addCookie", "(", "(", "new", "Cookie", "(", ")", ")", "->", "setName", "(", "$", "name", ")", "->", "setValue", "(", "$", "value", ")", "->", "setExpireTimestamp", "(", "$", "expire", ")", "->", "setPath", "(", "$", "path", ")", "->", "setDomain", "(", "$", "domain", ")", "->", "setSecure", "(", "$", "secure", ")", "->", "setHttpOnly", "(", "$", "httpOnly", ")", ")", ";", "}" ]
Creates or updates a cookie. @param string $name Cookie name. @param string $value Cookie value. @param int $expire Unix expiration timestamp, or 0 for session expire. @param string|null $path The path the cookie can be used on. @param string|null $domain The domain the cookie can be used on. @param bool $secure True for HTTPS only. @param bool $httpOnly True for HTTP(S) only (not accessible to JavaScript, etc). @return $this
[ "Creates", "or", "updates", "a", "cookie", "." ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L174-L184
4,790
roydejong/Enlighten
lib/Http/Response.php
Response.sendCookies
protected function sendCookies() { foreach ($this->cookies as $cookie) { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpireTimestamp(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } }
php
protected function sendCookies() { foreach ($this->cookies as $cookie) { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpireTimestamp(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } }
[ "protected", "function", "sendCookies", "(", ")", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "cookie", ")", "{", "setcookie", "(", "$", "cookie", "->", "getName", "(", ")", ",", "$", "cookie", "->", "getValue", "(", ")", ",", "$", "cookie", "->", "getExpireTimestamp", "(", ")", ",", "$", "cookie", "->", "getPath", "(", ")", ",", "$", "cookie", "->", "getDomain", "(", ")", ",", "$", "cookie", "->", "isSecure", "(", ")", ",", "$", "cookie", "->", "isHttpOnly", "(", ")", ")", ";", "}", "}" ]
Sends the HTTP cookies to the client. Causes output!
[ "Sends", "the", "HTTP", "cookies", "to", "the", "client", ".", "Causes", "output!" ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L214-L220
4,791
roydejong/Enlighten
lib/Http/Response.php
Response.sendHeaders
protected function sendHeaders() { header(sprintf('%s %s', self::PROTOCOL_VERSION, ResponseCode::getMessageForCode($this->statusCode))); foreach ($this->headers as $name => $value) { header(sprintf("%s: %s", $name, $value)); } }
php
protected function sendHeaders() { header(sprintf('%s %s', self::PROTOCOL_VERSION, ResponseCode::getMessageForCode($this->statusCode))); foreach ($this->headers as $name => $value) { header(sprintf("%s: %s", $name, $value)); } }
[ "protected", "function", "sendHeaders", "(", ")", "{", "header", "(", "sprintf", "(", "'%s %s'", ",", "self", "::", "PROTOCOL_VERSION", ",", "ResponseCode", "::", "getMessageForCode", "(", "$", "this", "->", "statusCode", ")", ")", ")", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "header", "(", "sprintf", "(", "\"%s: %s\"", ",", "$", "name", ",", "$", "value", ")", ")", ";", "}", "}" ]
Sends the HTTP headers to the client. Causes output!
[ "Sends", "the", "HTTP", "headers", "to", "the", "client", ".", "Causes", "output!" ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L226-L233
4,792
roydejong/Enlighten
lib/Http/Response.php
Response.send
public function send() { $this->sendHeaders(); $this->sendCookies(); if (ResponseCode::canHaveBody($this->statusCode)) { $this->sendBody(); } }
php
public function send() { $this->sendHeaders(); $this->sendCookies(); if (ResponseCode::canHaveBody($this->statusCode)) { $this->sendBody(); } }
[ "public", "function", "send", "(", ")", "{", "$", "this", "->", "sendHeaders", "(", ")", ";", "$", "this", "->", "sendCookies", "(", ")", ";", "if", "(", "ResponseCode", "::", "canHaveBody", "(", "$", "this", "->", "statusCode", ")", ")", "{", "$", "this", "->", "sendBody", "(", ")", ";", "}", "}" ]
Sends the HTTP response to the client. Causes output!
[ "Sends", "the", "HTTP", "response", "to", "the", "client", ".", "Causes", "output!" ]
67585b061a50f20da23de75ce920c8e26517d900
https://github.com/roydejong/Enlighten/blob/67585b061a50f20da23de75ce920c8e26517d900/lib/Http/Response.php#L248-L256
4,793
phlexible/phlexible
src/Phlexible/Bundle/SiterootBundle/Doctrine/SiterootManager.php
SiterootManager.applyIdentifier
private function applyIdentifier(Siteroot $siteroot) { $reflectionClass = new \ReflectionClass(get_class($siteroot)); $reflectionProperty = $reflectionClass->getProperty('id'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($siteroot, UuidUtil::generate()); }
php
private function applyIdentifier(Siteroot $siteroot) { $reflectionClass = new \ReflectionClass(get_class($siteroot)); $reflectionProperty = $reflectionClass->getProperty('id'); $reflectionProperty->setAccessible(true); $reflectionProperty->setValue($siteroot, UuidUtil::generate()); }
[ "private", "function", "applyIdentifier", "(", "Siteroot", "$", "siteroot", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "siteroot", ")", ")", ";", "$", "reflectionProperty", "=", "$", "reflectionClass", "->", "getProperty", "(", "'id'", ")", ";", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "reflectionProperty", "->", "setValue", "(", "$", "siteroot", ",", "UuidUtil", "::", "generate", "(", ")", ")", ";", "}" ]
Apply UUID as identifier when entity doesn't have one yet. @param Siteroot $siteroot
[ "Apply", "UUID", "as", "identifier", "when", "entity", "doesn", "t", "have", "one", "yet", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SiterootBundle/Doctrine/SiterootManager.php#L159-L166
4,794
99designs/ergo
classes/Ergo/Routing/RequestFilterChain.php
RequestFilterChain.filter
public function filter($request) { foreach($this->_filters as $filter) { if(!$request = $filter->filter($request)) { throw new Exception("Filter returned a null request"); } } return $request; }
php
public function filter($request) { foreach($this->_filters as $filter) { if(!$request = $filter->filter($request)) { throw new Exception("Filter returned a null request"); } } return $request; }
[ "public", "function", "filter", "(", "$", "request", ")", "{", "foreach", "(", "$", "this", "->", "_filters", "as", "$", "filter", ")", "{", "if", "(", "!", "$", "request", "=", "$", "filter", "->", "filter", "(", "$", "request", ")", ")", "{", "throw", "new", "Exception", "(", "\"Filter returned a null request\"", ")", ";", "}", "}", "return", "$", "request", ";", "}" ]
Filter a request, fail if a null result is returned
[ "Filter", "a", "request", "fail", "if", "a", "null", "result", "is", "returned" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Routing/RequestFilterChain.php#L12-L23
4,795
neam/codeception-saucelabs-metadata
src/Codeception/Extension/SaucelabsMetadata.php
SaucelabsMetadata.getCorrespondingSaucelabsJob
protected function getCorrespondingSaucelabsJob() { $jobs = $this->sauceApi()->getJobs($from = 0, $to = null, $limit = 1, $skip = null, $username = null); return $jobs['jobs'][0]; }
php
protected function getCorrespondingSaucelabsJob() { $jobs = $this->sauceApi()->getJobs($from = 0, $to = null, $limit = 1, $skip = null, $username = null); return $jobs['jobs'][0]; }
[ "protected", "function", "getCorrespondingSaucelabsJob", "(", ")", "{", "$", "jobs", "=", "$", "this", "->", "sauceApi", "(", ")", "->", "getJobs", "(", "$", "from", "=", "0", ",", "$", "to", "=", "null", ",", "$", "limit", "=", "1", ",", "$", "skip", "=", "null", ",", "$", "username", "=", "null", ")", ";", "return", "$", "jobs", "[", "'jobs'", "]", "[", "0", "]", ";", "}" ]
We currently assume that the firstmost job is the current test for which we should update metadata. This is not always true, but at the moment there seems to be little to be done in this matter. @return array
[ "We", "currently", "assume", "that", "the", "firstmost", "job", "is", "the", "current", "test", "for", "which", "we", "should", "update", "metadata", ".", "This", "is", "not", "always", "true", "but", "at", "the", "moment", "there", "seems", "to", "be", "little", "to", "be", "done", "in", "this", "matter", "." ]
54ac6d39aa8194d733e3e43e2f7ee392b0055d45
https://github.com/neam/codeception-saucelabs-metadata/blob/54ac6d39aa8194d733e3e43e2f7ee392b0055d45/src/Codeception/Extension/SaucelabsMetadata.php#L32-L36
4,796
neam/codeception-saucelabs-metadata
src/Codeception/Extension/SaucelabsMetadata.php
SaucelabsMetadata.gatherMetaData
protected function gatherMetaData($test) { $metadata = array( // Default tags from config 'tags' => isset($this->config['tags']) ? explode(",", $this->config['tags']) : array(), // Default custom data is empty 'custom-data' => array(), ); // Tag with the current test string reference $metadata['tags'][] = "test:" . $test->toString(); // Add codeception runtime options to custom-data $metadata['custom-data']['options'] = $this->options; return $metadata; }
php
protected function gatherMetaData($test) { $metadata = array( // Default tags from config 'tags' => isset($this->config['tags']) ? explode(",", $this->config['tags']) : array(), // Default custom data is empty 'custom-data' => array(), ); // Tag with the current test string reference $metadata['tags'][] = "test:" . $test->toString(); // Add codeception runtime options to custom-data $metadata['custom-data']['options'] = $this->options; return $metadata; }
[ "protected", "function", "gatherMetaData", "(", "$", "test", ")", "{", "$", "metadata", "=", "array", "(", "// Default tags from config", "'tags'", "=>", "isset", "(", "$", "this", "->", "config", "[", "'tags'", "]", ")", "?", "explode", "(", "\",\"", ",", "$", "this", "->", "config", "[", "'tags'", "]", ")", ":", "array", "(", ")", ",", "// Default custom data is empty", "'custom-data'", "=>", "array", "(", ")", ",", ")", ";", "// Tag with the current test string reference", "$", "metadata", "[", "'tags'", "]", "[", "]", "=", "\"test:\"", ".", "$", "test", "->", "toString", "(", ")", ";", "// Add codeception runtime options to custom-data", "$", "metadata", "[", "'custom-data'", "]", "[", "'options'", "]", "=", "$", "this", "->", "options", ";", "return", "$", "metadata", ";", "}" ]
Gather metadata about the current test to send to saucelabs, making it easier to filter tests @return array
[ "Gather", "metadata", "about", "the", "current", "test", "to", "send", "to", "saucelabs", "making", "it", "easier", "to", "filter", "tests" ]
54ac6d39aa8194d733e3e43e2f7ee392b0055d45
https://github.com/neam/codeception-saucelabs-metadata/blob/54ac6d39aa8194d733e3e43e2f7ee392b0055d45/src/Codeception/Extension/SaucelabsMetadata.php#L78-L94
4,797
anklimsk/cakephp-config-plugin
Lib/Utility/InitConfig.php
InitConfig.initConfig
public function initConfig($force = false) { $pluginName = $this->_getPluginName(); $checkPath = $this->_getCheckPath(); $configFile = $this->_getConfigFile(); $language = (string)Configure::read('Config.language'); if (!$force && !empty($checkPath) && Configure::check($checkPath)) { return; } // Local config without extra config file $conf = $this->getConfig(); $cachePath = 'static_cfg_' . Inflector::underscore($pluginName) . '_' . $language; $cached = Cache::read($cachePath, CAKE_CONFIG_PLUGIN_CACHE_CFG); if ($cached !== false) { $conf = Hash::mergeDiff($conf, (array)$cached); Configure::write($pluginName, $conf); return; } Configure::config('phpcfg', new PhpReader($this->path)); // Fallback to Plugin config which can be overwritten via local app config. Configure::load($pluginName . '.' . $configFile, 'phpcfg', false); $defaultConf = $this->getConfig(); // Local app config if (file_exists($this->path . $configFile . '.php')) { Configure::load($configFile, 'phpcfg', false); $localConf = $this->getConfig(); $conf = Hash::mergeDiff($conf, $localConf); } Configure::drop('phpcfg'); // BC comp: $conf = Hash::mergeDiff($conf, $defaultConf); Cache::write($cachePath, $conf, CAKE_CONFIG_PLUGIN_CACHE_CFG); Configure::write($pluginName, $conf); }
php
public function initConfig($force = false) { $pluginName = $this->_getPluginName(); $checkPath = $this->_getCheckPath(); $configFile = $this->_getConfigFile(); $language = (string)Configure::read('Config.language'); if (!$force && !empty($checkPath) && Configure::check($checkPath)) { return; } // Local config without extra config file $conf = $this->getConfig(); $cachePath = 'static_cfg_' . Inflector::underscore($pluginName) . '_' . $language; $cached = Cache::read($cachePath, CAKE_CONFIG_PLUGIN_CACHE_CFG); if ($cached !== false) { $conf = Hash::mergeDiff($conf, (array)$cached); Configure::write($pluginName, $conf); return; } Configure::config('phpcfg', new PhpReader($this->path)); // Fallback to Plugin config which can be overwritten via local app config. Configure::load($pluginName . '.' . $configFile, 'phpcfg', false); $defaultConf = $this->getConfig(); // Local app config if (file_exists($this->path . $configFile . '.php')) { Configure::load($configFile, 'phpcfg', false); $localConf = $this->getConfig(); $conf = Hash::mergeDiff($conf, $localConf); } Configure::drop('phpcfg'); // BC comp: $conf = Hash::mergeDiff($conf, $defaultConf); Cache::write($cachePath, $conf, CAKE_CONFIG_PLUGIN_CACHE_CFG); Configure::write($pluginName, $conf); }
[ "public", "function", "initConfig", "(", "$", "force", "=", "false", ")", "{", "$", "pluginName", "=", "$", "this", "->", "_getPluginName", "(", ")", ";", "$", "checkPath", "=", "$", "this", "->", "_getCheckPath", "(", ")", ";", "$", "configFile", "=", "$", "this", "->", "_getConfigFile", "(", ")", ";", "$", "language", "=", "(", "string", ")", "Configure", "::", "read", "(", "'Config.language'", ")", ";", "if", "(", "!", "$", "force", "&&", "!", "empty", "(", "$", "checkPath", ")", "&&", "Configure", "::", "check", "(", "$", "checkPath", ")", ")", "{", "return", ";", "}", "// Local config without extra config file", "$", "conf", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "cachePath", "=", "'static_cfg_'", ".", "Inflector", "::", "underscore", "(", "$", "pluginName", ")", ".", "'_'", ".", "$", "language", ";", "$", "cached", "=", "Cache", "::", "read", "(", "$", "cachePath", ",", "CAKE_CONFIG_PLUGIN_CACHE_CFG", ")", ";", "if", "(", "$", "cached", "!==", "false", ")", "{", "$", "conf", "=", "Hash", "::", "mergeDiff", "(", "$", "conf", ",", "(", "array", ")", "$", "cached", ")", ";", "Configure", "::", "write", "(", "$", "pluginName", ",", "$", "conf", ")", ";", "return", ";", "}", "Configure", "::", "config", "(", "'phpcfg'", ",", "new", "PhpReader", "(", "$", "this", "->", "path", ")", ")", ";", "// Fallback to Plugin config which can be overwritten via local app config.", "Configure", "::", "load", "(", "$", "pluginName", ".", "'.'", ".", "$", "configFile", ",", "'phpcfg'", ",", "false", ")", ";", "$", "defaultConf", "=", "$", "this", "->", "getConfig", "(", ")", ";", "// Local app config", "if", "(", "file_exists", "(", "$", "this", "->", "path", ".", "$", "configFile", ".", "'.php'", ")", ")", "{", "Configure", "::", "load", "(", "$", "configFile", ",", "'phpcfg'", ",", "false", ")", ";", "$", "localConf", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "conf", "=", "Hash", "::", "mergeDiff", "(", "$", "conf", ",", "$", "localConf", ")", ";", "}", "Configure", "::", "drop", "(", "'phpcfg'", ")", ";", "// BC comp:", "$", "conf", "=", "Hash", "::", "mergeDiff", "(", "$", "conf", ",", "$", "defaultConf", ")", ";", "Cache", "::", "write", "(", "$", "cachePath", ",", "$", "conf", ",", "CAKE_CONFIG_PLUGIN_CACHE_CFG", ")", ";", "Configure", "::", "write", "(", "$", "pluginName", ",", "$", "conf", ")", ";", "}" ]
Initializes configuration for plugin. @param bool $force If True, force initialize configuration @author [email protected] @return void
[ "Initializes", "configuration", "for", "plugin", "." ]
9659709541950470908f15860327cdd9f1d4e662
https://github.com/anklimsk/cakephp-config-plugin/blob/9659709541950470908f15860327cdd9f1d4e662/Lib/Utility/InitConfig.php#L134-L170
4,798
dazarobbo/Cola
src/BitwiseEnum.php
BitwiseEnum.fromInt
public static function fromInt($int){ if(!\is_int($int)){ throw new \InvalidArgumentException('$int must be an integer'); } $flags = new static(); foreach(static::getEnumValues() as $const){ if(($int & $const) === $const){ $flags->addFlag($const); } } return $flags; }
php
public static function fromInt($int){ if(!\is_int($int)){ throw new \InvalidArgumentException('$int must be an integer'); } $flags = new static(); foreach(static::getEnumValues() as $const){ if(($int & $const) === $const){ $flags->addFlag($const); } } return $flags; }
[ "public", "static", "function", "fromInt", "(", "$", "int", ")", "{", "if", "(", "!", "\\", "is_int", "(", "$", "int", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$int must be an integer'", ")", ";", "}", "$", "flags", "=", "new", "static", "(", ")", ";", "foreach", "(", "static", "::", "getEnumValues", "(", ")", "as", "$", "const", ")", "{", "if", "(", "(", "$", "int", "&", "$", "const", ")", "===", "$", "const", ")", "{", "$", "flags", "->", "addFlag", "(", "$", "const", ")", ";", "}", "}", "return", "$", "flags", ";", "}" ]
Converts an integer value to an enum of this type @param int $int @return \static @throws \InvalidArgumentException
[ "Converts", "an", "integer", "value", "to", "an", "enum", "of", "this", "type" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitwiseEnum.php#L46-L62
4,799
dazarobbo/Cola
src/BitwiseEnum.php
BitwiseEnum.getNames
public function getNames(){ $isSet = PHPArray::filter(static::getConstants(), function($value){ return $this->hasFlag($value); }); return \array_keys($isSet); }
php
public function getNames(){ $isSet = PHPArray::filter(static::getConstants(), function($value){ return $this->hasFlag($value); }); return \array_keys($isSet); }
[ "public", "function", "getNames", "(", ")", "{", "$", "isSet", "=", "PHPArray", "::", "filter", "(", "static", "::", "getConstants", "(", ")", ",", "function", "(", "$", "value", ")", "{", "return", "$", "this", "->", "hasFlag", "(", "$", "value", ")", ";", "}", ")", ";", "return", "\\", "array_keys", "(", "$", "isSet", ")", ";", "}" ]
Returns an array of this class' constant names which are defined in this instance @return string[]
[ "Returns", "an", "array", "of", "this", "class", "constant", "names", "which", "are", "defined", "in", "this", "instance" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/BitwiseEnum.php#L69-L77