id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
20,800
surebert/surebert-framework
src/sb/Request.php
Request.setInputArgsDelimiter
public function setInputArgsDelimiter($input_args_delimiter) { //parse arguments by removing path $args = preg_replace("~^.{" . strlen($this->path) . "}/?~", "", $this->request); //remove $_GET string $args = preg_replace("~\?.*?$~", "", $args); if ($args !== '') { $this->args = explode($input_args_delimiter, $args); //decodes url encoding foreach ($this->args as &$arg) { $arg = urldecode($arg); } if (method_exists('\App', 'filterAllInput')) { \App::filterAllInput($this->args); } } }
php
public function setInputArgsDelimiter($input_args_delimiter) { //parse arguments by removing path $args = preg_replace("~^.{" . strlen($this->path) . "}/?~", "", $this->request); //remove $_GET string $args = preg_replace("~\?.*?$~", "", $args); if ($args !== '') { $this->args = explode($input_args_delimiter, $args); //decodes url encoding foreach ($this->args as &$arg) { $arg = urldecode($arg); } if (method_exists('\App', 'filterAllInput')) { \App::filterAllInput($this->args); } } }
[ "public", "function", "setInputArgsDelimiter", "(", "$", "input_args_delimiter", ")", "{", "//parse arguments by removing path", "$", "args", "=", "preg_replace", "(", "\"~^.{\"", ".", "strlen", "(", "$", "this", "->", "path", ")", ".", "\"}/?~\"", ",", "\"\"", ",", "$", "this", "->", "request", ")", ";", "//remove $_GET string", "$", "args", "=", "preg_replace", "(", "\"~\\?.*?$~\"", ",", "\"\"", ",", "$", "args", ")", ";", "if", "(", "$", "args", "!==", "''", ")", "{", "$", "this", "->", "args", "=", "explode", "(", "$", "input_args_delimiter", ",", "$", "args", ")", ";", "//decodes url encoding", "foreach", "(", "$", "this", "->", "args", "as", "&", "$", "arg", ")", "{", "$", "arg", "=", "urldecode", "(", "$", "arg", ")", ";", "}", "if", "(", "method_exists", "(", "'\\App'", ",", "'filterAllInput'", ")", ")", "{", "\\", "App", "::", "filterAllInput", "(", "$", "this", "->", "args", ")", ";", "}", "}", "}" ]
Sets the input argument delimeter and parses it @param $input_args_delimiter
[ "Sets", "the", "input", "argument", "delimeter", "and", "parses", "it" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Request.php#L138-L160
20,801
surebert/surebert-framework
src/sb/Request.php
Request.getFile
public function getFile($key) { if (isset($this->files[$key])) { return $this->files[$key]; } return null; }
php
public function getFile($key) { if (isset($this->files[$key])) { return $this->files[$key]; } return null; }
[ "public", "function", "getFile", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "files", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "files", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Gets a uploaded file reference, otherwise returns null @param string $key The key to look for @return array the file that was uploaded
[ "Gets", "a", "uploaded", "file", "reference", "otherwise", "returns", "null" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Request.php#L290-L297
20,802
rhosocial/yii2-user
UserSearch.php
UserSearch.gmdate
public function gmdate($attribute, $params, $validator) { if (isset($this->$attribute)) { $timestamp = strtotime($this->$attribute); $this->{$attribute . 'InUtc'} = gmdate('Y-m-d H:i:s', $timestamp); } }
php
public function gmdate($attribute, $params, $validator) { if (isset($this->$attribute)) { $timestamp = strtotime($this->$attribute); $this->{$attribute . 'InUtc'} = gmdate('Y-m-d H:i:s', $timestamp); } }
[ "public", "function", "gmdate", "(", "$", "attribute", ",", "$", "params", ",", "$", "validator", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "$", "attribute", ")", ")", "{", "$", "timestamp", "=", "strtotime", "(", "$", "this", "->", "$", "attribute", ")", ";", "$", "this", "->", "{", "$", "attribute", ".", "'InUtc'", "}", "=", "gmdate", "(", "'Y-m-d H:i:s'", ",", "$", "timestamp", ")", ";", "}", "}" ]
Convert time attribute to UTC time. @param string $attribute @param array $params @param mixed $validator
[ "Convert", "time", "attribute", "to", "UTC", "time", "." ]
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/UserSearch.php#L84-L90
20,803
rhosocial/yii2-user
UserSearch.php
UserSearch.attributeLabels
public function attributeLabels() { $attributeLabels = parent::attributeLabels(); $attributeLabels['id'] = Yii::t('user', 'User ID'); $attributeLabels['nickname'] = Yii::t('user', 'Nickname'); $attributeLabels['first_name'] = Yii::t('user', 'First Name'); $attributeLabels['last_name'] = Yii::t('user', 'Last Name'); $attributeLabels['gf'] = Yii::t('user', 'Gender'); $attributeLabels['createdFrom'] = Yii::t('user', 'From'); $attributeLabels['createdTo'] = Yii::t('user', 'To'); return $attributeLabels; }
php
public function attributeLabels() { $attributeLabels = parent::attributeLabels(); $attributeLabels['id'] = Yii::t('user', 'User ID'); $attributeLabels['nickname'] = Yii::t('user', 'Nickname'); $attributeLabels['first_name'] = Yii::t('user', 'First Name'); $attributeLabels['last_name'] = Yii::t('user', 'Last Name'); $attributeLabels['gf'] = Yii::t('user', 'Gender'); $attributeLabels['createdFrom'] = Yii::t('user', 'From'); $attributeLabels['createdTo'] = Yii::t('user', 'To'); return $attributeLabels; }
[ "public", "function", "attributeLabels", "(", ")", "{", "$", "attributeLabels", "=", "parent", "::", "attributeLabels", "(", ")", ";", "$", "attributeLabels", "[", "'id'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'User ID'", ")", ";", "$", "attributeLabels", "[", "'nickname'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'Nickname'", ")", ";", "$", "attributeLabels", "[", "'first_name'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'First Name'", ")", ";", "$", "attributeLabels", "[", "'last_name'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'Last Name'", ")", ";", "$", "attributeLabels", "[", "'gf'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'Gender'", ")", ";", "$", "attributeLabels", "[", "'createdFrom'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'From'", ")", ";", "$", "attributeLabels", "[", "'createdTo'", "]", "=", "Yii", "::", "t", "(", "'user'", ",", "'To'", ")", ";", "return", "$", "attributeLabels", ";", "}" ]
Add `createdFrom` & `createdTo` attributes. @return array
[ "Add", "createdFrom", "&", "createdTo", "attributes", "." ]
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/UserSearch.php#L176-L187
20,804
Danack/GithubArtaxService
lib/GithubService/GithubArtaxService/GithubArtaxService.php
GithubArtaxService.shouldResponseBeCached
public function shouldResponseBeCached(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status == 200) { return true; } return false; }
php
public function shouldResponseBeCached(\Amp\Artax\Response $response) { $status = $response->getStatus(); if ($status == 200) { return true; } return false; }
[ "public", "function", "shouldResponseBeCached", "(", "\\", "Amp", "\\", "Artax", "\\", "Response", "$", "response", ")", "{", "$", "status", "=", "$", "response", "->", "getStatus", "(", ")", ";", "if", "(", "$", "status", "==", "200", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine whether the response should be cached. @return boolean
[ "Determine", "whether", "the", "response", "should", "be", "cached", "." ]
9f62b5be4f413207d4012e7fa084d0ae505680eb
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubArtaxService.php#L2574-L2581
20,805
roshangara/parser
src/Parser.php
Parser.fromXml
public function fromXml(string $xml): array { if (!$this->isEmptyValue($xml)) { libxml_use_internal_errors(true); // convert string to xml object $result = simplexml_load_string("$xml", 'SimpleXMLElement', LIBXML_NOCDATA); if ($result) { return $this->fromClass($result); } else { foreach (libxml_get_errors() as $error) { // if don`t have container add that`s if ($error->code == 5) { $this->errors = []; // append container and parse again return $this->fromXml("<DATA>$xml</DATA>"); } else $this->setError($error->code, $error->message); } } } return $this->result; }
php
public function fromXml(string $xml): array { if (!$this->isEmptyValue($xml)) { libxml_use_internal_errors(true); // convert string to xml object $result = simplexml_load_string("$xml", 'SimpleXMLElement', LIBXML_NOCDATA); if ($result) { return $this->fromClass($result); } else { foreach (libxml_get_errors() as $error) { // if don`t have container add that`s if ($error->code == 5) { $this->errors = []; // append container and parse again return $this->fromXml("<DATA>$xml</DATA>"); } else $this->setError($error->code, $error->message); } } } return $this->result; }
[ "public", "function", "fromXml", "(", "string", "$", "xml", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "xml", ")", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "// convert string to xml object", "$", "result", "=", "simplexml_load_string", "(", "\"$xml\"", ",", "'SimpleXMLElement'", ",", "LIBXML_NOCDATA", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "this", "->", "fromClass", "(", "$", "result", ")", ";", "}", "else", "{", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "{", "// if don`t have container add that`s", "if", "(", "$", "error", "->", "code", "==", "5", ")", "{", "$", "this", "->", "errors", "=", "[", "]", ";", "// append container and parse again", "return", "$", "this", "->", "fromXml", "(", "\"<DATA>$xml</DATA>\"", ")", ";", "}", "else", "$", "this", "->", "setError", "(", "$", "error", "->", "code", ",", "$", "error", "->", "message", ")", ";", "}", "}", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert xml to array @param string $xml @return array|mixed
[ "Convert", "xml", "to", "array" ]
24c6c3781fd4416fefb5218daad765b9edbcaa76
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L27-L57
20,806
roshangara/parser
src/Parser.php
Parser.fromXSD
public function fromXSD($xsd): array { if (!$this->isEmptyValue($xsd)) { return $this->fromXml($xsd->output); } return $this->result; }
php
public function fromXSD($xsd): array { if (!$this->isEmptyValue($xsd)) { return $this->fromXml($xsd->output); } return $this->result; }
[ "public", "function", "fromXSD", "(", "$", "xsd", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "xsd", ")", ")", "{", "return", "$", "this", "->", "fromXml", "(", "$", "xsd", "->", "output", ")", ";", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert class to array @param $xsd @return array|mixed
[ "Convert", "class", "to", "array" ]
24c6c3781fd4416fefb5218daad765b9edbcaa76
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L81-L89
20,807
roshangara/parser
src/Parser.php
Parser.fromJson
public function fromJson(string $json): array { if (!$this->isEmptyValue($json)) { if ($decode = json_decode(trim($json), true) and json_last_error() == JSON_ERROR_NONE) $this->result = $decode; else $this->setError(json_last_error(), json_last_error_msg()); } return $this->result; }
php
public function fromJson(string $json): array { if (!$this->isEmptyValue($json)) { if ($decode = json_decode(trim($json), true) and json_last_error() == JSON_ERROR_NONE) $this->result = $decode; else $this->setError(json_last_error(), json_last_error_msg()); } return $this->result; }
[ "public", "function", "fromJson", "(", "string", "$", "json", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isEmptyValue", "(", "$", "json", ")", ")", "{", "if", "(", "$", "decode", "=", "json_decode", "(", "trim", "(", "$", "json", ")", ",", "true", ")", "and", "json_last_error", "(", ")", "==", "JSON_ERROR_NONE", ")", "$", "this", "->", "result", "=", "$", "decode", ";", "else", "$", "this", "->", "setError", "(", "json_last_error", "(", ")", ",", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "this", "->", "result", ";", "}" ]
Convert json to array @param string $json @return array|mixed
[ "Convert", "json", "to", "array" ]
24c6c3781fd4416fefb5218daad765b9edbcaa76
https://github.com/roshangara/parser/blob/24c6c3781fd4416fefb5218daad765b9edbcaa76/src/Parser.php#L112-L123
20,808
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.setSourceList
protected function setSourceList(array $sourceParameters, array $globalParameters = array()) { // Creating as many Source instances as configured in the configuration file foreach ($sourceParameters as $key => $parameters) { if (!isset($parameters['type'])) { throw new Exception\BadProxyConfigurationException( sprintf("Missing parameters 'type' for remote source configuration '%s'", $key) ); } else { // Getting the type from the configuration $type = $parameters['type']; // Catching exception thrown in the SourceFactory try { // Getting Source instance from factory $source = $this->sourceFactory->getSourceInstance($type, $key, $parameters, $globalParameters); if ($source instanceof SourceInterface) { // Adding this Source instance to the list of Source instances to be processed by the Proxy $this->addSource($source); $this->sources[$key] = $source; } else { throw new Exception\BadProxyConfigurationException( sprintf( "Expected instance of 'Msl\ResourceProxy\Source\SourceInterface' but got '%s'", get_class($source) ) ); } } catch (Exception\BadSourceConfigConfigurationException $bscce) { throw new Exception\BadProxyConfigurationException( sprintf( "The following exception has been caught while generating a source object for the source '%s': %s", $key, $bscce->getMessage() ) ); } } } }
php
protected function setSourceList(array $sourceParameters, array $globalParameters = array()) { // Creating as many Source instances as configured in the configuration file foreach ($sourceParameters as $key => $parameters) { if (!isset($parameters['type'])) { throw new Exception\BadProxyConfigurationException( sprintf("Missing parameters 'type' for remote source configuration '%s'", $key) ); } else { // Getting the type from the configuration $type = $parameters['type']; // Catching exception thrown in the SourceFactory try { // Getting Source instance from factory $source = $this->sourceFactory->getSourceInstance($type, $key, $parameters, $globalParameters); if ($source instanceof SourceInterface) { // Adding this Source instance to the list of Source instances to be processed by the Proxy $this->addSource($source); $this->sources[$key] = $source; } else { throw new Exception\BadProxyConfigurationException( sprintf( "Expected instance of 'Msl\ResourceProxy\Source\SourceInterface' but got '%s'", get_class($source) ) ); } } catch (Exception\BadSourceConfigConfigurationException $bscce) { throw new Exception\BadProxyConfigurationException( sprintf( "The following exception has been caught while generating a source object for the source '%s': %s", $key, $bscce->getMessage() ) ); } } } }
[ "protected", "function", "setSourceList", "(", "array", "$", "sourceParameters", ",", "array", "$", "globalParameters", "=", "array", "(", ")", ")", "{", "// Creating as many Source instances as configured in the configuration file", "foreach", "(", "$", "sourceParameters", "as", "$", "key", "=>", "$", "parameters", ")", "{", "if", "(", "!", "isset", "(", "$", "parameters", "[", "'type'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"Missing parameters 'type' for remote source configuration '%s'\"", ",", "$", "key", ")", ")", ";", "}", "else", "{", "// Getting the type from the configuration", "$", "type", "=", "$", "parameters", "[", "'type'", "]", ";", "// Catching exception thrown in the SourceFactory", "try", "{", "// Getting Source instance from factory", "$", "source", "=", "$", "this", "->", "sourceFactory", "->", "getSourceInstance", "(", "$", "type", ",", "$", "key", ",", "$", "parameters", ",", "$", "globalParameters", ")", ";", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "// Adding this Source instance to the list of Source instances to be processed by the Proxy", "$", "this", "->", "addSource", "(", "$", "source", ")", ";", "$", "this", "->", "sources", "[", "$", "key", "]", "=", "$", "source", ";", "}", "else", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"Expected instance of 'Msl\\ResourceProxy\\Source\\SourceInterface' but got '%s'\"", ",", "get_class", "(", "$", "source", ")", ")", ")", ";", "}", "}", "catch", "(", "Exception", "\\", "BadSourceConfigConfigurationException", "$", "bscce", ")", "{", "throw", "new", "Exception", "\\", "BadProxyConfigurationException", "(", "sprintf", "(", "\"The following exception has been caught while generating a source object for the source '%s': %s\"", ",", "$", "key", ",", "$", "bscce", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}", "}", "}" ]
Creates and adds to the Source object list all the configured Source instances @param array $sourceParameters the configuration parameter array @param array $globalParameters the global configuration parameter array @throws \Msl\ResourceProxy\Exception\BadProxyConfigurationException @return void
[ "Creates", "and", "adds", "to", "the", "Source", "object", "list", "all", "the", "configured", "Source", "instances" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L171-L211
20,809
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResources
public function processResources() { // Fetching the sources iterator $errors = array(); foreach($this->sourcesIterator as $source) { // Processing all resources associated to the current source object if ($source instanceof SourceInterface) { try { $this->processResourcesBySource($source); } catch (Exception\PostParseException $e) { array_push($errors, $e); } catch (Exception\ResourceProxyExceptionInterface $e) { $msg = sprintf( 'General proxy error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } catch (\Exception $e) { $msg = sprintf( 'General error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } } } // If errors, we throw a global process exception if (count($errors) > 0) { throw new Exception\GlobalProcessException( $errors, sprintf( 'Errors while processing the sources for the following proxy: \'%s\'.', $this->getProxyName() ) ); } }
php
public function processResources() { // Fetching the sources iterator $errors = array(); foreach($this->sourcesIterator as $source) { // Processing all resources associated to the current source object if ($source instanceof SourceInterface) { try { $this->processResourcesBySource($source); } catch (Exception\PostParseException $e) { array_push($errors, $e); } catch (Exception\ResourceProxyExceptionInterface $e) { $msg = sprintf( 'General proxy error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } catch (\Exception $e) { $msg = sprintf( 'General error caught for the following source: \'%s\'. Error is: \'%s\'.', $source->getName(), $e->getMessage() ); array_push($errors, $msg); } } } // If errors, we throw a global process exception if (count($errors) > 0) { throw new Exception\GlobalProcessException( $errors, sprintf( 'Errors while processing the sources for the following proxy: \'%s\'.', $this->getProxyName() ) ); } }
[ "public", "function", "processResources", "(", ")", "{", "// Fetching the sources iterator", "$", "errors", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "sourcesIterator", "as", "$", "source", ")", "{", "// Processing all resources associated to the current source object", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "try", "{", "$", "this", "->", "processResourcesBySource", "(", "$", "source", ")", ";", "}", "catch", "(", "Exception", "\\", "PostParseException", "$", "e", ")", "{", "array_push", "(", "$", "errors", ",", "$", "e", ")", ";", "}", "catch", "(", "Exception", "\\", "ResourceProxyExceptionInterface", "$", "e", ")", "{", "$", "msg", "=", "sprintf", "(", "'General proxy error caught for the following source: \\'%s\\'. Error is: \\'%s\\'.'", ",", "$", "source", "->", "getName", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "errors", ",", "$", "msg", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "sprintf", "(", "'General error caught for the following source: \\'%s\\'. Error is: \\'%s\\'.'", ",", "$", "source", "->", "getName", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "errors", ",", "$", "msg", ")", ";", "}", "}", "}", "// If errors, we throw a global process exception", "if", "(", "count", "(", "$", "errors", ")", ">", "0", ")", "{", "throw", "new", "Exception", "\\", "GlobalProcessException", "(", "$", "errors", ",", "sprintf", "(", "'Errors while processing the sources for the following proxy: \\'%s\\'.'", ",", "$", "this", "->", "getProxyName", "(", ")", ")", ")", ";", "}", "}" ]
Processes all resources associated to the configured source objects for a proxy implementation @throws \Msl\ResourceProxy\Exception\GlobalProcessException @return void
[ "Processes", "all", "resources", "associated", "to", "the", "configured", "source", "objects", "for", "a", "proxy", "implementation" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L222-L261
20,810
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResourcesBySource
public function processResourcesBySource(SourceInterface $source) { // Getting all resources for the given source and process them (save the content in the configured output folder) // Getting result iterator $resources = $this->getResources($source); // Parsing the resource iterator $globalSuccess = true; $postParseErrors = array(); foreach ($resources as $resourceKey => $resource) { if ($resource instanceof ResourceInterface) { // Moving the content of the current resource to the output folder $success = $resource->moveToOutputFolder($this->outputFolder); if (!$success) { $globalSuccess = false; } try { // Launching the post parse unit action for the current resource object $result = $source->postParseUnitAction($resourceKey, $success); if ($result instanceof ParseResult && $result->getResult() === false) { $sourcePostParseError = sprintf( 'Post parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } catch (\Exception $e) { $sourcePostParseError = sprintf( 'Exception has been caught while parsing the resources for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } } try { // Running the global post parse action for the current source object $result = $source->postParseGlobalAction($globalSuccess); if ($result instanceof ParseResult && $result->getResult() === false) { $globalSourcePostParseError = sprintf( 'Post global parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } } catch (\Exception $e) { $globalSourcePostParseError = sprintf( 'Exception has been caught while running the post global action for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } // Launch a unique exception with all the post parse unit and post global errors if (count($postParseErrors) > 0) { throw new Exception\PostParseException( $postParseErrors, sprintf( 'Errors while running post unit and global actions for the following source: \'%s\'.', $source->toString() ) ); } // Return true if no exception return true; }
php
public function processResourcesBySource(SourceInterface $source) { // Getting all resources for the given source and process them (save the content in the configured output folder) // Getting result iterator $resources = $this->getResources($source); // Parsing the resource iterator $globalSuccess = true; $postParseErrors = array(); foreach ($resources as $resourceKey => $resource) { if ($resource instanceof ResourceInterface) { // Moving the content of the current resource to the output folder $success = $resource->moveToOutputFolder($this->outputFolder); if (!$success) { $globalSuccess = false; } try { // Launching the post parse unit action for the current resource object $result = $source->postParseUnitAction($resourceKey, $success); if ($result instanceof ParseResult && $result->getResult() === false) { $sourcePostParseError = sprintf( 'Post parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } catch (\Exception $e) { $sourcePostParseError = sprintf( 'Exception has been caught while parsing the resources for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $sourcePostParseError); } } } try { // Running the global post parse action for the current source object $result = $source->postParseGlobalAction($globalSuccess); if ($result instanceof ParseResult && $result->getResult() === false) { $globalSourcePostParseError = sprintf( 'Post global parse error for source \'%s\'. Error message is: \'%s\'.', $source->toString(), $result->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } } catch (\Exception $e) { $globalSourcePostParseError = sprintf( 'Exception has been caught while running the post global action for the source object \'%s\'. Error is: \'%s\'', $source->toString(), $e->getMessage() ); array_push($postParseErrors, $globalSourcePostParseError); } // Launch a unique exception with all the post parse unit and post global errors if (count($postParseErrors) > 0) { throw new Exception\PostParseException( $postParseErrors, sprintf( 'Errors while running post unit and global actions for the following source: \'%s\'.', $source->toString() ) ); } // Return true if no exception return true; }
[ "public", "function", "processResourcesBySource", "(", "SourceInterface", "$", "source", ")", "{", "// Getting all resources for the given source and process them (save the content in the configured output folder)", "// Getting result iterator", "$", "resources", "=", "$", "this", "->", "getResources", "(", "$", "source", ")", ";", "// Parsing the resource iterator", "$", "globalSuccess", "=", "true", ";", "$", "postParseErrors", "=", "array", "(", ")", ";", "foreach", "(", "$", "resources", "as", "$", "resourceKey", "=>", "$", "resource", ")", "{", "if", "(", "$", "resource", "instanceof", "ResourceInterface", ")", "{", "// Moving the content of the current resource to the output folder", "$", "success", "=", "$", "resource", "->", "moveToOutputFolder", "(", "$", "this", "->", "outputFolder", ")", ";", "if", "(", "!", "$", "success", ")", "{", "$", "globalSuccess", "=", "false", ";", "}", "try", "{", "// Launching the post parse unit action for the current resource object", "$", "result", "=", "$", "source", "->", "postParseUnitAction", "(", "$", "resourceKey", ",", "$", "success", ")", ";", "if", "(", "$", "result", "instanceof", "ParseResult", "&&", "$", "result", "->", "getResult", "(", ")", "===", "false", ")", "{", "$", "sourcePostParseError", "=", "sprintf", "(", "'Post parse error for source \\'%s\\'. Error message is: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "result", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "sourcePostParseError", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "sourcePostParseError", "=", "sprintf", "(", "'Exception has been caught while parsing the resources for the source object \\'%s\\'. Error is: \\'%s\\''", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "sourcePostParseError", ")", ";", "}", "}", "}", "try", "{", "// Running the global post parse action for the current source object", "$", "result", "=", "$", "source", "->", "postParseGlobalAction", "(", "$", "globalSuccess", ")", ";", "if", "(", "$", "result", "instanceof", "ParseResult", "&&", "$", "result", "->", "getResult", "(", ")", "===", "false", ")", "{", "$", "globalSourcePostParseError", "=", "sprintf", "(", "'Post global parse error for source \\'%s\\'. Error message is: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "result", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "globalSourcePostParseError", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "globalSourcePostParseError", "=", "sprintf", "(", "'Exception has been caught while running the post global action for the source object \\'%s\\'. Error is: \\'%s\\''", ",", "$", "source", "->", "toString", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "array_push", "(", "$", "postParseErrors", ",", "$", "globalSourcePostParseError", ")", ";", "}", "// Launch a unique exception with all the post parse unit and post global errors", "if", "(", "count", "(", "$", "postParseErrors", ")", ">", "0", ")", "{", "throw", "new", "Exception", "\\", "PostParseException", "(", "$", "postParseErrors", ",", "sprintf", "(", "'Errors while running post unit and global actions for the following source: \\'%s\\'.'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "// Return true if no exception", "return", "true", ";", "}" ]
Processes all resources associated to the given Source object @param SourceInterface $source the source object to be processed @throws \Msl\ResourceProxy\Exception\SourceGetDataException @throws \Msl\ResourceProxy\Exception\PostParseException @return bool
[ "Processes", "all", "resources", "associated", "to", "the", "given", "Source", "object" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L273-L344
20,811
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.processResourcesBySourceName
public function processResourcesBySourceName($sourceName) { // Getting source object $source = $this->getSourceByName($sourceName); if (!$source instanceof SourceInterface) { throw new Exception\SourceNotFoundException( $sourceName, sprintf( 'Impossible to find a source object with the following name: \'%s\'.', $sourceName ) ); } // Now processing the found source object return $this->processResourcesBySource($source); }
php
public function processResourcesBySourceName($sourceName) { // Getting source object $source = $this->getSourceByName($sourceName); if (!$source instanceof SourceInterface) { throw new Exception\SourceNotFoundException( $sourceName, sprintf( 'Impossible to find a source object with the following name: \'%s\'.', $sourceName ) ); } // Now processing the found source object return $this->processResourcesBySource($source); }
[ "public", "function", "processResourcesBySourceName", "(", "$", "sourceName", ")", "{", "// Getting source object", "$", "source", "=", "$", "this", "->", "getSourceByName", "(", "$", "sourceName", ")", ";", "if", "(", "!", "$", "source", "instanceof", "SourceInterface", ")", "{", "throw", "new", "Exception", "\\", "SourceNotFoundException", "(", "$", "sourceName", ",", "sprintf", "(", "'Impossible to find a source object with the following name: \\'%s\\'.'", ",", "$", "sourceName", ")", ")", ";", "}", "// Now processing the found source object", "return", "$", "this", "->", "processResourcesBySource", "(", "$", "source", ")", ";", "}" ]
Processes all resources associated to a Source object for the given source name @param string $sourceName the source name to be processed @return bool @throws \Msl\ResourceProxy\Exception\SourceNotFoundException @throws \Msl\ResourceProxy\Exception\SourceGetDataException @throws \Msl\ResourceProxy\Exception\PostParseException
[ "Processes", "all", "resources", "associated", "to", "a", "Source", "object", "for", "the", "given", "source", "name" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L357-L373
20,812
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getSourceByName
public function getSourceByName($sourceName) { if (isset($this->sources[$sourceName])) { return $this->sources[$sourceName]; } return null; }
php
public function getSourceByName($sourceName) { if (isset($this->sources[$sourceName])) { return $this->sources[$sourceName]; } return null; }
[ "public", "function", "getSourceByName", "(", "$", "sourceName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "sources", "[", "$", "sourceName", "]", ")", ")", "{", "return", "$", "this", "->", "sources", "[", "$", "sourceName", "]", ";", "}", "return", "null", ";", "}" ]
Returns the Source object for the given source name @param string $sourceName the source name @return null|SourceInterface
[ "Returns", "the", "Source", "object", "for", "the", "given", "source", "name" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L439-L445
20,813
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getResources
public function getResources(SourceInterface $source) { // Getting resources iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the resources for the following source object: %s', $source->toString() ) ); } }
php
public function getResources(SourceInterface $source) { // Getting resources iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the resources for the following source object: %s', $source->toString() ) ); } }
[ "public", "function", "getResources", "(", "SourceInterface", "$", "source", ")", "{", "// Getting resources iterator", "try", "{", "return", "$", "source", "->", "getContentIterator", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetDataException", "(", "sprintf", "(", "'Exception caught while getting the resources for the following source object: %s'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "}" ]
Returns an Iterator containing all the resources for the given source object @param \Msl\ResourceProxy\Source\SourceInterface $source the source object @throws \Msl\ResourceProxy\Exception\SourceGetDataException @return null|Iterator
[ "Returns", "an", "Iterator", "containing", "all", "the", "resources", "for", "the", "given", "source", "object" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L456-L469
20,814
mslib/resource-proxy
Msl/ResourceProxy/Proxy/AbstractProxy.php
AbstractProxy.getResourcesBySourceName
public function getResourcesBySourceName($sourceName) { // Getting source object first $source = $this->getSourceByName($sourceName); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the content for the following source object: %s', $source->toString() ) ); } } return null; }
php
public function getResourcesBySourceName($sourceName) { // Getting source object first $source = $this->getSourceByName($sourceName); // Getting the data if ($source instanceof SourceInterface) { // Getting result iterator try { return $source->getContentIterator(); } catch (\Exception $e) { throw new Exception\SourceGetDataException( sprintf( 'Exception caught while getting the content for the following source object: %s', $source->toString() ) ); } } return null; }
[ "public", "function", "getResourcesBySourceName", "(", "$", "sourceName", ")", "{", "// Getting source object first", "$", "source", "=", "$", "this", "->", "getSourceByName", "(", "$", "sourceName", ")", ";", "// Getting the data", "if", "(", "$", "source", "instanceof", "SourceInterface", ")", "{", "// Getting result iterator", "try", "{", "return", "$", "source", "->", "getContentIterator", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetDataException", "(", "sprintf", "(", "'Exception caught while getting the content for the following source object: %s'", ",", "$", "source", "->", "toString", "(", ")", ")", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns an Iterator containing all the resources for the given source name @param string $sourceName the source name @throws \Msl\ResourceProxy\Exception\SourceGetDataException @return null|Iterator
[ "Returns", "an", "Iterator", "containing", "all", "the", "resources", "for", "the", "given", "source", "name" ]
be3f8589753f738f5114443a3465f5e84aecd156
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Proxy/AbstractProxy.php#L480-L500
20,815
jasny/codeception-module
src/Module.php
Module.init
public function init() { $this->container = $this->initContainer(); if ($this->container->has(ServerRequestInterface::class)) { $this->baseRequest = $this->container->get(ServerRequestInterface::class); } if ($this->container->has(ResponseInterface::class)) { $this->baseResponse = $this->container->get(ResponseInterface::class); } }
php
public function init() { $this->container = $this->initContainer(); if ($this->container->has(ServerRequestInterface::class)) { $this->baseRequest = $this->container->get(ServerRequestInterface::class); } if ($this->container->has(ResponseInterface::class)) { $this->baseResponse = $this->container->get(ResponseInterface::class); } }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "container", "=", "$", "this", "->", "initContainer", "(", ")", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "ServerRequestInterface", "::", "class", ")", ")", "{", "$", "this", "->", "baseRequest", "=", "$", "this", "->", "container", "->", "get", "(", "ServerRequestInterface", "::", "class", ")", ";", "}", "if", "(", "$", "this", "->", "container", "->", "has", "(", "ResponseInterface", "::", "class", ")", ")", "{", "$", "this", "->", "baseResponse", "=", "$", "this", "->", "container", "->", "get", "(", "ResponseInterface", "::", "class", ")", ";", "}", "}" ]
Initialize the module
[ "Initialize", "the", "module" ]
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L109-L120
20,816
jasny/codeception-module
src/Module.php
Module._before
public function _before(TestInterface $test) { $this->init(); $this->client = new Connector(); $this->client->setRouter($this->container->get(RouterInterface::class)); if (isset($this->baseRequest)) { $this->client->setBaseRequest($this->baseRequest); } if (isset($this->baseResponse)) { $this->client->setBaseResponse($this->baseResponse); } parent::_before($test); }
php
public function _before(TestInterface $test) { $this->init(); $this->client = new Connector(); $this->client->setRouter($this->container->get(RouterInterface::class)); if (isset($this->baseRequest)) { $this->client->setBaseRequest($this->baseRequest); } if (isset($this->baseResponse)) { $this->client->setBaseResponse($this->baseResponse); } parent::_before($test); }
[ "public", "function", "_before", "(", "TestInterface", "$", "test", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "this", "->", "client", "=", "new", "Connector", "(", ")", ";", "$", "this", "->", "client", "->", "setRouter", "(", "$", "this", "->", "container", "->", "get", "(", "RouterInterface", "::", "class", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "baseRequest", ")", ")", "{", "$", "this", "->", "client", "->", "setBaseRequest", "(", "$", "this", "->", "baseRequest", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "baseResponse", ")", ")", "{", "$", "this", "->", "client", "->", "setBaseResponse", "(", "$", "this", "->", "baseResponse", ")", ";", "}", "parent", "::", "_before", "(", "$", "test", ")", ";", "}" ]
Before each test @param TestInterface $test
[ "Before", "each", "test" ]
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L153-L169
20,817
jasny/codeception-module
src/Module.php
Module._after
public function _after(TestInterface $test) { if ($this->sessionStatus() === PHP_SESSION_ACTIVE) { $this->sessionDestroy(); } if (isset($this->client) && $this->client instanceof Connector) { $this->client->reset(); if (isset($this->baseRequest)) { $this->baseRequest = $this->client->getBaseRequest(); } if (isset($this->baseResponse)) { $this->baseResponse = $this->client->getBaseResponse(); } } parent::_after($test); }
php
public function _after(TestInterface $test) { if ($this->sessionStatus() === PHP_SESSION_ACTIVE) { $this->sessionDestroy(); } if (isset($this->client) && $this->client instanceof Connector) { $this->client->reset(); if (isset($this->baseRequest)) { $this->baseRequest = $this->client->getBaseRequest(); } if (isset($this->baseResponse)) { $this->baseResponse = $this->client->getBaseResponse(); } } parent::_after($test); }
[ "public", "function", "_after", "(", "TestInterface", "$", "test", ")", "{", "if", "(", "$", "this", "->", "sessionStatus", "(", ")", "===", "PHP_SESSION_ACTIVE", ")", "{", "$", "this", "->", "sessionDestroy", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "client", ")", "&&", "$", "this", "->", "client", "instanceof", "Connector", ")", "{", "$", "this", "->", "client", "->", "reset", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "baseRequest", ")", ")", "{", "$", "this", "->", "baseRequest", "=", "$", "this", "->", "client", "->", "getBaseRequest", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "baseResponse", ")", ")", "{", "$", "this", "->", "baseResponse", "=", "$", "this", "->", "client", "->", "getBaseResponse", "(", ")", ";", "}", "}", "parent", "::", "_after", "(", "$", "test", ")", ";", "}" ]
After each test @param TestInterface $test
[ "After", "each", "test" ]
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L176-L195
20,818
jasny/codeception-module
src/Module.php
Module._failed
public function _failed(TestInterface $test, $fail) { if (isset($this->container) && $this->container->has(ErrorHandlerInterface::class)) { $error = $this->container->get(ErrorHandlerInterface::class)->getError(); if ($error) { $this->debug((string)$error); } } parent::_failed($test, $fail); }
php
public function _failed(TestInterface $test, $fail) { if (isset($this->container) && $this->container->has(ErrorHandlerInterface::class)) { $error = $this->container->get(ErrorHandlerInterface::class)->getError(); if ($error) { $this->debug((string)$error); } } parent::_failed($test, $fail); }
[ "public", "function", "_failed", "(", "TestInterface", "$", "test", ",", "$", "fail", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", ")", "&&", "$", "this", "->", "container", "->", "has", "(", "ErrorHandlerInterface", "::", "class", ")", ")", "{", "$", "error", "=", "$", "this", "->", "container", "->", "get", "(", "ErrorHandlerInterface", "::", "class", ")", "->", "getError", "(", ")", ";", "if", "(", "$", "error", ")", "{", "$", "this", "->", "debug", "(", "(", "string", ")", "$", "error", ")", ";", "}", "}", "parent", "::", "_failed", "(", "$", "test", ",", "$", "fail", ")", ";", "}" ]
Called when test fails @param TestInterface $test @param mixed $fail
[ "Called", "when", "test", "fails" ]
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Module.php#L203-L215
20,819
wboyz/laravel-enum
src/BaseEnum.php
BaseEnum.getValue
public static function getValue($key) { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); if (! $reflectionClass->hasConstant($key)) { return static::DEFAULT_VALUE; } return $reflectionClass->getConstant($key); }
php
public static function getValue($key) { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); if (! $reflectionClass->hasConstant($key)) { return static::DEFAULT_VALUE; } return $reflectionClass->getConstant($key); }
[ "public", "static", "function", "getValue", "(", "$", "key", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "!", "$", "reflectionClass", "->", "hasConstant", "(", "$", "key", ")", ")", "{", "return", "static", "::", "DEFAULT_VALUE", ";", "}", "return", "$", "reflectionClass", "->", "getConstant", "(", "$", "key", ")", ";", "}" ]
Returns an enum value by its key. @return mixed
[ "Returns", "an", "enum", "value", "by", "its", "key", "." ]
7e34d4eca779e3764fb9b56f612db9bc0b54c9c2
https://github.com/wboyz/laravel-enum/blob/7e34d4eca779e3764fb9b56f612db9bc0b54c9c2/src/BaseEnum.php#L16-L26
20,820
wboyz/laravel-enum
src/BaseEnum.php
BaseEnum.toDictionary
public static function toDictionary() { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); $dictionary = $reflectionClass->getConstants(); unset($dictionary['DEFAULT_VALUE']); return $dictionary; }
php
public static function toDictionary() { $className = get_called_class(); $reflectionClass = new ReflectionClass($className); $dictionary = $reflectionClass->getConstants(); unset($dictionary['DEFAULT_VALUE']); return $dictionary; }
[ "public", "static", "function", "toDictionary", "(", ")", "{", "$", "className", "=", "get_called_class", "(", ")", ";", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "$", "dictionary", "=", "$", "reflectionClass", "->", "getConstants", "(", ")", ";", "unset", "(", "$", "dictionary", "[", "'DEFAULT_VALUE'", "]", ")", ";", "return", "$", "dictionary", ";", "}" ]
Returns the enum as dictionary. @return array
[ "Returns", "the", "enum", "as", "dictionary", "." ]
7e34d4eca779e3764fb9b56f612db9bc0b54c9c2
https://github.com/wboyz/laravel-enum/blob/7e34d4eca779e3764fb9b56f612db9bc0b54c9c2/src/BaseEnum.php#L53-L62
20,821
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.connect
protected function connect() { $errno = null; $errstr = null; if ( $this->options->connectionType !== self::CONNECTION_PLAIN && !ezcBaseFeatures::hasExtensionSupport( 'openssl' ) ) { throw new ezcBaseExtensionNotFoundException( 'openssl', null, "PHP not configured --with-openssl." ); } if ( count( $this->options->connectionOptions ) > 0 ) { $context = stream_context_create( $this->options->connectionOptions ); $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout, STREAM_CLIENT_CONNECT, $context ); } else { $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout ); } if ( is_resource( $this->connection ) ) { stream_set_timeout( $this->connection, $this->options->timeout ); $this->status = self::STATUS_CONNECTED; $greeting = $this->getData(); $this->login(); } else { throw new ezcMailTransportSmtpException( "Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}." ); } }
php
protected function connect() { $errno = null; $errstr = null; if ( $this->options->connectionType !== self::CONNECTION_PLAIN && !ezcBaseFeatures::hasExtensionSupport( 'openssl' ) ) { throw new ezcBaseExtensionNotFoundException( 'openssl', null, "PHP not configured --with-openssl." ); } if ( count( $this->options->connectionOptions ) > 0 ) { $context = stream_context_create( $this->options->connectionOptions ); $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout, STREAM_CLIENT_CONNECT, $context ); } else { $this->connection = @stream_socket_client( "{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}", $errno, $errstr, $this->options->timeout ); } if ( is_resource( $this->connection ) ) { stream_set_timeout( $this->connection, $this->options->timeout ); $this->status = self::STATUS_CONNECTED; $greeting = $this->getData(); $this->login(); } else { throw new ezcMailTransportSmtpException( "Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}." ); } }
[ "protected", "function", "connect", "(", ")", "{", "$", "errno", "=", "null", ";", "$", "errstr", "=", "null", ";", "if", "(", "$", "this", "->", "options", "->", "connectionType", "!==", "self", "::", "CONNECTION_PLAIN", "&&", "!", "ezcBaseFeatures", "::", "hasExtensionSupport", "(", "'openssl'", ")", ")", "{", "throw", "new", "ezcBaseExtensionNotFoundException", "(", "'openssl'", ",", "null", ",", "\"PHP not configured --with-openssl.\"", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "options", "->", "connectionOptions", ")", ">", "0", ")", "{", "$", "context", "=", "stream_context_create", "(", "$", "this", "->", "options", "->", "connectionOptions", ")", ";", "$", "this", "->", "connection", "=", "@", "stream_socket_client", "(", "\"{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}\"", ",", "$", "errno", ",", "$", "errstr", ",", "$", "this", "->", "options", "->", "timeout", ",", "STREAM_CLIENT_CONNECT", ",", "$", "context", ")", ";", "}", "else", "{", "$", "this", "->", "connection", "=", "@", "stream_socket_client", "(", "\"{$this->options->connectionType}://{$this->serverHost}:{$this->serverPort}\"", ",", "$", "errno", ",", "$", "errstr", ",", "$", "this", "->", "options", "->", "timeout", ")", ";", "}", "if", "(", "is_resource", "(", "$", "this", "->", "connection", ")", ")", "{", "stream_set_timeout", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "options", "->", "timeout", ")", ";", "$", "this", "->", "status", "=", "self", "::", "STATUS_CONNECTED", ";", "$", "greeting", "=", "$", "this", "->", "getData", "(", ")", ";", "$", "this", "->", "login", "(", ")", ";", "}", "else", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"Failed to connect to the smtp server: {$this->serverHost}:{$this->serverPort}.\"", ")", ";", "}", "}" ]
Creates a connection to the SMTP server and initiates the login procedure. @todo The @ should be removed when PHP doesn't throw warnings for connect problems @throws ezcMailTransportSmtpException if no connection could be made or if the login failed @throws ezcBaseExtensionNotFoundException if trying to use SSL and the openssl extension is not installed
[ "Creates", "a", "connection", "to", "the", "SMTP", "server", "and", "initiates", "the", "login", "procedure", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L537-L569
20,822
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.login
protected function login() { if ( $this->doAuthenticate ) { $this->sendData( 'EHLO ' . $this->senderHost ); } else { $this->sendData( 'HELO ' . $this->senderHost ); } if ( $this->getReplyCode( $response ) !== '250' ) { throw new ezcMailTransportSmtpException( "HELO/EHLO failed with error: {$response}." ); } // do authentication if ( $this->doAuthenticate ) { if ( $this->options->preferredAuthMethod !== self::AUTH_AUTO ) { $this->auth( $this->options->preferredAuthMethod ); } else { preg_match( "/250-AUTH[= ](.*)/", $response, $matches ); if ( count( $matches ) > 0 ) { $methods = explode( ' ', trim( $matches[1] ) ); } if ( count( $matches ) === 0 || count( $methods ) === 0 ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept the AUTH command.' ); } $authenticated = false; $methods = $this->sortAuthMethods( $methods ); foreach ( $methods as $method ) { if ( $this->auth( $method ) === true ) { $authenticated = true; break; } } if ( $authenticated === false ) { throw new ezcMailTransportSmtpException( 'SMTP server did not respond correctly to any of the authentication methods ' . implode( ', ', $methods ) . '.' ); } } } $this->status = self::STATUS_AUTHENTICATED; }
php
protected function login() { if ( $this->doAuthenticate ) { $this->sendData( 'EHLO ' . $this->senderHost ); } else { $this->sendData( 'HELO ' . $this->senderHost ); } if ( $this->getReplyCode( $response ) !== '250' ) { throw new ezcMailTransportSmtpException( "HELO/EHLO failed with error: {$response}." ); } // do authentication if ( $this->doAuthenticate ) { if ( $this->options->preferredAuthMethod !== self::AUTH_AUTO ) { $this->auth( $this->options->preferredAuthMethod ); } else { preg_match( "/250-AUTH[= ](.*)/", $response, $matches ); if ( count( $matches ) > 0 ) { $methods = explode( ' ', trim( $matches[1] ) ); } if ( count( $matches ) === 0 || count( $methods ) === 0 ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept the AUTH command.' ); } $authenticated = false; $methods = $this->sortAuthMethods( $methods ); foreach ( $methods as $method ) { if ( $this->auth( $method ) === true ) { $authenticated = true; break; } } if ( $authenticated === false ) { throw new ezcMailTransportSmtpException( 'SMTP server did not respond correctly to any of the authentication methods ' . implode( ', ', $methods ) . '.' ); } } } $this->status = self::STATUS_AUTHENTICATED; }
[ "protected", "function", "login", "(", ")", "{", "if", "(", "$", "this", "->", "doAuthenticate", ")", "{", "$", "this", "->", "sendData", "(", "'EHLO '", ".", "$", "this", "->", "senderHost", ")", ";", "}", "else", "{", "$", "this", "->", "sendData", "(", "'HELO '", ".", "$", "this", "->", "senderHost", ")", ";", "}", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "response", ")", "!==", "'250'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"HELO/EHLO failed with error: {$response}.\"", ")", ";", "}", "// do authentication", "if", "(", "$", "this", "->", "doAuthenticate", ")", "{", "if", "(", "$", "this", "->", "options", "->", "preferredAuthMethod", "!==", "self", "::", "AUTH_AUTO", ")", "{", "$", "this", "->", "auth", "(", "$", "this", "->", "options", "->", "preferredAuthMethod", ")", ";", "}", "else", "{", "preg_match", "(", "\"/250-AUTH[= ](.*)/\"", ",", "$", "response", ",", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "$", "methods", "=", "explode", "(", "' '", ",", "trim", "(", "$", "matches", "[", "1", "]", ")", ")", ";", "}", "if", "(", "count", "(", "$", "matches", ")", "===", "0", "||", "count", "(", "$", "methods", ")", "===", "0", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept the AUTH command.'", ")", ";", "}", "$", "authenticated", "=", "false", ";", "$", "methods", "=", "$", "this", "->", "sortAuthMethods", "(", "$", "methods", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "$", "this", "->", "auth", "(", "$", "method", ")", "===", "true", ")", "{", "$", "authenticated", "=", "true", ";", "break", ";", "}", "}", "if", "(", "$", "authenticated", "===", "false", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not respond correctly to any of the authentication methods '", ".", "implode", "(", "', '", ",", "$", "methods", ")", ".", "'.'", ")", ";", "}", "}", "}", "$", "this", "->", "status", "=", "self", "::", "STATUS_AUTHENTICATED", ";", "}" ]
Performs the initial handshake with the SMTP server and authenticates the user, if login data is provided to the constructor. @throws ezcMailTransportSmtpException if the HELO/EHLO command or authentication fails
[ "Performs", "the", "initial", "handshake", "with", "the", "SMTP", "server", "and", "authenticates", "the", "user", "if", "login", "data", "is", "provided", "to", "the", "constructor", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L579-L632
20,823
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authCramMd5
protected function authCramMd5() { $this->sendData( 'AUTH CRAM-MD5' ); if ( $this->getReplyCode( $response ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH CRAM-MD5.' ); } $serverDigest = trim( substr( $response, 4 ) ); $clientDigest = hash_hmac( 'md5', base64_decode( $serverDigest ), $this->password ); $login = base64_encode( "{$this->user} {$clientDigest}" ); $this->sendData( $login ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authCramMd5() { $this->sendData( 'AUTH CRAM-MD5' ); if ( $this->getReplyCode( $response ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH CRAM-MD5.' ); } $serverDigest = trim( substr( $response, 4 ) ); $clientDigest = hash_hmac( 'md5', base64_decode( $serverDigest ), $this->password ); $login = base64_encode( "{$this->user} {$clientDigest}" ); $this->sendData( $login ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authCramMd5", "(", ")", "{", "$", "this", "->", "sendData", "(", "'AUTH CRAM-MD5'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "response", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH CRAM-MD5.'", ")", ";", "}", "$", "serverDigest", "=", "trim", "(", "substr", "(", "$", "response", ",", "4", ")", ")", ";", "$", "clientDigest", "=", "hash_hmac", "(", "'md5'", ",", "base64_decode", "(", "$", "serverDigest", ")", ",", "$", "this", "->", "password", ")", ";", "$", "login", "=", "base64_encode", "(", "\"{$this->user} {$clientDigest}\"", ")", ";", "$", "this", "->", "sendData", "(", "$", "login", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH CRAM-MD5' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "CRAM", "-", "MD5", "and", "returns", "true", "if", "successful", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L828-L847
20,824
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlm
protected function authNtlm() { if ( !ezcBaseFeatures::hasExtensionSupport( 'mcrypt' ) ) { throw new ezcBaseExtensionNotFoundException( 'mcrypt', null, "PHP not compiled with --with-mcrypt." ); } // Send NTLM type 1 message $msg1 = base64_encode( $this->authNtlmMessageType1( $this->senderHost, $this->serverHost ) ); $this->sendData( "AUTH NTLM {$msg1}" ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH NTLM.' ); } // Parse NTLM type 2 message $msg2 = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = array( substr( $msg2, 0, 8 ), // Signature ("NTLMSSP\0") substr( $msg2, 8, 4 ), // Message type substr( $msg2, 12, 8 ), // Target name (security buffer) substr( $msg2, 20, 4 ), // Flags substr( $msg2, 24, 8 ), // Challenge substr( $msg2, 32 ) // The rest of information ); $challenge = $parts[4]; // Send NTLM type 3 message $msg3 = base64_encode( $this->authNtlmMessageType3( $challenge, $this->user, $this->password, $this->senderHost, $this->serverHost ) ); $this->sendData( $msg3 ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow NTLM authentication.' ); } }
php
protected function authNtlm() { if ( !ezcBaseFeatures::hasExtensionSupport( 'mcrypt' ) ) { throw new ezcBaseExtensionNotFoundException( 'mcrypt', null, "PHP not compiled with --with-mcrypt." ); } // Send NTLM type 1 message $msg1 = base64_encode( $this->authNtlmMessageType1( $this->senderHost, $this->serverHost ) ); $this->sendData( "AUTH NTLM {$msg1}" ); if ( $this->getReplyCode( $serverResponse ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH NTLM.' ); } // Parse NTLM type 2 message $msg2 = base64_decode( trim( substr( $serverResponse, 4 ) ) ); $parts = array( substr( $msg2, 0, 8 ), // Signature ("NTLMSSP\0") substr( $msg2, 8, 4 ), // Message type substr( $msg2, 12, 8 ), // Target name (security buffer) substr( $msg2, 20, 4 ), // Flags substr( $msg2, 24, 8 ), // Challenge substr( $msg2, 32 ) // The rest of information ); $challenge = $parts[4]; // Send NTLM type 3 message $msg3 = base64_encode( $this->authNtlmMessageType3( $challenge, $this->user, $this->password, $this->senderHost, $this->serverHost ) ); $this->sendData( $msg3 ); if ( $this->getReplyCode( $serverResponse ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not allow NTLM authentication.' ); } }
[ "protected", "function", "authNtlm", "(", ")", "{", "if", "(", "!", "ezcBaseFeatures", "::", "hasExtensionSupport", "(", "'mcrypt'", ")", ")", "{", "throw", "new", "ezcBaseExtensionNotFoundException", "(", "'mcrypt'", ",", "null", ",", "\"PHP not compiled with --with-mcrypt.\"", ")", ";", "}", "// Send NTLM type 1 message", "$", "msg1", "=", "base64_encode", "(", "$", "this", "->", "authNtlmMessageType1", "(", "$", "this", "->", "senderHost", ",", "$", "this", "->", "serverHost", ")", ")", ";", "$", "this", "->", "sendData", "(", "\"AUTH NTLM {$msg1}\"", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH NTLM.'", ")", ";", "}", "// Parse NTLM type 2 message", "$", "msg2", "=", "base64_decode", "(", "trim", "(", "substr", "(", "$", "serverResponse", ",", "4", ")", ")", ")", ";", "$", "parts", "=", "array", "(", "substr", "(", "$", "msg2", ",", "0", ",", "8", ")", ",", "// Signature (\"NTLMSSP\\0\")", "substr", "(", "$", "msg2", ",", "8", ",", "4", ")", ",", "// Message type", "substr", "(", "$", "msg2", ",", "12", ",", "8", ")", ",", "// Target name (security buffer)", "substr", "(", "$", "msg2", ",", "20", ",", "4", ")", ",", "// Flags", "substr", "(", "$", "msg2", ",", "24", ",", "8", ")", ",", "// Challenge", "substr", "(", "$", "msg2", ",", "32", ")", "// The rest of information", ")", ";", "$", "challenge", "=", "$", "parts", "[", "4", "]", ";", "// Send NTLM type 3 message", "$", "msg3", "=", "base64_encode", "(", "$", "this", "->", "authNtlmMessageType3", "(", "$", "challenge", ",", "$", "this", "->", "user", ",", "$", "this", "->", "password", ",", "$", "this", "->", "senderHost", ",", "$", "this", "->", "serverHost", ")", ")", ";", "$", "this", "->", "sendData", "(", "$", "msg3", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "serverResponse", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not allow NTLM authentication.'", ")", ";", "}", "}" ]
Tries to login to the SMTP server with 'AUTH NTLM' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "NTLM", "and", "returns", "true", "if", "successful", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L857-L894
20,825
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authLogin
protected function authLogin() { $this->sendData( 'AUTH LOGIN' ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH LOGIN.' ); } $this->sendData( base64_encode( $this->user ) ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( "SMTP server did not accept login: {$this->user}." ); } $this->sendData( base64_encode( $this->password ) ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authLogin() { $this->sendData( 'AUTH LOGIN' ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH LOGIN.' ); } $this->sendData( base64_encode( $this->user ) ); if ( $this->getReplyCode( $error ) !== '334' ) { throw new ezcMailTransportSmtpException( "SMTP server did not accept login: {$this->user}." ); } $this->sendData( base64_encode( $this->password ) ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authLogin", "(", ")", "{", "$", "this", "->", "sendData", "(", "'AUTH LOGIN'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server does not accept AUTH LOGIN.'", ")", ";", "}", "$", "this", "->", "sendData", "(", "base64_encode", "(", "$", "this", "->", "user", ")", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'334'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"SMTP server did not accept login: {$this->user}.\"", ")", ";", "}", "$", "this", "->", "sendData", "(", "base64_encode", "(", "$", "this", "->", "password", ")", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH LOGIN' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "LOGIN", "and", "returns", "true", "if", "successful", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L904-L925
20,826
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authPlain
protected function authPlain() { $digest = base64_encode( "\0{$this->user}\0{$this->password}" ); $this->sendData( "AUTH PLAIN {$digest}" ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
php
protected function authPlain() { $digest = base64_encode( "\0{$this->user}\0{$this->password}" ); $this->sendData( "AUTH PLAIN {$digest}" ); if ( $this->getReplyCode( $error ) !== '235' ) { throw new ezcMailTransportSmtpException( 'SMTP server did not accept the provided username and password.' ); } return true; }
[ "protected", "function", "authPlain", "(", ")", "{", "$", "digest", "=", "base64_encode", "(", "\"\\0{$this->user}\\0{$this->password}\"", ")", ";", "$", "this", "->", "sendData", "(", "\"AUTH PLAIN {$digest}\"", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'235'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "'SMTP server did not accept the provided username and password.'", ")", ";", "}", "return", "true", ";", "}" ]
Tries to login to the SMTP server with 'AUTH PLAIN' and returns true if successful. @throws ezcMailTransportSmtpException if the SMTP server returned an error @return bool
[ "Tries", "to", "login", "to", "the", "SMTP", "server", "with", "AUTH", "PLAIN", "and", "returns", "true", "if", "successful", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L935-L945
20,827
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.disconnect
public function disconnect() { if ( $this->status != self::STATUS_NOT_CONNECTED ) { $this->sendData( 'QUIT' ); $replyCode = $this->getReplyCode( $error ) !== '221'; fclose( $this->connection ); $this->status = self::STATUS_NOT_CONNECTED; if ( $replyCode ) { throw new ezcMailTransportSmtpException( "QUIT failed with error: $error." ); } } }
php
public function disconnect() { if ( $this->status != self::STATUS_NOT_CONNECTED ) { $this->sendData( 'QUIT' ); $replyCode = $this->getReplyCode( $error ) !== '221'; fclose( $this->connection ); $this->status = self::STATUS_NOT_CONNECTED; if ( $replyCode ) { throw new ezcMailTransportSmtpException( "QUIT failed with error: $error." ); } } }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "status", "!=", "self", "::", "STATUS_NOT_CONNECTED", ")", "{", "$", "this", "->", "sendData", "(", "'QUIT'", ")", ";", "$", "replyCode", "=", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'221'", ";", "fclose", "(", "$", "this", "->", "connection", ")", ";", "$", "this", "->", "status", "=", "self", "::", "STATUS_NOT_CONNECTED", ";", "if", "(", "$", "replyCode", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"QUIT failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the QUIT command to the server and breaks the connection. @throws ezcMailTransportSmtpException if the QUIT command failed
[ "Sends", "the", "QUIT", "command", "to", "the", "server", "and", "breaks", "the", "connection", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L953-L966
20,828
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.cmdData
protected function cmdData() { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'DATA' ); if ( $this->getReplyCode( $error ) !== '354' ) { throw new ezcMailTransportSmtpException( "DATA failed with error: $error." ); } } }
php
protected function cmdData() { if ( $this->status === self::STATUS_AUTHENTICATED ) { $this->sendData( 'DATA' ); if ( $this->getReplyCode( $error ) !== '354' ) { throw new ezcMailTransportSmtpException( "DATA failed with error: $error." ); } } }
[ "protected", "function", "cmdData", "(", ")", "{", "if", "(", "$", "this", "->", "status", "===", "self", "::", "STATUS_AUTHENTICATED", ")", "{", "$", "this", "->", "sendData", "(", "'DATA'", ")", ";", "if", "(", "$", "this", "->", "getReplyCode", "(", "$", "error", ")", "!==", "'354'", ")", "{", "throw", "new", "ezcMailTransportSmtpException", "(", "\"DATA failed with error: $error.\"", ")", ";", "}", "}", "}" ]
Sends the DATA command to the SMTP server. @throws ezcMailTransportSmtpException if there is no valid connection or if the DATA command failed
[ "Sends", "the", "DATA", "command", "to", "the", "SMTP", "server", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1043-L1053
20,829
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.getData
protected function getData() { $data = ''; $line = ''; $loops = 0; if ( is_resource( $this->connection ) ) { while ( ( strpos( $data, self::CRLF ) === false || (string) substr( $line, 3, 1 ) !== ' ' ) && $loops < 100 ) { $line = fgets( $this->connection, 512 ); $data .= $line; $loops++; } return $data; } throw new ezcMailTransportSmtpException( 'Could not read from SMTP stream. It was probably terminated by the host.' ); }
php
protected function getData() { $data = ''; $line = ''; $loops = 0; if ( is_resource( $this->connection ) ) { while ( ( strpos( $data, self::CRLF ) === false || (string) substr( $line, 3, 1 ) !== ' ' ) && $loops < 100 ) { $line = fgets( $this->connection, 512 ); $data .= $line; $loops++; } return $data; } throw new ezcMailTransportSmtpException( 'Could not read from SMTP stream. It was probably terminated by the host.' ); }
[ "protected", "function", "getData", "(", ")", "{", "$", "data", "=", "''", ";", "$", "line", "=", "''", ";", "$", "loops", "=", "0", ";", "if", "(", "is_resource", "(", "$", "this", "->", "connection", ")", ")", "{", "while", "(", "(", "strpos", "(", "$", "data", ",", "self", "::", "CRLF", ")", "===", "false", "||", "(", "string", ")", "substr", "(", "$", "line", ",", "3", ",", "1", ")", "!==", "' '", ")", "&&", "$", "loops", "<", "100", ")", "{", "$", "line", "=", "fgets", "(", "$", "this", "->", "connection", ",", "512", ")", ";", "$", "data", ".=", "$", "line", ";", "$", "loops", "++", ";", "}", "return", "$", "data", ";", "}", "throw", "new", "ezcMailTransportSmtpException", "(", "'Could not read from SMTP stream. It was probably terminated by the host.'", ")", ";", "}" ]
Returns data received from the connection stream. @throws ezcMailTransportSmtpException if there is no valid connection @return string
[ "Returns", "data", "received", "from", "the", "connection", "stream", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1083-L1100
20,830
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmMessageType1
protected function authNtlmMessageType1( $workstation, $domain ) { $parts = array( "NTLMSSP\x00", "\x01\x00\x00\x00", "\x07\x32\x00\x00", $this->authNtlmSecurityBuffer( $domain, 32 + strlen( $workstation ) ), $this->authNtlmSecurityBuffer( $workstation, 32 ), $workstation, $domain ); return implode( "", $parts ); }
php
protected function authNtlmMessageType1( $workstation, $domain ) { $parts = array( "NTLMSSP\x00", "\x01\x00\x00\x00", "\x07\x32\x00\x00", $this->authNtlmSecurityBuffer( $domain, 32 + strlen( $workstation ) ), $this->authNtlmSecurityBuffer( $workstation, 32 ), $workstation, $domain ); return implode( "", $parts ); }
[ "protected", "function", "authNtlmMessageType1", "(", "$", "workstation", ",", "$", "domain", ")", "{", "$", "parts", "=", "array", "(", "\"NTLMSSP\\x00\"", ",", "\"\\x01\\x00\\x00\\x00\"", ",", "\"\\x07\\x32\\x00\\x00\"", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "domain", ",", "32", "+", "strlen", "(", "$", "workstation", ")", ")", ",", "$", "this", "->", "authNtlmSecurityBuffer", "(", "$", "workstation", ",", "32", ")", ",", "$", "workstation", ",", "$", "domain", ")", ";", "return", "implode", "(", "\"\"", ",", "$", "parts", ")", ";", "}" ]
Generates an NTLM type 1 message. @param string $workstation @param string $domain @return string
[ "Generates", "an", "NTLM", "type", "1", "message", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1145-L1158
20,831
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmResponse
protected function authNtlmResponse( $challenge, $password ) { $password = chunk_split( $password, 1, "\x00" ); $password = hash( 'md4', $password, true ); $password .= str_repeat( "\x00", 21 - strlen( $password ) ); $td = mcrypt_module_open( 'des', '', 'ecb', '' ); $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND ); $response = ''; for ( $i = 0; $i < 21; $i += 7 ) { $packed = ''; for ( $p = $i; $p < $i + 7; $p++ ) { $packed .= str_pad( decbin( ord( substr( $password, $p, 1 ) ) ), 8, '0', STR_PAD_LEFT ); } $key = ''; for ( $p = 0; $p < strlen( $packed ); $p += 7 ) { $s = substr( $packed, $p, 7 ); $b = $s . ( ( substr_count( $s, '1' ) % 2 ) ? '0' : '1' ); $key .= chr( bindec( $b ) ); } mcrypt_generic_init( $td, $key, $iv ); $response .= mcrypt_generic( $td, $challenge ); mcrypt_generic_deinit( $td ); } mcrypt_module_close( $td ); return $response; }
php
protected function authNtlmResponse( $challenge, $password ) { $password = chunk_split( $password, 1, "\x00" ); $password = hash( 'md4', $password, true ); $password .= str_repeat( "\x00", 21 - strlen( $password ) ); $td = mcrypt_module_open( 'des', '', 'ecb', '' ); $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND ); $response = ''; for ( $i = 0; $i < 21; $i += 7 ) { $packed = ''; for ( $p = $i; $p < $i + 7; $p++ ) { $packed .= str_pad( decbin( ord( substr( $password, $p, 1 ) ) ), 8, '0', STR_PAD_LEFT ); } $key = ''; for ( $p = 0; $p < strlen( $packed ); $p += 7 ) { $s = substr( $packed, $p, 7 ); $b = $s . ( ( substr_count( $s, '1' ) % 2 ) ? '0' : '1' ); $key .= chr( bindec( $b ) ); } mcrypt_generic_init( $td, $key, $iv ); $response .= mcrypt_generic( $td, $challenge ); mcrypt_generic_deinit( $td ); } mcrypt_module_close( $td ); return $response; }
[ "protected", "function", "authNtlmResponse", "(", "$", "challenge", ",", "$", "password", ")", "{", "$", "password", "=", "chunk_split", "(", "$", "password", ",", "1", ",", "\"\\x00\"", ")", ";", "$", "password", "=", "hash", "(", "'md4'", ",", "$", "password", ",", "true", ")", ";", "$", "password", ".=", "str_repeat", "(", "\"\\x00\"", ",", "21", "-", "strlen", "(", "$", "password", ")", ")", ";", "$", "td", "=", "mcrypt_module_open", "(", "'des'", ",", "''", ",", "'ecb'", ",", "''", ")", ";", "$", "iv", "=", "mcrypt_create_iv", "(", "mcrypt_enc_get_iv_size", "(", "$", "td", ")", ",", "MCRYPT_RAND", ")", ";", "$", "response", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "21", ";", "$", "i", "+=", "7", ")", "{", "$", "packed", "=", "''", ";", "for", "(", "$", "p", "=", "$", "i", ";", "$", "p", "<", "$", "i", "+", "7", ";", "$", "p", "++", ")", "{", "$", "packed", ".=", "str_pad", "(", "decbin", "(", "ord", "(", "substr", "(", "$", "password", ",", "$", "p", ",", "1", ")", ")", ")", ",", "8", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}", "$", "key", "=", "''", ";", "for", "(", "$", "p", "=", "0", ";", "$", "p", "<", "strlen", "(", "$", "packed", ")", ";", "$", "p", "+=", "7", ")", "{", "$", "s", "=", "substr", "(", "$", "packed", ",", "$", "p", ",", "7", ")", ";", "$", "b", "=", "$", "s", ".", "(", "(", "substr_count", "(", "$", "s", ",", "'1'", ")", "%", "2", ")", "?", "'0'", ":", "'1'", ")", ";", "$", "key", ".=", "chr", "(", "bindec", "(", "$", "b", ")", ")", ";", "}", "mcrypt_generic_init", "(", "$", "td", ",", "$", "key", ",", "$", "iv", ")", ";", "$", "response", ".=", "mcrypt_generic", "(", "$", "td", ",", "$", "challenge", ")", ";", "mcrypt_generic_deinit", "(", "$", "td", ")", ";", "}", "mcrypt_module_close", "(", "$", "td", ")", ";", "return", "$", "response", ";", "}" ]
Calculates an NTLM response to be used in the creation of the NTLM type 3 message. @param string $challenge @param string $password @return string
[ "Calculates", "an", "NTLM", "response", "to", "be", "used", "in", "the", "creation", "of", "the", "NTLM", "type", "3", "message", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1215-L1248
20,832
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php
ezcMailSmtpTransport.authNtlmSecurityBuffer
protected function authNtlmSecurityBuffer( $text, $offset ) { return pack( 'v', strlen( $text ) ) . pack( 'v', strlen( $text ) ) . pack( 'V', $offset ); }
php
protected function authNtlmSecurityBuffer( $text, $offset ) { return pack( 'v', strlen( $text ) ) . pack( 'v', strlen( $text ) ) . pack( 'V', $offset ); }
[ "protected", "function", "authNtlmSecurityBuffer", "(", "$", "text", ",", "$", "offset", ")", "{", "return", "pack", "(", "'v'", ",", "strlen", "(", "$", "text", ")", ")", ".", "pack", "(", "'v'", ",", "strlen", "(", "$", "text", ")", ")", ".", "pack", "(", "'V'", ",", "$", "offset", ")", ";", "}" ]
Creates an NTLM security buffer information string. The structure of the security buffer is: - a short containing the length of the buffer content in bytes (may be zero). - a short containing the allocated space for the buffer in bytes (greater than or equal to the length; typically the same as the length). - a long containing the offset to the start of the buffer in bytes (from the beginning of the NTLM message). Example: - buffer content length: 1234 bytes (0xd204 in hexa) - allocated space: 1234 bytes( 0xd204 in hexa) - offset: 4321 bytes (0xe1100000 in hexa) then the security buffer would be 0xd204d204e1100000 (in hexa). @param string $text @param int $offset @return string
[ "Creates", "an", "NTLM", "security", "buffer", "information", "string", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/smtp/smtp_transport.php#L1272-L1277
20,833
surebert/surebert-framework
src/sb/Excel/Reader/HTML.php
HTML.hyperlink
public function hyperlink($row, $col, $sheet=0) { $link = isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink']) ? $this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink'] : false; if ($link) { return $link['link']; } return ''; }
php
public function hyperlink($row, $col, $sheet=0) { $link = isset($this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink']) ? $this->sheets[$sheet]['cellsInfo'][$row][$col]['hyperlink'] : false; if ($link) { return $link['link']; } return ''; }
[ "public", "function", "hyperlink", "(", "$", "row", ",", "$", "col", ",", "$", "sheet", "=", "0", ")", "{", "$", "link", "=", "isset", "(", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'hyperlink'", "]", ")", "?", "$", "this", "->", "sheets", "[", "$", "sheet", "]", "[", "'cellsInfo'", "]", "[", "$", "row", "]", "[", "$", "col", "]", "[", "'hyperlink'", "]", ":", "false", ";", "if", "(", "$", "link", ")", "{", "return", "$", "link", "[", "'link'", "]", ";", "}", "return", "''", ";", "}" ]
get hyperlink if cell is hyperlinked @param int $row @param int $col @param int $sheet @return string
[ "get", "hyperlink", "if", "cell", "is", "hyperlinked" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Reader/HTML.php#L107-L114
20,834
JBZoo/Assets
src/Collection.php
Collection.remove
public function remove($name) { $names = (array)$name; foreach ($names as $name) { if (Arr::key($name, $this->_assets)) { unset($this->_assets[$name]); } } }
php
public function remove($name) { $names = (array)$name; foreach ($names as $name) { if (Arr::key($name, $this->_assets)) { unset($this->_assets[$name]); } } }
[ "public", "function", "remove", "(", "$", "name", ")", "{", "$", "names", "=", "(", "array", ")", "$", "name", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "Arr", "::", "key", "(", "$", "name", ",", "$", "this", "->", "_assets", ")", ")", "{", "unset", "(", "$", "this", "->", "_assets", "[", "$", "name", "]", ")", ";", "}", "}", "}" ]
Removes assets from collection. @param string|array $name @return void
[ "Removes", "assets", "from", "collection", "." ]
134a109378f5b5e955dfb15e6ed2821581564991
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Collection.php#L82-L91
20,835
wilmoore/attributes.php
src/Attributes.php
Attributes.resetChangeHistory
function resetChangeHistory($attribute) { if ($this->propertyExists($attribute, 'changes')) { $this->setPropertyFor($attribute, 'changes', [], null, false); } return $this; }
php
function resetChangeHistory($attribute) { if ($this->propertyExists($attribute, 'changes')) { $this->setPropertyFor($attribute, 'changes', [], null, false); } return $this; }
[ "function", "resetChangeHistory", "(", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "propertyExists", "(", "$", "attribute", ",", "'changes'", ")", ")", "{", "$", "this", "->", "setPropertyFor", "(", "$", "attribute", ",", "'changes'", ",", "[", "]", ",", "null", ",", "false", ")", ";", "}", "return", "$", "this", ";", "}" ]
`resetChangeHistory` clears the change history for an attribute @param string $attribute attribute name @return $this
[ "resetChangeHistory", "clears", "the", "change", "history", "for", "an", "attribute" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L48-L54
20,836
wilmoore/attributes.php
src/Attributes.php
Attributes.propertyExists
function propertyExists($attribute, $property) { return array_key_exists($attribute, $this->__attributes) && array_key_exists($property, $this->__attributes[$attribute]); }
php
function propertyExists($attribute, $property) { return array_key_exists($attribute, $this->__attributes) && array_key_exists($property, $this->__attributes[$attribute]); }
[ "function", "propertyExists", "(", "$", "attribute", ",", "$", "property", ")", "{", "return", "array_key_exists", "(", "$", "attribute", ",", "$", "this", "->", "__attributes", ")", "&&", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", ")", ";", "}" ]
`propertyExists` determines if an attribute property has been set. @param string $attribute attribute name @param string $property property name @api public @return boolean
[ "propertyExists", "determines", "if", "an", "attribute", "property", "has", "been", "set", "." ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L79-L82
20,837
wilmoore/attributes.php
src/Attributes.php
Attributes.get
function get($name, $default=null) { $map = array_map(function($name) use($default){ if ($this->__isset($name)) { return $this->__attributes[$name]['value']; } elseif ($this->propertyExists($name, 'default')) { return $this->__attributes[$name]['default']; } return (null === $default) ? null : $default; }, (array) $name); return count($map) > 1 ? $map : $map[0]; }
php
function get($name, $default=null) { $map = array_map(function($name) use($default){ if ($this->__isset($name)) { return $this->__attributes[$name]['value']; } elseif ($this->propertyExists($name, 'default')) { return $this->__attributes[$name]['default']; } return (null === $default) ? null : $default; }, (array) $name); return count($map) > 1 ? $map : $map[0]; }
[ "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "map", "=", "array_map", "(", "function", "(", "$", "name", ")", "use", "(", "$", "default", ")", "{", "if", "(", "$", "this", "->", "__isset", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "__attributes", "[", "$", "name", "]", "[", "'value'", "]", ";", "}", "elseif", "(", "$", "this", "->", "propertyExists", "(", "$", "name", ",", "'default'", ")", ")", "{", "return", "$", "this", "->", "__attributes", "[", "$", "name", "]", "[", "'default'", "]", ";", "}", "return", "(", "null", "===", "$", "default", ")", "?", "null", ":", "$", "default", ";", "}", ",", "(", "array", ")", "$", "name", ")", ";", "return", "count", "(", "$", "map", ")", ">", "1", "?", "$", "map", ":", "$", "map", "[", "0", "]", ";", "}" ]
`get` returns attributes value or, if attribute value is null, returns default value if given @param string $name attribute name @param mixed $default [optional] default return value @return mixed
[ "get", "returns", "attributes", "value", "or", "if", "attribute", "value", "is", "null", "returns", "default", "value", "if", "given" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L109-L121
20,838
wilmoore/attributes.php
src/Attributes.php
Attributes.set
function set($attribute, $value = null) { $attributes = is_array($attribute) ? $attribute : [$attribute => $value]; foreach ($attributes as $attr => $val) { if ($this->getPropertyFor($attr, 'accepts')) { $acceptsConstraint = new Attributes\Constraint\Accepts($this->getPropertyFor($attr, 'accepts')); if (!$acceptsConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'minimum')) { $minimumConstraint = new Attributes\Constraint\Minimum($this->getPropertyFor($attr, 'minimum')); if (!$minimumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'maximum')) { $maximumConstraint = new Attributes\Constraint\Maximum($this->getPropertyFor($attr, 'maximum')); if (!$maximumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } $this->setPropertyFor($attr, 'value', $val, 'set'); } return $this; }
php
function set($attribute, $value = null) { $attributes = is_array($attribute) ? $attribute : [$attribute => $value]; foreach ($attributes as $attr => $val) { if ($this->getPropertyFor($attr, 'accepts')) { $acceptsConstraint = new Attributes\Constraint\Accepts($this->getPropertyFor($attr, 'accepts')); if (!$acceptsConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'minimum')) { $minimumConstraint = new Attributes\Constraint\Minimum($this->getPropertyFor($attr, 'minimum')); if (!$minimumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } if ($this->getPropertyFor($attr, 'maximum')) { $maximumConstraint = new Attributes\Constraint\Maximum($this->getPropertyFor($attr, 'maximum')); if (!$maximumConstraint->isValid($val)) { throw new InvalidArgumentException(__CLASS__ . " does not accept {$val} as value for the property {$attr}"); } } $this->setPropertyFor($attr, 'value', $val, 'set'); } return $this; }
[ "function", "set", "(", "$", "attribute", ",", "$", "value", "=", "null", ")", "{", "$", "attributes", "=", "is_array", "(", "$", "attribute", ")", "?", "$", "attribute", ":", "[", "$", "attribute", "=>", "$", "value", "]", ";", "foreach", "(", "$", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'accepts'", ")", ")", "{", "$", "acceptsConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Accepts", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'accepts'", ")", ")", ";", "if", "(", "!", "$", "acceptsConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'minimum'", ")", ")", "{", "$", "minimumConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Minimum", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'minimum'", ")", ")", ";", "if", "(", "!", "$", "minimumConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "if", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'maximum'", ")", ")", "{", "$", "maximumConstraint", "=", "new", "Attributes", "\\", "Constraint", "\\", "Maximum", "(", "$", "this", "->", "getPropertyFor", "(", "$", "attr", ",", "'maximum'", ")", ")", ";", "if", "(", "!", "$", "maximumConstraint", "->", "isValid", "(", "$", "val", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__CLASS__", ".", "\" does not accept {$val} as value for the property {$attr}\"", ")", ";", "}", "}", "$", "this", "->", "setPropertyFor", "(", "$", "attr", ",", "'value'", ",", "$", "val", ",", "'set'", ")", ";", "}", "return", "$", "this", ";", "}" ]
`set` attributes value @param string $attribute attribute name @param mixed $value attribute value @return $this
[ "set", "attributes", "value" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L144-L176
20,839
wilmoore/attributes.php
src/Attributes.php
Attributes.push
function push($attribute, $value) { if (! $this->has($attribute)) { return $this; } $new = $this->get($attribute); if (! is_array($new) && !$new instanceof Traversable) { return $this; } $new[] = $value; $this->setPropertyFor($attribute, 'value', $new, 'push'); return $this; }
php
function push($attribute, $value) { if (! $this->has($attribute)) { return $this; } $new = $this->get($attribute); if (! is_array($new) && !$new instanceof Traversable) { return $this; } $new[] = $value; $this->setPropertyFor($attribute, 'value', $new, 'push'); return $this; }
[ "function", "push", "(", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "return", "$", "this", ";", "}", "$", "new", "=", "$", "this", "->", "get", "(", "$", "attribute", ")", ";", "if", "(", "!", "is_array", "(", "$", "new", ")", "&&", "!", "$", "new", "instanceof", "Traversable", ")", "{", "return", "$", "this", ";", "}", "$", "new", "[", "]", "=", "$", "value", ";", "$", "this", "->", "setPropertyFor", "(", "$", "attribute", ",", "'value'", ",", "$", "new", ",", "'push'", ")", ";", "return", "$", "this", ";", "}" ]
`push` a new value onto end of array @param string $attribute attribute name @param mixed $value attribute value @return $this
[ "push", "a", "new", "value", "onto", "end", "of", "array" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L187-L202
20,840
wilmoore/attributes.php
src/Attributes.php
Attributes.getPropertyFor
private function getPropertyFor($attribute, $property) { return $this->propertyExists($attribute, $property) ? $this->__attributes[$attribute][$property] : null; }
php
private function getPropertyFor($attribute, $property) { return $this->propertyExists($attribute, $property) ? $this->__attributes[$attribute][$property] : null; }
[ "private", "function", "getPropertyFor", "(", "$", "attribute", ",", "$", "property", ")", "{", "return", "$", "this", "->", "propertyExists", "(", "$", "attribute", ",", "$", "property", ")", "?", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "$", "property", "]", ":", "null", ";", "}" ]
`getPropertyFor` returns an attribute property by name @param string $attribute attribute name @param string $property property name @return boolean
[ "getPropertyFor", "returns", "an", "attribute", "property", "by", "name" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L239-L243
20,841
wilmoore/attributes.php
src/Attributes.php
Attributes.setPropertyFor
private function setPropertyFor($attribute, $property, $value, $action, $changeTracking = true) { if (! $this->has($attribute)) {return;} if ($changeTracking) { $this->__attributes[$attribute]['changes'][] = [ 'action' => $action, 'from' => $this->get($attribute), 'to' => $value, 'when' => new DateTime('now', new DateTimezone('UTC')) ]; } $this->__attributes[$attribute][$property] = $value; }
php
private function setPropertyFor($attribute, $property, $value, $action, $changeTracking = true) { if (! $this->has($attribute)) {return;} if ($changeTracking) { $this->__attributes[$attribute]['changes'][] = [ 'action' => $action, 'from' => $this->get($attribute), 'to' => $value, 'when' => new DateTime('now', new DateTimezone('UTC')) ]; } $this->__attributes[$attribute][$property] = $value; }
[ "private", "function", "setPropertyFor", "(", "$", "attribute", ",", "$", "property", ",", "$", "value", ",", "$", "action", ",", "$", "changeTracking", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "attribute", ")", ")", "{", "return", ";", "}", "if", "(", "$", "changeTracking", ")", "{", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "'changes'", "]", "[", "]", "=", "[", "'action'", "=>", "$", "action", ",", "'from'", "=>", "$", "this", "->", "get", "(", "$", "attribute", ")", ",", "'to'", "=>", "$", "value", ",", "'when'", "=>", "new", "DateTime", "(", "'now'", ",", "new", "DateTimezone", "(", "'UTC'", ")", ")", "]", ";", "}", "$", "this", "->", "__attributes", "[", "$", "attribute", "]", "[", "$", "property", "]", "=", "$", "value", ";", "}" ]
`setPropertyFor` sets an attribute property value @param string $attribute attribute name @param string $property property name @param mixed $value property value @return boolean
[ "setPropertyFor", "sets", "an", "attribute", "property", "value" ]
d36de26a0d28c35d64ce9b3fc868572e39911ee7
https://github.com/wilmoore/attributes.php/blob/d36de26a0d28c35d64ce9b3fc868572e39911ee7/src/Attributes.php#L255-L268
20,842
barrelstrength/craftnet-php
src/PluginLicenses.php
PluginLicenses.get
public function get(array $options = []) { $pagination = ''; if (isset($options['page']) && is_int($options['page'])) { $pagination = '?page='.$options['page']; } if (isset($options['key'])) { return $this->client->get('plugin-licenses/'.$options['key'].$pagination); } return $this->client->get('plugin-licenses'.$pagination); }
php
public function get(array $options = []) { $pagination = ''; if (isset($options['page']) && is_int($options['page'])) { $pagination = '?page='.$options['page']; } if (isset($options['key'])) { return $this->client->get('plugin-licenses/'.$options['key'].$pagination); } return $this->client->get('plugin-licenses'.$pagination); }
[ "public", "function", "get", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "pagination", "=", "''", ";", "if", "(", "isset", "(", "$", "options", "[", "'page'", "]", ")", "&&", "is_int", "(", "$", "options", "[", "'page'", "]", ")", ")", "{", "$", "pagination", "=", "'?page='", ".", "$", "options", "[", "'page'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'key'", "]", ")", ")", "{", "return", "$", "this", "->", "client", "->", "get", "(", "'plugin-licenses/'", ".", "$", "options", "[", "'key'", "]", ".", "$", "pagination", ")", ";", "}", "return", "$", "this", "->", "client", "->", "get", "(", "'plugin-licenses'", ".", "$", "pagination", ")", ";", "}" ]
Gets one or more licenses for the given Craft ID account @param array $options @return mixed|\Psr\Http\Message\ResponseInterface @throws \GuzzleHttp\Exception\GuzzleException
[ "Gets", "one", "or", "more", "licenses", "for", "the", "given", "Craft", "ID", "account" ]
90c9767b6bef6078bc062b3bfcdde38b24c843fc
https://github.com/barrelstrength/craftnet-php/blob/90c9767b6bef6078bc062b3bfcdde38b24c843fc/src/PluginLicenses.php#L30-L43
20,843
phpnfe/tools
src/Certificado/Base.php
Base.pem2Der
protected static function pem2Der($pemData) { $begin = 'CERTIFICATE-----'; $end = '-----END'; //extrai o conteúdo do certificado entre as marcas BEGIN e END $pemData1 = substr($pemData, strpos($pemData, $begin) + strlen($begin)); $pemData2 = substr($pemData1, 0, strpos($pemData1, $end)); //converte o resultado para binário obtendo um certificado em formato DER $derData = base64_decode((string) $pemData2); return $derData; }
php
protected static function pem2Der($pemData) { $begin = 'CERTIFICATE-----'; $end = '-----END'; //extrai o conteúdo do certificado entre as marcas BEGIN e END $pemData1 = substr($pemData, strpos($pemData, $begin) + strlen($begin)); $pemData2 = substr($pemData1, 0, strpos($pemData1, $end)); //converte o resultado para binário obtendo um certificado em formato DER $derData = base64_decode((string) $pemData2); return $derData; }
[ "protected", "static", "function", "pem2Der", "(", "$", "pemData", ")", "{", "$", "begin", "=", "'CERTIFICATE-----'", ";", "$", "end", "=", "'-----END'", ";", "//extrai o conteúdo do certificado entre as marcas BEGIN e END", "$", "pemData1", "=", "substr", "(", "$", "pemData", ",", "strpos", "(", "$", "pemData", ",", "$", "begin", ")", "+", "strlen", "(", "$", "begin", ")", ")", ";", "$", "pemData2", "=", "substr", "(", "$", "pemData1", ",", "0", ",", "strpos", "(", "$", "pemData1", ",", "$", "end", ")", ")", ";", "//converte o resultado para binário obtendo um certificado em formato DER", "$", "derData", "=", "base64_decode", "(", "(", "string", ")", "$", "pemData2", ")", ";", "return", "$", "derData", ";", "}" ]
pem2Der Transforma o certificado do formato PEM para o formato DER. @param string $pem_data @return string
[ "pem2Der", "Transforma", "o", "certificado", "do", "formato", "PEM", "para", "o", "formato", "DER", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L12-L23
20,844
phpnfe/tools
src/Certificado/Base.php
Base.xBase128
protected static function xBase128($abIn, $qIn, $flag) { $abc = $abIn; if ($qIn > 127) { $abc = self::xBase128($abc, floor($qIn / 128), false); } $qIn2 = $qIn % 128; if ($flag) { $abc[] = $qIn2; } else { $abc[] = 0x80 | $qIn2; } return $abc; }
php
protected static function xBase128($abIn, $qIn, $flag) { $abc = $abIn; if ($qIn > 127) { $abc = self::xBase128($abc, floor($qIn / 128), false); } $qIn2 = $qIn % 128; if ($flag) { $abc[] = $qIn2; } else { $abc[] = 0x80 | $qIn2; } return $abc; }
[ "protected", "static", "function", "xBase128", "(", "$", "abIn", ",", "$", "qIn", ",", "$", "flag", ")", "{", "$", "abc", "=", "$", "abIn", ";", "if", "(", "$", "qIn", ">", "127", ")", "{", "$", "abc", "=", "self", "::", "xBase128", "(", "$", "abc", ",", "floor", "(", "$", "qIn", "/", "128", ")", ",", "false", ")", ";", "}", "$", "qIn2", "=", "$", "qIn", "%", "128", ";", "if", "(", "$", "flag", ")", "{", "$", "abc", "[", "]", "=", "$", "qIn2", ";", "}", "else", "{", "$", "abc", "[", "]", "=", "0x80", "|", "$", "qIn2", ";", "}", "return", "$", "abc", ";", "}" ]
xBase128 Retorna o dado convertido em asc. @param array $abIn @param int $qIn @param bool $flag @return int
[ "xBase128", "Retorna", "o", "dado", "convertido", "em", "asc", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L71-L85
20,845
phpnfe/tools
src/Certificado/Base.php
Base.printHex
protected static function printHex($value) { $tabVal = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; $hex = ''; for ($i = 0; $i < strlen($value); $i++) { $lsig = ord(substr($value, $i, 1)) % 16; $msig = (ord(substr($value, $i, 1)) - $lsig) / 16; $lessSig = $tabVal[$lsig]; $moreSig = $tabVal[$msig]; $hex .= $moreSig . $lessSig; } return $hex; }
php
protected static function printHex($value) { $tabVal = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; $hex = ''; for ($i = 0; $i < strlen($value); $i++) { $lsig = ord(substr($value, $i, 1)) % 16; $msig = (ord(substr($value, $i, 1)) - $lsig) / 16; $lessSig = $tabVal[$lsig]; $moreSig = $tabVal[$msig]; $hex .= $moreSig . $lessSig; } return $hex; }
[ "protected", "static", "function", "printHex", "(", "$", "value", ")", "{", "$", "tabVal", "=", "[", "'0'", ",", "'1'", ",", "'2'", ",", "'3'", ",", "'4'", ",", "'5'", ",", "'6'", ",", "'7'", ",", "'8'", ",", "'9'", ",", "'A'", ",", "'B'", ",", "'C'", ",", "'D'", ",", "'E'", ",", "'F'", "]", ";", "$", "hex", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "value", ")", ";", "$", "i", "++", ")", "{", "$", "lsig", "=", "ord", "(", "substr", "(", "$", "value", ",", "$", "i", ",", "1", ")", ")", "%", "16", ";", "$", "msig", "=", "(", "ord", "(", "substr", "(", "$", "value", ",", "$", "i", ",", "1", ")", ")", "-", "$", "lsig", ")", "/", "16", ";", "$", "lessSig", "=", "$", "tabVal", "[", "$", "lsig", "]", ";", "$", "moreSig", "=", "$", "tabVal", "[", "$", "msig", "]", ";", "$", "hex", ".=", "$", "moreSig", ".", "$", "lessSig", ";", "}", "return", "$", "hex", ";", "}" ]
Retorna o valor em caracteres hexadecimais. @param string $value @return string @return void
[ "Retorna", "o", "valor", "em", "caracteres", "hexadecimais", "." ]
303ca311989e0b345071f61b71d2b3bf7ee80454
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Base.php#L94-L107
20,846
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Controller/ModelManager.php
Aoe_Layout_Controller_ModelManager.editAction
public function editAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
php
public function editAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } if ($this->getRequest()->isPost()) { $postData = $this->getRequest()->getPost(); try { foreach ($this->preprocessPostData($postData) as $key => $value) { $model->setDataUsingMethod($key, $value); } $model->save(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Saved Successfully'); return; } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); } } $this->loadLayout(); $this->renderLayout(); }
[ "public", "function", "editAction", "(", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", ")", ";", "if", "(", "$", "model", "->", "isObjectNew", "(", ")", ")", "{", "$", "this", "->", "_forward", "(", "'noroute'", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "getRequest", "(", ")", "->", "isPost", "(", ")", ")", "{", "$", "postData", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "preprocessPostData", "(", "$", "postData", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "model", "->", "setDataUsingMethod", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "model", "->", "save", "(", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getGridUrl", "(", ")", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addSuccess", "(", "'Saved Successfully'", ")", ";", "return", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "Zend_Db_Statement_Exception", "&&", "$", "e", "->", "getChainedException", "(", ")", "instanceof", "PDOException", ")", "{", "$", "e", "=", "$", "e", "->", "getChainedException", "(", ")", ";", "}", "Mage", "::", "logException", "(", "$", "e", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "$", "this", "->", "loadLayout", "(", ")", ";", "$", "this", "->", "renderLayout", "(", ")", ";", "}" ]
Edit an existing record
[ "Edit", "an", "existing", "record" ]
d88ba3406cf12dbaf09548477133c3cb27d155ed
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/ModelManager.php#L51-L80
20,847
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Controller/ModelManager.php
Aoe_Layout_Controller_ModelManager.deleteAction
public function deleteAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } try { $model->delete(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Deleted Successfully'); } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); $this->_redirectUrl($this->getHelper()->getEditUrl($model)); } }
php
public function deleteAction() { $model = $this->loadModel(); if ($model->isObjectNew()) { $this->_forward('noroute'); return; } try { $model->delete(); $this->_redirectUrl($this->getHelper()->getGridUrl()); $this->_getSession()->addSuccess('Deleted Successfully'); } catch (Exception $e) { if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) { $e = $e->getChainedException(); } Mage::logException($e); $this->_getSession()->addError($e->getMessage()); $this->_redirectUrl($this->getHelper()->getEditUrl($model)); } }
[ "public", "function", "deleteAction", "(", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", ")", ";", "if", "(", "$", "model", "->", "isObjectNew", "(", ")", ")", "{", "$", "this", "->", "_forward", "(", "'noroute'", ")", ";", "return", ";", "}", "try", "{", "$", "model", "->", "delete", "(", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getGridUrl", "(", ")", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addSuccess", "(", "'Deleted Successfully'", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "Zend_Db_Statement_Exception", "&&", "$", "e", "->", "getChainedException", "(", ")", "instanceof", "PDOException", ")", "{", "$", "e", "=", "$", "e", "->", "getChainedException", "(", ")", ";", "}", "Mage", "::", "logException", "(", "$", "e", ")", ";", "$", "this", "->", "_getSession", "(", ")", "->", "addError", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "_redirectUrl", "(", "$", "this", "->", "getHelper", "(", ")", "->", "getEditUrl", "(", "$", "model", ")", ")", ";", "}", "}" ]
Delete an existing record
[ "Delete", "an", "existing", "record" ]
d88ba3406cf12dbaf09548477133c3cb27d155ed
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Controller/ModelManager.php#L85-L105
20,848
jeffturcotte/jest
src/Jest/Injector.php
Injector.invoke
public function invoke(Callable $callable) { $reflection = $this->reflectCallable($callable); $args = []; foreach($reflection->getParameters() as $param) { $type = $param->getClass()->getName(); if (in_array($type, $this->resolving)) { throw new \LogicException("Recursive dependency: $type is currently instatiating."); } $args[] = ($param->allowsNull() && !isset($this[$type])) ? null : $this[$type]; } return call_user_func_array($callable, $args); }
php
public function invoke(Callable $callable) { $reflection = $this->reflectCallable($callable); $args = []; foreach($reflection->getParameters() as $param) { $type = $param->getClass()->getName(); if (in_array($type, $this->resolving)) { throw new \LogicException("Recursive dependency: $type is currently instatiating."); } $args[] = ($param->allowsNull() && !isset($this[$type])) ? null : $this[$type]; } return call_user_func_array($callable, $args); }
[ "public", "function", "invoke", "(", "Callable", "$", "callable", ")", "{", "$", "reflection", "=", "$", "this", "->", "reflectCallable", "(", "$", "callable", ")", ";", "$", "args", "=", "[", "]", ";", "foreach", "(", "$", "reflection", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "type", "=", "$", "param", "->", "getClass", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "in_array", "(", "$", "type", ",", "$", "this", "->", "resolving", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Recursive dependency: $type is currently instatiating.\"", ")", ";", "}", "$", "args", "[", "]", "=", "(", "$", "param", "->", "allowsNull", "(", ")", "&&", "!", "isset", "(", "$", "this", "[", "$", "type", "]", ")", ")", "?", "null", ":", "$", "this", "[", "$", "type", "]", ";", "}", "return", "call_user_func_array", "(", "$", "callable", ",", "$", "args", ")", ";", "}" ]
Invoke a callable and injects dependencies @param $callable mixed The Closure or object to inject dependencies into @return mixed The value return from the callable
[ "Invoke", "a", "callable", "and", "injects", "dependencies" ]
1afab9a2939d0c3d977b3992563ca37e77f87c1f
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L55-L72
20,849
jeffturcotte/jest
src/Jest/Injector.php
Injector.offsetGet
public function offsetGet($class) { if (!isset($this->factories[$class]) && !isset($this->instances[$class])) { throw new \InvalidArgumentException("$class has not been defined"); } if (isset($this->instances[$class])) { return $this->instances[$class]; } array_push($this->resolving, $class); $object = $this->invoke($this->factories[$class]); array_pop($this->resolving); return $object; }
php
public function offsetGet($class) { if (!isset($this->factories[$class]) && !isset($this->instances[$class])) { throw new \InvalidArgumentException("$class has not been defined"); } if (isset($this->instances[$class])) { return $this->instances[$class]; } array_push($this->resolving, $class); $object = $this->invoke($this->factories[$class]); array_pop($this->resolving); return $object; }
[ "public", "function", "offsetGet", "(", "$", "class", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factories", "[", "$", "class", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "instances", "[", "$", "class", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"$class has not been defined\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "instances", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "instances", "[", "$", "class", "]", ";", "}", "array_push", "(", "$", "this", "->", "resolving", ",", "$", "class", ")", ";", "$", "object", "=", "$", "this", "->", "invoke", "(", "$", "this", "->", "factories", "[", "$", "class", "]", ")", ";", "array_pop", "(", "$", "this", "->", "resolving", ")", ";", "return", "$", "object", ";", "}" ]
get a dependency for the supplied class @param $type string The type to get @return mixed The dependency/type value
[ "get", "a", "dependency", "for", "the", "supplied", "class" ]
1afab9a2939d0c3d977b3992563ca37e77f87c1f
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L110-L125
20,850
jeffturcotte/jest
src/Jest/Injector.php
Injector.offsetSet
public function offsetSet($class, $factory) { if (is_callable($factory)) { $this->factories[$class] = $factory; } else if (is_object($factory)) { $this->instances[$class] = $factory; } else { throw new \InvalidArgumentException("Dependency supplied is neither a callable or an object"); } }
php
public function offsetSet($class, $factory) { if (is_callable($factory)) { $this->factories[$class] = $factory; } else if (is_object($factory)) { $this->instances[$class] = $factory; } else { throw new \InvalidArgumentException("Dependency supplied is neither a callable or an object"); } }
[ "public", "function", "offsetSet", "(", "$", "class", ",", "$", "factory", ")", "{", "if", "(", "is_callable", "(", "$", "factory", ")", ")", "{", "$", "this", "->", "factories", "[", "$", "class", "]", "=", "$", "factory", ";", "}", "else", "if", "(", "is_object", "(", "$", "factory", ")", ")", "{", "$", "this", "->", "instances", "[", "$", "class", "]", "=", "$", "factory", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Dependency supplied is neither a callable or an object\"", ")", ";", "}", "}" ]
Registers a dependency for injection @throws \InvalidArgumentException @param $class string The class to register @param $factory mixed A callable or object The factory used to create the dependency or the instance of the dependency
[ "Registers", "a", "dependency", "for", "injection" ]
1afab9a2939d0c3d977b3992563ca37e77f87c1f
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L139-L148
20,851
jeffturcotte/jest
src/Jest/Injector.php
Injector.reflectCallable
protected function reflectCallable($callable) { if (is_string($callable) && strpos($callable, '::')) { $callable = explode('::', $callable, 2); } if (is_a($callable, 'Closure')) { $reflection = new \ReflectionFunction($callable); } else if (is_object($callable)) { $reflection = new \ReflectionMethod(get_class($callable), '__invoke'); } else if (is_array($callable) && count($callable) == 2) { $reflection = new \ReflectionMethod((is_object($callable[0]) ? get_class($callable[0]) : $callable[0]), $callable[1]); } else if (is_string($callable) && function_exists($callable)) { $reflection = new \ReflectionFunction($callable); } return $reflection; }
php
protected function reflectCallable($callable) { if (is_string($callable) && strpos($callable, '::')) { $callable = explode('::', $callable, 2); } if (is_a($callable, 'Closure')) { $reflection = new \ReflectionFunction($callable); } else if (is_object($callable)) { $reflection = new \ReflectionMethod(get_class($callable), '__invoke'); } else if (is_array($callable) && count($callable) == 2) { $reflection = new \ReflectionMethod((is_object($callable[0]) ? get_class($callable[0]) : $callable[0]), $callable[1]); } else if (is_string($callable) && function_exists($callable)) { $reflection = new \ReflectionFunction($callable); } return $reflection; }
[ "protected", "function", "reflectCallable", "(", "$", "callable", ")", "{", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "strpos", "(", "$", "callable", ",", "'::'", ")", ")", "{", "$", "callable", "=", "explode", "(", "'::'", ",", "$", "callable", ",", "2", ")", ";", "}", "if", "(", "is_a", "(", "$", "callable", ",", "'Closure'", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "}", "else", "if", "(", "is_object", "(", "$", "callable", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "get_class", "(", "$", "callable", ")", ",", "'__invoke'", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "callable", ")", "&&", "count", "(", "$", "callable", ")", "==", "2", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "(", "is_object", "(", "$", "callable", "[", "0", "]", ")", "?", "get_class", "(", "$", "callable", "[", "0", "]", ")", ":", "$", "callable", "[", "0", "]", ")", ",", "$", "callable", "[", "1", "]", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "function_exists", "(", "$", "callable", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "}", "return", "$", "reflection", ";", "}" ]
Reflect a callable @param $callable Callable The callable to reflect @return ReflectionFunction|ReflectionMethod
[ "Reflect", "a", "callable" ]
1afab9a2939d0c3d977b3992563ca37e77f87c1f
https://github.com/jeffturcotte/jest/blob/1afab9a2939d0c3d977b3992563ca37e77f87c1f/src/Jest/Injector.php#L159-L176
20,852
InactiveProjects/limoncello-illuminate
app/Database/Seeds/Runner.php
Runner.run
public function run() { Model::unguard(); try { foreach ($this->seederClasses as $seederClass) { $this->parentSeeder->call($seederClass); } } finally { Model::reguard(); } }
php
public function run() { Model::unguard(); try { foreach ($this->seederClasses as $seederClass) { $this->parentSeeder->call($seederClass); } } finally { Model::reguard(); } }
[ "public", "function", "run", "(", ")", "{", "Model", "::", "unguard", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "seederClasses", "as", "$", "seederClass", ")", "{", "$", "this", "->", "parentSeeder", "->", "call", "(", "$", "seederClass", ")", ";", "}", "}", "finally", "{", "Model", "::", "reguard", "(", ")", ";", "}", "}" ]
Run seeders. @return void @SuppressWarnings(PHPMD.StaticAccess)
[ "Run", "seeders", "." ]
cae6fc26190efcf090495a5c3582c10fa2430897
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Seeds/Runner.php#L44-L54
20,853
interactivesolutions/honeycomb-core
src/http/controllers/traits/HCQueryMaking.php
HCQueryMaking.checkForDeleted
protected function checkForDeleted(Builder $query) { if (request()->has('deleted') && request()->input('deleted') === '1') $query = $query->onlyTrashed(); return $query; }
php
protected function checkForDeleted(Builder $query) { if (request()->has('deleted') && request()->input('deleted') === '1') $query = $query->onlyTrashed(); return $query; }
[ "protected", "function", "checkForDeleted", "(", "Builder", "$", "query", ")", "{", "if", "(", "request", "(", ")", "->", "has", "(", "'deleted'", ")", "&&", "request", "(", ")", "->", "input", "(", "'deleted'", ")", "===", "'1'", ")", "$", "query", "=", "$", "query", "->", "onlyTrashed", "(", ")", ";", "return", "$", "query", ";", "}" ]
Check for deleted records option @param Builder $query @return mixed
[ "Check", "for", "deleted", "records", "option" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/http/controllers/traits/HCQueryMaking.php#L140-L146
20,854
gregoryv/php-logger
src/Logger.php
Logger.turn
public function turn($toggle) { if(preg_match_all('/^(on|off) (all)?\s?(debug|info|notice|warn|error|critical|alert|emergency)$/', $toggle, $matches)) { $flag = $matches[1][0]; $all = $matches[2][0]; $name = $matches[3][0]; $this->sieve->toggle($flag, $name); if($all === 'all') { self::$SIEVE->toggle($flag, $name); } } else { throw new \InvalidArgumentException("Invalid format: $toggle"); } }
php
public function turn($toggle) { if(preg_match_all('/^(on|off) (all)?\s?(debug|info|notice|warn|error|critical|alert|emergency)$/', $toggle, $matches)) { $flag = $matches[1][0]; $all = $matches[2][0]; $name = $matches[3][0]; $this->sieve->toggle($flag, $name); if($all === 'all') { self::$SIEVE->toggle($flag, $name); } } else { throw new \InvalidArgumentException("Invalid format: $toggle"); } }
[ "public", "function", "turn", "(", "$", "toggle", ")", "{", "if", "(", "preg_match_all", "(", "'/^(on|off) (all)?\\s?(debug|info|notice|warn|error|critical|alert|emergency)$/'", ",", "$", "toggle", ",", "$", "matches", ")", ")", "{", "$", "flag", "=", "$", "matches", "[", "1", "]", "[", "0", "]", ";", "$", "all", "=", "$", "matches", "[", "2", "]", "[", "0", "]", ";", "$", "name", "=", "$", "matches", "[", "3", "]", "[", "0", "]", ";", "$", "this", "->", "sieve", "->", "toggle", "(", "$", "flag", ",", "$", "name", ")", ";", "if", "(", "$", "all", "===", "'all'", ")", "{", "self", "::", "$", "SIEVE", "->", "toggle", "(", "$", "flag", ",", "$", "name", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid format: $toggle\"", ")", ";", "}", "}" ]
Sets logging state of the given severity level in a readable format @example $log->turn('on debug'); @example $log->turn('off all warn'); @param string $toggle format: (on|off) [all] (debug|info|notice|warn|error|critical|alert|emergency)
[ "Sets", "logging", "state", "of", "the", "given", "severity", "level", "in", "a", "readable", "format" ]
0f8ffc360a0233531a9775359929af8876997862
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/Logger.php#L68-L81
20,855
zhouyl/mellivora
Mellivora/Support/Collection.php
Collection.every
public function every($key, $operator = null, $value = null) { if (func_num_args() === 1) { $callback = $this->valueRetriever($key); foreach ($this->items as $k => $v) { if (!$callback($v, $k)) { return false; } } return true; } if (func_num_args() === 2) { $value = $operator; $operator = '='; } return $this->every($this->operatorForWhere($key, $operator, $value)); }
php
public function every($key, $operator = null, $value = null) { if (func_num_args() === 1) { $callback = $this->valueRetriever($key); foreach ($this->items as $k => $v) { if (!$callback($v, $k)) { return false; } } return true; } if (func_num_args() === 2) { $value = $operator; $operator = '='; } return $this->every($this->operatorForWhere($key, $operator, $value)); }
[ "public", "function", "every", "(", "$", "key", ",", "$", "operator", "=", "null", ",", "$", "value", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "1", ")", "{", "$", "callback", "=", "$", "this", "->", "valueRetriever", "(", "$", "key", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "!", "$", "callback", "(", "$", "v", ",", "$", "k", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "if", "(", "func_num_args", "(", ")", "===", "2", ")", "{", "$", "value", "=", "$", "operator", ";", "$", "operator", "=", "'='", ";", "}", "return", "$", "this", "->", "every", "(", "$", "this", "->", "operatorForWhere", "(", "$", "key", ",", "$", "operator", ",", "$", "value", ")", ")", ";", "}" ]
Determine if all items in the collection pass the given test. @param callable|string $key @param mixed $operator @param mixed $value @return bool
[ "Determine", "if", "all", "items", "in", "the", "collection", "pass", "the", "given", "test", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L289-L310
20,856
zhouyl/mellivora
Mellivora/Support/Collection.php
Collection.mapToGroups
public function mapToGroups(callable $callback) { $groups = $this->map($callback)->reduce(function ($groups, $pair) { $groups[key($pair)][] = reset($pair); return $groups; }, []); return (new static($groups))->map([$this, 'make']); }
php
public function mapToGroups(callable $callback) { $groups = $this->map($callback)->reduce(function ($groups, $pair) { $groups[key($pair)][] = reset($pair); return $groups; }, []); return (new static($groups))->map([$this, 'make']); }
[ "public", "function", "mapToGroups", "(", "callable", "$", "callback", ")", "{", "$", "groups", "=", "$", "this", "->", "map", "(", "$", "callback", ")", "->", "reduce", "(", "function", "(", "$", "groups", ",", "$", "pair", ")", "{", "$", "groups", "[", "key", "(", "$", "pair", ")", "]", "[", "]", "=", "reset", "(", "$", "pair", ")", ";", "return", "$", "groups", ";", "}", ",", "[", "]", ")", ";", "return", "(", "new", "static", "(", "$", "groups", ")", ")", "->", "map", "(", "[", "$", "this", ",", "'make'", "]", ")", ";", "}" ]
Run a grouping map over the items. The callback should return an associative array with a single key/value pair. @param callable $callback @return static
[ "Run", "a", "grouping", "map", "over", "the", "items", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Support/Collection.php#L771-L780
20,857
hametuha/wpametu
src/WPametu/AutoLoader.php
AutoLoader.register_commands
private function register_commands() { foreach ( $this->commands as $class_name ) { \WP_CLI::add_command( $class_name::COMMAND_NAME, $class_name ); } }
php
private function register_commands() { foreach ( $this->commands as $class_name ) { \WP_CLI::add_command( $class_name::COMMAND_NAME, $class_name ); } }
[ "private", "function", "register_commands", "(", ")", "{", "foreach", "(", "$", "this", "->", "commands", "as", "$", "class_name", ")", "{", "\\", "WP_CLI", "::", "add_command", "(", "$", "class_name", "::", "COMMAND_NAME", ",", "$", "class_name", ")", ";", "}", "}" ]
Register All commands
[ "Register", "All", "commands" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L259-L263
20,858
hametuha/wpametu
src/WPametu/AutoLoader.php
AutoLoader.ajax_register
public function ajax_register() { if ( AjaxBase::is_ajax() ) { foreach ( $this->ajax_controllers as $class_name ) { /** @var AjaxBase $instance */ $instance = $class_name::get_instance(); $instance->register(); } } }
php
public function ajax_register() { if ( AjaxBase::is_ajax() ) { foreach ( $this->ajax_controllers as $class_name ) { /** @var AjaxBase $instance */ $instance = $class_name::get_instance(); $instance->register(); } } }
[ "public", "function", "ajax_register", "(", ")", "{", "if", "(", "AjaxBase", "::", "is_ajax", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "ajax_controllers", "as", "$", "class_name", ")", "{", "/** @var AjaxBase $instance */", "$", "instance", "=", "$", "class_name", "::", "get_instance", "(", ")", ";", "$", "instance", "->", "register", "(", ")", ";", "}", "}", "}" ]
Register ajax actions
[ "Register", "ajax", "actions" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L268-L276
20,859
hametuha/wpametu
src/WPametu/AutoLoader.php
AutoLoader.scan_post_type
public function scan_post_type() { $flg = false; foreach ( $this->namespaces as $ns => $dir ) { $dir = $dir . '/' . $ns . '/ThePost'; if ( is_dir( $dir ) ) { foreach ( scandir( $dir ) as $file ) { if ( ! preg_match( '/^\./u', $file ) ) { $base_class = str_replace( '.php', '', $file ); $class_name = $ns . '\\ThePost\\' . $base_class; if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, PostHelper::class ) ) { $this->post_type_to_override[ $this->str->camel_to_hyphen( $base_class ) ] = $class_name; $flg = true; } } } } } if ( $flg ) { add_action( 'the_post', [ $this, 'the_post' ] ); } }
php
public function scan_post_type() { $flg = false; foreach ( $this->namespaces as $ns => $dir ) { $dir = $dir . '/' . $ns . '/ThePost'; if ( is_dir( $dir ) ) { foreach ( scandir( $dir ) as $file ) { if ( ! preg_match( '/^\./u', $file ) ) { $base_class = str_replace( '.php', '', $file ); $class_name = $ns . '\\ThePost\\' . $base_class; if ( class_exists( $class_name ) && $this->is_sub_class_of( $class_name, PostHelper::class ) ) { $this->post_type_to_override[ $this->str->camel_to_hyphen( $base_class ) ] = $class_name; $flg = true; } } } } } if ( $flg ) { add_action( 'the_post', [ $this, 'the_post' ] ); } }
[ "public", "function", "scan_post_type", "(", ")", "{", "$", "flg", "=", "false", ";", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "ns", "=>", "$", "dir", ")", "{", "$", "dir", "=", "$", "dir", ".", "'/'", ".", "$", "ns", ".", "'/ThePost'", ";", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", "foreach", "(", "scandir", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "if", "(", "!", "preg_match", "(", "'/^\\./u'", ",", "$", "file", ")", ")", "{", "$", "base_class", "=", "str_replace", "(", "'.php'", ",", "''", ",", "$", "file", ")", ";", "$", "class_name", "=", "$", "ns", ".", "'\\\\ThePost\\\\'", ".", "$", "base_class", ";", "if", "(", "class_exists", "(", "$", "class_name", ")", "&&", "$", "this", "->", "is_sub_class_of", "(", "$", "class_name", ",", "PostHelper", "::", "class", ")", ")", "{", "$", "this", "->", "post_type_to_override", "[", "$", "this", "->", "str", "->", "camel_to_hyphen", "(", "$", "base_class", ")", "]", "=", "$", "class_name", ";", "$", "flg", "=", "true", ";", "}", "}", "}", "}", "}", "if", "(", "$", "flg", ")", "{", "add_action", "(", "'the_post'", ",", "[", "$", "this", ",", "'the_post'", "]", ")", ";", "}", "}" ]
Scan original post type to override
[ "Scan", "original", "post", "type", "to", "override" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/AutoLoader.php#L281-L301
20,860
gruzilla/hydra
src/Hydra/Hydra.php
Hydra.run
public function run() { foreach ($this->jobs as $job) { $this->worker->run($job); } while ($this->worker->isRunning()) { // waiting for worker to finish } // allow chaining return $this; }
php
public function run() { foreach ($this->jobs as $job) { $this->worker->run($job); } while ($this->worker->isRunning()) { // waiting for worker to finish } // allow chaining return $this; }
[ "public", "function", "run", "(", ")", "{", "foreach", "(", "$", "this", "->", "jobs", "as", "$", "job", ")", "{", "$", "this", "->", "worker", "->", "run", "(", "$", "job", ")", ";", "}", "while", "(", "$", "this", "->", "worker", "->", "isRunning", "(", ")", ")", "{", "// waiting for worker to finish", "}", "// allow chaining", "return", "$", "this", ";", "}" ]
run all jobs using the worker @return self
[ "run", "all", "jobs", "using", "the", "worker" ]
47f381cc48e1a26bfe2e211d8dcb54c787ea0478
https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Hydra.php#L90-L102
20,861
Erdiko/core
src/cache/Memcached.php
Memcached.put
public function put($key, $data) { $key = $this->getKeyCode($key); $data = json_encode($data); $this->memcacheObj->set($key, $data); }
php
public function put($key, $data) { $key = $this->getKeyCode($key); $data = json_encode($data); $this->memcacheObj->set($key, $data); }
[ "public", "function", "put", "(", "$", "key", ",", "$", "data", ")", "{", "$", "key", "=", "$", "this", "->", "getKeyCode", "(", "$", "key", ")", ";", "$", "data", "=", "json_encode", "(", "$", "data", ")", ";", "$", "this", "->", "memcacheObj", "->", "set", "(", "$", "key", ",", "$", "data", ")", ";", "}" ]
Put data into cache @parm mixed $key @parm mixed $data @note If you put a object into cache, the json_encode function will ignore any private property.
[ "Put", "data", "into", "cache" ]
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L77-L83
20,862
Erdiko/core
src/cache/Memcached.php
Memcached.has
public function has($key) { $key = $this->getKeyCode($key); $value = $this->memcacheObj->get($key); if (!$value) { return false; } else { return true; } }
php
public function has($key) { $key = $this->getKeyCode($key); $value = $this->memcacheObj->get($key); if (!$value) { return false; } else { return true; } }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "getKeyCode", "(", "$", "key", ")", ";", "$", "value", "=", "$", "this", "->", "memcacheObj", "->", "get", "(", "$", "key", ")", ";", "if", "(", "!", "$", "value", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}" ]
Check if the key exists in cache @parm mixed $key @return true if the key exist in cache @return false if the key does not exist in cache
[ "Check", "if", "the", "key", "exists", "in", "cache" ]
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L109-L120
20,863
Erdiko/core
src/cache/Memcached.php
Memcached.delete
public function delete($key) { $filename = $this->getKeyCode($key); $this->memcacheObj->delete($filename); }
php
public function delete($key) { $filename = $this->getKeyCode($key); $this->memcacheObj->delete($filename); }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "filename", "=", "$", "this", "->", "getKeyCode", "(", "$", "key", ")", ";", "$", "this", "->", "memcacheObj", "->", "delete", "(", "$", "filename", ")", ";", "}" ]
Remove a key from cache @parm mixed $key
[ "Remove", "a", "key", "from", "cache" ]
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/cache/Memcached.php#L128-L132
20,864
JBZoo/Assets
src/Factory.php
Factory.create
public function create($alias, $source, $dependencies = [], $options = []) { $assetType = isset($options['type']) ? $options['type'] : ''; if (isset($this->_customTypes[$assetType])) { $assetType = $this->_customTypes[$assetType]; } elseif (is_callable($source)) { $assetType = 'Callback'; } elseif (is_string($source)) { $ext = strtolower(FS::ext($source)); if ($ext === 'js') { $assetType = 'JsFile'; } elseif ($ext === 'css') { $assetType = 'CssFile'; } elseif ($ext === 'less') { $assetType = 'LessFile'; } elseif ($ext === 'jsx') { $assetType = 'JsxFile'; } } elseif (is_array($source)) { $assetType = 'Collection'; } $className = __NAMESPACE__ . '\\Asset\\' . $assetType; if (class_exists($className)) { $options = is_array($options) ? new Data($options) : $options; return new $className($this->getManager(), $alias, $source, $dependencies, $options); } throw new Exception('Undefined asset type: ' . print_r($source, true)); }
php
public function create($alias, $source, $dependencies = [], $options = []) { $assetType = isset($options['type']) ? $options['type'] : ''; if (isset($this->_customTypes[$assetType])) { $assetType = $this->_customTypes[$assetType]; } elseif (is_callable($source)) { $assetType = 'Callback'; } elseif (is_string($source)) { $ext = strtolower(FS::ext($source)); if ($ext === 'js') { $assetType = 'JsFile'; } elseif ($ext === 'css') { $assetType = 'CssFile'; } elseif ($ext === 'less') { $assetType = 'LessFile'; } elseif ($ext === 'jsx') { $assetType = 'JsxFile'; } } elseif (is_array($source)) { $assetType = 'Collection'; } $className = __NAMESPACE__ . '\\Asset\\' . $assetType; if (class_exists($className)) { $options = is_array($options) ? new Data($options) : $options; return new $className($this->getManager(), $alias, $source, $dependencies, $options); } throw new Exception('Undefined asset type: ' . print_r($source, true)); }
[ "public", "function", "create", "(", "$", "alias", ",", "$", "source", ",", "$", "dependencies", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "assetType", "=", "isset", "(", "$", "options", "[", "'type'", "]", ")", "?", "$", "options", "[", "'type'", "]", ":", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "_customTypes", "[", "$", "assetType", "]", ")", ")", "{", "$", "assetType", "=", "$", "this", "->", "_customTypes", "[", "$", "assetType", "]", ";", "}", "elseif", "(", "is_callable", "(", "$", "source", ")", ")", "{", "$", "assetType", "=", "'Callback'", ";", "}", "elseif", "(", "is_string", "(", "$", "source", ")", ")", "{", "$", "ext", "=", "strtolower", "(", "FS", "::", "ext", "(", "$", "source", ")", ")", ";", "if", "(", "$", "ext", "===", "'js'", ")", "{", "$", "assetType", "=", "'JsFile'", ";", "}", "elseif", "(", "$", "ext", "===", "'css'", ")", "{", "$", "assetType", "=", "'CssFile'", ";", "}", "elseif", "(", "$", "ext", "===", "'less'", ")", "{", "$", "assetType", "=", "'LessFile'", ";", "}", "elseif", "(", "$", "ext", "===", "'jsx'", ")", "{", "$", "assetType", "=", "'JsxFile'", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "source", ")", ")", "{", "$", "assetType", "=", "'Collection'", ";", "}", "$", "className", "=", "__NAMESPACE__", ".", "'\\\\Asset\\\\'", ".", "$", "assetType", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "$", "options", "=", "is_array", "(", "$", "options", ")", "?", "new", "Data", "(", "$", "options", ")", ":", "$", "options", ";", "return", "new", "$", "className", "(", "$", "this", "->", "getManager", "(", ")", ",", "$", "alias", ",", "$", "source", ",", "$", "dependencies", ",", "$", "options", ")", ";", "}", "throw", "new", "Exception", "(", "'Undefined asset type: '", ".", "print_r", "(", "$", "source", ",", "true", ")", ")", ";", "}" ]
Create asset instance. @param string $alias @param mixed $source @param string|array $dependencies @param string|array $options @throws Exception @return Asset
[ "Create", "asset", "instance", "." ]
134a109378f5b5e955dfb15e6ed2821581564991
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Factory.php#L75-L112
20,865
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.getStatusOfTaskWithId
public function getStatusOfTaskWithId($taskId) { $task = $this->taskRepo->find($taskId); if (!($task instanceof Task)) { //the task was not found return Task::STATUS_GONE; } return $task->getStatus(); }
php
public function getStatusOfTaskWithId($taskId) { $task = $this->taskRepo->find($taskId); if (!($task instanceof Task)) { //the task was not found return Task::STATUS_GONE; } return $task->getStatus(); }
[ "public", "function", "getStatusOfTaskWithId", "(", "$", "taskId", ")", "{", "$", "task", "=", "$", "this", "->", "taskRepo", "->", "find", "(", "$", "taskId", ")", ";", "if", "(", "!", "(", "$", "task", "instanceof", "Task", ")", ")", "{", "//the task was not found", "return", "Task", "::", "STATUS_GONE", ";", "}", "return", "$", "task", "->", "getStatus", "(", ")", ";", "}" ]
Returns the current status of a task @param integer $taskId @return string
[ "Returns", "the", "current", "status", "of", "a", "task" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L126-L134
20,866
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.cleanUpTasks
public function cleanUpTasks($timePeriod) { $query = $this->entityManager->createQuery( 'DELETE FROM WebdevviePheanstalkTaskQueueBundle:Task t WHERE t.status = :status and t.created <= :older' ); $query->setParameter('status', array(Task::STATUS_DONE)); $query->setParameter('older', date("Y-m-d H:i:s", time() - $timePeriod)); $query->execute(); }
php
public function cleanUpTasks($timePeriod) { $query = $this->entityManager->createQuery( 'DELETE FROM WebdevviePheanstalkTaskQueueBundle:Task t WHERE t.status = :status and t.created <= :older' ); $query->setParameter('status', array(Task::STATUS_DONE)); $query->setParameter('older', date("Y-m-d H:i:s", time() - $timePeriod)); $query->execute(); }
[ "public", "function", "cleanUpTasks", "(", "$", "timePeriod", ")", "{", "$", "query", "=", "$", "this", "->", "entityManager", "->", "createQuery", "(", "'DELETE\n FROM WebdevviePheanstalkTaskQueueBundle:Task t\n WHERE\n t.status = :status and\n t.created <= :older'", ")", ";", "$", "query", "->", "setParameter", "(", "'status'", ",", "array", "(", "Task", "::", "STATUS_DONE", ")", ")", ";", "$", "query", "->", "setParameter", "(", "'older'", ",", "date", "(", "\"Y-m-d H:i:s\"", ",", "time", "(", ")", "-", "$", "timePeriod", ")", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "}" ]
Cleans up tasks that are marked as done @param integer $timePeriod @return void
[ "Cleans", "up", "tasks", "that", "are", "marked", "as", "done" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L202-L214
20,867
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.reserveTask
public function reserveTask($tube = null) { if (is_null($tube)) { $tube = $this->defaultTube; } $inTask = $this->beanstalk ->watch($tube) ->ignore('default') ->reserve(2); if ($inTask === false) { return null; } $data = $inTask->getData(); $parts = explode("::", $data, 2); if (count($parts) !== 2) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube}"); } try { $taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json'); } catch (UnsupportedFormatException $exception) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube} "); } catch (\ReflectionException $exception) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException( "Invalid format in TaskQueue {$tube} class " . $parts[0] . ' is unknown' ); } if (!($taskObject instanceof TaskDescriptionInterface)) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid data in TaskQueue {$tube}"); } if (!$this->databaseDisabled) { $taskEntity = $this->taskRepo->find($taskObject->getTaskIdentifier()); } else { //remake the task entity $taskEntity = new Task($taskObject, '', $tube); } if (!($taskEntity instanceof Task)) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException( "Unable to find taskEntity for task:" . $taskObject->getTaskIdentifier() ); } /** * @var Task $taskEntity */ $workPackage = new WorkPackage($taskEntity, $inTask, $taskObject); $this->updateTaskStatus($workPackage, Task::STATUS_WORKING); return $workPackage; }
php
public function reserveTask($tube = null) { if (is_null($tube)) { $tube = $this->defaultTube; } $inTask = $this->beanstalk ->watch($tube) ->ignore('default') ->reserve(2); if ($inTask === false) { return null; } $data = $inTask->getData(); $parts = explode("::", $data, 2); if (count($parts) !== 2) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube}"); } try { $taskObject = $this->serializer->deserialize($parts[1], $parts[0], 'json'); } catch (UnsupportedFormatException $exception) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid format in TaskQueue {$tube} "); } catch (\ReflectionException $exception) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException( "Invalid format in TaskQueue {$tube} class " . $parts[0] . ' is unknown' ); } if (!($taskObject instanceof TaskDescriptionInterface)) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException("Invalid data in TaskQueue {$tube}"); } if (!$this->databaseDisabled) { $taskEntity = $this->taskRepo->find($taskObject->getTaskIdentifier()); } else { //remake the task entity $taskEntity = new Task($taskObject, '', $tube); } if (!($taskEntity instanceof Task)) { $this->beanstalk->delete($inTask); throw new TaskQueueServiceException( "Unable to find taskEntity for task:" . $taskObject->getTaskIdentifier() ); } /** * @var Task $taskEntity */ $workPackage = new WorkPackage($taskEntity, $inTask, $taskObject); $this->updateTaskStatus($workPackage, Task::STATUS_WORKING); return $workPackage; }
[ "public", "function", "reserveTask", "(", "$", "tube", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "tube", ")", ")", "{", "$", "tube", "=", "$", "this", "->", "defaultTube", ";", "}", "$", "inTask", "=", "$", "this", "->", "beanstalk", "->", "watch", "(", "$", "tube", ")", "->", "ignore", "(", "'default'", ")", "->", "reserve", "(", "2", ")", ";", "if", "(", "$", "inTask", "===", "false", ")", "{", "return", "null", ";", "}", "$", "data", "=", "$", "inTask", "->", "getData", "(", ")", ";", "$", "parts", "=", "explode", "(", "\"::\"", ",", "$", "data", ",", "2", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "!==", "2", ")", "{", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "inTask", ")", ";", "throw", "new", "TaskQueueServiceException", "(", "\"Invalid format in TaskQueue {$tube}\"", ")", ";", "}", "try", "{", "$", "taskObject", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "parts", "[", "1", "]", ",", "$", "parts", "[", "0", "]", ",", "'json'", ")", ";", "}", "catch", "(", "UnsupportedFormatException", "$", "exception", ")", "{", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "inTask", ")", ";", "throw", "new", "TaskQueueServiceException", "(", "\"Invalid format in TaskQueue {$tube} \"", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "exception", ")", "{", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "inTask", ")", ";", "throw", "new", "TaskQueueServiceException", "(", "\"Invalid format in TaskQueue {$tube} class \"", ".", "$", "parts", "[", "0", "]", ".", "' is unknown'", ")", ";", "}", "if", "(", "!", "(", "$", "taskObject", "instanceof", "TaskDescriptionInterface", ")", ")", "{", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "inTask", ")", ";", "throw", "new", "TaskQueueServiceException", "(", "\"Invalid data in TaskQueue {$tube}\"", ")", ";", "}", "if", "(", "!", "$", "this", "->", "databaseDisabled", ")", "{", "$", "taskEntity", "=", "$", "this", "->", "taskRepo", "->", "find", "(", "$", "taskObject", "->", "getTaskIdentifier", "(", ")", ")", ";", "}", "else", "{", "//remake the task entity", "$", "taskEntity", "=", "new", "Task", "(", "$", "taskObject", ",", "''", ",", "$", "tube", ")", ";", "}", "if", "(", "!", "(", "$", "taskEntity", "instanceof", "Task", ")", ")", "{", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "inTask", ")", ";", "throw", "new", "TaskQueueServiceException", "(", "\"Unable to find taskEntity for task:\"", ".", "$", "taskObject", "->", "getTaskIdentifier", "(", ")", ")", ";", "}", "/**\n * @var Task $taskEntity\n */", "$", "workPackage", "=", "new", "WorkPackage", "(", "$", "taskEntity", ",", "$", "inTask", ",", "$", "taskObject", ")", ";", "$", "this", "->", "updateTaskStatus", "(", "$", "workPackage", ",", "Task", "::", "STATUS_WORKING", ")", ";", "return", "$", "workPackage", ";", "}" ]
Returns a task to work on. @param string $tube (optional) the tube(queue) to reserve a task from @throws TaskQueueServiceException @return WorkPackage
[ "Returns", "a", "task", "to", "work", "on", "." ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L224-L275
20,868
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.markDone
public function markDone(WorkPackage $task, $log) { if ($this->logWorkerOutputOnSuccess) { $this->updateTaskLog($task, $log); } $this->updateTaskStatus($task, Task::STATUS_DONE); $this->beanstalk->delete($task->getPheanstalkJob()); }
php
public function markDone(WorkPackage $task, $log) { if ($this->logWorkerOutputOnSuccess) { $this->updateTaskLog($task, $log); } $this->updateTaskStatus($task, Task::STATUS_DONE); $this->beanstalk->delete($task->getPheanstalkJob()); }
[ "public", "function", "markDone", "(", "WorkPackage", "$", "task", ",", "$", "log", ")", "{", "if", "(", "$", "this", "->", "logWorkerOutputOnSuccess", ")", "{", "$", "this", "->", "updateTaskLog", "(", "$", "task", ",", "$", "log", ")", ";", "}", "$", "this", "->", "updateTaskStatus", "(", "$", "task", ",", "Task", "::", "STATUS_DONE", ")", ";", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "task", "->", "getPheanstalkJob", "(", ")", ")", ";", "}" ]
Deletes a task from the queue @param WorkPackage $task @param string $log @throws TaskQueueServiceException @return void
[ "Deletes", "a", "task", "from", "the", "queue" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L285-L292
20,869
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.markFailed
public function markFailed(WorkPackage $task, $log) { if ($this->logWorkerOutputOnFailure) { $this->updateTaskLog($task, $log); } $this->updateTaskStatus($task, Task::STATUS_FAILED); $this->beanstalk->delete($task->getPheanstalkJob()); }
php
public function markFailed(WorkPackage $task, $log) { if ($this->logWorkerOutputOnFailure) { $this->updateTaskLog($task, $log); } $this->updateTaskStatus($task, Task::STATUS_FAILED); $this->beanstalk->delete($task->getPheanstalkJob()); }
[ "public", "function", "markFailed", "(", "WorkPackage", "$", "task", ",", "$", "log", ")", "{", "if", "(", "$", "this", "->", "logWorkerOutputOnFailure", ")", "{", "$", "this", "->", "updateTaskLog", "(", "$", "task", ",", "$", "log", ")", ";", "}", "$", "this", "->", "updateTaskStatus", "(", "$", "task", ",", "Task", "::", "STATUS_FAILED", ")", ";", "$", "this", "->", "beanstalk", "->", "delete", "(", "$", "task", "->", "getPheanstalkJob", "(", ")", ")", ";", "}" ]
Marks a job as failed and deletes it from the beanstalk tube @param WorkPackage $task @param string $log @throws TaskQueueServiceException @return void
[ "Marks", "a", "job", "as", "failed", "and", "deletes", "it", "from", "the", "beanstalk", "tube" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L302-L309
20,870
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.updateTaskLog
private function updateTaskLog(WorkPackage $task, $log) { if ($this->databaseDisabled) { return; } $taskEntity = $task->getTaskEntity(); if ($taskEntity instanceof Task) { $taskEntity->setLog($log); //make sure it is stored... $this->entityManager->flush($taskEntity); } else { throw new TaskQueueServiceException("Entity is not of type Task"); } }
php
private function updateTaskLog(WorkPackage $task, $log) { if ($this->databaseDisabled) { return; } $taskEntity = $task->getTaskEntity(); if ($taskEntity instanceof Task) { $taskEntity->setLog($log); //make sure it is stored... $this->entityManager->flush($taskEntity); } else { throw new TaskQueueServiceException("Entity is not of type Task"); } }
[ "private", "function", "updateTaskLog", "(", "WorkPackage", "$", "task", ",", "$", "log", ")", "{", "if", "(", "$", "this", "->", "databaseDisabled", ")", "{", "return", ";", "}", "$", "taskEntity", "=", "$", "task", "->", "getTaskEntity", "(", ")", ";", "if", "(", "$", "taskEntity", "instanceof", "Task", ")", "{", "$", "taskEntity", "->", "setLog", "(", "$", "log", ")", ";", "//make sure it is stored...", "$", "this", "->", "entityManager", "->", "flush", "(", "$", "taskEntity", ")", ";", "}", "else", "{", "throw", "new", "TaskQueueServiceException", "(", "\"Entity is not of type Task\"", ")", ";", "}", "}" ]
Writes the log to the Task entity @param WorkPackage $task @param string $log @return void @throws TaskQueueServiceException
[ "Writes", "the", "log", "to", "the", "Task", "entity" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L319-L332
20,871
webdevvie/pheanstalk-task-queue-bundle
Service/TaskQueueService.php
TaskQueueService.updateTaskStatus
private function updateTaskStatus(WorkPackage $task, $status) { if ($this->databaseDisabled) { return; } $taskEntity = $task->getTaskEntity(); if ($taskEntity instanceof Task) { $taskEntity->setStatus($status); //make sure it is stored... $this->entityManager->flush($taskEntity); } else { throw new TaskQueueServiceException("Entity is not of type Task"); } }
php
private function updateTaskStatus(WorkPackage $task, $status) { if ($this->databaseDisabled) { return; } $taskEntity = $task->getTaskEntity(); if ($taskEntity instanceof Task) { $taskEntity->setStatus($status); //make sure it is stored... $this->entityManager->flush($taskEntity); } else { throw new TaskQueueServiceException("Entity is not of type Task"); } }
[ "private", "function", "updateTaskStatus", "(", "WorkPackage", "$", "task", ",", "$", "status", ")", "{", "if", "(", "$", "this", "->", "databaseDisabled", ")", "{", "return", ";", "}", "$", "taskEntity", "=", "$", "task", "->", "getTaskEntity", "(", ")", ";", "if", "(", "$", "taskEntity", "instanceof", "Task", ")", "{", "$", "taskEntity", "->", "setStatus", "(", "$", "status", ")", ";", "//make sure it is stored...", "$", "this", "->", "entityManager", "->", "flush", "(", "$", "taskEntity", ")", ";", "}", "else", "{", "throw", "new", "TaskQueueServiceException", "(", "\"Entity is not of type Task\"", ")", ";", "}", "}" ]
Updates the task status @param WorkPackage $task @param string $status @return void @throws TaskQueueServiceException
[ "Updates", "the", "task", "status" ]
db5e63a8f844e345dc2e69ce8e94b32d851020eb
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Service/TaskQueueService.php#L342-L355
20,872
thanhtaivtt/taiscript
src/Handler/Handler.php
Handler.readData
public function readData($pathFilename) { $pathFilename = ucfirst($pathFilename); $pathFilename = realpath(__DIR__) . "/../Template/{$pathFilename}.template"; $file = fopen($pathFilename, 'r'); if ($data = fread($file, filesize($pathFilename))) { return str_replace('<\?php', '<?php', $data); } else { throw new \ErrorException(realpath(__DIR__) . "/../Template/{$pathFilename}.template not Found"); } }
php
public function readData($pathFilename) { $pathFilename = ucfirst($pathFilename); $pathFilename = realpath(__DIR__) . "/../Template/{$pathFilename}.template"; $file = fopen($pathFilename, 'r'); if ($data = fread($file, filesize($pathFilename))) { return str_replace('<\?php', '<?php', $data); } else { throw new \ErrorException(realpath(__DIR__) . "/../Template/{$pathFilename}.template not Found"); } }
[ "public", "function", "readData", "(", "$", "pathFilename", ")", "{", "$", "pathFilename", "=", "ucfirst", "(", "$", "pathFilename", ")", ";", "$", "pathFilename", "=", "realpath", "(", "__DIR__", ")", ".", "\"/../Template/{$pathFilename}.template\"", ";", "$", "file", "=", "fopen", "(", "$", "pathFilename", ",", "'r'", ")", ";", "if", "(", "$", "data", "=", "fread", "(", "$", "file", ",", "filesize", "(", "$", "pathFilename", ")", ")", ")", "{", "return", "str_replace", "(", "'<\\?php'", ",", "'<?php'", ",", "$", "data", ")", ";", "}", "else", "{", "throw", "new", "\\", "ErrorException", "(", "realpath", "(", "__DIR__", ")", ".", "\"/../Template/{$pathFilename}.template not Found\"", ")", ";", "}", "}" ]
Read data form template folder @param $pathFilename @return mixed @throws \ErrorException
[ "Read", "data", "form", "template", "folder" ]
fbc0d2e30172dcfb9de48a457872f12c7ab5c6ca
https://github.com/thanhtaivtt/taiscript/blob/fbc0d2e30172dcfb9de48a457872f12c7ab5c6ca/src/Handler/Handler.php#L27-L40
20,873
z38/pc-axis
src/Px.php
Px.variables
public function variables() { if (!$this->hasKeyword('STUB')) { return $this->keyword('HEADING')->values; } elseif (!$this->hasKeyword('HEADING')) { return $this->keyword('STUB')->values; } else { return array_merge($this->keyword('STUB')->values, $this->keyword('HEADING')->values); } }
php
public function variables() { if (!$this->hasKeyword('STUB')) { return $this->keyword('HEADING')->values; } elseif (!$this->hasKeyword('HEADING')) { return $this->keyword('STUB')->values; } else { return array_merge($this->keyword('STUB')->values, $this->keyword('HEADING')->values); } }
[ "public", "function", "variables", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasKeyword", "(", "'STUB'", ")", ")", "{", "return", "$", "this", "->", "keyword", "(", "'HEADING'", ")", "->", "values", ";", "}", "elseif", "(", "!", "$", "this", "->", "hasKeyword", "(", "'HEADING'", ")", ")", "{", "return", "$", "this", "->", "keyword", "(", "'STUB'", ")", "->", "values", ";", "}", "else", "{", "return", "array_merge", "(", "$", "this", "->", "keyword", "(", "'STUB'", ")", "->", "values", ",", "$", "this", "->", "keyword", "(", "'HEADING'", ")", "->", "values", ")", ";", "}", "}" ]
Returns a list of all variables. @return array
[ "Returns", "a", "list", "of", "all", "variables", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L71-L80
20,874
z38/pc-axis
src/Px.php
Px.values
public function values($variable) { foreach ($this->keywordList('VALUES') as $keyword) { if ($keyword->subKeys[0] == $variable) { return $keyword->values; } } throw new RuntimeException(sprintf('Could not determine values of "%s".', $variable)); }
php
public function values($variable) { foreach ($this->keywordList('VALUES') as $keyword) { if ($keyword->subKeys[0] == $variable) { return $keyword->values; } } throw new RuntimeException(sprintf('Could not determine values of "%s".', $variable)); }
[ "public", "function", "values", "(", "$", "variable", ")", "{", "foreach", "(", "$", "this", "->", "keywordList", "(", "'VALUES'", ")", "as", "$", "keyword", ")", "{", "if", "(", "$", "keyword", "->", "subKeys", "[", "0", "]", "==", "$", "variable", ")", "{", "return", "$", "keyword", "->", "values", ";", "}", "}", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Could not determine values of \"%s\".'", ",", "$", "variable", ")", ")", ";", "}" ]
Returns a list of all possible values of a variable. @param string $variable @return array
[ "Returns", "a", "list", "of", "all", "possible", "values", "of", "a", "variable", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L89-L97
20,875
z38/pc-axis
src/Px.php
Px.codes
public function codes($variable) { foreach ($this->keywordList('CODES') as $keyword) { if ($keyword->subKeys[0] == $variable) { return $keyword->values; } } return null; }
php
public function codes($variable) { foreach ($this->keywordList('CODES') as $keyword) { if ($keyword->subKeys[0] == $variable) { return $keyword->values; } } return null; }
[ "public", "function", "codes", "(", "$", "variable", ")", "{", "foreach", "(", "$", "this", "->", "keywordList", "(", "'CODES'", ")", "as", "$", "keyword", ")", "{", "if", "(", "$", "keyword", "->", "subKeys", "[", "0", "]", "==", "$", "variable", ")", "{", "return", "$", "keyword", "->", "values", ";", "}", "}", "return", "null", ";", "}" ]
Returns a list of all possible codes of a variable. @param string $variable @return array|null
[ "Returns", "a", "list", "of", "all", "possible", "codes", "of", "a", "variable", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L106-L115
20,876
z38/pc-axis
src/Px.php
Px.index
public function index($indices) { $this->assertIndexMultipliers(); $index = 0; for ($i = 0, $length = count($this->indexMultipliers); $i < $length; ++$i) { $index += $indices[$i] * $this->indexMultipliers[$i]; } return $index; }
php
public function index($indices) { $this->assertIndexMultipliers(); $index = 0; for ($i = 0, $length = count($this->indexMultipliers); $i < $length; ++$i) { $index += $indices[$i] * $this->indexMultipliers[$i]; } return $index; }
[ "public", "function", "index", "(", "$", "indices", ")", "{", "$", "this", "->", "assertIndexMultipliers", "(", ")", ";", "$", "index", "=", "0", ";", "for", "(", "$", "i", "=", "0", ",", "$", "length", "=", "count", "(", "$", "this", "->", "indexMultipliers", ")", ";", "$", "i", "<", "$", "length", ";", "++", "$", "i", ")", "{", "$", "index", "+=", "$", "indices", "[", "$", "i", "]", "*", "$", "this", "->", "indexMultipliers", "[", "$", "i", "]", ";", "}", "return", "$", "index", ";", "}" ]
Computes the index within the data matrix. @param array $indices An array of all value indices @return int
[ "Computes", "the", "index", "within", "the", "data", "matrix", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L124-L134
20,877
z38/pc-axis
src/Px.php
Px.datum
public function datum($indices) { $this->assertData(); $index = $this->index($indices); if (isset($this->data[$index])) { return $this->data[$index]; } else { return null; } }
php
public function datum($indices) { $this->assertData(); $index = $this->index($indices); if (isset($this->data[$index])) { return $this->data[$index]; } else { return null; } }
[ "public", "function", "datum", "(", "$", "indices", ")", "{", "$", "this", "->", "assertData", "(", ")", ";", "$", "index", "=", "$", "this", "->", "index", "(", "$", "indices", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "index", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets a single data point. @param array $indices An array of all value indices @return string
[ "Gets", "a", "single", "data", "point", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L143-L153
20,878
z38/pc-axis
src/Px.php
Px.keywordList
public function keywordList($keyword) { $this->assertKeywords(); if (isset($this->keywords[$keyword])) { return $this->keywords[$keyword]; } else { return []; } }
php
public function keywordList($keyword) { $this->assertKeywords(); if (isset($this->keywords[$keyword])) { return $this->keywords[$keyword]; } else { return []; } }
[ "public", "function", "keywordList", "(", "$", "keyword", ")", "{", "$", "this", "->", "assertKeywords", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "keywords", "[", "$", "keyword", "]", ")", ")", "{", "return", "$", "this", "->", "keywords", "[", "$", "keyword", "]", ";", "}", "else", "{", "return", "[", "]", ";", "}", "}" ]
Returns all keywords with a given name. @param string $keyword @return array
[ "Returns", "all", "keywords", "with", "a", "given", "name", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L174-L183
20,879
z38/pc-axis
src/Px.php
Px.keyword
public function keyword($keyword) { $list = $this->keywordList($keyword); if (empty($list)) { throw new RuntimeException(sprintf('Keyword "%s" does not exist.', $keyword)); } return $list[0]; }
php
public function keyword($keyword) { $list = $this->keywordList($keyword); if (empty($list)) { throw new RuntimeException(sprintf('Keyword "%s" does not exist.', $keyword)); } return $list[0]; }
[ "public", "function", "keyword", "(", "$", "keyword", ")", "{", "$", "list", "=", "$", "this", "->", "keywordList", "(", "$", "keyword", ")", ";", "if", "(", "empty", "(", "$", "list", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Keyword \"%s\" does not exist.'", ",", "$", "keyword", ")", ")", ";", "}", "return", "$", "list", "[", "0", "]", ";", "}" ]
Returns the first keyword with a given name. @param string $keyword @return object
[ "Returns", "the", "first", "keyword", "with", "a", "given", "name", "." ]
de568ff3525e4ea76870749a49cffdae4e05a603
https://github.com/z38/pc-axis/blob/de568ff3525e4ea76870749a49cffdae4e05a603/src/Px.php#L206-L214
20,880
eXistenZNL/PermCheck
src/Filesystem/AbstractFilesystem.php
AbstractFilesystem.getFiles
public function getFiles() { $iterator = new RecursiveDirectoryIterator( $this->directory, FilesystemIterator::SKIP_DOTS ); $iterator = new RecursiveIteratorIterator($iterator); $iterator->rewind(); return $iterator; }
php
public function getFiles() { $iterator = new RecursiveDirectoryIterator( $this->directory, FilesystemIterator::SKIP_DOTS ); $iterator = new RecursiveIteratorIterator($iterator); $iterator->rewind(); return $iterator; }
[ "public", "function", "getFiles", "(", ")", "{", "$", "iterator", "=", "new", "RecursiveDirectoryIterator", "(", "$", "this", "->", "directory", ",", "FilesystemIterator", "::", "SKIP_DOTS", ")", ";", "$", "iterator", "=", "new", "RecursiveIteratorIterator", "(", "$", "iterator", ")", ";", "$", "iterator", "->", "rewind", "(", ")", ";", "return", "$", "iterator", ";", "}" ]
Give back a list of all files in a given directory, recursively This returns the filename relative to the given directory. @return Iterator
[ "Give", "back", "a", "list", "of", "all", "files", "in", "a", "given", "directory", "recursively", "This", "returns", "the", "filename", "relative", "to", "the", "given", "directory", "." ]
f22f2936350f6b440222fb6ea37dfc382fc4550e
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/Filesystem/AbstractFilesystem.php#L51-L61
20,881
Erdiko/core
src/AjaxResponse.php
AjaxResponse.render
public function render() { $responseData = array( "status" => $this->_statusCode, "body" => $this->_content, "errors" => $this->_errors ); return json_encode($responseData); }
php
public function render() { $responseData = array( "status" => $this->_statusCode, "body" => $this->_content, "errors" => $this->_errors ); return json_encode($responseData); }
[ "public", "function", "render", "(", ")", "{", "$", "responseData", "=", "array", "(", "\"status\"", "=>", "$", "this", "->", "_statusCode", ",", "\"body\"", "=>", "$", "this", "->", "_content", ",", "\"errors\"", "=>", "$", "this", "->", "_errors", ")", ";", "return", "json_encode", "(", "$", "responseData", ")", ";", "}" ]
Ajax render function @return string
[ "Ajax", "render", "function" ]
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/AjaxResponse.php#L72-L81
20,882
xiewulong/yii2-fileupload
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php
XcacheClassLoader.findFile
public function findFile($class) { if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class)); } return $file; }
php
public function findFile($class) { if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { xcache_set($this->prefix.$class, $file = $this->classFinder->findFile($class)); } return $file; }
[ "public", "function", "findFile", "(", "$", "class", ")", "{", "if", "(", "xcache_isset", "(", "$", "this", "->", "prefix", ".", "$", "class", ")", ")", "{", "$", "file", "=", "xcache_get", "(", "$", "this", "->", "prefix", ".", "$", "class", ")", ";", "}", "else", "{", "xcache_set", "(", "$", "this", "->", "prefix", ".", "$", "class", ",", "$", "file", "=", "$", "this", "->", "classFinder", "->", "findFile", "(", "$", "class", ")", ")", ";", "}", "return", "$", "file", ";", "}" ]
Finds a file by class name while caching lookups to Xcache. @param string $class A class name to resolve to file @return string|null
[ "Finds", "a", "file", "by", "class", "name", "while", "caching", "lookups", "to", "Xcache", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/XcacheClassLoader.php#L114-L123
20,883
stk2k/net-driver
src/Http/HttpRequest.php
HttpRequest.addHttpHeader
public function addHttpHeader($http_header, $value) { $field = EnumRequestOption::HTTP_HEADERS; $http_headers = isset($this->options[$field]) ? $this->options[$field] : []; foreach($http_headers as $key => $header){ if (strpos($header, $http_header) === 0){ $http_headers[$key] = "$http_header: $value\r\n"; return; } } $http_headers[$http_header] = $value; $this->options[$field] = $http_headers; }
php
public function addHttpHeader($http_header, $value) { $field = EnumRequestOption::HTTP_HEADERS; $http_headers = isset($this->options[$field]) ? $this->options[$field] : []; foreach($http_headers as $key => $header){ if (strpos($header, $http_header) === 0){ $http_headers[$key] = "$http_header: $value\r\n"; return; } } $http_headers[$http_header] = $value; $this->options[$field] = $http_headers; }
[ "public", "function", "addHttpHeader", "(", "$", "http_header", ",", "$", "value", ")", "{", "$", "field", "=", "EnumRequestOption", "::", "HTTP_HEADERS", ";", "$", "http_headers", "=", "isset", "(", "$", "this", "->", "options", "[", "$", "field", "]", ")", "?", "$", "this", "->", "options", "[", "$", "field", "]", ":", "[", "]", ";", "foreach", "(", "$", "http_headers", "as", "$", "key", "=>", "$", "header", ")", "{", "if", "(", "strpos", "(", "$", "header", ",", "$", "http_header", ")", "===", "0", ")", "{", "$", "http_headers", "[", "$", "key", "]", "=", "\"$http_header: $value\\r\\n\"", ";", "return", ";", "}", "}", "$", "http_headers", "[", "$", "http_header", "]", "=", "$", "value", ";", "$", "this", "->", "options", "[", "$", "field", "]", "=", "$", "http_headers", ";", "}" ]
Add HTTP Header @param string $http_header @param string $value
[ "Add", "HTTP", "Header" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L74-L88
20,884
stk2k/net-driver
src/Http/HttpRequest.php
HttpRequest.getHttpHeaders
public function getHttpHeaders() { $field = EnumRequestOption::HTTP_HEADERS; $http_deaders = isset($this->options[$field]) ? $this->options[$field] : []; $http_deaders = array_merge($this->getDefaultHttpHeaders(), $http_deaders); return $http_deaders; }
php
public function getHttpHeaders() { $field = EnumRequestOption::HTTP_HEADERS; $http_deaders = isset($this->options[$field]) ? $this->options[$field] : []; $http_deaders = array_merge($this->getDefaultHttpHeaders(), $http_deaders); return $http_deaders; }
[ "public", "function", "getHttpHeaders", "(", ")", "{", "$", "field", "=", "EnumRequestOption", "::", "HTTP_HEADERS", ";", "$", "http_deaders", "=", "isset", "(", "$", "this", "->", "options", "[", "$", "field", "]", ")", "?", "$", "this", "->", "options", "[", "$", "field", "]", ":", "[", "]", ";", "$", "http_deaders", "=", "array_merge", "(", "$", "this", "->", "getDefaultHttpHeaders", "(", ")", ",", "$", "http_deaders", ")", ";", "return", "$", "http_deaders", ";", "}" ]
Get HTTP headers @return array
[ "Get", "HTTP", "headers" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L95-L103
20,885
stk2k/net-driver
src/Http/HttpRequest.php
HttpRequest.getExtraOptions
public function getExtraOptions() { $field = EnumRequestOption::EXTRA_OPTIONS; return isset($this->options[$field]) ? $this->options[$field] : []; }
php
public function getExtraOptions() { $field = EnumRequestOption::EXTRA_OPTIONS; return isset($this->options[$field]) ? $this->options[$field] : []; }
[ "public", "function", "getExtraOptions", "(", ")", "{", "$", "field", "=", "EnumRequestOption", "::", "EXTRA_OPTIONS", ";", "return", "isset", "(", "$", "this", "->", "options", "[", "$", "field", "]", ")", "?", "$", "this", "->", "options", "[", "$", "field", "]", ":", "[", "]", ";", "}" ]
Get extra options @return array
[ "Get", "extra", "options" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L110-L114
20,886
stk2k/net-driver
src/Http/HttpRequest.php
HttpRequest.getVerbose
public function getVerbose() { $field = EnumRequestOption::VERBOSE; return isset($this->options[$field]) ? $this->options[$field] : false; }
php
public function getVerbose() { $field = EnumRequestOption::VERBOSE; return isset($this->options[$field]) ? $this->options[$field] : false; }
[ "public", "function", "getVerbose", "(", ")", "{", "$", "field", "=", "EnumRequestOption", "::", "VERBOSE", ";", "return", "isset", "(", "$", "this", "->", "options", "[", "$", "field", "]", ")", "?", "$", "this", "->", "options", "[", "$", "field", "]", ":", "false", ";", "}" ]
Get verbose options @return bool
[ "Get", "verbose", "options" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpRequest.php#L121-L125
20,887
GrupaZero/api
src/Gzero/Api/Transformer/ContentTransformer.php
ContentTransformer.transform
public function transform($content) { $content = $this->entityToArray(Content::class, $content); return [ 'id' => $this->setNullableValue($content['id']), 'parentId' => $this->setNullableValue($content['parent_id']), 'type' => $content['type'], 'theme' => $content['theme'], 'weight' => (int) $content['weight'], 'rating' => (int) $content['rating'], 'visits' => (int) $content['visits'], 'isActive' => (bool) $content['is_active'], 'isOnHome' => (bool) $content['is_on_home'], 'isCommentAllowed' => (bool) $content['is_comment_allowed'], 'isPromoted' => (bool) $content['is_promoted'], 'isSticky' => (bool) $content['is_sticky'], 'path' => $this->buildPath($content['path']), 'publishedAt' => $content['published_at'], 'createdAt' => $content['created_at'], 'updatedAt' => $content['updated_at'] ]; }
php
public function transform($content) { $content = $this->entityToArray(Content::class, $content); return [ 'id' => $this->setNullableValue($content['id']), 'parentId' => $this->setNullableValue($content['parent_id']), 'type' => $content['type'], 'theme' => $content['theme'], 'weight' => (int) $content['weight'], 'rating' => (int) $content['rating'], 'visits' => (int) $content['visits'], 'isActive' => (bool) $content['is_active'], 'isOnHome' => (bool) $content['is_on_home'], 'isCommentAllowed' => (bool) $content['is_comment_allowed'], 'isPromoted' => (bool) $content['is_promoted'], 'isSticky' => (bool) $content['is_sticky'], 'path' => $this->buildPath($content['path']), 'publishedAt' => $content['published_at'], 'createdAt' => $content['created_at'], 'updatedAt' => $content['updated_at'] ]; }
[ "public", "function", "transform", "(", "$", "content", ")", "{", "$", "content", "=", "$", "this", "->", "entityToArray", "(", "Content", "::", "class", ",", "$", "content", ")", ";", "return", "[", "'id'", "=>", "$", "this", "->", "setNullableValue", "(", "$", "content", "[", "'id'", "]", ")", ",", "'parentId'", "=>", "$", "this", "->", "setNullableValue", "(", "$", "content", "[", "'parent_id'", "]", ")", ",", "'type'", "=>", "$", "content", "[", "'type'", "]", ",", "'theme'", "=>", "$", "content", "[", "'theme'", "]", ",", "'weight'", "=>", "(", "int", ")", "$", "content", "[", "'weight'", "]", ",", "'rating'", "=>", "(", "int", ")", "$", "content", "[", "'rating'", "]", ",", "'visits'", "=>", "(", "int", ")", "$", "content", "[", "'visits'", "]", ",", "'isActive'", "=>", "(", "bool", ")", "$", "content", "[", "'is_active'", "]", ",", "'isOnHome'", "=>", "(", "bool", ")", "$", "content", "[", "'is_on_home'", "]", ",", "'isCommentAllowed'", "=>", "(", "bool", ")", "$", "content", "[", "'is_comment_allowed'", "]", ",", "'isPromoted'", "=>", "(", "bool", ")", "$", "content", "[", "'is_promoted'", "]", ",", "'isSticky'", "=>", "(", "bool", ")", "$", "content", "[", "'is_sticky'", "]", ",", "'path'", "=>", "$", "this", "->", "buildPath", "(", "$", "content", "[", "'path'", "]", ")", ",", "'publishedAt'", "=>", "$", "content", "[", "'published_at'", "]", ",", "'createdAt'", "=>", "$", "content", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "content", "[", "'updated_at'", "]", "]", ";", "}" ]
Transforms content entity @param Content|array $content Content entity @return array
[ "Transforms", "content", "entity" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/ContentTransformer.php#L46-L67
20,888
GrupaZero/api
src/Gzero/Api/Transformer/FileTransformer.php
FileTransformer.transform
public function transform($file) { $thumb = null; if ($file->type === 'image') { $width = config('gzero.image.thumb.width'); $height = config('gzero.image.thumb.height'); $thumb = croppaUrl($file->getFullPath(), $width, $height); } $file = $this->entityToArray(File::class, $file); return [ 'id' => (int) $file['id'], 'type' => $file['type'], 'name' => $file['name'], 'extension' => $file['extension'], 'size' => (int) $file['size'], 'mimeType' => $file['mime_type'], 'info' => $file['info'], 'thumb' => $thumb, 'weight' => $this->setPivotNullableValue($file, 'weight'), 'isActive' => (bool) $file['is_active'], 'createdBy' => (int) $file['created_by'], 'createdAt' => $file['created_at'], 'updatedAt' => $file['updated_at'] ]; }
php
public function transform($file) { $thumb = null; if ($file->type === 'image') { $width = config('gzero.image.thumb.width'); $height = config('gzero.image.thumb.height'); $thumb = croppaUrl($file->getFullPath(), $width, $height); } $file = $this->entityToArray(File::class, $file); return [ 'id' => (int) $file['id'], 'type' => $file['type'], 'name' => $file['name'], 'extension' => $file['extension'], 'size' => (int) $file['size'], 'mimeType' => $file['mime_type'], 'info' => $file['info'], 'thumb' => $thumb, 'weight' => $this->setPivotNullableValue($file, 'weight'), 'isActive' => (bool) $file['is_active'], 'createdBy' => (int) $file['created_by'], 'createdAt' => $file['created_at'], 'updatedAt' => $file['updated_at'] ]; }
[ "public", "function", "transform", "(", "$", "file", ")", "{", "$", "thumb", "=", "null", ";", "if", "(", "$", "file", "->", "type", "===", "'image'", ")", "{", "$", "width", "=", "config", "(", "'gzero.image.thumb.width'", ")", ";", "$", "height", "=", "config", "(", "'gzero.image.thumb.height'", ")", ";", "$", "thumb", "=", "croppaUrl", "(", "$", "file", "->", "getFullPath", "(", ")", ",", "$", "width", ",", "$", "height", ")", ";", "}", "$", "file", "=", "$", "this", "->", "entityToArray", "(", "File", "::", "class", ",", "$", "file", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "file", "[", "'id'", "]", ",", "'type'", "=>", "$", "file", "[", "'type'", "]", ",", "'name'", "=>", "$", "file", "[", "'name'", "]", ",", "'extension'", "=>", "$", "file", "[", "'extension'", "]", ",", "'size'", "=>", "(", "int", ")", "$", "file", "[", "'size'", "]", ",", "'mimeType'", "=>", "$", "file", "[", "'mime_type'", "]", ",", "'info'", "=>", "$", "file", "[", "'info'", "]", ",", "'thumb'", "=>", "$", "thumb", ",", "'weight'", "=>", "$", "this", "->", "setPivotNullableValue", "(", "$", "file", ",", "'weight'", ")", ",", "'isActive'", "=>", "(", "bool", ")", "$", "file", "[", "'is_active'", "]", ",", "'createdBy'", "=>", "(", "int", ")", "$", "file", "[", "'created_by'", "]", ",", "'createdAt'", "=>", "$", "file", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "file", "[", "'updated_at'", "]", "]", ";", "}" ]
Transforms file entity @param File|array $file file entity @return array
[ "Transforms", "file", "entity" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/FileTransformer.php#L35-L61
20,889
GrupaZero/api
src/Gzero/Api/Transformer/FileTransformer.php
FileTransformer.setPivotNullableValue
private function setPivotNullableValue($file, $key) { if (array_key_exists('pivot', $file)) { return $this->setNullableValue($file['pivot'][$key]); } return null; }
php
private function setPivotNullableValue($file, $key) { if (array_key_exists('pivot', $file)) { return $this->setNullableValue($file['pivot'][$key]); } return null; }
[ "private", "function", "setPivotNullableValue", "(", "$", "file", ",", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "'pivot'", ",", "$", "file", ")", ")", "{", "return", "$", "this", "->", "setNullableValue", "(", "$", "file", "[", "'pivot'", "]", "[", "$", "key", "]", ")", ";", "}", "return", "null", ";", "}" ]
Returns pivot integer value or null @param array $file file to check for pivot @param string $key to evaluate @return int|null
[ "Returns", "pivot", "integer", "value", "or", "null" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/FileTransformer.php#L96-L103
20,890
Visithor/visithor
src/Visithor/Executor/Executor.php
Executor.execute
public function execute( UrlChain $urlChain, RendererInterface $renderer, OutputInterface $output ) { $result = 0; foreach ($urlChain->getUrls() as $url) { $result = $result | $this->executeUrl( $this->client, $url, $renderer, $output ); } return $result; }
php
public function execute( UrlChain $urlChain, RendererInterface $renderer, OutputInterface $output ) { $result = 0; foreach ($urlChain->getUrls() as $url) { $result = $result | $this->executeUrl( $this->client, $url, $renderer, $output ); } return $result; }
[ "public", "function", "execute", "(", "UrlChain", "$", "urlChain", ",", "RendererInterface", "$", "renderer", ",", "OutputInterface", "$", "output", ")", "{", "$", "result", "=", "0", ";", "foreach", "(", "$", "urlChain", "->", "getUrls", "(", ")", "as", "$", "url", ")", "{", "$", "result", "=", "$", "result", "|", "$", "this", "->", "executeUrl", "(", "$", "this", "->", "client", ",", "$", "url", ",", "$", "renderer", ",", "$", "output", ")", ";", "}", "return", "$", "result", ";", "}" ]
Renders the output of the result of executing some urls given a client instance If all urls are executed as expected, then the result of the operation will be 0. Otherwise, the result will be 1. @param UrlChain $urlChain Url chain @param RendererInterface $renderer Renderer @param OutputInterface $output Output @return int Result of the execution
[ "Renders", "the", "output", "of", "the", "result", "of", "executing", "some", "urls", "given", "a", "client", "instance" ]
201ba2cfc536a0875983c79226947aa20b9f4dca
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Executor/Executor.php#L71-L88
20,891
Visithor/visithor
src/Visithor/Executor/Executor.php
Executor.executeUrl
protected function executeUrl( ClientInterface $client, Url $url, RendererInterface $renderer, OutputInterface $output ) { $resultHTTPCode = $client->getResponseHTTPCode($url); $resultExecution = in_array( $resultHTTPCode, $url->getAcceptableHttpCodes() ) ? 0 : 1; $renderer->render( $output, $url, $resultHTTPCode, (0 === $resultExecution) ); return $resultExecution; }
php
protected function executeUrl( ClientInterface $client, Url $url, RendererInterface $renderer, OutputInterface $output ) { $resultHTTPCode = $client->getResponseHTTPCode($url); $resultExecution = in_array( $resultHTTPCode, $url->getAcceptableHttpCodes() ) ? 0 : 1; $renderer->render( $output, $url, $resultHTTPCode, (0 === $resultExecution) ); return $resultExecution; }
[ "protected", "function", "executeUrl", "(", "ClientInterface", "$", "client", ",", "Url", "$", "url", ",", "RendererInterface", "$", "renderer", ",", "OutputInterface", "$", "output", ")", "{", "$", "resultHTTPCode", "=", "$", "client", "->", "getResponseHTTPCode", "(", "$", "url", ")", ";", "$", "resultExecution", "=", "in_array", "(", "$", "resultHTTPCode", ",", "$", "url", "->", "getAcceptableHttpCodes", "(", ")", ")", "?", "0", ":", "1", ";", "$", "renderer", "->", "render", "(", "$", "output", ",", "$", "url", ",", "$", "resultHTTPCode", ",", "(", "0", "===", "$", "resultExecution", ")", ")", ";", "return", "$", "resultExecution", ";", "}" ]
Executes an URL and render the result given a renderer. If the url is executed as expected, then the result of the operation will be 0. Otherwise, the result will be 1. @param ClientInterface $client Client @param Url $url Url @param RendererInterface $renderer Renderer @param OutputInterface $output Output @return boolean Result of the execution
[ "Executes", "an", "URL", "and", "render", "the", "result", "given", "a", "renderer", "." ]
201ba2cfc536a0875983c79226947aa20b9f4dca
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Executor/Executor.php#L115-L137
20,892
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.createStream
public function createStream($serverconfig = null) { if ($serverconfig == null) { $serverconfig = $this->default_streamserver_config; } $stream = new $this->stream_class; $stream->setRtmpServer($this->streamserver_config[$serverconfig]['rtmp_url']); $stream->setRtmpApp($this->streamserver_config[$serverconfig]['app']); return $stream; }
php
public function createStream($serverconfig = null) { if ($serverconfig == null) { $serverconfig = $this->default_streamserver_config; } $stream = new $this->stream_class; $stream->setRtmpServer($this->streamserver_config[$serverconfig]['rtmp_url']); $stream->setRtmpApp($this->streamserver_config[$serverconfig]['app']); return $stream; }
[ "public", "function", "createStream", "(", "$", "serverconfig", "=", "null", ")", "{", "if", "(", "$", "serverconfig", "==", "null", ")", "{", "$", "serverconfig", "=", "$", "this", "->", "default_streamserver_config", ";", "}", "$", "stream", "=", "new", "$", "this", "->", "stream_class", ";", "$", "stream", "->", "setRtmpServer", "(", "$", "this", "->", "streamserver_config", "[", "$", "serverconfig", "]", "[", "'rtmp_url'", "]", ")", ";", "$", "stream", "->", "setRtmpApp", "(", "$", "this", "->", "streamserver_config", "[", "$", "serverconfig", "]", "[", "'app'", "]", ")", ";", "return", "$", "stream", ";", "}" ]
returns a new stream object preset with default streamserver config
[ "returns", "a", "new", "stream", "object", "preset", "with", "default", "streamserver", "config" ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L36-L45
20,893
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.startRecording
public function startRecording($stream) { $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']); $rtmp_app = end($parts); $success = $this->record( $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'], $rtmp_app, $stream->getUniqID() ); if ($success) { $stream->setTechnicalStatus(Stream::STATE_RECORDING); $this->em->persist($stream); $this->em->flush(); $event = new StartRecordingStreamEvent($stream); $this->dispatcher->dispatch( OktolabMediaEvent::STREAM_START_RECORDING, $event ); return true; } return false; }
php
public function startRecording($stream) { $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']); $rtmp_app = end($parts); $success = $this->record( $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'], $rtmp_app, $stream->getUniqID() ); if ($success) { $stream->setTechnicalStatus(Stream::STATE_RECORDING); $this->em->persist($stream); $this->em->flush(); $event = new StartRecordingStreamEvent($stream); $this->dispatcher->dispatch( OktolabMediaEvent::STREAM_START_RECORDING, $event ); return true; } return false; }
[ "public", "function", "startRecording", "(", "$", "stream", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "this", "->", "streamserver_config", "[", "$", "stream", "->", "getRtmpServer", "(", ")", "]", "[", "'rtmp_url'", "]", ")", ";", "$", "rtmp_app", "=", "end", "(", "$", "parts", ")", ";", "$", "success", "=", "$", "this", "->", "record", "(", "$", "this", "->", "streamserver_config", "[", "$", "stream", "->", "getRtmpServer", "(", ")", "]", "[", "'rtmp_control'", "]", ",", "$", "rtmp_app", ",", "$", "stream", "->", "getUniqID", "(", ")", ")", ";", "if", "(", "$", "success", ")", "{", "$", "stream", "->", "setTechnicalStatus", "(", "Stream", "::", "STATE_RECORDING", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "stream", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "$", "event", "=", "new", "StartRecordingStreamEvent", "(", "$", "stream", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "OktolabMediaEvent", "::", "STREAM_START_RECORDING", ",", "$", "event", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
start recording a stream.
[ "start", "recording", "a", "stream", "." ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L78-L100
20,894
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.endRecording
public function endRecording($stream) { $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']); $rtmp_app = end($parts); $success = $this->record( $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'], $rtmp_app, $stream->getUniqID(), false ); if ($success) { $stream->setTechnicalStatus(Stream::STATE_ENDED); $this->em->persist($stream); $this->em->flush(); // $event = new EndRecordingStreamEvent($stream); // $this->dispatcher->dispatch( // OktolabMediaEvent::STREAM_END_RECORDING, // $event // ); return true; } return false; }
php
public function endRecording($stream) { $parts = explode('/', $this->streamserver_config[$stream->getRtmpServer()]['rtmp_url']); $rtmp_app = end($parts); $success = $this->record( $this->streamserver_config[$stream->getRtmpServer()]['rtmp_control'], $rtmp_app, $stream->getUniqID(), false ); if ($success) { $stream->setTechnicalStatus(Stream::STATE_ENDED); $this->em->persist($stream); $this->em->flush(); // $event = new EndRecordingStreamEvent($stream); // $this->dispatcher->dispatch( // OktolabMediaEvent::STREAM_END_RECORDING, // $event // ); return true; } return false; }
[ "public", "function", "endRecording", "(", "$", "stream", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "this", "->", "streamserver_config", "[", "$", "stream", "->", "getRtmpServer", "(", ")", "]", "[", "'rtmp_url'", "]", ")", ";", "$", "rtmp_app", "=", "end", "(", "$", "parts", ")", ";", "$", "success", "=", "$", "this", "->", "record", "(", "$", "this", "->", "streamserver_config", "[", "$", "stream", "->", "getRtmpServer", "(", ")", "]", "[", "'rtmp_control'", "]", ",", "$", "rtmp_app", ",", "$", "stream", "->", "getUniqID", "(", ")", ",", "false", ")", ";", "if", "(", "$", "success", ")", "{", "$", "stream", "->", "setTechnicalStatus", "(", "Stream", "::", "STATE_ENDED", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "stream", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "// $event = new EndRecordingStreamEvent($stream);", "// $this->dispatcher->dispatch(", "// OktolabMediaEvent::STREAM_END_RECORDING,", "// $event", "// );", "return", "true", ";", "}", "return", "false", ";", "}" ]
end recording a stream
[ "end", "recording", "a", "stream" ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L105-L128
20,895
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.addPublishToAdress
public function addPublishToAdress($stream, $rtmp_adress, $clientid, $new_name, $type = 'publisher', $srv = null) { return $this->redirect( $stream->getRtmpApp(), $stream->getUniqID(), $rtmp_adress, $clientid, $new_name, $type, $srv ); }
php
public function addPublishToAdress($stream, $rtmp_adress, $clientid, $new_name, $type = 'publisher', $srv = null) { return $this->redirect( $stream->getRtmpApp(), $stream->getUniqID(), $rtmp_adress, $clientid, $new_name, $type, $srv ); }
[ "public", "function", "addPublishToAdress", "(", "$", "stream", ",", "$", "rtmp_adress", ",", "$", "clientid", ",", "$", "new_name", ",", "$", "type", "=", "'publisher'", ",", "$", "srv", "=", "null", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "stream", "->", "getRtmpApp", "(", ")", ",", "$", "stream", "->", "getUniqID", "(", ")", ",", "$", "rtmp_adress", ",", "$", "clientid", ",", "$", "new_name", ",", "$", "type", ",", "$", "srv", ")", ";", "}" ]
adds a push to another rtmp server. can be used to send a stream to facebook, youtube, etc. @var stream the stream you want to push @var rtmp_adress the adress you want to push to @var cientid the streamkey of the destination @var new_name the app of the rtmp server you want to push to @var srv optional nginx server to use
[ "adds", "a", "push", "to", "another", "rtmp", "server", ".", "can", "be", "used", "to", "send", "a", "stream", "to", "facebook", "youtube", "etc", "." ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L154-L165
20,896
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.drop
public function drop($control_url, $app, $name, $type = 'publisher', $addr = null, $clientid = null, $srv = null) { $query = []; $query['app'] = $app; $query['name'] = $name; if ($addr) { $query['addr'] = $addr; } if ($clientid) { $query['clientid'] = $clientid; } if ($srv) { $query['srv'] = $srv; } $client = new Client(); try { $response = $client->request( 'GET', $url .'/control/drop/'.$type, [ 'query' => $query ] ); } catch (RequestException $e) { return false; } catch (Exception $e) { return false; } return true; }
php
public function drop($control_url, $app, $name, $type = 'publisher', $addr = null, $clientid = null, $srv = null) { $query = []; $query['app'] = $app; $query['name'] = $name; if ($addr) { $query['addr'] = $addr; } if ($clientid) { $query['clientid'] = $clientid; } if ($srv) { $query['srv'] = $srv; } $client = new Client(); try { $response = $client->request( 'GET', $url .'/control/drop/'.$type, [ 'query' => $query ] ); } catch (RequestException $e) { return false; } catch (Exception $e) { return false; } return true; }
[ "public", "function", "drop", "(", "$", "control_url", ",", "$", "app", ",", "$", "name", ",", "$", "type", "=", "'publisher'", ",", "$", "addr", "=", "null", ",", "$", "clientid", "=", "null", ",", "$", "srv", "=", "null", ")", "{", "$", "query", "=", "[", "]", ";", "$", "query", "[", "'app'", "]", "=", "$", "app", ";", "$", "query", "[", "'name'", "]", "=", "$", "name", ";", "if", "(", "$", "addr", ")", "{", "$", "query", "[", "'addr'", "]", "=", "$", "addr", ";", "}", "if", "(", "$", "clientid", ")", "{", "$", "query", "[", "'clientid'", "]", "=", "$", "clientid", ";", "}", "if", "(", "$", "srv", ")", "{", "$", "query", "[", "'srv'", "]", "=", "$", "srv", ";", "}", "$", "client", "=", "new", "Client", "(", ")", ";", "try", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'GET'", ",", "$", "url", ".", "'/control/drop/'", ".", "$", "type", ",", "[", "'query'", "=>", "$", "query", "]", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
send a drop command to the rtmp server @var app the app name @var name the streamkey @var type the type for your drop command publisher|subscriber|client @var addr the optional client adress @var clientId the optional nginx client id @var srv optional server{} block number within rtmp{} block. default the first is used (nginx rtmp)
[ "send", "a", "drop", "command", "to", "the", "rtmp", "server" ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L228-L261
20,897
OKTOTV/OktolabMediaBundle
Model/StreamService.php
StreamService.redirect
public function redirect($control_url, $app, $name, $new_adress, $new_clientid, $new_name, $type = 'publisher', $srv = null) { $query = []; $query['app'] = $app; $query['name'] = $name; $query['addr'] = $new_adress; $query['clientid'] = $new_clientid; $query['newname'] = $new_name; if ($srv) { $query['srv'] = $srv; } $client = new Client(); try { $response = $client->request( 'GET', $url .'/control/redirect/'.$type, [ 'query' => $query ] ); } catch (RequestException $e) { return false; } catch (Exception $e) { return false; } return true; }
php
public function redirect($control_url, $app, $name, $new_adress, $new_clientid, $new_name, $type = 'publisher', $srv = null) { $query = []; $query['app'] = $app; $query['name'] = $name; $query['addr'] = $new_adress; $query['clientid'] = $new_clientid; $query['newname'] = $new_name; if ($srv) { $query['srv'] = $srv; } $client = new Client(); try { $response = $client->request( 'GET', $url .'/control/redirect/'.$type, [ 'query' => $query ] ); } catch (RequestException $e) { return false; } catch (Exception $e) { return false; } return true; }
[ "public", "function", "redirect", "(", "$", "control_url", ",", "$", "app", ",", "$", "name", ",", "$", "new_adress", ",", "$", "new_clientid", ",", "$", "new_name", ",", "$", "type", "=", "'publisher'", ",", "$", "srv", "=", "null", ")", "{", "$", "query", "=", "[", "]", ";", "$", "query", "[", "'app'", "]", "=", "$", "app", ";", "$", "query", "[", "'name'", "]", "=", "$", "name", ";", "$", "query", "[", "'addr'", "]", "=", "$", "new_adress", ";", "$", "query", "[", "'clientid'", "]", "=", "$", "new_clientid", ";", "$", "query", "[", "'newname'", "]", "=", "$", "new_name", ";", "if", "(", "$", "srv", ")", "{", "$", "query", "[", "'srv'", "]", "=", "$", "srv", ";", "}", "$", "client", "=", "new", "Client", "(", ")", ";", "try", "{", "$", "response", "=", "$", "client", "->", "request", "(", "'GET'", ",", "$", "url", ".", "'/control/redirect/'", ".", "$", "type", ",", "[", "'query'", "=>", "$", "query", "]", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "return", "false", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
sends a redirect command to the rtmp server @var app the rtmp app name @var name the streamkey @var new_adress the optional client adress @var clientId the optional nginx client id @var new_name new stream name to redirect to (streamkey) @var new_clientid optional nginx client id
[ "sends", "a", "redirect", "command", "to", "the", "rtmp", "server" ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/StreamService.php#L272-L302
20,898
wenbinye/PhalconX
src/Http/Request.php
Request.getFile
public function getFile($name) { if (!isset($this->files)) { $files = $this->getUploadedFiles(); foreach ($files as $file) { $key = $file->getKey(); if (isset($key)) { $this->files[$key] = $file; } else { $this->files[] = $file; } } } if (isset($this->files[$name])) { return $this->files[$name]; } else { throw new \InvalidArgumentException("Upload file '$name' is empty"); } }
php
public function getFile($name) { if (!isset($this->files)) { $files = $this->getUploadedFiles(); foreach ($files as $file) { $key = $file->getKey(); if (isset($key)) { $this->files[$key] = $file; } else { $this->files[] = $file; } } } if (isset($this->files[$name])) { return $this->files[$name]; } else { throw new \InvalidArgumentException("Upload file '$name' is empty"); } }
[ "public", "function", "getFile", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "files", ")", ")", "{", "$", "files", "=", "$", "this", "->", "getUploadedFiles", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "key", "=", "$", "file", "->", "getKey", "(", ")", ";", "if", "(", "isset", "(", "$", "key", ")", ")", "{", "$", "this", "->", "files", "[", "$", "key", "]", "=", "$", "file", ";", "}", "else", "{", "$", "this", "->", "files", "[", "]", "=", "$", "file", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "files", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "files", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Upload file '$name' is empty\"", ")", ";", "}", "}" ]
Gets upload file object by name @return Phalcon\Http\Request\File
[ "Gets", "upload", "file", "object", "by", "name" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Http/Request.php#L50-L68
20,899
wenbinye/PhalconX
src/Http/Request.php
Request.getBody
public function getBody() { if (!isset($this->body)) { if (function_exists('http_get_request_body')) { $this->body = http_get_request_body(); } else { $this->body = @file_get_contents('php://input'); } } return $this->body; }
php
public function getBody() { if (!isset($this->body)) { if (function_exists('http_get_request_body')) { $this->body = http_get_request_body(); } else { $this->body = @file_get_contents('php://input'); } } return $this->body; }
[ "public", "function", "getBody", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "body", ")", ")", "{", "if", "(", "function_exists", "(", "'http_get_request_body'", ")", ")", "{", "$", "this", "->", "body", "=", "http_get_request_body", "(", ")", ";", "}", "else", "{", "$", "this", "->", "body", "=", "@", "file_get_contents", "(", "'php://input'", ")", ";", "}", "}", "return", "$", "this", "->", "body", ";", "}" ]
Gets post body content @return string
[ "Gets", "post", "body", "content" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Http/Request.php#L75-L85