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
229,600
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.getPath
public function getPath() { $node = $this; $path = []; while (true) { $path[] = $node["name"]; if ($node->isRoot()) { break; } $node = self::loadById($node["parents"][0]); if (is_null($node)) { throw new \Exception("No parent node found with ID {$node['parents'][0]}."); } if ($node->isRoot()) { break; } } $path = array_reverse($path); return implode('/', $path); }
php
public function getPath() { $node = $this; $path = []; while (true) { $path[] = $node["name"]; if ($node->isRoot()) { break; } $node = self::loadById($node["parents"][0]); if (is_null($node)) { throw new \Exception("No parent node found with ID {$node['parents'][0]}."); } if ($node->isRoot()) { break; } } $path = array_reverse($path); return implode('/', $path); }
[ "public", "function", "getPath", "(", ")", "{", "$", "node", "=", "$", "this", ";", "$", "path", "=", "[", "]", ";", "while", "(", "true", ")", "{", "$", "path", "[", "]", "=", "$", "node", "[", "\"name\"", "]", ";", "if", "(", "$", "node", "->", "isRoot", "(", ")", ")", "{", "break", ";", "}", "$", "node", "=", "self", "::", "loadById", "(", "$", "node", "[", "\"parents\"", "]", "[", "0", "]", ")", ";", "if", "(", "is_null", "(", "$", "node", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"No parent node found with ID {$node['parents'][0]}.\"", ")", ";", "}", "if", "(", "$", "node", "->", "isRoot", "(", ")", ")", "{", "break", ";", "}", "}", "$", "path", "=", "array_reverse", "(", "$", "path", ")", ";", "return", "implode", "(", "'/'", ",", "$", "path", ")", ";", "}" ]
Build and return the remote directory path of the given `Node`. @return string @throws \Exception
[ "Build", "and", "return", "the", "remote", "directory", "path", "of", "the", "given", "Node", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L303-L327
229,601
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.init
public static function init(Account $account, Cache $cacheStore) { if (self::$initialized === true) { throw new \Exception("`Node` class has already been initialized."); } self::$account = $account; self::$cacheStore = $cacheStore; self::$httpClient = new Client(); self::$initialized = true; }
php
public static function init(Account $account, Cache $cacheStore) { if (self::$initialized === true) { throw new \Exception("`Node` class has already been initialized."); } self::$account = $account; self::$cacheStore = $cacheStore; self::$httpClient = new Client(); self::$initialized = true; }
[ "public", "static", "function", "init", "(", "Account", "$", "account", ",", "Cache", "$", "cacheStore", ")", "{", "if", "(", "self", "::", "$", "initialized", "===", "true", ")", "{", "throw", "new", "\\", "Exception", "(", "\"`Node` class has already been initialized.\"", ")", ";", "}", "self", "::", "$", "account", "=", "$", "account", ";", "self", "::", "$", "cacheStore", "=", "$", "cacheStore", ";", "self", "::", "$", "httpClient", "=", "new", "Client", "(", ")", ";", "self", "::", "$", "initialized", "=", "true", ";", "}" ]
Set the local storage cache. @param \CloudDrive\Account $account @param \CloudDrive\Cache $cacheStore @throws \Exception
[ "Set", "the", "local", "storage", "cache", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L337-L348
229,602
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.load
public static function load($param) { if (!($node = self::loadById($param))) { $node = self::loadByPath($param); } return $node; }
php
public static function load($param) { if (!($node = self::loadById($param))) { $node = self::loadByPath($param); } return $node; }
[ "public", "static", "function", "load", "(", "$", "param", ")", "{", "if", "(", "!", "(", "$", "node", "=", "self", "::", "loadById", "(", "$", "param", ")", ")", ")", "{", "$", "node", "=", "self", "::", "loadByPath", "(", "$", "param", ")", ";", "}", "return", "$", "node", ";", "}" ]
Load a `Node` given an ID or remote path. @param string $param Parameter to find the `Node` by: ID or path @return \CloudDrive\Node|null
[ "Load", "a", "Node", "given", "an", "ID", "or", "remote", "path", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L407-L414
229,603
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.loadByPath
public static function loadByPath($path) { $path = trim($path, '/'); if (!$path) { return self::loadRoot(); } $info = pathinfo($path); $nodes = self::loadByName($info['basename']); if (empty($nodes)) { return null; } foreach ($nodes as $node) { if ($node->getPath() === $path) { return $node; } } return null; }
php
public static function loadByPath($path) { $path = trim($path, '/'); if (!$path) { return self::loadRoot(); } $info = pathinfo($path); $nodes = self::loadByName($info['basename']); if (empty($nodes)) { return null; } foreach ($nodes as $node) { if ($node->getPath() === $path) { return $node; } } return null; }
[ "public", "static", "function", "loadByPath", "(", "$", "path", ")", "{", "$", "path", "=", "trim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "!", "$", "path", ")", "{", "return", "self", "::", "loadRoot", "(", ")", ";", "}", "$", "info", "=", "pathinfo", "(", "$", "path", ")", ";", "$", "nodes", "=", "self", "::", "loadByName", "(", "$", "info", "[", "'basename'", "]", ")", ";", "if", "(", "empty", "(", "$", "nodes", ")", ")", "{", "return", "null", ";", "}", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "getPath", "(", ")", "===", "$", "path", ")", "{", "return", "$", "node", ";", "}", "}", "return", "null", ";", "}" ]
Find and return `Node` that matches the given remote path. @param string $path Remote path of the `Node` @return \CloudDrive\Node|null @throws \Exception
[ "Find", "and", "return", "Node", "that", "matches", "the", "given", "remote", "path", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L460-L480
229,604
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.loadRoot
public static function loadRoot() { $results = self::loadByName('Cloud Drive'); if (empty($results)) { throw new \Exception("No node by name 'Cloud Drive' found in the database."); } foreach ($results as $result) { if ($result->isRoot()) { return $result; } } throw new \Exception("Unable to find root node."); }
php
public static function loadRoot() { $results = self::loadByName('Cloud Drive'); if (empty($results)) { throw new \Exception("No node by name 'Cloud Drive' found in the database."); } foreach ($results as $result) { if ($result->isRoot()) { return $result; } } throw new \Exception("Unable to find root node."); }
[ "public", "static", "function", "loadRoot", "(", ")", "{", "$", "results", "=", "self", "::", "loadByName", "(", "'Cloud Drive'", ")", ";", "if", "(", "empty", "(", "$", "results", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"No node by name 'Cloud Drive' found in the database.\"", ")", ";", "}", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "if", "(", "$", "result", "->", "isRoot", "(", ")", ")", "{", "return", "$", "result", ";", "}", "}", "throw", "new", "\\", "Exception", "(", "\"Unable to find root node.\"", ")", ";", "}" ]
Return the root `Node`. @return \CloudDrive\Node @throws \Exception
[ "Return", "the", "root", "Node", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L488-L502
229,605
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.move
public function move(Node $newFolder) { if (!$newFolder->isFolder()) { throw new \Exception("New destination node is not a folder."); } if (!$this->isFile() && !$this->isFolder()) { throw new \Exception("Moving a node can only be performed on FILE and FOLDER kinds."); } $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->post( self::$account->getMetadataUrl() . "nodes/{$newFolder['id']}/children", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'json' => [ 'fromParent' => $this['parents'][0], 'childId' => $this['id'], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
php
public function move(Node $newFolder) { if (!$newFolder->isFolder()) { throw new \Exception("New destination node is not a folder."); } if (!$this->isFile() && !$this->isFolder()) { throw new \Exception("Moving a node can only be performed on FILE and FOLDER kinds."); } $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->post( self::$account->getMetadataUrl() . "nodes/{$newFolder['id']}/children", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'json' => [ 'fromParent' => $this['parents'][0], 'childId' => $this['id'], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
[ "public", "function", "move", "(", "Node", "$", "newFolder", ")", "{", "if", "(", "!", "$", "newFolder", "->", "isFolder", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"New destination node is not a folder.\"", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isFile", "(", ")", "&&", "!", "$", "this", "->", "isFolder", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Moving a node can only be performed on FILE and FOLDER kinds.\"", ")", ";", "}", "$", "retval", "=", "[", "'success'", "=>", "false", ",", "'data'", "=>", "[", "]", ",", "]", ";", "$", "response", "=", "self", "::", "$", "httpClient", "->", "post", "(", "self", "::", "$", "account", "->", "getMetadataUrl", "(", ")", ".", "\"nodes/{$newFolder['id']}/children\"", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "self", "::", "$", "account", "->", "getToken", "(", ")", "[", "'access_token'", "]", ",", "]", ",", "'json'", "=>", "[", "'fromParent'", "=>", "$", "this", "[", "'parents'", "]", "[", "0", "]", ",", "'childId'", "=>", "$", "this", "[", "'id'", "]", ",", "]", ",", "'exceptions'", "=>", "false", ",", "]", ")", ";", "$", "retval", "[", "'data'", "]", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "200", ")", "{", "$", "retval", "[", "'success'", "]", "=", "true", ";", "$", "this", "->", "replace", "(", "$", "retval", "[", "'data'", "]", ")", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Move a FILE or FOLDER `Node` to a new remote location. @param \CloudDrive\Node $newFolder @return array @throws \Exception
[ "Move", "a", "FILE", "or", "FOLDER", "Node", "to", "a", "new", "remote", "location", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L512-L550
229,606
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.overwrite
public function overwrite($localPath) { $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->put( self::$account->getContentUrl() . "nodes/{$this['id']}/content", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'multipart' => [ [ 'name' => 'content', 'contents' => fopen($localPath, 'r'), ], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; } return $retval; }
php
public function overwrite($localPath) { $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->put( self::$account->getContentUrl() . "nodes/{$this['id']}/content", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'multipart' => [ [ 'name' => 'content', 'contents' => fopen($localPath, 'r'), ], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; } return $retval; }
[ "public", "function", "overwrite", "(", "$", "localPath", ")", "{", "$", "retval", "=", "[", "'success'", "=>", "false", ",", "'data'", "=>", "[", "]", ",", "]", ";", "$", "response", "=", "self", "::", "$", "httpClient", "->", "put", "(", "self", "::", "$", "account", "->", "getContentUrl", "(", ")", ".", "\"nodes/{$this['id']}/content\"", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "self", "::", "$", "account", "->", "getToken", "(", ")", "[", "'access_token'", "]", ",", "]", ",", "'multipart'", "=>", "[", "[", "'name'", "=>", "'content'", ",", "'contents'", "=>", "fopen", "(", "$", "localPath", ",", "'r'", ")", ",", "]", ",", "]", ",", "'exceptions'", "=>", "false", ",", "]", ")", ";", "$", "retval", "[", "'data'", "]", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "200", ")", "{", "$", "retval", "[", "'success'", "]", "=", "true", ";", "}", "return", "$", "retval", ";", "}" ]
Replace file contents of the `Node` with the file located at the given local path. @param string $localPath @return array
[ "Replace", "file", "contents", "of", "the", "Node", "with", "the", "file", "located", "at", "the", "given", "local", "path", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L560-L590
229,607
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.rename
public function rename($name) { $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->patch( self::$account->getMetadataUrl() . "nodes/{$this['id']}", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'json' => [ 'name' => $name, ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
php
public function rename($name) { $retval = [ 'success' => false, 'data' => [], ]; $response = self::$httpClient->patch( self::$account->getMetadataUrl() . "nodes/{$this['id']}", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'json' => [ 'name' => $name, ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
[ "public", "function", "rename", "(", "$", "name", ")", "{", "$", "retval", "=", "[", "'success'", "=>", "false", ",", "'data'", "=>", "[", "]", ",", "]", ";", "$", "response", "=", "self", "::", "$", "httpClient", "->", "patch", "(", "self", "::", "$", "account", "->", "getMetadataUrl", "(", ")", ".", "\"nodes/{$this['id']}\"", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "self", "::", "$", "account", "->", "getToken", "(", ")", "[", "'access_token'", "]", ",", "]", ",", "'json'", "=>", "[", "'name'", "=>", "$", "name", ",", "]", ",", "'exceptions'", "=>", "false", ",", "]", ")", ";", "$", "retval", "[", "'data'", "]", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "200", ")", "{", "$", "retval", "[", "'success'", "]", "=", "true", ";", "$", "this", "->", "replace", "(", "$", "retval", "[", "'data'", "]", ")", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Modify the name of a remote `Node`. @param string $name @return array
[ "Modify", "the", "name", "of", "a", "remote", "Node", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L599-L628
229,608
alex-phillips/clouddrive-php
src/CloudDrive/Node.php
Node.restore
public function restore() { $retval = [ 'success' => false, 'data' => [], ]; if ($this['status'] === 'AVAILABLE') { $retval['data']['message'] = 'Node is already available.'; return $retval; } $response = self::$httpClient->post( self::$account->getMetadataUrl() . "trash/{$this['id']}/restore", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
php
public function restore() { $retval = [ 'success' => false, 'data' => [], ]; if ($this['status'] === 'AVAILABLE') { $retval['data']['message'] = 'Node is already available.'; return $retval; } $response = self::$httpClient->post( self::$account->getMetadataUrl() . "trash/{$this['id']}/restore", [ 'headers' => [ 'Authorization' => 'Bearer ' . self::$account->getToken()['access_token'], ], 'exceptions' => false, ] ); $retval['data'] = json_decode((string)$response->getBody(), true); if ($response->getStatusCode() === 200) { $retval['success'] = true; $this->replace($retval['data']); $this->save(); } return $retval; }
[ "public", "function", "restore", "(", ")", "{", "$", "retval", "=", "[", "'success'", "=>", "false", ",", "'data'", "=>", "[", "]", ",", "]", ";", "if", "(", "$", "this", "[", "'status'", "]", "===", "'AVAILABLE'", ")", "{", "$", "retval", "[", "'data'", "]", "[", "'message'", "]", "=", "'Node is already available.'", ";", "return", "$", "retval", ";", "}", "$", "response", "=", "self", "::", "$", "httpClient", "->", "post", "(", "self", "::", "$", "account", "->", "getMetadataUrl", "(", ")", ".", "\"trash/{$this['id']}/restore\"", ",", "[", "'headers'", "=>", "[", "'Authorization'", "=>", "'Bearer '", ".", "self", "::", "$", "account", "->", "getToken", "(", ")", "[", "'access_token'", "]", ",", "]", ",", "'exceptions'", "=>", "false", ",", "]", ")", ";", "$", "retval", "[", "'data'", "]", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "200", ")", "{", "$", "retval", "[", "'success'", "]", "=", "true", ";", "$", "this", "->", "replace", "(", "$", "retval", "[", "'data'", "]", ")", ";", "$", "this", "->", "save", "(", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Restore the `Node` from the trash. @return array
[ "Restore", "the", "Node", "from", "the", "trash", "." ]
f369d0567c55ee1c7650246ce6938815fbddc5bf
https://github.com/alex-phillips/clouddrive-php/blob/f369d0567c55ee1c7650246ce6938815fbddc5bf/src/CloudDrive/Node.php#L635-L667
229,609
joomla-framework/datetime
src/DateTimeIterator.php
DateTimeIterator.next
public function next() { $this->key++; $this->current = $this->current->add($this->interval); }
php
public function next() { $this->key++; $this->current = $this->current->add($this->interval); }
[ "public", "function", "next", "(", ")", "{", "$", "this", "->", "key", "++", ";", "$", "this", "->", "current", "=", "$", "this", "->", "current", "->", "add", "(", "$", "this", "->", "interval", ")", ";", "}" ]
Moves the current position to the next date. @return void @since 2.0.0
[ "Moves", "the", "current", "position", "to", "the", "next", "date", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeIterator.php#L105-L109
229,610
joomla-framework/datetime
src/Date.php
Date.cast
private static function cast(Date $date = null) { if (!is_null($date)) { $date = new DateTime($date); } return $date; }
php
private static function cast(Date $date = null) { if (!is_null($date)) { $date = new DateTime($date); } return $date; }
[ "private", "static", "function", "cast", "(", "Date", "$", "date", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "date", ")", ")", "{", "$", "date", "=", "new", "DateTime", "(", "$", "date", ")", ";", "}", "return", "$", "date", ";", "}" ]
Casts to DateTime. @param Date $date Date to cast. @return DateTime|null @since 2.0.0
[ "Casts", "to", "DateTime", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/Date.php#L421-L429
229,611
cgsmith/zf1-recaptcha-2
src/Cgsmith/View/Helper/FormRecaptcha.php
FormRecaptcha.formRecaptcha
public function formRecaptcha($name, $value = null, $attribs = null, $options = null, $listsep = '') { if (!isset($attribs['siteKey']) || !isset($attribs['secretKey'])) { throw new \Zend_Exception('Site key is not set in the view helper'); } $customClasses = ''; if( isset( $attribs['classes'] )) { if( is_array( $attribs['classes'] ) ) { $customClasses = implode(' ', $attribs['classes']); } else { $customClasses = $attribs['classes']; } } $js = '<script src=\'https://www.google.com/recaptcha/api.js\'></script>'; $captcha= '<div class="g-recaptcha ' . $customClasses . '" data-sitekey="' . $attribs['siteKey'] . '"></div>'; return $js . $captcha; }
php
public function formRecaptcha($name, $value = null, $attribs = null, $options = null, $listsep = '') { if (!isset($attribs['siteKey']) || !isset($attribs['secretKey'])) { throw new \Zend_Exception('Site key is not set in the view helper'); } $customClasses = ''; if( isset( $attribs['classes'] )) { if( is_array( $attribs['classes'] ) ) { $customClasses = implode(' ', $attribs['classes']); } else { $customClasses = $attribs['classes']; } } $js = '<script src=\'https://www.google.com/recaptcha/api.js\'></script>'; $captcha= '<div class="g-recaptcha ' . $customClasses . '" data-sitekey="' . $attribs['siteKey'] . '"></div>'; return $js . $captcha; }
[ "public", "function", "formRecaptcha", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "attribs", "=", "null", ",", "$", "options", "=", "null", ",", "$", "listsep", "=", "''", ")", "{", "if", "(", "!", "isset", "(", "$", "attribs", "[", "'siteKey'", "]", ")", "||", "!", "isset", "(", "$", "attribs", "[", "'secretKey'", "]", ")", ")", "{", "throw", "new", "\\", "Zend_Exception", "(", "'Site key is not set in the view helper'", ")", ";", "}", "$", "customClasses", "=", "''", ";", "if", "(", "isset", "(", "$", "attribs", "[", "'classes'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "attribs", "[", "'classes'", "]", ")", ")", "{", "$", "customClasses", "=", "implode", "(", "' '", ",", "$", "attribs", "[", "'classes'", "]", ")", ";", "}", "else", "{", "$", "customClasses", "=", "$", "attribs", "[", "'classes'", "]", ";", "}", "}", "$", "js", "=", "'<script src=\\'https://www.google.com/recaptcha/api.js\\'></script>'", ";", "$", "captcha", "=", "'<div class=\"g-recaptcha '", ".", "$", "customClasses", ".", "'\" data-sitekey=\"'", ".", "$", "attribs", "[", "'siteKey'", "]", ".", "'\"></div>'", ";", "return", "$", "js", ".", "$", "captcha", ";", "}" ]
For google recaptcha div to render properly @param $name @param null $value @param null $attribs @param null $options @param string $listsep @return string @throws \Zend_Exception
[ "For", "google", "recaptcha", "div", "to", "render", "properly" ]
fa2ab15df2dd27943e9ea61a7790c3566d78b19a
https://github.com/cgsmith/zf1-recaptcha-2/blob/fa2ab15df2dd27943e9ea61a7790c3566d78b19a/src/Cgsmith/View/Helper/FormRecaptcha.php#L24-L42
229,612
milesj/utility
Model/Datasource/FeedSource.php
FeedSource._extract
protected function _extract($item, $keys = array('value')) { if (is_array($item)) { if (isset($item[0])) { return $this->_extract($item[0], $keys); } else { foreach ($keys as $key) { if (!empty($item[$key])) { return trim($item[$key]); } else if (isset($item['attributes'])) { return $this->_extract($item['attributes'], $keys); } } } } return trim($item); }
php
protected function _extract($item, $keys = array('value')) { if (is_array($item)) { if (isset($item[0])) { return $this->_extract($item[0], $keys); } else { foreach ($keys as $key) { if (!empty($item[$key])) { return trim($item[$key]); } else if (isset($item['attributes'])) { return $this->_extract($item['attributes'], $keys); } } } } return trim($item); }
[ "protected", "function", "_extract", "(", "$", "item", ",", "$", "keys", "=", "array", "(", "'value'", ")", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "_extract", "(", "$", "item", "[", "0", "]", ",", "$", "keys", ")", ";", "}", "else", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "item", "[", "$", "key", "]", ")", ")", "{", "return", "trim", "(", "$", "item", "[", "$", "key", "]", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "item", "[", "'attributes'", "]", ")", ")", "{", "return", "$", "this", "->", "_extract", "(", "$", "item", "[", "'attributes'", "]", ",", "$", "keys", ")", ";", "}", "}", "}", "}", "return", "trim", "(", "$", "item", ")", ";", "}" ]
Extracts a certain value from a node. @param string $item @param array $keys @return string
[ "Extracts", "a", "certain", "value", "from", "a", "node", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Datasource/FeedSource.php#L198-L216
229,613
milesj/utility
Model/Datasource/FeedSource.php
FeedSource._truncate
protected function _truncate($feed, $count = null) { if (!$feed) { return $feed; } if ($count === null) { $count = 20; } if ($count && count($feed) > $count) { $feed = array_slice($feed, 0, $count); } return array_values($feed); }
php
protected function _truncate($feed, $count = null) { if (!$feed) { return $feed; } if ($count === null) { $count = 20; } if ($count && count($feed) > $count) { $feed = array_slice($feed, 0, $count); } return array_values($feed); }
[ "protected", "function", "_truncate", "(", "$", "feed", ",", "$", "count", "=", "null", ")", "{", "if", "(", "!", "$", "feed", ")", "{", "return", "$", "feed", ";", "}", "if", "(", "$", "count", "===", "null", ")", "{", "$", "count", "=", "20", ";", "}", "if", "(", "$", "count", "&&", "count", "(", "$", "feed", ")", ">", "$", "count", ")", "{", "$", "feed", "=", "array_slice", "(", "$", "feed", ",", "0", ",", "$", "count", ")", ";", "}", "return", "array_values", "(", "$", "feed", ")", ";", "}" ]
Truncates the feed to a certain length. @param array $feed @param int $count @return array
[ "Truncates", "the", "feed", "to", "a", "certain", "length", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Datasource/FeedSource.php#L339-L353
229,614
Codegyre/RoboCI
src/Command/Travis/Build.php
Build.ciTravisBuild
public function ciTravisBuild($opts = ['name' => null, 'recipes' => false, 'image' => false]) { if (!$opts['image']) $opts['image'] = Config::$baseImage; return (new Builder)->execute($opts); }
php
public function ciTravisBuild($opts = ['name' => null, 'recipes' => false, 'image' => false]) { if (!$opts['image']) $opts['image'] = Config::$baseImage; return (new Builder)->execute($opts); }
[ "public", "function", "ciTravisBuild", "(", "$", "opts", "=", "[", "'name'", "=>", "null", ",", "'recipes'", "=>", "false", ",", "'image'", "=>", "false", "]", ")", "{", "if", "(", "!", "$", "opts", "[", "'image'", "]", ")", "$", "opts", "[", "'image'", "]", "=", "Config", "::", "$", "baseImage", ";", "return", "(", "new", "Builder", ")", "->", "execute", "(", "$", "opts", ")", ";", "}" ]
Provisions new container using Chef cookbooks from Travis CI Takes very looooooooooong time, better to use created image @param array $opts
[ "Provisions", "new", "container", "using", "Chef", "cookbooks", "from", "Travis", "CI", "Takes", "very", "looooooooooong", "time", "better", "to", "use", "created", "image" ]
886f340d7d8ca808607da9a41d2e6ba18075bdf1
https://github.com/Codegyre/RoboCI/blob/886f340d7d8ca808607da9a41d2e6ba18075bdf1/src/Command/Travis/Build.php#L17-L21
229,615
gridonic/hapi
src/Harvest/Model/Harvest.php
Harvest.get
public function get($property) { $value = null; if ($this->_convert) { $property = str_replace( "_", "-", $property ); } else { $property = str_replace( "-", "_", $property ); } if (array_key_exists($property, $this->_values)) { return $this->_values[$property]; } else { return null; } }
php
public function get($property) { $value = null; if ($this->_convert) { $property = str_replace( "_", "-", $property ); } else { $property = str_replace( "-", "_", $property ); } if (array_key_exists($property, $this->_values)) { return $this->_values[$property]; } else { return null; } }
[ "public", "function", "get", "(", "$", "property", ")", "{", "$", "value", "=", "null", ";", "if", "(", "$", "this", "->", "_convert", ")", "{", "$", "property", "=", "str_replace", "(", "\"_\"", ",", "\"-\"", ",", "$", "property", ")", ";", "}", "else", "{", "$", "property", "=", "str_replace", "(", "\"-\"", ",", "\"_\"", ",", "$", "property", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "_values", ")", ")", "{", "return", "$", "this", "->", "_values", "[", "$", "property", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
get specified property @param mixed $property @return mixed
[ "get", "specified", "property" ]
018c05b548428aa3e8d1040e0e2b1ec75b85adfe
https://github.com/gridonic/hapi/blob/018c05b548428aa3e8d1040e0e2b1ec75b85adfe/src/Harvest/Model/Harvest.php#L55-L71
229,616
gridonic/hapi
src/Harvest/Model/Harvest.php
Harvest.parseXml
public function parseXml($node) { foreach ($node->childNodes as $item) { if ($item->nodeName != "#text") { $this->set( $item->nodeName, $item->nodeValue); } } }
php
public function parseXml($node) { foreach ($node->childNodes as $item) { if ($item->nodeName != "#text") { $this->set( $item->nodeName, $item->nodeValue); } } }
[ "public", "function", "parseXml", "(", "$", "node", ")", "{", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "nodeName", "!=", "\"#text\"", ")", "{", "$", "this", "->", "set", "(", "$", "item", "->", "nodeName", ",", "$", "item", "->", "nodeValue", ")", ";", "}", "}", "}" ]
magic method used for method overloading @param \DOMNode $node xml node to parse @return void
[ "magic", "method", "used", "for", "method", "overloading" ]
018c05b548428aa3e8d1040e0e2b1ec75b85adfe
https://github.com/gridonic/hapi/blob/018c05b548428aa3e8d1040e0e2b1ec75b85adfe/src/Harvest/Model/Harvest.php#L130-L138
229,617
odan/database
src/Database/Condition.php
Condition.getRightFieldValue
protected function getRightFieldValue($rightField, $comparison): array { if ($comparison == 'in' || $comparison == 'not in') { $rightField = '(' . implode(', ', $this->quoter->quoteArray((array)$rightField)) . ')'; } elseif ($comparison == 'greatest' || $comparison == 'least' || $comparison == 'coalesce' || $comparison == 'interval' || $comparison === 'strcmp') { $comparison = '= ' . $comparison; $rightField = '(' . implode(', ', $this->quoter->quoteArray((array)$rightField)) . ')'; } elseif ($comparison === '=' && $rightField === null) { $comparison = 'IS'; $rightField = $this->quoter->quoteValue($rightField); } elseif (($comparison === '<>' || $comparison === '!=') && $rightField === null) { $comparison = 'IS NOT'; $rightField = $this->quoter->quoteValue($rightField); } elseif ($comparison === 'between' || $comparison === 'not between') { $between1 = $this->quoter->quoteValue($rightField[0]); $between2 = $this->quoter->quoteValue($rightField[1]); $rightField = sprintf('%s AND %s', $between1, $between2); } elseif ($rightField instanceof RawExp) { $rightField = $rightField->getValue(); } else { $rightField = $this->quoter->quoteValue($rightField); } return [$rightField, strtoupper($comparison)]; }
php
protected function getRightFieldValue($rightField, $comparison): array { if ($comparison == 'in' || $comparison == 'not in') { $rightField = '(' . implode(', ', $this->quoter->quoteArray((array)$rightField)) . ')'; } elseif ($comparison == 'greatest' || $comparison == 'least' || $comparison == 'coalesce' || $comparison == 'interval' || $comparison === 'strcmp') { $comparison = '= ' . $comparison; $rightField = '(' . implode(', ', $this->quoter->quoteArray((array)$rightField)) . ')'; } elseif ($comparison === '=' && $rightField === null) { $comparison = 'IS'; $rightField = $this->quoter->quoteValue($rightField); } elseif (($comparison === '<>' || $comparison === '!=') && $rightField === null) { $comparison = 'IS NOT'; $rightField = $this->quoter->quoteValue($rightField); } elseif ($comparison === 'between' || $comparison === 'not between') { $between1 = $this->quoter->quoteValue($rightField[0]); $between2 = $this->quoter->quoteValue($rightField[1]); $rightField = sprintf('%s AND %s', $between1, $between2); } elseif ($rightField instanceof RawExp) { $rightField = $rightField->getValue(); } else { $rightField = $this->quoter->quoteValue($rightField); } return [$rightField, strtoupper($comparison)]; }
[ "protected", "function", "getRightFieldValue", "(", "$", "rightField", ",", "$", "comparison", ")", ":", "array", "{", "if", "(", "$", "comparison", "==", "'in'", "||", "$", "comparison", "==", "'not in'", ")", "{", "$", "rightField", "=", "'('", ".", "implode", "(", "', '", ",", "$", "this", "->", "quoter", "->", "quoteArray", "(", "(", "array", ")", "$", "rightField", ")", ")", ".", "')'", ";", "}", "elseif", "(", "$", "comparison", "==", "'greatest'", "||", "$", "comparison", "==", "'least'", "||", "$", "comparison", "==", "'coalesce'", "||", "$", "comparison", "==", "'interval'", "||", "$", "comparison", "===", "'strcmp'", ")", "{", "$", "comparison", "=", "'= '", ".", "$", "comparison", ";", "$", "rightField", "=", "'('", ".", "implode", "(", "', '", ",", "$", "this", "->", "quoter", "->", "quoteArray", "(", "(", "array", ")", "$", "rightField", ")", ")", ".", "')'", ";", "}", "elseif", "(", "$", "comparison", "===", "'='", "&&", "$", "rightField", "===", "null", ")", "{", "$", "comparison", "=", "'IS'", ";", "$", "rightField", "=", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "rightField", ")", ";", "}", "elseif", "(", "(", "$", "comparison", "===", "'<>'", "||", "$", "comparison", "===", "'!='", ")", "&&", "$", "rightField", "===", "null", ")", "{", "$", "comparison", "=", "'IS NOT'", ";", "$", "rightField", "=", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "rightField", ")", ";", "}", "elseif", "(", "$", "comparison", "===", "'between'", "||", "$", "comparison", "===", "'not between'", ")", "{", "$", "between1", "=", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "rightField", "[", "0", "]", ")", ";", "$", "between2", "=", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "rightField", "[", "1", "]", ")", ";", "$", "rightField", "=", "sprintf", "(", "'%s AND %s'", ",", "$", "between1", ",", "$", "between2", ")", ";", "}", "elseif", "(", "$", "rightField", "instanceof", "RawExp", ")", "{", "$", "rightField", "=", "$", "rightField", "->", "getValue", "(", ")", ";", "}", "else", "{", "$", "rightField", "=", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "rightField", ")", ";", "}", "return", "[", "$", "rightField", ",", "strtoupper", "(", "$", "comparison", ")", "]", ";", "}" ]
Comparison Functions and Operators. https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html @param mixed $rightField @param mixed $comparison @return array
[ "Comparison", "Functions", "and", "Operators", "." ]
e514fb45ab72718a77b34ed2c44906f5159e8278
https://github.com/odan/database/blob/e514fb45ab72718a77b34ed2c44906f5159e8278/src/Database/Condition.php#L120-L148
229,618
odan/database
src/Database/Condition.php
Condition.where
public function where($conditions): self { if ($conditions[0] instanceof Closure) { $this->addClauseCondClosure('where', 'AND', $conditions[0]); return $this; } $this->where[] = ['and', $conditions]; return $this; }
php
public function where($conditions): self { if ($conditions[0] instanceof Closure) { $this->addClauseCondClosure('where', 'AND', $conditions[0]); return $this; } $this->where[] = ['and', $conditions]; return $this; }
[ "public", "function", "where", "(", "$", "conditions", ")", ":", "self", "{", "if", "(", "$", "conditions", "[", "0", "]", "instanceof", "Closure", ")", "{", "$", "this", "->", "addClauseCondClosure", "(", "'where'", ",", "'AND'", ",", "$", "conditions", "[", "0", "]", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "where", "[", "]", "=", "[", "'and'", ",", "$", "conditions", "]", ";", "return", "$", "this", ";", "}" ]
Where AND condition. @param array ...$conditions (field, comparison, value) or (field, comparison, new RawExp('table.field')) or new RawExp('...') @return self
[ "Where", "AND", "condition", "." ]
e514fb45ab72718a77b34ed2c44906f5159e8278
https://github.com/odan/database/blob/e514fb45ab72718a77b34ed2c44906f5159e8278/src/Database/Condition.php#L171-L181
229,619
odan/database
src/Database/Condition.php
Condition.addClauseCondClosure
protected function addClauseCondClosure($clause, $andor, $closure) { // retain the prior set of conditions, and temporarily reset the clause // for the closure to work with (otherwise there will be an extraneous // opening AND/OR keyword) $set = $this->$clause; $this->$clause = []; // invoke the closure, which will re-populate the $this->$clause $closure($this->query); // are there new clause elements? if (!$this->$clause) { // no: restore the old ones, and done $this->$clause = $set; return; } // append an opening parenthesis to the prior set of conditions, // with AND/OR as needed ... if ($set) { $set[] = new RawExp(strtoupper($andor) . ' ('); } else { $set[] = new RawExp('('); } // append the new conditions to the set, with indenting $sql = []; $sql = $this->getConditionSql($sql, $this->$clause, ''); foreach ($sql as $cond) { $set[] = new RawExp($cond); } $set[] = new RawExp(')'); // ... then put the full set of conditions back into $this->$clause $this->$clause = $set; return; }
php
protected function addClauseCondClosure($clause, $andor, $closure) { // retain the prior set of conditions, and temporarily reset the clause // for the closure to work with (otherwise there will be an extraneous // opening AND/OR keyword) $set = $this->$clause; $this->$clause = []; // invoke the closure, which will re-populate the $this->$clause $closure($this->query); // are there new clause elements? if (!$this->$clause) { // no: restore the old ones, and done $this->$clause = $set; return; } // append an opening parenthesis to the prior set of conditions, // with AND/OR as needed ... if ($set) { $set[] = new RawExp(strtoupper($andor) . ' ('); } else { $set[] = new RawExp('('); } // append the new conditions to the set, with indenting $sql = []; $sql = $this->getConditionSql($sql, $this->$clause, ''); foreach ($sql as $cond) { $set[] = new RawExp($cond); } $set[] = new RawExp(')'); // ... then put the full set of conditions back into $this->$clause $this->$clause = $set; return; }
[ "protected", "function", "addClauseCondClosure", "(", "$", "clause", ",", "$", "andor", ",", "$", "closure", ")", "{", "// retain the prior set of conditions, and temporarily reset the clause", "// for the closure to work with (otherwise there will be an extraneous", "// opening AND/OR keyword)", "$", "set", "=", "$", "this", "->", "$", "clause", ";", "$", "this", "->", "$", "clause", "=", "[", "]", ";", "// invoke the closure, which will re-populate the $this->$clause", "$", "closure", "(", "$", "this", "->", "query", ")", ";", "// are there new clause elements?", "if", "(", "!", "$", "this", "->", "$", "clause", ")", "{", "// no: restore the old ones, and done", "$", "this", "->", "$", "clause", "=", "$", "set", ";", "return", ";", "}", "// append an opening parenthesis to the prior set of conditions,", "// with AND/OR as needed ...", "if", "(", "$", "set", ")", "{", "$", "set", "[", "]", "=", "new", "RawExp", "(", "strtoupper", "(", "$", "andor", ")", ".", "' ('", ")", ";", "}", "else", "{", "$", "set", "[", "]", "=", "new", "RawExp", "(", "'('", ")", ";", "}", "// append the new conditions to the set, with indenting", "$", "sql", "=", "[", "]", ";", "$", "sql", "=", "$", "this", "->", "getConditionSql", "(", "$", "sql", ",", "$", "this", "->", "$", "clause", ",", "''", ")", ";", "foreach", "(", "$", "sql", "as", "$", "cond", ")", "{", "$", "set", "[", "]", "=", "new", "RawExp", "(", "$", "cond", ")", ";", "}", "$", "set", "[", "]", "=", "new", "RawExp", "(", "')'", ")", ";", "// ... then put the full set of conditions back into $this->$clause", "$", "this", "->", "$", "clause", "=", "$", "set", ";", "return", ";", "}" ]
Adds to a clause through a closure, enclosing within parentheses. @param string $clause the clause to work with, typically 'where' or 'having' @param string $andor add the condition using this operator, typically 'AND' or 'OR' @param callable $closure the closure that adds to the clause @return void
[ "Adds", "to", "a", "clause", "through", "a", "closure", "enclosing", "within", "parentheses", "." ]
e514fb45ab72718a77b34ed2c44906f5159e8278
https://github.com/odan/database/blob/e514fb45ab72718a77b34ed2c44906f5159e8278/src/Database/Condition.php#L192-L229
229,620
fuelphp/common
src/RegexFactory.php
RegexFactory.get
public function get($delimit = true) { // If there are still open delimiters throw an exception if ($this->openDelimiters !== 0) { throw new \LogicException('A delimiter has not been closed!'); } $expression = $this->expression; if ($delimit) { $expression = '/' . $expression . '/' . $this->flags; } return $expression; }
php
public function get($delimit = true) { // If there are still open delimiters throw an exception if ($this->openDelimiters !== 0) { throw new \LogicException('A delimiter has not been closed!'); } $expression = $this->expression; if ($delimit) { $expression = '/' . $expression . '/' . $this->flags; } return $expression; }
[ "public", "function", "get", "(", "$", "delimit", "=", "true", ")", "{", "// If there are still open delimiters throw an exception", "if", "(", "$", "this", "->", "openDelimiters", "!==", "0", ")", "{", "throw", "new", "\\", "LogicException", "(", "'A delimiter has not been closed!'", ")", ";", "}", "$", "expression", "=", "$", "this", "->", "expression", ";", "if", "(", "$", "delimit", ")", "{", "$", "expression", "=", "'/'", ".", "$", "expression", ".", "'/'", ".", "$", "this", "->", "flags", ";", "}", "return", "$", "expression", ";", "}" ]
Gets the built expression @param bool $delimit Set to false to disable adding the delimiters to the string @return string @since 2.0
[ "Gets", "the", "built", "expression" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/RegexFactory.php#L74-L90
229,621
joomla-framework/datetime
src/Translator/DateTimeTranslator.php
DateTimeTranslator.get
public function get($item, array $replace = array()) { $this->load(); if (!isset($this->loaded[$this->locale][$item])) { return $item; } $line = $this->loaded[$this->locale][$item]; return $this->makeReplacements($line, $replace); }
php
public function get($item, array $replace = array()) { $this->load(); if (!isset($this->loaded[$this->locale][$item])) { return $item; } $line = $this->loaded[$this->locale][$item]; return $this->makeReplacements($line, $replace); }
[ "public", "function", "get", "(", "$", "item", ",", "array", "$", "replace", "=", "array", "(", ")", ")", "{", "$", "this", "->", "load", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "loaded", "[", "$", "this", "->", "locale", "]", "[", "$", "item", "]", ")", ")", "{", "return", "$", "item", ";", "}", "$", "line", "=", "$", "this", "->", "loaded", "[", "$", "this", "->", "locale", "]", "[", "$", "item", "]", ";", "return", "$", "this", "->", "makeReplacements", "(", "$", "line", ",", "$", "replace", ")", ";", "}" ]
Returns a translated item. @param string $item The item to translate. @param array $replace An replace array. @return string @since 2.0.0
[ "Returns", "a", "translated", "item", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/Translator/DateTimeTranslator.php#L52-L64
229,622
joomla-framework/datetime
src/Translator/DateTimeTranslator.php
DateTimeTranslator.choice
public function choice($item, $number, array $replace = array()) { $lines = $this->get($item, $replace); $replace['count'] = $number; return $this->makeReplacements($this->selector->choose($lines, $number, $this->locale), $replace); }
php
public function choice($item, $number, array $replace = array()) { $lines = $this->get($item, $replace); $replace['count'] = $number; return $this->makeReplacements($this->selector->choose($lines, $number, $this->locale), $replace); }
[ "public", "function", "choice", "(", "$", "item", ",", "$", "number", ",", "array", "$", "replace", "=", "array", "(", ")", ")", "{", "$", "lines", "=", "$", "this", "->", "get", "(", "$", "item", ",", "$", "replace", ")", ";", "$", "replace", "[", "'count'", "]", "=", "$", "number", ";", "return", "$", "this", "->", "makeReplacements", "(", "$", "this", "->", "selector", "->", "choose", "(", "$", "lines", ",", "$", "number", ",", "$", "this", "->", "locale", ")", ",", "$", "replace", ")", ";", "}" ]
Returns a translated item with a proper form for pluralization. @param string $item The item to translate. @param integer $number Number of items for pluralization. @param array $replace An replace array. @return string @since 2.0.0
[ "Returns", "a", "translated", "item", "with", "a", "proper", "form", "for", "pluralization", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/Translator/DateTimeTranslator.php#L77-L84
229,623
joomla-framework/datetime
src/Translator/DateTimeTranslator.php
DateTimeTranslator.load
private function load() { if ($this->isLoaded()) { return; } $path = sprintf('%s/../../lang/%s.php', __DIR__, $this->locale); if (file_exists($path)) { $this->loaded[$this->locale] = require $path; } }
php
private function load() { if ($this->isLoaded()) { return; } $path = sprintf('%s/../../lang/%s.php', __DIR__, $this->locale); if (file_exists($path)) { $this->loaded[$this->locale] = require $path; } }
[ "private", "function", "load", "(", ")", "{", "if", "(", "$", "this", "->", "isLoaded", "(", ")", ")", "{", "return", ";", "}", "$", "path", "=", "sprintf", "(", "'%s/../../lang/%s.php'", ",", "__DIR__", ",", "$", "this", "->", "locale", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "loaded", "[", "$", "this", "->", "locale", "]", "=", "require", "$", "path", ";", "}", "}" ]
Loads dictionary. @return void @since 2.0.0
[ "Loads", "dictionary", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/Translator/DateTimeTranslator.php#L93-L106
229,624
joomla-framework/datetime
src/Translator/DateTimeTranslator.php
DateTimeTranslator.makeReplacements
private function makeReplacements($line, array $replace) { foreach ($replace as $key => $value) { $line = str_replace(':' . $key, $value, $line); } return $line; }
php
private function makeReplacements($line, array $replace) { foreach ($replace as $key => $value) { $line = str_replace(':' . $key, $value, $line); } return $line; }
[ "private", "function", "makeReplacements", "(", "$", "line", ",", "array", "$", "replace", ")", "{", "foreach", "(", "$", "replace", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "line", "=", "str_replace", "(", "':'", ".", "$", "key", ",", "$", "value", ",", "$", "line", ")", ";", "}", "return", "$", "line", ";", "}" ]
Replaces elements in a line. @param string $line The original line. @param array $replace An replace array. @return string @since 2.0.0
[ "Replaces", "elements", "in", "a", "line", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/Translator/DateTimeTranslator.php#L130-L138
229,625
fuelphp/common
src/DateRange.php
DateRange.offsetExists
public function offsetExists($offset) { foreach ($this as $key => $value) { if ($key == $offset) { return true; } } return false; }
php
public function offsetExists($offset) { foreach ($this as $key => $value) { if ($key == $offset) { return true; } } return false; }
[ "public", "function", "offsetExists", "(", "$", "offset", ")", "{", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "==", "$", "offset", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if a given object exists
[ "Check", "if", "a", "given", "object", "exists" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DateRange.php#L93-L103
229,626
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.loadPlugin
protected function loadPlugin($plugin) { $pluginName = get_class($plugin); $apiVersion = self::API_VERSION_0_9; if ($plugin instanceof PicoPluginInterface) { if (defined($pluginName . '::API_VERSION')) { $apiVersion = $pluginName::API_VERSION; } else { $apiVersion = self::API_VERSION_1_0; } } if (!isset($this->plugins[$apiVersion][$pluginName])) { // PicoDeprecated currently supports all previous API versions $this->plugins[$apiVersion][$pluginName] = $plugin; } }
php
protected function loadPlugin($plugin) { $pluginName = get_class($plugin); $apiVersion = self::API_VERSION_0_9; if ($plugin instanceof PicoPluginInterface) { if (defined($pluginName . '::API_VERSION')) { $apiVersion = $pluginName::API_VERSION; } else { $apiVersion = self::API_VERSION_1_0; } } if (!isset($this->plugins[$apiVersion][$pluginName])) { // PicoDeprecated currently supports all previous API versions $this->plugins[$apiVersion][$pluginName] = $plugin; } }
[ "protected", "function", "loadPlugin", "(", "$", "plugin", ")", "{", "$", "pluginName", "=", "get_class", "(", "$", "plugin", ")", ";", "$", "apiVersion", "=", "self", "::", "API_VERSION_0_9", ";", "if", "(", "$", "plugin", "instanceof", "PicoPluginInterface", ")", "{", "if", "(", "defined", "(", "$", "pluginName", ".", "'::API_VERSION'", ")", ")", "{", "$", "apiVersion", "=", "$", "pluginName", "::", "API_VERSION", ";", "}", "else", "{", "$", "apiVersion", "=", "self", "::", "API_VERSION_1_0", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "plugins", "[", "$", "apiVersion", "]", "[", "$", "pluginName", "]", ")", ")", "{", "// PicoDeprecated currently supports all previous API versions", "$", "this", "->", "plugins", "[", "$", "apiVersion", "]", "[", "$", "pluginName", "]", "=", "$", "plugin", ";", "}", "}" ]
Adds a plugin to PicoDeprecated's plugin index to trigger deprecated events by API level @see self::onPluginsLoaded() @see self::onPluginManuallyLoaded() @param object $plugin loaded plugin instance @return void
[ "Adds", "a", "plugin", "to", "PicoDeprecated", "s", "plugin", "index", "to", "trigger", "deprecated", "events", "by", "API", "level" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L249-L266
229,627
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.onConfigLoaded
public function onConfigLoaded(array &$config) { $this->defineConstants(); $this->loadScriptedConfig($config); $this->loadRootDirConfig($config); if (!isset($GLOBALS['config'])) { $GLOBALS['config'] = &$config; } }
php
public function onConfigLoaded(array &$config) { $this->defineConstants(); $this->loadScriptedConfig($config); $this->loadRootDirConfig($config); if (!isset($GLOBALS['config'])) { $GLOBALS['config'] = &$config; } }
[ "public", "function", "onConfigLoaded", "(", "array", "&", "$", "config", ")", "{", "$", "this", "->", "defineConstants", "(", ")", ";", "$", "this", "->", "loadScriptedConfig", "(", "$", "config", ")", ";", "$", "this", "->", "loadRootDirConfig", "(", "$", "config", ")", ";", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'config'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'config'", "]", "=", "&", "$", "config", ";", "}", "}" ]
Re-introduces various config-related characteristics 1. Defines various config-related constants ({@see self::defineConstants()}) 2. Reads `config.php` in Pico's config dir (`config/config.php`) ({@see self::loadScriptedConfig()}) 3. Reads `config.php` in Pico's root dir ({@see self::loadRootDirConfig()}) 4. Defines the global `$config` variable @see self::defineConstants() @see self::loadScriptedConfig() @see self::loadRootDirConfig() @see DummyPlugin::onConfigLoaded()
[ "Re", "-", "introduces", "various", "config", "-", "related", "characteristics" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L284-L293
229,628
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.defineConstants
protected function defineConstants() { if (!defined('ROOT_DIR')) { define('ROOT_DIR', $this->getRootDir()); } if (!defined('CONFIG_DIR')) { define('CONFIG_DIR', $this->getConfigDir()); } if (!defined('LIB_DIR')) { $picoReflector = new ReflectionClass('Pico'); define('LIB_DIR', dirname($picoReflector->getFileName()) . '/'); } if (!defined('PLUGINS_DIR')) { define('PLUGINS_DIR', $this->getPluginsDir()); } if (!defined('THEMES_DIR')) { define('THEMES_DIR', $this->getThemesDir()); } if (!defined('CONTENT_DIR')) { define('CONTENT_DIR', $this->getConfig('content_dir')); } if (!defined('CONTENT_EXT')) { define('CONTENT_EXT', $this->getConfig('content_ext')); } }
php
protected function defineConstants() { if (!defined('ROOT_DIR')) { define('ROOT_DIR', $this->getRootDir()); } if (!defined('CONFIG_DIR')) { define('CONFIG_DIR', $this->getConfigDir()); } if (!defined('LIB_DIR')) { $picoReflector = new ReflectionClass('Pico'); define('LIB_DIR', dirname($picoReflector->getFileName()) . '/'); } if (!defined('PLUGINS_DIR')) { define('PLUGINS_DIR', $this->getPluginsDir()); } if (!defined('THEMES_DIR')) { define('THEMES_DIR', $this->getThemesDir()); } if (!defined('CONTENT_DIR')) { define('CONTENT_DIR', $this->getConfig('content_dir')); } if (!defined('CONTENT_EXT')) { define('CONTENT_EXT', $this->getConfig('content_ext')); } }
[ "protected", "function", "defineConstants", "(", ")", "{", "if", "(", "!", "defined", "(", "'ROOT_DIR'", ")", ")", "{", "define", "(", "'ROOT_DIR'", ",", "$", "this", "->", "getRootDir", "(", ")", ")", ";", "}", "if", "(", "!", "defined", "(", "'CONFIG_DIR'", ")", ")", "{", "define", "(", "'CONFIG_DIR'", ",", "$", "this", "->", "getConfigDir", "(", ")", ")", ";", "}", "if", "(", "!", "defined", "(", "'LIB_DIR'", ")", ")", "{", "$", "picoReflector", "=", "new", "ReflectionClass", "(", "'Pico'", ")", ";", "define", "(", "'LIB_DIR'", ",", "dirname", "(", "$", "picoReflector", "->", "getFileName", "(", ")", ")", ".", "'/'", ")", ";", "}", "if", "(", "!", "defined", "(", "'PLUGINS_DIR'", ")", ")", "{", "define", "(", "'PLUGINS_DIR'", ",", "$", "this", "->", "getPluginsDir", "(", ")", ")", ";", "}", "if", "(", "!", "defined", "(", "'THEMES_DIR'", ")", ")", "{", "define", "(", "'THEMES_DIR'", ",", "$", "this", "->", "getThemesDir", "(", ")", ")", ";", "}", "if", "(", "!", "defined", "(", "'CONTENT_DIR'", ")", ")", "{", "define", "(", "'CONTENT_DIR'", ",", "$", "this", "->", "getConfig", "(", "'content_dir'", ")", ")", ";", "}", "if", "(", "!", "defined", "(", "'CONTENT_EXT'", ")", ")", "{", "define", "(", "'CONTENT_EXT'", ",", "$", "this", "->", "getConfig", "(", "'content_ext'", ")", ")", ";", "}", "}" ]
Defines various config-related constants `ROOT_DIR`, `LIB_DIR`, `PLUGINS_DIR`, `THEMES_DIR` and `CONTENT_EXT` were removed in v1.0, `CONTENT_DIR` existed just in v0.9, `CONFIG_DIR` just for a short time between v0.9 and v1.0 and `CACHE_DIR` was dropped with v1.0 without a replacement. @see self::onConfigLoaded() @return void
[ "Defines", "various", "config", "-", "related", "constants" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L307-L331
229,629
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.loadRootDirConfig
protected function loadRootDirConfig(array &$realConfig) { if (file_exists($this->getRootDir() . 'config.php')) { $config = null; // scope isolated require() $includeClosure = function ($configFile) use (&$config) { require($configFile); }; if (PHP_VERSION_ID >= 50400) { $includeClosure = $includeClosure->bindTo(null); } $includeClosure($this->getRootDir() . 'config.php'); if (is_array($config)) { if (isset($config['base_url'])) { $config['base_url'] = rtrim($config['base_url'], '/') . '/'; } if (isset($config['content_dir'])) { $config['content_dir'] = rtrim($config['content_dir'], '/\\') . '/'; } $realConfig = $config + $realConfig; } } }
php
protected function loadRootDirConfig(array &$realConfig) { if (file_exists($this->getRootDir() . 'config.php')) { $config = null; // scope isolated require() $includeClosure = function ($configFile) use (&$config) { require($configFile); }; if (PHP_VERSION_ID >= 50400) { $includeClosure = $includeClosure->bindTo(null); } $includeClosure($this->getRootDir() . 'config.php'); if (is_array($config)) { if (isset($config['base_url'])) { $config['base_url'] = rtrim($config['base_url'], '/') . '/'; } if (isset($config['content_dir'])) { $config['content_dir'] = rtrim($config['content_dir'], '/\\') . '/'; } $realConfig = $config + $realConfig; } } }
[ "protected", "function", "loadRootDirConfig", "(", "array", "&", "$", "realConfig", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "getRootDir", "(", ")", ".", "'config.php'", ")", ")", "{", "$", "config", "=", "null", ";", "// scope isolated require()", "$", "includeClosure", "=", "function", "(", "$", "configFile", ")", "use", "(", "&", "$", "config", ")", "{", "require", "(", "$", "configFile", ")", ";", "}", ";", "if", "(", "PHP_VERSION_ID", ">=", "50400", ")", "{", "$", "includeClosure", "=", "$", "includeClosure", "->", "bindTo", "(", "null", ")", ";", "}", "$", "includeClosure", "(", "$", "this", "->", "getRootDir", "(", ")", ".", "'config.php'", ")", ";", "if", "(", "is_array", "(", "$", "config", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'base_url'", "]", ")", ")", "{", "$", "config", "[", "'base_url'", "]", "=", "rtrim", "(", "$", "config", "[", "'base_url'", "]", ",", "'/'", ")", ".", "'/'", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'content_dir'", "]", ")", ")", "{", "$", "config", "[", "'content_dir'", "]", "=", "rtrim", "(", "$", "config", "[", "'content_dir'", "]", ",", "'/\\\\'", ")", ".", "'/'", ";", "}", "$", "realConfig", "=", "$", "config", "+", "$", "realConfig", ";", "}", "}", "}" ]
Reads a config.php in Pico's root dir @see self::onConfigLoaded() @see Pico::loadConfig() @param array &$realConfig array of config variables @return void
[ "Reads", "a", "config", ".", "php", "in", "Pico", "s", "root", "dir" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L390-L416
229,630
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.lowerFileMeta
protected function lowerFileMeta(array &$meta) { $metaHeaders = $this->getMetaHeaders(); // get unregistered meta $unregisteredMeta = array(); foreach ($meta as $key => $value) { if (!in_array($key, $metaHeaders)) { $unregisteredMeta[$key] = &$meta[$key]; } } // Pico 1.0 lowered unregistered meta unsolicited... if ($unregisteredMeta) { $metaHeadersLowered = array_change_key_case($metaHeaders, CASE_LOWER); foreach ($unregisteredMeta as $key => $value) { $keyLowered = strtolower($key); if (isset($metaHeadersLowered[$keyLowered])) { $registeredKey = $metaHeadersLowered[$keyLowered]; if ($meta[$registeredKey] === '') { $meta[$registeredKey] = &$unregisteredMeta[$key]; } } else if (!isset($meta[$keyLowered]) || ($meta[$keyLowered] === '')) { $meta[$keyLowered] = &$unregisteredMeta[$key]; } } } }
php
protected function lowerFileMeta(array &$meta) { $metaHeaders = $this->getMetaHeaders(); // get unregistered meta $unregisteredMeta = array(); foreach ($meta as $key => $value) { if (!in_array($key, $metaHeaders)) { $unregisteredMeta[$key] = &$meta[$key]; } } // Pico 1.0 lowered unregistered meta unsolicited... if ($unregisteredMeta) { $metaHeadersLowered = array_change_key_case($metaHeaders, CASE_LOWER); foreach ($unregisteredMeta as $key => $value) { $keyLowered = strtolower($key); if (isset($metaHeadersLowered[$keyLowered])) { $registeredKey = $metaHeadersLowered[$keyLowered]; if ($meta[$registeredKey] === '') { $meta[$registeredKey] = &$unregisteredMeta[$key]; } } else if (!isset($meta[$keyLowered]) || ($meta[$keyLowered] === '')) { $meta[$keyLowered] = &$unregisteredMeta[$key]; } } } }
[ "protected", "function", "lowerFileMeta", "(", "array", "&", "$", "meta", ")", "{", "$", "metaHeaders", "=", "$", "this", "->", "getMetaHeaders", "(", ")", ";", "// get unregistered meta", "$", "unregisteredMeta", "=", "array", "(", ")", ";", "foreach", "(", "$", "meta", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "metaHeaders", ")", ")", "{", "$", "unregisteredMeta", "[", "$", "key", "]", "=", "&", "$", "meta", "[", "$", "key", "]", ";", "}", "}", "// Pico 1.0 lowered unregistered meta unsolicited...", "if", "(", "$", "unregisteredMeta", ")", "{", "$", "metaHeadersLowered", "=", "array_change_key_case", "(", "$", "metaHeaders", ",", "CASE_LOWER", ")", ";", "foreach", "(", "$", "unregisteredMeta", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keyLowered", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "metaHeadersLowered", "[", "$", "keyLowered", "]", ")", ")", "{", "$", "registeredKey", "=", "$", "metaHeadersLowered", "[", "$", "keyLowered", "]", ";", "if", "(", "$", "meta", "[", "$", "registeredKey", "]", "===", "''", ")", "{", "$", "meta", "[", "$", "registeredKey", "]", "=", "&", "$", "unregisteredMeta", "[", "$", "key", "]", ";", "}", "}", "else", "if", "(", "!", "isset", "(", "$", "meta", "[", "$", "keyLowered", "]", ")", "||", "(", "$", "meta", "[", "$", "keyLowered", "]", "===", "''", ")", ")", "{", "$", "meta", "[", "$", "keyLowered", "]", "=", "&", "$", "unregisteredMeta", "[", "$", "key", "]", ";", "}", "}", "}", "}" ]
Lowers a page's meta headers as with Pico 1.0 and older This makes unregistered meta headers available using lowered array keys and matches registered meta headers in a case-insensitive manner. @param array &$meta meta data @param array $metaHeaders known meta header fields @return void
[ "Lowers", "a", "page", "s", "meta", "headers", "as", "with", "Pico", "1", ".", "0", "and", "older" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L749-L776
229,631
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.triggersApiEvents
public function triggersApiEvents($apiVersion) { $apiVersions = func_get_args(); foreach ($apiVersions as $apiVersion) { if (isset($this->plugins[$apiVersion])) { return true; } } return false; }
php
public function triggersApiEvents($apiVersion) { $apiVersions = func_get_args(); foreach ($apiVersions as $apiVersion) { if (isset($this->plugins[$apiVersion])) { return true; } } return false; }
[ "public", "function", "triggersApiEvents", "(", "$", "apiVersion", ")", "{", "$", "apiVersions", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "apiVersions", "as", "$", "apiVersion", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "plugins", "[", "$", "apiVersion", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether events of a particular API level are triggered or not @param int $apiVersion,... API version to check @return boolean TRUE if PicoDeprecated triggers events of one of the passed API levels, FALSE otherwise
[ "Returns", "whether", "events", "of", "a", "particular", "API", "level", "are", "triggered", "or", "not" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L800-L810
229,632
picocms/pico-deprecated
PicoDeprecated.php
PicoDeprecated.triggerEvent
public function triggerEvent($apiVersion, $eventName, array $params = array()) { if (!isset($this->plugins[$apiVersion])) { return; } // API v0 if ($apiVersion === self::API_VERSION_0_9) { // API v0 events are also triggered on plugins using API v1 (but not later) $plugins = $this->plugins[self::API_VERSION_0_9]; if (isset($this->plugins[self::API_VERSION_1_0])) { $plugins = array_merge($plugins, $this->plugins[self::API_VERSION_1_0]); } foreach ($plugins as $plugin) { if (method_exists($plugin, $eventName)) { call_user_func_array(array($plugin, $eventName), $params); } } return; } // API v1 and later foreach ($this->plugins[$apiVersion] as $plugin) { $plugin->handleEvent($eventName, $params); } }
php
public function triggerEvent($apiVersion, $eventName, array $params = array()) { if (!isset($this->plugins[$apiVersion])) { return; } // API v0 if ($apiVersion === self::API_VERSION_0_9) { // API v0 events are also triggered on plugins using API v1 (but not later) $plugins = $this->plugins[self::API_VERSION_0_9]; if (isset($this->plugins[self::API_VERSION_1_0])) { $plugins = array_merge($plugins, $this->plugins[self::API_VERSION_1_0]); } foreach ($plugins as $plugin) { if (method_exists($plugin, $eventName)) { call_user_func_array(array($plugin, $eventName), $params); } } return; } // API v1 and later foreach ($this->plugins[$apiVersion] as $plugin) { $plugin->handleEvent($eventName, $params); } }
[ "public", "function", "triggerEvent", "(", "$", "apiVersion", ",", "$", "eventName", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "plugins", "[", "$", "apiVersion", "]", ")", ")", "{", "return", ";", "}", "// API v0", "if", "(", "$", "apiVersion", "===", "self", "::", "API_VERSION_0_9", ")", "{", "// API v0 events are also triggered on plugins using API v1 (but not later)", "$", "plugins", "=", "$", "this", "->", "plugins", "[", "self", "::", "API_VERSION_0_9", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "plugins", "[", "self", "::", "API_VERSION_1_0", "]", ")", ")", "{", "$", "plugins", "=", "array_merge", "(", "$", "plugins", ",", "$", "this", "->", "plugins", "[", "self", "::", "API_VERSION_1_0", "]", ")", ";", "}", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "method_exists", "(", "$", "plugin", ",", "$", "eventName", ")", ")", "{", "call_user_func_array", "(", "array", "(", "$", "plugin", ",", "$", "eventName", ")", ",", "$", "params", ")", ";", "}", "}", "return", ";", "}", "// API v1 and later", "foreach", "(", "$", "this", "->", "plugins", "[", "$", "apiVersion", "]", "as", "$", "plugin", ")", "{", "$", "plugin", "->", "handleEvent", "(", "$", "eventName", ",", "$", "params", ")", ";", "}", "}" ]
Triggers deprecated events on plugins of different API versions Please note that events of a specific API version are only triggered on plugins with this particular API version. Deprecated events of API v0 are also triggered on plugins using API v1. You can use this public method in other plugins to trigger custom events on plugins using a particular API version. If you want to trigger a custom event on all plugins, no matter their API version (except for plugins using API v0), use {@see Pico::triggerEvent()} instead. @see Pico::triggerEvent() @param int $apiVersion API version of the event @param string $eventName event to trigger @param array $params parameters to pass @return void
[ "Triggers", "deprecated", "events", "on", "plugins", "of", "different", "API", "versions" ]
795de9a6f724809fccd3f85a3bf8ad32092dd944
https://github.com/picocms/pico-deprecated/blob/795de9a6f724809fccd3f85a3bf8ad32092dd944/PicoDeprecated.php#L832-L859
229,633
charliedevelopment/craft3-advanced-url-field
src/fields/AdvancedUrlField.php
AdvancedUrlField.validateUrl
public function validateUrl(ElementInterface $element) { $value = $element->getFieldValue($this->handle); // Make sure the value matches at least one of the allowed types. $matches = false; foreach ($this->urlTypes as $type) { switch ($type) { case 'relative': // Starts with a forward slash, and contains no whitespace. $matches = $matches | preg_match('/^\/\S*$/iu', $value); break; case 'absolute': // Regex by diegoperini, documented at https://mathiasbynens.be/demo/url-regex $matches = $matches | preg_match('/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu', $value); break; case 'mailto': // Begins with 'mailto:' and contains at least one @ symbol. $matches = $matches | preg_match('/^mailto:.*@.*/u', $value); break; case 'tel': // Begins with 'tel:'. $matches = $matches | preg_match('/^tel:.*/u', $value); break; default: $element->addError($this->handle, Craft::t('advanced-url-field', 'Unknown URL type in field settings.')); break; } } if (!$matches) { $element->addError($this->handle, Craft::t('advanced-url-field', 'URL provided does not match the allowed formats.')); } }
php
public function validateUrl(ElementInterface $element) { $value = $element->getFieldValue($this->handle); // Make sure the value matches at least one of the allowed types. $matches = false; foreach ($this->urlTypes as $type) { switch ($type) { case 'relative': // Starts with a forward slash, and contains no whitespace. $matches = $matches | preg_match('/^\/\S*$/iu', $value); break; case 'absolute': // Regex by diegoperini, documented at https://mathiasbynens.be/demo/url-regex $matches = $matches | preg_match('/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]+-?)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu', $value); break; case 'mailto': // Begins with 'mailto:' and contains at least one @ symbol. $matches = $matches | preg_match('/^mailto:.*@.*/u', $value); break; case 'tel': // Begins with 'tel:'. $matches = $matches | preg_match('/^tel:.*/u', $value); break; default: $element->addError($this->handle, Craft::t('advanced-url-field', 'Unknown URL type in field settings.')); break; } } if (!$matches) { $element->addError($this->handle, Craft::t('advanced-url-field', 'URL provided does not match the allowed formats.')); } }
[ "public", "function", "validateUrl", "(", "ElementInterface", "$", "element", ")", "{", "$", "value", "=", "$", "element", "->", "getFieldValue", "(", "$", "this", "->", "handle", ")", ";", "// Make sure the value matches at least one of the allowed types.", "$", "matches", "=", "false", ";", "foreach", "(", "$", "this", "->", "urlTypes", "as", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'relative'", ":", "// Starts with a forward slash, and contains no whitespace.", "$", "matches", "=", "$", "matches", "|", "preg_match", "(", "'/^\\/\\S*$/iu'", ",", "$", "value", ")", ";", "break", ";", "case", "'absolute'", ":", "// Regex by diegoperini, documented at https://mathiasbynens.be/demo/url-regex", "$", "matches", "=", "$", "matches", "|", "preg_match", "(", "'/^(?:(?:https?|ftp):\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)*(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu'", ",", "$", "value", ")", ";", "break", ";", "case", "'mailto'", ":", "// Begins with 'mailto:' and contains at least one @ symbol.", "$", "matches", "=", "$", "matches", "|", "preg_match", "(", "'/^mailto:.*@.*/u'", ",", "$", "value", ")", ";", "break", ";", "case", "'tel'", ":", "// Begins with 'tel:'.", "$", "matches", "=", "$", "matches", "|", "preg_match", "(", "'/^tel:.*/u'", ",", "$", "value", ")", ";", "break", ";", "default", ":", "$", "element", "->", "addError", "(", "$", "this", "->", "handle", ",", "Craft", "::", "t", "(", "'advanced-url-field'", ",", "'Unknown URL type in field settings.'", ")", ")", ";", "break", ";", "}", "}", "if", "(", "!", "$", "matches", ")", "{", "$", "element", "->", "addError", "(", "$", "this", "->", "handle", ",", "Craft", "::", "t", "(", "'advanced-url-field'", ",", "'URL provided does not match the allowed formats.'", ")", ")", ";", "}", "}" ]
Ensures the URL provided matches the allowed URL types. @param ElementInterface $element The element with the value being validated. @return void
[ "Ensures", "the", "URL", "provided", "matches", "the", "allowed", "URL", "types", "." ]
2dd290ab30cefe81cd56e9e79b0964017ac11b44
https://github.com/charliedevelopment/craft3-advanced-url-field/blob/2dd290ab30cefe81cd56e9e79b0964017ac11b44/src/fields/AdvancedUrlField.php#L125-L158
229,634
softark/creole
block/TableTrait.php
TableTrait.consumeTable
protected function consumeTable($lines, $current) { $pattern =<<< REGEXP /(?<=\|)( ([^\|]*?{{{.*?}}}[^\|]*?)+| ([^\|]*~\|[^\|]*?)+| [^\|]* )(?=\|)/x REGEXP; // regexp pattern should be in the order of from specific/long/complicated to general/short/simple. $block = [ 'table', 'rows' => [], ]; for ($i = $current, $count = count($lines); $i < $count; $i++) { $line = trim($lines[$i]); if ($line === '' || $line[0] !== '|') { break; } $header = $i === $current; preg_match_all($pattern, '|' . trim($line, '| ') . '|', $matches); $row = []; foreach ($matches[0] as $text) { $cell = []; if (isset($text[0]) && $text[0] === '=') { $cell['tag'] = 'th'; $cell['text'] = $this->parseInline(trim(substr($text, 1))); } else { $cell['tag'] = 'td'; $cell['text'] = $this->parseInline(trim($text)); $header = false; } $row['cells'][] = $cell; } $row['header'] = $header; $block['rows'][] = $row; } return [$block, --$i]; }
php
protected function consumeTable($lines, $current) { $pattern =<<< REGEXP /(?<=\|)( ([^\|]*?{{{.*?}}}[^\|]*?)+| ([^\|]*~\|[^\|]*?)+| [^\|]* )(?=\|)/x REGEXP; // regexp pattern should be in the order of from specific/long/complicated to general/short/simple. $block = [ 'table', 'rows' => [], ]; for ($i = $current, $count = count($lines); $i < $count; $i++) { $line = trim($lines[$i]); if ($line === '' || $line[0] !== '|') { break; } $header = $i === $current; preg_match_all($pattern, '|' . trim($line, '| ') . '|', $matches); $row = []; foreach ($matches[0] as $text) { $cell = []; if (isset($text[0]) && $text[0] === '=') { $cell['tag'] = 'th'; $cell['text'] = $this->parseInline(trim(substr($text, 1))); } else { $cell['tag'] = 'td'; $cell['text'] = $this->parseInline(trim($text)); $header = false; } $row['cells'][] = $cell; } $row['header'] = $header; $block['rows'][] = $row; } return [$block, --$i]; }
[ "protected", "function", "consumeTable", "(", "$", "lines", ",", "$", "current", ")", "{", "$", "pattern", "=", "<<< REGEXP\n/(?<=\\|)(\n ([^\\|]*?{{{.*?}}}[^\\|]*?)+|\n ([^\\|]*~\\|[^\\|]*?)+|\n [^\\|]*\n)(?=\\|)/x\nREGEXP", ";", "// regexp pattern should be in the order of from specific/long/complicated to general/short/simple.", "$", "block", "=", "[", "'table'", ",", "'rows'", "=>", "[", "]", ",", "]", ";", "for", "(", "$", "i", "=", "$", "current", ",", "$", "count", "=", "count", "(", "$", "lines", ")", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "line", "=", "trim", "(", "$", "lines", "[", "$", "i", "]", ")", ";", "if", "(", "$", "line", "===", "''", "||", "$", "line", "[", "0", "]", "!==", "'|'", ")", "{", "break", ";", "}", "$", "header", "=", "$", "i", "===", "$", "current", ";", "preg_match_all", "(", "$", "pattern", ",", "'|'", ".", "trim", "(", "$", "line", ",", "'| '", ")", ".", "'|'", ",", "$", "matches", ")", ";", "$", "row", "=", "[", "]", ";", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "text", ")", "{", "$", "cell", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "text", "[", "0", "]", ")", "&&", "$", "text", "[", "0", "]", "===", "'='", ")", "{", "$", "cell", "[", "'tag'", "]", "=", "'th'", ";", "$", "cell", "[", "'text'", "]", "=", "$", "this", "->", "parseInline", "(", "trim", "(", "substr", "(", "$", "text", ",", "1", ")", ")", ")", ";", "}", "else", "{", "$", "cell", "[", "'tag'", "]", "=", "'td'", ";", "$", "cell", "[", "'text'", "]", "=", "$", "this", "->", "parseInline", "(", "trim", "(", "$", "text", ")", ")", ";", "$", "header", "=", "false", ";", "}", "$", "row", "[", "'cells'", "]", "[", "]", "=", "$", "cell", ";", "}", "$", "row", "[", "'header'", "]", "=", "$", "header", ";", "$", "block", "[", "'rows'", "]", "[", "]", "=", "$", "row", ";", "}", "return", "[", "$", "block", ",", "--", "$", "i", "]", ";", "}" ]
Consume lines for a table
[ "Consume", "lines", "for", "a", "table" ]
f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b
https://github.com/softark/creole/blob/f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b/block/TableTrait.php#L26-L66
229,635
softark/creole
block/TableTrait.php
TableTrait.renderTable
protected function renderTable($block) { $content = ""; $first = true; foreach($block['rows'] as $row) { if ($first) { if ($row['header']) { $content .= "<thead>\n"; } else { $content .= "<tbody>\n"; } } $content .= "<tr>\n"; foreach ($row['cells'] as $cell) { $tag = $cell['tag']; $cellText = $this->renderAbsy($cell['text']); if (empty($cellText)) { $cellText = '&nbsp;'; } $content .= "<$tag>$cellText</$tag>\n"; } $content .= "</tr>\n"; if ($first) { if ($row['header']) { $content .= "</thead>\n<tbody>\n"; } $first = false; } } return "<table>\n$content</tbody>\n</table>\n"; }
php
protected function renderTable($block) { $content = ""; $first = true; foreach($block['rows'] as $row) { if ($first) { if ($row['header']) { $content .= "<thead>\n"; } else { $content .= "<tbody>\n"; } } $content .= "<tr>\n"; foreach ($row['cells'] as $cell) { $tag = $cell['tag']; $cellText = $this->renderAbsy($cell['text']); if (empty($cellText)) { $cellText = '&nbsp;'; } $content .= "<$tag>$cellText</$tag>\n"; } $content .= "</tr>\n"; if ($first) { if ($row['header']) { $content .= "</thead>\n<tbody>\n"; } $first = false; } } return "<table>\n$content</tbody>\n</table>\n"; }
[ "protected", "function", "renderTable", "(", "$", "block", ")", "{", "$", "content", "=", "\"\"", ";", "$", "first", "=", "true", ";", "foreach", "(", "$", "block", "[", "'rows'", "]", "as", "$", "row", ")", "{", "if", "(", "$", "first", ")", "{", "if", "(", "$", "row", "[", "'header'", "]", ")", "{", "$", "content", ".=", "\"<thead>\\n\"", ";", "}", "else", "{", "$", "content", ".=", "\"<tbody>\\n\"", ";", "}", "}", "$", "content", ".=", "\"<tr>\\n\"", ";", "foreach", "(", "$", "row", "[", "'cells'", "]", "as", "$", "cell", ")", "{", "$", "tag", "=", "$", "cell", "[", "'tag'", "]", ";", "$", "cellText", "=", "$", "this", "->", "renderAbsy", "(", "$", "cell", "[", "'text'", "]", ")", ";", "if", "(", "empty", "(", "$", "cellText", ")", ")", "{", "$", "cellText", "=", "'&nbsp;'", ";", "}", "$", "content", ".=", "\"<$tag>$cellText</$tag>\\n\"", ";", "}", "$", "content", ".=", "\"</tr>\\n\"", ";", "if", "(", "$", "first", ")", "{", "if", "(", "$", "row", "[", "'header'", "]", ")", "{", "$", "content", ".=", "\"</thead>\\n<tbody>\\n\"", ";", "}", "$", "first", "=", "false", ";", "}", "}", "return", "\"<table>\\n$content</tbody>\\n</table>\\n\"", ";", "}" ]
render a table block
[ "render", "a", "table", "block" ]
f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b
https://github.com/softark/creole/blob/f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b/block/TableTrait.php#L71-L101
229,636
vkovic/laravel-db-redirector
src/package/Models/RedirectRule.php
RedirectRule.deleteChainedRecursively
public static function deleteChainedRecursively($destination) { $destination = mb_strtolower(trim($destination, '/')); $redirectRules = RedirectRule::where('destination', $destination)->get(); if ($redirectRules->count() > 1) { $message = 'There is multiple redirections with the same destination! '; $message .= 'Recursive delete will not continue'; throw new \Exception($message); } $redirectRule = $redirectRules->first(); if ($redirectRule === null) { return; } $nextDestination = $redirectRule->origin; $redirectRule->delete(); self::deleteChainedRecursively($nextDestination); }
php
public static function deleteChainedRecursively($destination) { $destination = mb_strtolower(trim($destination, '/')); $redirectRules = RedirectRule::where('destination', $destination)->get(); if ($redirectRules->count() > 1) { $message = 'There is multiple redirections with the same destination! '; $message .= 'Recursive delete will not continue'; throw new \Exception($message); } $redirectRule = $redirectRules->first(); if ($redirectRule === null) { return; } $nextDestination = $redirectRule->origin; $redirectRule->delete(); self::deleteChainedRecursively($nextDestination); }
[ "public", "static", "function", "deleteChainedRecursively", "(", "$", "destination", ")", "{", "$", "destination", "=", "mb_strtolower", "(", "trim", "(", "$", "destination", ",", "'/'", ")", ")", ";", "$", "redirectRules", "=", "RedirectRule", "::", "where", "(", "'destination'", ",", "$", "destination", ")", "->", "get", "(", ")", ";", "if", "(", "$", "redirectRules", "->", "count", "(", ")", ">", "1", ")", "{", "$", "message", "=", "'There is multiple redirections with the same destination! '", ";", "$", "message", ".=", "'Recursive delete will not continue'", ";", "throw", "new", "\\", "Exception", "(", "$", "message", ")", ";", "}", "$", "redirectRule", "=", "$", "redirectRules", "->", "first", "(", ")", ";", "if", "(", "$", "redirectRule", "===", "null", ")", "{", "return", ";", "}", "$", "nextDestination", "=", "$", "redirectRule", "->", "origin", ";", "$", "redirectRule", "->", "delete", "(", ")", ";", "self", "::", "deleteChainedRecursively", "(", "$", "nextDestination", ")", ";", "}" ]
Delete chained redirect with recursive delete @param $destination @throws \Exception When there is multiple rules with same destination exception will be raised @return void
[ "Delete", "chained", "redirect", "with", "recursive", "delete" ]
fa44d932c33ea650e401e3f4f711f68b307fd617
https://github.com/vkovic/laravel-db-redirector/blob/fa44d932c33ea650e401e3f4f711f68b307fd617/src/package/Models/RedirectRule.php#L59-L83
229,637
netgen/NetgenOpenGraphBundle
bundle/MetaTag/Collector.php
Collector.collect
public function collect(Content $content) { $metaTags = array(); $allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph') ? $this->configResolver->getParameter('global_handlers', 'netgen_open_graph') : array(); $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); $contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph') ? $this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph') : array(); if (isset($contentTypeHandlers[$contentType->identifier])) { $allHandlers = array_merge( isset($allHandlers['all_content_types']) ? $allHandlers['all_content_types'] : array(), $contentTypeHandlers[$contentType->identifier] ); } else { $allHandlers = isset($allHandlers['all_content_types']) ? $allHandlers['all_content_types'] : array(); } foreach ($allHandlers as $handler) { $metaTagHandler = $this->metaTagHandlers->getHandler($handler['handler']); if ($metaTagHandler instanceof ContentAware) { $metaTagHandler->setContent($content); } $newMetaTags = $metaTagHandler->getMetaTags($handler['tag'], $handler['params']); foreach ($newMetaTags as $metaTag) { if (!$metaTag instanceof Item) { throw new LogicException( '\'' . $handler['handler'] . '\' handler returned wrong value.' . ' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.'); } $metaTagValue = $metaTag->getTagValue(); if (!empty($metaTagValue)) { $metaTags[] = $metaTag; } } } return $metaTags; }
php
public function collect(Content $content) { $metaTags = array(); $allHandlers = $this->configResolver->hasParameter('global_handlers', 'netgen_open_graph') ? $this->configResolver->getParameter('global_handlers', 'netgen_open_graph') : array(); $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId); $contentTypeHandlers = $this->configResolver->hasParameter('content_type_handlers', 'netgen_open_graph') ? $this->configResolver->getParameter('content_type_handlers', 'netgen_open_graph') : array(); if (isset($contentTypeHandlers[$contentType->identifier])) { $allHandlers = array_merge( isset($allHandlers['all_content_types']) ? $allHandlers['all_content_types'] : array(), $contentTypeHandlers[$contentType->identifier] ); } else { $allHandlers = isset($allHandlers['all_content_types']) ? $allHandlers['all_content_types'] : array(); } foreach ($allHandlers as $handler) { $metaTagHandler = $this->metaTagHandlers->getHandler($handler['handler']); if ($metaTagHandler instanceof ContentAware) { $metaTagHandler->setContent($content); } $newMetaTags = $metaTagHandler->getMetaTags($handler['tag'], $handler['params']); foreach ($newMetaTags as $metaTag) { if (!$metaTag instanceof Item) { throw new LogicException( '\'' . $handler['handler'] . '\' handler returned wrong value.' . ' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class($metaTag) . '\'.'); } $metaTagValue = $metaTag->getTagValue(); if (!empty($metaTagValue)) { $metaTags[] = $metaTag; } } } return $metaTags; }
[ "public", "function", "collect", "(", "Content", "$", "content", ")", "{", "$", "metaTags", "=", "array", "(", ")", ";", "$", "allHandlers", "=", "$", "this", "->", "configResolver", "->", "hasParameter", "(", "'global_handlers'", ",", "'netgen_open_graph'", ")", "?", "$", "this", "->", "configResolver", "->", "getParameter", "(", "'global_handlers'", ",", "'netgen_open_graph'", ")", ":", "array", "(", ")", ";", "$", "contentType", "=", "$", "this", "->", "contentTypeService", "->", "loadContentType", "(", "$", "content", "->", "contentInfo", "->", "contentTypeId", ")", ";", "$", "contentTypeHandlers", "=", "$", "this", "->", "configResolver", "->", "hasParameter", "(", "'content_type_handlers'", ",", "'netgen_open_graph'", ")", "?", "$", "this", "->", "configResolver", "->", "getParameter", "(", "'content_type_handlers'", ",", "'netgen_open_graph'", ")", ":", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "contentTypeHandlers", "[", "$", "contentType", "->", "identifier", "]", ")", ")", "{", "$", "allHandlers", "=", "array_merge", "(", "isset", "(", "$", "allHandlers", "[", "'all_content_types'", "]", ")", "?", "$", "allHandlers", "[", "'all_content_types'", "]", ":", "array", "(", ")", ",", "$", "contentTypeHandlers", "[", "$", "contentType", "->", "identifier", "]", ")", ";", "}", "else", "{", "$", "allHandlers", "=", "isset", "(", "$", "allHandlers", "[", "'all_content_types'", "]", ")", "?", "$", "allHandlers", "[", "'all_content_types'", "]", ":", "array", "(", ")", ";", "}", "foreach", "(", "$", "allHandlers", "as", "$", "handler", ")", "{", "$", "metaTagHandler", "=", "$", "this", "->", "metaTagHandlers", "->", "getHandler", "(", "$", "handler", "[", "'handler'", "]", ")", ";", "if", "(", "$", "metaTagHandler", "instanceof", "ContentAware", ")", "{", "$", "metaTagHandler", "->", "setContent", "(", "$", "content", ")", ";", "}", "$", "newMetaTags", "=", "$", "metaTagHandler", "->", "getMetaTags", "(", "$", "handler", "[", "'tag'", "]", ",", "$", "handler", "[", "'params'", "]", ")", ";", "foreach", "(", "$", "newMetaTags", "as", "$", "metaTag", ")", "{", "if", "(", "!", "$", "metaTag", "instanceof", "Item", ")", "{", "throw", "new", "LogicException", "(", "'\\''", ".", "$", "handler", "[", "'handler'", "]", ".", "'\\' handler returned wrong value.'", ".", "' Expected \\'Netgen\\Bundle\\OpenGraphBundle\\MetaTag\\Item\\', got \\''", ".", "get_class", "(", "$", "metaTag", ")", ".", "'\\'.'", ")", ";", "}", "$", "metaTagValue", "=", "$", "metaTag", "->", "getTagValue", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "metaTagValue", ")", ")", "{", "$", "metaTags", "[", "]", "=", "$", "metaTag", ";", "}", "}", "}", "return", "$", "metaTags", ";", "}" ]
Collects meta tags from all handlers registered for provided content. @param \eZ\Publish\API\Repository\Values\Content\Content $content @return \Netgen\Bundle\OpenGraphBundle\MetaTag\Item[]
[ "Collects", "meta", "tags", "from", "all", "handlers", "registered", "for", "provided", "content", "." ]
fcaad267742492cfa4049adbf075343c262c4767
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/MetaTag/Collector.php#L50-L94
229,638
josegonzalez/cakephp-wysiwyg
View/Helper/WysiwygHelper.php
WysiwygHelper.changeEditor
public function changeEditor($editor, $helperOptions = array()) { $this->helper = ucfirst($editor); if (!empty($helperOptions)) { $this->updateSettings($helperOptions); } if (!isset($this->importedHelpers[$this->helper])) { throw new MissingHelperException(sprintf("Missing Wysiwyg.%s Helper", $this->helper)); } if (!$this->importedHelpers[$this->helper]) { $class = 'Wysiwyg.' . $this->helper; $helpers = ObjectCollection::normalizeObjectArray(array($class)); foreach ($helpers as $properties) { list($plugin, $class) = pluginSplit($properties['class']); $this->{$class} = $this->_View->Helpers->load($properties['class'], $properties['settings']); } $this->importedHelpers[$this->helper] = true; } }
php
public function changeEditor($editor, $helperOptions = array()) { $this->helper = ucfirst($editor); if (!empty($helperOptions)) { $this->updateSettings($helperOptions); } if (!isset($this->importedHelpers[$this->helper])) { throw new MissingHelperException(sprintf("Missing Wysiwyg.%s Helper", $this->helper)); } if (!$this->importedHelpers[$this->helper]) { $class = 'Wysiwyg.' . $this->helper; $helpers = ObjectCollection::normalizeObjectArray(array($class)); foreach ($helpers as $properties) { list($plugin, $class) = pluginSplit($properties['class']); $this->{$class} = $this->_View->Helpers->load($properties['class'], $properties['settings']); } $this->importedHelpers[$this->helper] = true; } }
[ "public", "function", "changeEditor", "(", "$", "editor", ",", "$", "helperOptions", "=", "array", "(", ")", ")", "{", "$", "this", "->", "helper", "=", "ucfirst", "(", "$", "editor", ")", ";", "if", "(", "!", "empty", "(", "$", "helperOptions", ")", ")", "{", "$", "this", "->", "updateSettings", "(", "$", "helperOptions", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "importedHelpers", "[", "$", "this", "->", "helper", "]", ")", ")", "{", "throw", "new", "MissingHelperException", "(", "sprintf", "(", "\"Missing Wysiwyg.%s Helper\"", ",", "$", "this", "->", "helper", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "importedHelpers", "[", "$", "this", "->", "helper", "]", ")", "{", "$", "class", "=", "'Wysiwyg.'", ".", "$", "this", "->", "helper", ";", "$", "helpers", "=", "ObjectCollection", "::", "normalizeObjectArray", "(", "array", "(", "$", "class", ")", ")", ";", "foreach", "(", "$", "helpers", "as", "$", "properties", ")", "{", "list", "(", "$", "plugin", ",", "$", "class", ")", "=", "pluginSplit", "(", "$", "properties", "[", "'class'", "]", ")", ";", "$", "this", "->", "{", "$", "class", "}", "=", "$", "this", "->", "_View", "->", "Helpers", "->", "load", "(", "$", "properties", "[", "'class'", "]", ",", "$", "properties", "[", "'settings'", "]", ")", ";", "}", "$", "this", "->", "importedHelpers", "[", "$", "this", "->", "helper", "]", "=", "true", ";", "}", "}" ]
Changes the editor on the fly @param string $editor String name of editor, excluding the word 'Helper' @param array $helperOptions Each type of wysiwyg helper takes different options. @return void @throws MissingHelperException
[ "Changes", "the", "editor", "on", "the", "fly" ]
c4909d29e8942797fa360946507768066a47adb0
https://github.com/josegonzalez/cakephp-wysiwyg/blob/c4909d29e8942797fa360946507768066a47adb0/View/Helper/WysiwygHelper.php#L86-L107
229,639
josegonzalez/cakephp-wysiwyg
View/Helper/WysiwygHelper.php
WysiwygHelper.input
public function input($field = null, $options = array(), $editorOptions = array()) { return $this->{$this->helper}->input($field, $options, $editorOptions); }
php
public function input($field = null, $options = array(), $editorOptions = array()) { return $this->{$this->helper}->input($field, $options, $editorOptions); }
[ "public", "function", "input", "(", "$", "field", "=", "null", ",", "$", "options", "=", "array", "(", ")", ",", "$", "editorOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "{", "$", "this", "->", "helper", "}", "->", "input", "(", "$", "field", ",", "$", "options", ",", "$", "editorOptions", ")", ";", "}" ]
Returns the appropriate input field element @param string $field - used to build input name for views, @param array $options Array of HTML attributes. @param array $editorOptions Array of editor attributes for this input field @return string
[ "Returns", "the", "appropriate", "input", "field", "element" ]
c4909d29e8942797fa360946507768066a47adb0
https://github.com/josegonzalez/cakephp-wysiwyg/blob/c4909d29e8942797fa360946507768066a47adb0/View/Helper/WysiwygHelper.php#L117-L119
229,640
josegonzalez/cakephp-wysiwyg
View/Helper/WysiwygHelper.php
WysiwygHelper.textarea
public function textarea($field = null, $options = array(), $editorOptions = array()) { return $this->{$this->helper}->textarea($field, $options, $editorOptions); }
php
public function textarea($field = null, $options = array(), $editorOptions = array()) { return $this->{$this->helper}->textarea($field, $options, $editorOptions); }
[ "public", "function", "textarea", "(", "$", "field", "=", "null", ",", "$", "options", "=", "array", "(", ")", ",", "$", "editorOptions", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "{", "$", "this", "->", "helper", "}", "->", "textarea", "(", "$", "field", ",", "$", "options", ",", "$", "editorOptions", ")", ";", "}" ]
Returns the appropriate textarea element @param string $field - used to build input name for views, @param array $options Array of HTML attributes. @param array $editorOptions Array of editor attributes for this textarea @return string
[ "Returns", "the", "appropriate", "textarea", "element" ]
c4909d29e8942797fa360946507768066a47adb0
https://github.com/josegonzalez/cakephp-wysiwyg/blob/c4909d29e8942797fa360946507768066a47adb0/View/Helper/WysiwygHelper.php#L129-L131
229,641
milesj/utility
Model/Behavior/EnumerableBehavior.php
EnumerableBehavior.enum
public function enum($model, $key = null, $value = null) { $alias = is_string($model) ? $model : $model->alias; if (!isset($this->_enums[$alias])) { throw new InvalidArgumentException(sprintf('%s::$enum does not exist', $alias)); } $enum = $this->_enums[$alias]; if ($key) { if (!isset($enum[$key])) { throw new OutOfBoundsException(sprintf('Field %s does not exist within %s::$enum', $key, $model->alias)); } if ($value !== null) { return isset($enum[$key][$value]) ? $enum[$key][$value] : null; } else { return $enum[$key]; } } return $enum; }
php
public function enum($model, $key = null, $value = null) { $alias = is_string($model) ? $model : $model->alias; if (!isset($this->_enums[$alias])) { throw new InvalidArgumentException(sprintf('%s::$enum does not exist', $alias)); } $enum = $this->_enums[$alias]; if ($key) { if (!isset($enum[$key])) { throw new OutOfBoundsException(sprintf('Field %s does not exist within %s::$enum', $key, $model->alias)); } if ($value !== null) { return isset($enum[$key][$value]) ? $enum[$key][$value] : null; } else { return $enum[$key]; } } return $enum; }
[ "public", "function", "enum", "(", "$", "model", ",", "$", "key", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "alias", "=", "is_string", "(", "$", "model", ")", "?", "$", "model", ":", "$", "model", "->", "alias", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_enums", "[", "$", "alias", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s::$enum does not exist'", ",", "$", "alias", ")", ")", ";", "}", "$", "enum", "=", "$", "this", "->", "_enums", "[", "$", "alias", "]", ";", "if", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "enum", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "sprintf", "(", "'Field %s does not exist within %s::$enum'", ",", "$", "key", ",", "$", "model", "->", "alias", ")", ")", ";", "}", "if", "(", "$", "value", "!==", "null", ")", "{", "return", "isset", "(", "$", "enum", "[", "$", "key", "]", "[", "$", "value", "]", ")", "?", "$", "enum", "[", "$", "key", "]", "[", "$", "value", "]", ":", "null", ";", "}", "else", "{", "return", "$", "enum", "[", "$", "key", "]", ";", "}", "}", "return", "$", "enum", ";", "}" ]
Helper method for grabbing and filtering the enum from the model. @param Model|string $model @param string $key @param mixed $value @return mixed @throws InvalidArgumentException @throws OutOfBoundsException
[ "Helper", "method", "for", "grabbing", "and", "filtering", "the", "enum", "from", "the", "model", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/EnumerableBehavior.php#L123-L145
229,642
milesj/utility
Model/Behavior/EnumerableBehavior.php
EnumerableBehavior.options
public function options(Model $model, Controller $controller = null) { $enum = array(); if (isset($this->_enums[$model->alias])) { foreach ($this->_enums[$model->alias] as $key => $values) { $var = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $key))); if ($controller) { $controller->set($var, $values); } $enum[$var] = $values; } } return $enum; }
php
public function options(Model $model, Controller $controller = null) { $enum = array(); if (isset($this->_enums[$model->alias])) { foreach ($this->_enums[$model->alias] as $key => $values) { $var = Inflector::variable(Inflector::pluralize(preg_replace('/_id$/', '', $key))); if ($controller) { $controller->set($var, $values); } $enum[$var] = $values; } } return $enum; }
[ "public", "function", "options", "(", "Model", "$", "model", ",", "Controller", "$", "controller", "=", "null", ")", "{", "$", "enum", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_enums", "[", "$", "model", "->", "alias", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_enums", "[", "$", "model", "->", "alias", "]", "as", "$", "key", "=>", "$", "values", ")", "{", "$", "var", "=", "Inflector", "::", "variable", "(", "Inflector", "::", "pluralize", "(", "preg_replace", "(", "'/_id$/'", ",", "''", ",", "$", "key", ")", ")", ")", ";", "if", "(", "$", "controller", ")", "{", "$", "controller", "->", "set", "(", "$", "var", ",", "$", "values", ")", ";", "}", "$", "enum", "[", "$", "var", "]", "=", "$", "values", ";", "}", "}", "return", "$", "enum", ";", "}" ]
Generate select options based on the enum fields which will be used for form input auto-magic. If a Controller is passed, it will auto-set the data to the views. @param Model $model @param Controller|null $controller @return array
[ "Generate", "select", "options", "based", "on", "the", "enum", "fields", "which", "will", "be", "used", "for", "form", "input", "auto", "-", "magic", ".", "If", "a", "Controller", "is", "passed", "it", "will", "auto", "-", "set", "the", "data", "to", "the", "views", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/EnumerableBehavior.php#L155-L171
229,643
milesj/utility
Model/Behavior/EnumerableBehavior.php
EnumerableBehavior.validateEnum
public function validateEnum(Model $model, $check, $rule) { $field = key($check); $value = $check[$field]; if ($value === '' || $value === null || $value === false) { return (bool) $rule['allowEmpty']; } $enum = $this->enum($model, $field); return isset($enum[$value]); }
php
public function validateEnum(Model $model, $check, $rule) { $field = key($check); $value = $check[$field]; if ($value === '' || $value === null || $value === false) { return (bool) $rule['allowEmpty']; } $enum = $this->enum($model, $field); return isset($enum[$value]); }
[ "public", "function", "validateEnum", "(", "Model", "$", "model", ",", "$", "check", ",", "$", "rule", ")", "{", "$", "field", "=", "key", "(", "$", "check", ")", ";", "$", "value", "=", "$", "check", "[", "$", "field", "]", ";", "if", "(", "$", "value", "===", "''", "||", "$", "value", "===", "null", "||", "$", "value", "===", "false", ")", "{", "return", "(", "bool", ")", "$", "rule", "[", "'allowEmpty'", "]", ";", "}", "$", "enum", "=", "$", "this", "->", "enum", "(", "$", "model", ",", "$", "field", ")", ";", "return", "isset", "(", "$", "enum", "[", "$", "value", "]", ")", ";", "}" ]
Used for model validation to validate a value is within a certain field enum. @param Model $model @param array $check @param array $rule @return bool
[ "Used", "for", "model", "validation", "to", "validate", "a", "value", "is", "within", "a", "certain", "field", "enum", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/EnumerableBehavior.php#L181-L192
229,644
milesj/utility
Model/Behavior/EnumerableBehavior.php
EnumerableBehavior.afterFind
public function afterFind(Model $model, $results, $primary = true) { $alias = $model->alias; if (!$this->format || ($model->id && !$this->onUpdate) || empty($this->_enums[$alias])) { return $results; } if ($results) { $enum = $this->_enums[$alias]; foreach ($results as &$result) { foreach ($enum as $key => $nop) { if (isset($result[$alias][$key])) { $value = $result[$alias][$key]; if ($this->format === self::REPLACE) { $result[$alias][$key] = $this->enum($model, $key, $value); if ($this->persist) { $result[$alias][$key . $this->suffix] = $value; } } else if ($this->format === self::APPEND) { $result[$alias][$key . $this->suffix] = $this->enum($model, $key, $value); } } } } } return $results; }
php
public function afterFind(Model $model, $results, $primary = true) { $alias = $model->alias; if (!$this->format || ($model->id && !$this->onUpdate) || empty($this->_enums[$alias])) { return $results; } if ($results) { $enum = $this->_enums[$alias]; foreach ($results as &$result) { foreach ($enum as $key => $nop) { if (isset($result[$alias][$key])) { $value = $result[$alias][$key]; if ($this->format === self::REPLACE) { $result[$alias][$key] = $this->enum($model, $key, $value); if ($this->persist) { $result[$alias][$key . $this->suffix] = $value; } } else if ($this->format === self::APPEND) { $result[$alias][$key . $this->suffix] = $this->enum($model, $key, $value); } } } } } return $results; }
[ "public", "function", "afterFind", "(", "Model", "$", "model", ",", "$", "results", ",", "$", "primary", "=", "true", ")", "{", "$", "alias", "=", "$", "model", "->", "alias", ";", "if", "(", "!", "$", "this", "->", "format", "||", "(", "$", "model", "->", "id", "&&", "!", "$", "this", "->", "onUpdate", ")", "||", "empty", "(", "$", "this", "->", "_enums", "[", "$", "alias", "]", ")", ")", "{", "return", "$", "results", ";", "}", "if", "(", "$", "results", ")", "{", "$", "enum", "=", "$", "this", "->", "_enums", "[", "$", "alias", "]", ";", "foreach", "(", "$", "results", "as", "&", "$", "result", ")", "{", "foreach", "(", "$", "enum", "as", "$", "key", "=>", "$", "nop", ")", "{", "if", "(", "isset", "(", "$", "result", "[", "$", "alias", "]", "[", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "result", "[", "$", "alias", "]", "[", "$", "key", "]", ";", "if", "(", "$", "this", "->", "format", "===", "self", "::", "REPLACE", ")", "{", "$", "result", "[", "$", "alias", "]", "[", "$", "key", "]", "=", "$", "this", "->", "enum", "(", "$", "model", ",", "$", "key", ",", "$", "value", ")", ";", "if", "(", "$", "this", "->", "persist", ")", "{", "$", "result", "[", "$", "alias", "]", "[", "$", "key", ".", "$", "this", "->", "suffix", "]", "=", "$", "value", ";", "}", "}", "else", "if", "(", "$", "this", "->", "format", "===", "self", "::", "APPEND", ")", "{", "$", "result", "[", "$", "alias", "]", "[", "$", "key", ".", "$", "this", "->", "suffix", "]", "=", "$", "this", "->", "enum", "(", "$", "model", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}", "}", "}", "return", "$", "results", ";", "}" ]
Format the results by replacing all enum fields with their respective value replacement. @param Model $model @param array $results @param bool $primary @return mixed
[ "Format", "the", "results", "by", "replacing", "all", "enum", "fields", "with", "their", "respective", "value", "replacement", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/EnumerableBehavior.php#L202-L232
229,645
hubzero/orcid-php
src/Oauth.php
Oauth.getAuthorizationUrl
public function getAuthorizationUrl() { // Check for required items if (!$this->clientId) { throw new Exception('Client ID is required'); } if (!$this->scope) { throw new Exception('Scope is required'); } if (!$this->redirectUri) { throw new Exception('Redirect URI is required'); } // Start building url (enpoint is the same for public and member APIs) $url = 'https://'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME . '/' . self::AUTHORIZE; $url .= '?client_id=' . $this->clientId; $url .= '&scope=' . $this->scope; $url .= '&redirect_uri=' . urlencode($this->redirectUri); $url .= '&response_type=code'; // Process non-required fields $url .= ($this->showLogin) ? '&show_login=true' : ''; $url .= (isset($this->state)) ? '&state=' . $this->state : ''; $url .= (isset($this->familyNames)) ? '&family_names=' . $this->familyNames : ''; $url .= (isset($this->givenNames)) ? '&given_names=' . $this->givenNames : ''; $url .= (isset($this->email)) ? '&email=' . urlencode($this->email) : ''; return $url; }
php
public function getAuthorizationUrl() { // Check for required items if (!$this->clientId) { throw new Exception('Client ID is required'); } if (!$this->scope) { throw new Exception('Scope is required'); } if (!$this->redirectUri) { throw new Exception('Redirect URI is required'); } // Start building url (enpoint is the same for public and member APIs) $url = 'https://'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME . '/' . self::AUTHORIZE; $url .= '?client_id=' . $this->clientId; $url .= '&scope=' . $this->scope; $url .= '&redirect_uri=' . urlencode($this->redirectUri); $url .= '&response_type=code'; // Process non-required fields $url .= ($this->showLogin) ? '&show_login=true' : ''; $url .= (isset($this->state)) ? '&state=' . $this->state : ''; $url .= (isset($this->familyNames)) ? '&family_names=' . $this->familyNames : ''; $url .= (isset($this->givenNames)) ? '&given_names=' . $this->givenNames : ''; $url .= (isset($this->email)) ? '&email=' . urlencode($this->email) : ''; return $url; }
[ "public", "function", "getAuthorizationUrl", "(", ")", "{", "// Check for required items", "if", "(", "!", "$", "this", "->", "clientId", ")", "{", "throw", "new", "Exception", "(", "'Client ID is required'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "scope", ")", "{", "throw", "new", "Exception", "(", "'Scope is required'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "redirectUri", ")", "{", "throw", "new", "Exception", "(", "'Redirect URI is required'", ")", ";", "}", "// Start building url (enpoint is the same for public and member APIs)", "$", "url", "=", "'https://'", ";", "$", "url", ".=", "(", "!", "empty", "(", "$", "this", "->", "environment", ")", ")", "?", "$", "this", "->", "environment", ".", "'.'", ":", "''", ";", "$", "url", ".=", "self", "::", "HOSTNAME", ".", "'/'", ".", "self", "::", "AUTHORIZE", ";", "$", "url", ".=", "'?client_id='", ".", "$", "this", "->", "clientId", ";", "$", "url", ".=", "'&scope='", ".", "$", "this", "->", "scope", ";", "$", "url", ".=", "'&redirect_uri='", ".", "urlencode", "(", "$", "this", "->", "redirectUri", ")", ";", "$", "url", ".=", "'&response_type=code'", ";", "// Process non-required fields", "$", "url", ".=", "(", "$", "this", "->", "showLogin", ")", "?", "'&show_login=true'", ":", "''", ";", "$", "url", ".=", "(", "isset", "(", "$", "this", "->", "state", ")", ")", "?", "'&state='", ".", "$", "this", "->", "state", ":", "''", ";", "$", "url", ".=", "(", "isset", "(", "$", "this", "->", "familyNames", ")", ")", "?", "'&family_names='", ".", "$", "this", "->", "familyNames", ":", "''", ";", "$", "url", ".=", "(", "isset", "(", "$", "this", "->", "givenNames", ")", ")", "?", "'&given_names='", ".", "$", "this", "->", "givenNames", ":", "''", ";", "$", "url", ".=", "(", "isset", "(", "$", "this", "->", "email", ")", ")", "?", "'&email='", ".", "urlencode", "(", "$", "this", "->", "email", ")", ":", "''", ";", "return", "$", "url", ";", "}" ]
Gets the authorization URL based on the instance parameters @return string
[ "Gets", "the", "authorization", "URL", "based", "on", "the", "instance", "parameters" ]
2b9a31bd3932af0e18d4b80029901c8ec84a0861
https://github.com/hubzero/orcid-php/blob/2b9a31bd3932af0e18d4b80029901c8ec84a0861/src/Oauth.php#L372-L402
229,646
hubzero/orcid-php
src/Oauth.php
Oauth.authenticate
public function authenticate($code) { // Validate code if (!$code || strlen($code) != 6) { throw new Exception('Invalid authorization code'); } // Check for required items if (!$this->clientId) { throw new Exception('Client ID is required'); } if (!$this->clientSecret) { throw new Exception('Client secret is required'); } if (!$this->redirectUri) { throw new Exception('Redirect URI is required'); } $fields = [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'code' => $code, 'redirect_uri' => urlencode($this->redirectUri), 'grant_type' => 'authorization_code' ]; $url = 'https://'; $url .= $this->level . '.'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME . '/' . self::TOKEN; $this->http->setUrl($url) ->setPostFields($fields) ->setHeader(['Accept' => 'application/json']); $data = json_decode($this->http->execute()); if (isset($data->access_token)) { $this->setAccessToken($data->access_token); $this->setOrcid($data->orcid); } else { // Seems like the response format changes on occasion...not sure what's going on there? $error = (isset($data->error_description)) ? $data->error_description : $data->{'error-desc'}->value; throw new Exception($error); } return $this; }
php
public function authenticate($code) { // Validate code if (!$code || strlen($code) != 6) { throw new Exception('Invalid authorization code'); } // Check for required items if (!$this->clientId) { throw new Exception('Client ID is required'); } if (!$this->clientSecret) { throw new Exception('Client secret is required'); } if (!$this->redirectUri) { throw new Exception('Redirect URI is required'); } $fields = [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'code' => $code, 'redirect_uri' => urlencode($this->redirectUri), 'grant_type' => 'authorization_code' ]; $url = 'https://'; $url .= $this->level . '.'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME . '/' . self::TOKEN; $this->http->setUrl($url) ->setPostFields($fields) ->setHeader(['Accept' => 'application/json']); $data = json_decode($this->http->execute()); if (isset($data->access_token)) { $this->setAccessToken($data->access_token); $this->setOrcid($data->orcid); } else { // Seems like the response format changes on occasion...not sure what's going on there? $error = (isset($data->error_description)) ? $data->error_description : $data->{'error-desc'}->value; throw new Exception($error); } return $this; }
[ "public", "function", "authenticate", "(", "$", "code", ")", "{", "// Validate code", "if", "(", "!", "$", "code", "||", "strlen", "(", "$", "code", ")", "!=", "6", ")", "{", "throw", "new", "Exception", "(", "'Invalid authorization code'", ")", ";", "}", "// Check for required items", "if", "(", "!", "$", "this", "->", "clientId", ")", "{", "throw", "new", "Exception", "(", "'Client ID is required'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "clientSecret", ")", "{", "throw", "new", "Exception", "(", "'Client secret is required'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "redirectUri", ")", "{", "throw", "new", "Exception", "(", "'Redirect URI is required'", ")", ";", "}", "$", "fields", "=", "[", "'client_id'", "=>", "$", "this", "->", "clientId", ",", "'client_secret'", "=>", "$", "this", "->", "clientSecret", ",", "'code'", "=>", "$", "code", ",", "'redirect_uri'", "=>", "urlencode", "(", "$", "this", "->", "redirectUri", ")", ",", "'grant_type'", "=>", "'authorization_code'", "]", ";", "$", "url", "=", "'https://'", ";", "$", "url", ".=", "$", "this", "->", "level", ".", "'.'", ";", "$", "url", ".=", "(", "!", "empty", "(", "$", "this", "->", "environment", ")", ")", "?", "$", "this", "->", "environment", ".", "'.'", ":", "''", ";", "$", "url", ".=", "self", "::", "HOSTNAME", ".", "'/'", ".", "self", "::", "TOKEN", ";", "$", "this", "->", "http", "->", "setUrl", "(", "$", "url", ")", "->", "setPostFields", "(", "$", "fields", ")", "->", "setHeader", "(", "[", "'Accept'", "=>", "'application/json'", "]", ")", ";", "$", "data", "=", "json_decode", "(", "$", "this", "->", "http", "->", "execute", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "data", "->", "access_token", ")", ")", "{", "$", "this", "->", "setAccessToken", "(", "$", "data", "->", "access_token", ")", ";", "$", "this", "->", "setOrcid", "(", "$", "data", "->", "orcid", ")", ";", "}", "else", "{", "// Seems like the response format changes on occasion...not sure what's going on there?", "$", "error", "=", "(", "isset", "(", "$", "data", "->", "error_description", ")", ")", "?", "$", "data", "->", "error_description", ":", "$", "data", "->", "{", "'error-desc'", "}", "->", "value", ";", "throw", "new", "Exception", "(", "$", "error", ")", ";", "}", "return", "$", "this", ";", "}" ]
Takes the given code and requests an auth token @param string $code the oauth code needed to request the access token @return $this @throws Exception
[ "Takes", "the", "given", "code", "and", "requests", "an", "auth", "token" ]
2b9a31bd3932af0e18d4b80029901c8ec84a0861
https://github.com/hubzero/orcid-php/blob/2b9a31bd3932af0e18d4b80029901c8ec84a0861/src/Oauth.php#L411-L459
229,647
hubzero/orcid-php
src/Oauth.php
Oauth.getProfile
public function getProfile($orcid = null) { $this->http->setUrl($this->getApiEndpoint('record', $orcid)); if ($this->level == 'api') { // If using the members api, we have to have an access token set if (!$this->getAccessToken()) { throw new Exception('You must first set an access token or authenticate'); } $this->http->setHeader([ 'Content-Type' => 'application/vnd.orcid+json', 'Authorization' => 'Bearer ' . $this->getAccessToken() ]); } else { $this->http->setHeader('Accept: application/vnd.orcid+json'); } return json_decode($this->http->execute()); }
php
public function getProfile($orcid = null) { $this->http->setUrl($this->getApiEndpoint('record', $orcid)); if ($this->level == 'api') { // If using the members api, we have to have an access token set if (!$this->getAccessToken()) { throw new Exception('You must first set an access token or authenticate'); } $this->http->setHeader([ 'Content-Type' => 'application/vnd.orcid+json', 'Authorization' => 'Bearer ' . $this->getAccessToken() ]); } else { $this->http->setHeader('Accept: application/vnd.orcid+json'); } return json_decode($this->http->execute()); }
[ "public", "function", "getProfile", "(", "$", "orcid", "=", "null", ")", "{", "$", "this", "->", "http", "->", "setUrl", "(", "$", "this", "->", "getApiEndpoint", "(", "'record'", ",", "$", "orcid", ")", ")", ";", "if", "(", "$", "this", "->", "level", "==", "'api'", ")", "{", "// If using the members api, we have to have an access token set", "if", "(", "!", "$", "this", "->", "getAccessToken", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'You must first set an access token or authenticate'", ")", ";", "}", "$", "this", "->", "http", "->", "setHeader", "(", "[", "'Content-Type'", "=>", "'application/vnd.orcid+json'", ",", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "getAccessToken", "(", ")", "]", ")", ";", "}", "else", "{", "$", "this", "->", "http", "->", "setHeader", "(", "'Accept: application/vnd.orcid+json'", ")", ";", "}", "return", "json_decode", "(", "$", "this", "->", "http", "->", "execute", "(", ")", ")", ";", "}" ]
Grabs the user's profile You'll probably call this method after completing the proper oauth exchange. But, in theory, you could call this without oauth and pass in a ORCID iD, assuming you use the public API endpoint. @param string $orcid the orcid to look up, if not already set as class prop @return object @throws Exception
[ "Grabs", "the", "user", "s", "profile" ]
2b9a31bd3932af0e18d4b80029901c8ec84a0861
https://github.com/hubzero/orcid-php/blob/2b9a31bd3932af0e18d4b80029901c8ec84a0861/src/Oauth.php#L482-L501
229,648
hubzero/orcid-php
src/Oauth.php
Oauth.getApiEndpoint
private function getApiEndpoint($endpoint, $orcid = null) { $url = 'https://'; $url .= $this->level . '.'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME; $url .= '/v' . self::VERSION . '/'; $url .= $orcid ?: $this->getOrcid(); $url .= '/' . $endpoint; return $url; }
php
private function getApiEndpoint($endpoint, $orcid = null) { $url = 'https://'; $url .= $this->level . '.'; $url .= (!empty($this->environment)) ? $this->environment . '.' : ''; $url .= self::HOSTNAME; $url .= '/v' . self::VERSION . '/'; $url .= $orcid ?: $this->getOrcid(); $url .= '/' . $endpoint; return $url; }
[ "private", "function", "getApiEndpoint", "(", "$", "endpoint", ",", "$", "orcid", "=", "null", ")", "{", "$", "url", "=", "'https://'", ";", "$", "url", ".=", "$", "this", "->", "level", ".", "'.'", ";", "$", "url", ".=", "(", "!", "empty", "(", "$", "this", "->", "environment", ")", ")", "?", "$", "this", "->", "environment", ".", "'.'", ":", "''", ";", "$", "url", ".=", "self", "::", "HOSTNAME", ";", "$", "url", ".=", "'/v'", ".", "self", "::", "VERSION", ".", "'/'", ";", "$", "url", ".=", "$", "orcid", "?", ":", "$", "this", "->", "getOrcid", "(", ")", ";", "$", "url", ".=", "'/'", ".", "$", "endpoint", ";", "return", "$", "url", ";", "}" ]
Creates the qualified api endpoint for retrieving the desired data @param string $endpoint the shortname of the endpoint @param string $orcid the orcid to look up, if not already specified @return string
[ "Creates", "the", "qualified", "api", "endpoint", "for", "retrieving", "the", "desired", "data" ]
2b9a31bd3932af0e18d4b80029901c8ec84a0861
https://github.com/hubzero/orcid-php/blob/2b9a31bd3932af0e18d4b80029901c8ec84a0861/src/Oauth.php#L510-L521
229,649
vkovic/laravel-db-redirector
src/package/DbRedirectorRouter.php
DbRedirectorRouter.getPotentialRules
public function getPotentialRules($uri) { // // Try to match uri with rule without route params // $redirectRules = RedirectRule::where('origin', $uri)->get(); if ($redirectRules->isNotEmpty()) { return $redirectRules; } // // Try to match uri with rule with url params: // // Search only rules with params but without optional params $query = RedirectRule::where('origin', 'LIKE', '%{%') ->where('origin', 'NOT LIKE', '%?}%'); // Narrow potential matches by matching number of url segments // (by matching number of slashes) $slashesCount = substr_count($uri, '/'); $rawWhere = \DB::raw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))"); $query = $query->where($rawWhere, $slashesCount); // Ordering $query // Route with lesser number of parameters will have top priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))") // Rules with params nearer end of route will have last priority ->orderByRaw("INSTR(origin, '{') DESC"); // Get collection of potential rules $potentialRules = $query->get(); if ($potentialRules->isNotEmpty()) { return $potentialRules; } // // Try to match uri with rule with optional url params: // // Search only rules with optional params $query = RedirectRule::where('origin', 'LIKE', '%?}%'); // Ordering $query // Route with less segments will have top priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))") // Route with lesser number of parameters will have next priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))") // Rules with params nearer end of route will have last priority ->orderByRaw("INSTR(origin, '{') DESC"); return $query->get(); }
php
public function getPotentialRules($uri) { // // Try to match uri with rule without route params // $redirectRules = RedirectRule::where('origin', $uri)->get(); if ($redirectRules->isNotEmpty()) { return $redirectRules; } // // Try to match uri with rule with url params: // // Search only rules with params but without optional params $query = RedirectRule::where('origin', 'LIKE', '%{%') ->where('origin', 'NOT LIKE', '%?}%'); // Narrow potential matches by matching number of url segments // (by matching number of slashes) $slashesCount = substr_count($uri, '/'); $rawWhere = \DB::raw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))"); $query = $query->where($rawWhere, $slashesCount); // Ordering $query // Route with lesser number of parameters will have top priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))") // Rules with params nearer end of route will have last priority ->orderByRaw("INSTR(origin, '{') DESC"); // Get collection of potential rules $potentialRules = $query->get(); if ($potentialRules->isNotEmpty()) { return $potentialRules; } // // Try to match uri with rule with optional url params: // // Search only rules with optional params $query = RedirectRule::where('origin', 'LIKE', '%?}%'); // Ordering $query // Route with less segments will have top priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))") // Route with lesser number of parameters will have next priority ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))") // Rules with params nearer end of route will have last priority ->orderByRaw("INSTR(origin, '{') DESC"); return $query->get(); }
[ "public", "function", "getPotentialRules", "(", "$", "uri", ")", "{", "//", "// Try to match uri with rule without route params", "//", "$", "redirectRules", "=", "RedirectRule", "::", "where", "(", "'origin'", ",", "$", "uri", ")", "->", "get", "(", ")", ";", "if", "(", "$", "redirectRules", "->", "isNotEmpty", "(", ")", ")", "{", "return", "$", "redirectRules", ";", "}", "//", "// Try to match uri with rule with url params:", "//", "// Search only rules with params but without optional params", "$", "query", "=", "RedirectRule", "::", "where", "(", "'origin'", ",", "'LIKE'", ",", "'%{%'", ")", "->", "where", "(", "'origin'", ",", "'NOT LIKE'", ",", "'%?}%'", ")", ";", "// Narrow potential matches by matching number of url segments", "// (by matching number of slashes)", "$", "slashesCount", "=", "substr_count", "(", "$", "uri", ",", "'/'", ")", ";", "$", "rawWhere", "=", "\\", "DB", "::", "raw", "(", "\"LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))\"", ")", ";", "$", "query", "=", "$", "query", "->", "where", "(", "$", "rawWhere", ",", "$", "slashesCount", ")", ";", "// Ordering", "$", "query", "// Route with lesser number of parameters will have top priority", "->", "orderByRaw", "(", "\"LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))\"", ")", "// Rules with params nearer end of route will have last priority", "->", "orderByRaw", "(", "\"INSTR(origin, '{') DESC\"", ")", ";", "// Get collection of potential rules", "$", "potentialRules", "=", "$", "query", "->", "get", "(", ")", ";", "if", "(", "$", "potentialRules", "->", "isNotEmpty", "(", ")", ")", "{", "return", "$", "potentialRules", ";", "}", "//", "// Try to match uri with rule with optional url params:", "//", "// Search only rules with optional params", "$", "query", "=", "RedirectRule", "::", "where", "(", "'origin'", ",", "'LIKE'", ",", "'%?}%'", ")", ";", "// Ordering", "$", "query", "// Route with less segments will have top priority", "->", "orderByRaw", "(", "\"LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))\"", ")", "// Route with lesser number of parameters will have next priority", "->", "orderByRaw", "(", "\"LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))\"", ")", "// Rules with params nearer end of route will have last priority", "->", "orderByRaw", "(", "\"INSTR(origin, '{') DESC\"", ")", ";", "return", "$", "query", "->", "get", "(", ")", ";", "}" ]
Get potential rules based on requested URI @param string $uri @return Collection
[ "Get", "potential", "rules", "based", "on", "requested", "URI" ]
fa44d932c33ea650e401e3f4f711f68b307fd617
https://github.com/vkovic/laravel-db-redirector/blob/fa44d932c33ea650e401e3f4f711f68b307fd617/src/package/DbRedirectorRouter.php#L64-L121
229,650
vkovic/laravel-db-redirector
src/package/DbRedirectorRouter.php
DbRedirectorRouter.resolveDestination
protected function resolveDestination($destination) { foreach ($this->router->getCurrentRoute()->parameters() as $key => $value) { $destination = str_replace("{{$key}}", $value, $destination); } // Remove non existent optional params from destination // but after existent params has been resolved $destination = preg_replace('/\/{[\w-_]+}/', '', $destination); return $destination; }
php
protected function resolveDestination($destination) { foreach ($this->router->getCurrentRoute()->parameters() as $key => $value) { $destination = str_replace("{{$key}}", $value, $destination); } // Remove non existent optional params from destination // but after existent params has been resolved $destination = preg_replace('/\/{[\w-_]+}/', '', $destination); return $destination; }
[ "protected", "function", "resolveDestination", "(", "$", "destination", ")", "{", "foreach", "(", "$", "this", "->", "router", "->", "getCurrentRoute", "(", ")", "->", "parameters", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "destination", "=", "str_replace", "(", "\"{{$key}}\"", ",", "$", "value", ",", "$", "destination", ")", ";", "}", "// Remove non existent optional params from destination", "// but after existent params has been resolved", "$", "destination", "=", "preg_replace", "(", "'/\\/{[\\w-_]+}/'", ",", "''", ",", "$", "destination", ")", ";", "return", "$", "destination", ";", "}" ]
Resolve destination by replacing parameters from current route into destination rule @param string $destination @return mixed
[ "Resolve", "destination", "by", "replacing", "parameters", "from", "current", "route", "into", "destination", "rule" ]
fa44d932c33ea650e401e3f4f711f68b307fd617
https://github.com/vkovic/laravel-db-redirector/blob/fa44d932c33ea650e401e3f4f711f68b307fd617/src/package/DbRedirectorRouter.php#L131-L142
229,651
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.from
public static function from(DateTime $start, $amount, DateInterval $interval) { $end = self::buildDatetime($start, $amount, $interval, true); return new DateTimeRange($start, $end, $interval); }
php
public static function from(DateTime $start, $amount, DateInterval $interval) { $end = self::buildDatetime($start, $amount, $interval, true); return new DateTimeRange($start, $end, $interval); }
[ "public", "static", "function", "from", "(", "DateTime", "$", "start", ",", "$", "amount", ",", "DateInterval", "$", "interval", ")", "{", "$", "end", "=", "self", "::", "buildDatetime", "(", "$", "start", ",", "$", "amount", ",", "$", "interval", ",", "true", ")", ";", "return", "new", "DateTimeRange", "(", "$", "start", ",", "$", "end", ",", "$", "interval", ")", ";", "}" ]
Creates a DateTimeRange object from the start date for the given amount od dates. @param DateTime $start The start date. @param integer $amount The amount of dates included in a range. @param DateInterval $interval The interval between adjacent dates. @return DateTimeRange @since 2.0.0
[ "Creates", "a", "DateTimeRange", "object", "from", "the", "start", "date", "for", "the", "given", "amount", "od", "dates", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L76-L81
229,652
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.to
public static function to(DateTime $end, $amount, DateInterval $interval) { $start = self::buildDatetime($end, $amount, $interval, false); return new DateTimeRange($start, $end, $interval); }
php
public static function to(DateTime $end, $amount, DateInterval $interval) { $start = self::buildDatetime($end, $amount, $interval, false); return new DateTimeRange($start, $end, $interval); }
[ "public", "static", "function", "to", "(", "DateTime", "$", "end", ",", "$", "amount", ",", "DateInterval", "$", "interval", ")", "{", "$", "start", "=", "self", "::", "buildDatetime", "(", "$", "end", ",", "$", "amount", ",", "$", "interval", ",", "false", ")", ";", "return", "new", "DateTimeRange", "(", "$", "start", ",", "$", "end", ",", "$", "interval", ")", ";", "}" ]
Creates a DateTimeRange object to the end date for the given amount od dates. @param DateTime $end The end date. @param integer $amount The amount of dates included in a range. @param DateInterval $interval The interval between adjacent dates. @return DateTimeRange @since 2.0.0
[ "Creates", "a", "DateTimeRange", "object", "to", "the", "end", "date", "for", "the", "given", "amount", "od", "dates", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L94-L99
229,653
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.includes
public function includes(DateTime $datetime) { return !$datetime->isBefore($this->start) && !$datetime->isAfter($this->end); }
php
public function includes(DateTime $datetime) { return !$datetime->isBefore($this->start) && !$datetime->isAfter($this->end); }
[ "public", "function", "includes", "(", "DateTime", "$", "datetime", ")", "{", "return", "!", "$", "datetime", "->", "isBefore", "(", "$", "this", "->", "start", ")", "&&", "!", "$", "datetime", "->", "isAfter", "(", "$", "this", "->", "end", ")", ";", "}" ]
Checks if the given date is included in the range. @param DateTime $datetime The date to compare to. @return boolean @since 2.0.0
[ "Checks", "if", "the", "given", "date", "is", "included", "in", "the", "range", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L158-L161
229,654
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.equals
public function equals(DateTimeRange $range) { return $this->start->equals($range->start) && $this->end->equals($range->end) && $this->interval->equals($range->interval); }
php
public function equals(DateTimeRange $range) { return $this->start->equals($range->start) && $this->end->equals($range->end) && $this->interval->equals($range->interval); }
[ "public", "function", "equals", "(", "DateTimeRange", "$", "range", ")", "{", "return", "$", "this", "->", "start", "->", "equals", "(", "$", "range", "->", "start", ")", "&&", "$", "this", "->", "end", "->", "equals", "(", "$", "range", "->", "end", ")", "&&", "$", "this", "->", "interval", "->", "equals", "(", "$", "range", "->", "interval", ")", ";", "}" ]
Checks if ranges are equal. @param DateTimeRange $range The range to compare to. @return boolean @since 2.0.0
[ "Checks", "if", "ranges", "are", "equal", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L172-L175
229,655
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.includesRange
public function includesRange(DateTimeRange $range) { return $this->includes($range->start) && $this->includes($range->end); }
php
public function includesRange(DateTimeRange $range) { return $this->includes($range->start) && $this->includes($range->end); }
[ "public", "function", "includesRange", "(", "DateTimeRange", "$", "range", ")", "{", "return", "$", "this", "->", "includes", "(", "$", "range", "->", "start", ")", "&&", "$", "this", "->", "includes", "(", "$", "range", "->", "end", ")", ";", "}" ]
Checks if the given range is included in the current one. @param DateTimeRange $range The range to compare to. @return boolean @since 2.0.0
[ "Checks", "if", "the", "given", "range", "is", "included", "in", "the", "current", "one", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L200-L203
229,656
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.abuts
public function abuts(DateTimeRange $range) { return !$this->overlaps($range) && $this->gap($range)->isEmpty(); }
php
public function abuts(DateTimeRange $range) { return !$this->overlaps($range) && $this->gap($range)->isEmpty(); }
[ "public", "function", "abuts", "(", "DateTimeRange", "$", "range", ")", "{", "return", "!", "$", "this", "->", "overlaps", "(", "$", "range", ")", "&&", "$", "this", "->", "gap", "(", "$", "range", ")", "->", "isEmpty", "(", ")", ";", "}" ]
Checks if ranges abuts with each other. @param DateTimeRange $range The range to compare to. @return boolean @since 2.0.0
[ "Checks", "if", "ranges", "abuts", "with", "each", "other", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L244-L247
229,657
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.compare
private static function compare(DateTimeRange $a, DateTimeRange $b) { if (!$a->interval->equals($b->interval)) { throw new \InvalidArgumentException('Intervals of ranges are not equal.'); } if ($a->equals($b)) { return 0; } if ($a->start()->isAfter($b->start())) { return 1; } if ($a->start()->isBefore($b->start()) || $a->end()->isBefore($b->end())) { return -1; } return 1; }
php
private static function compare(DateTimeRange $a, DateTimeRange $b) { if (!$a->interval->equals($b->interval)) { throw new \InvalidArgumentException('Intervals of ranges are not equal.'); } if ($a->equals($b)) { return 0; } if ($a->start()->isAfter($b->start())) { return 1; } if ($a->start()->isBefore($b->start()) || $a->end()->isBefore($b->end())) { return -1; } return 1; }
[ "private", "static", "function", "compare", "(", "DateTimeRange", "$", "a", ",", "DateTimeRange", "$", "b", ")", "{", "if", "(", "!", "$", "a", "->", "interval", "->", "equals", "(", "$", "b", "->", "interval", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Intervals of ranges are not equal.'", ")", ";", "}", "if", "(", "$", "a", "->", "equals", "(", "$", "b", ")", ")", "{", "return", "0", ";", "}", "if", "(", "$", "a", "->", "start", "(", ")", "->", "isAfter", "(", "$", "b", "->", "start", "(", ")", ")", ")", "{", "return", "1", ";", "}", "if", "(", "$", "a", "->", "start", "(", ")", "->", "isBefore", "(", "$", "b", "->", "start", "(", ")", ")", "||", "$", "a", "->", "end", "(", ")", "->", "isBefore", "(", "$", "b", "->", "end", "(", ")", ")", ")", "{", "return", "-", "1", ";", "}", "return", "1", ";", "}" ]
Compares two objects. @param DateTimeRange $a Base object. @param DateTimeRange $b Object to compare to. @return integer @since 2.0.0 @throws \InvalidArgumentException
[ "Compares", "two", "objects", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L364-L387
229,658
joomla-framework/datetime
src/DateTimeRange.php
DateTimeRange.buildDatetime
private static function buildDatetime(DateTime $base, $amount, DateInterval $interval, $byAddition = true) { if (intval($amount) < 2) { throw new \InvalidArgumentException('Amount have to be greater than 2'); } // Start from 2, because start date and end date also count for ($i = 2; $i <= $amount; $i++) { $base = $byAddition ? $base->add($interval) : $base->sub($interval); } return $base; }
php
private static function buildDatetime(DateTime $base, $amount, DateInterval $interval, $byAddition = true) { if (intval($amount) < 2) { throw new \InvalidArgumentException('Amount have to be greater than 2'); } // Start from 2, because start date and end date also count for ($i = 2; $i <= $amount; $i++) { $base = $byAddition ? $base->add($interval) : $base->sub($interval); } return $base; }
[ "private", "static", "function", "buildDatetime", "(", "DateTime", "$", "base", ",", "$", "amount", ",", "DateInterval", "$", "interval", ",", "$", "byAddition", "=", "true", ")", "{", "if", "(", "intval", "(", "$", "amount", ")", "<", "2", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Amount have to be greater than 2'", ")", ";", "}", "// Start from 2, because start date and end date also count", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<=", "$", "amount", ";", "$", "i", "++", ")", "{", "$", "base", "=", "$", "byAddition", "?", "$", "base", "->", "add", "(", "$", "interval", ")", ":", "$", "base", "->", "sub", "(", "$", "interval", ")", ";", "}", "return", "$", "base", ";", "}" ]
Builds the date. @param DateTime $base The base date. @param integer $amount The amount of dates included in a range. @param DateInterval $interval The interval between adjacent dates. @param boolean $byAddition Should build the final date using addition or subtraction? @return DateTime @since 2.0.0 @throws \InvalidArgumentException
[ "Builds", "the", "date", "." ]
732fb60f054fa6aceaef93ff9a12d939d2a4797c
https://github.com/joomla-framework/datetime/blob/732fb60f054fa6aceaef93ff9a12d939d2a4797c/src/DateTimeRange.php#L402-L416
229,659
fuelphp/common
src/Format.php
Format._fromYaml
protected function _fromYaml($data) { if ( ! class_exists('Symfony\Component\Yaml\Yaml')) { // @codeCoverageIgnoreStart throw new \RuntimeException('You need to install the "symfony/yaml" composer package to use Format::fromYaml()'); // @codeCoverageIgnoreEnd } $parser = new \Symfony\Component\Yaml\Yaml(); return $parser::parse($data); }
php
protected function _fromYaml($data) { if ( ! class_exists('Symfony\Component\Yaml\Yaml')) { // @codeCoverageIgnoreStart throw new \RuntimeException('You need to install the "symfony/yaml" composer package to use Format::fromYaml()'); // @codeCoverageIgnoreEnd } $parser = new \Symfony\Component\Yaml\Yaml(); return $parser::parse($data); }
[ "protected", "function", "_fromYaml", "(", "$", "data", ")", "{", "if", "(", "!", "class_exists", "(", "'Symfony\\Component\\Yaml\\Yaml'", ")", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'You need to install the \"symfony/yaml\" composer package to use Format::fromYaml()'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "$", "parser", "=", "new", "\\", "Symfony", "\\", "Component", "\\", "Yaml", "\\", "Yaml", "(", ")", ";", "return", "$", "parser", "::", "parse", "(", "$", "data", ")", ";", "}" ]
Import YAML data @param string $string @return array
[ "Import", "YAML", "data" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Format.php#L444-L455
229,660
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.start
public function start() { if($this->findElement()) { // Find all the objects! while(!$this->arrayEnd) { if(!$this->eatWhitespace()) break; if($this->readObject()){ yield $this->packageJSON(); $this->sanitize(); } } } }
php
public function start() { if($this->findElement()) { // Find all the objects! while(!$this->arrayEnd) { if(!$this->eatWhitespace()) break; if($this->readObject()){ yield $this->packageJSON(); $this->sanitize(); } } } }
[ "public", "function", "start", "(", ")", "{", "if", "(", "$", "this", "->", "findElement", "(", ")", ")", "{", "// Find all the objects!", "while", "(", "!", "$", "this", "->", "arrayEnd", ")", "{", "if", "(", "!", "$", "this", "->", "eatWhitespace", "(", ")", ")", "break", ";", "if", "(", "$", "this", "->", "readObject", "(", ")", ")", "{", "yield", "$", "this", "->", "packageJSON", "(", ")", ";", "$", "this", "->", "sanitize", "(", ")", ";", "}", "}", "}", "}" ]
Find all objects in the file provided. It is the users job to ensure the json is actually valid before starting this function.
[ "Find", "all", "objects", "in", "the", "file", "provided", ".", "It", "is", "the", "users", "job", "to", "ensure", "the", "json", "is", "actually", "valid", "before", "starting", "this", "function", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L67-L80
229,661
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.getStream
private function getStream() { if(!feof($this->loader->getFile())) { $this->stream .= fread($this->loader->getFile(), $this->loader->getBytes()); return true; } return false; }
php
private function getStream() { if(!feof($this->loader->getFile())) { $this->stream .= fread($this->loader->getFile(), $this->loader->getBytes()); return true; } return false; }
[ "private", "function", "getStream", "(", ")", "{", "if", "(", "!", "feof", "(", "$", "this", "->", "loader", "->", "getFile", "(", ")", ")", ")", "{", "$", "this", "->", "stream", ".=", "fread", "(", "$", "this", "->", "loader", "->", "getFile", "(", ")", ",", "$", "this", "->", "loader", "->", "getBytes", "(", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add the proper amount of bytes to the stream if we are all out of data to read return false. @return bool
[ "Add", "the", "proper", "amount", "of", "bytes", "to", "the", "stream", "if", "we", "are", "all", "out", "of", "data", "to", "read", "return", "false", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L88-L97
229,662
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.findElement
private function findElement() { // Keep looping while we look for the set element while($this->getStream()){ $streamLength = mb_strlen($this->stream); // Check to make sure that we do not miss the string because it has been broken in half. if($streamLength > mb_strlen($this->loader->getElement()) && $streamLength > (3 * $this->loader->getBytes())) { $this->stream = substr($this->stream, $this->loader->getBytes()); } $found_element = strpos($this->stream, $this->loader->getElement()); if($found_element !== false) { return $this->trimStream(); } } $this->arrayEnd = true; return false; }
php
private function findElement() { // Keep looping while we look for the set element while($this->getStream()){ $streamLength = mb_strlen($this->stream); // Check to make sure that we do not miss the string because it has been broken in half. if($streamLength > mb_strlen($this->loader->getElement()) && $streamLength > (3 * $this->loader->getBytes())) { $this->stream = substr($this->stream, $this->loader->getBytes()); } $found_element = strpos($this->stream, $this->loader->getElement()); if($found_element !== false) { return $this->trimStream(); } } $this->arrayEnd = true; return false; }
[ "private", "function", "findElement", "(", ")", "{", "// Keep looping while we look for the set element", "while", "(", "$", "this", "->", "getStream", "(", ")", ")", "{", "$", "streamLength", "=", "mb_strlen", "(", "$", "this", "->", "stream", ")", ";", "// Check to make sure that we do not miss the string because it has been broken in half.", "if", "(", "$", "streamLength", ">", "mb_strlen", "(", "$", "this", "->", "loader", "->", "getElement", "(", ")", ")", "&&", "$", "streamLength", ">", "(", "3", "*", "$", "this", "->", "loader", "->", "getBytes", "(", ")", ")", ")", "{", "$", "this", "->", "stream", "=", "substr", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "loader", "->", "getBytes", "(", ")", ")", ";", "}", "$", "found_element", "=", "strpos", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "loader", "->", "getElement", "(", ")", ")", ";", "if", "(", "$", "found_element", "!==", "false", ")", "{", "return", "$", "this", "->", "trimStream", "(", ")", ";", "}", "}", "$", "this", "->", "arrayEnd", "=", "true", ";", "return", "false", ";", "}" ]
Return bool if we have found the element set by the user or not. @return bool
[ "Return", "bool", "if", "we", "have", "found", "the", "element", "set", "by", "the", "user", "or", "not", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L105-L125
229,663
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.trimStream
private function trimStream() { // Get the current position after we have found the element. $position = strpos($this->stream, $this->loader->getElement()) + 1; while($this->getStream()) { $streamLength = mb_strlen($this->stream); for($i = $position; $i < $streamLength; $i++) { if(!ctype_space($this->stream{$i}) && $this->stream{$i} == '[' ) { // The stream will now read in the entire object $this->stream = substr($this->stream, ++$i); // Edge case where array was last char in string if($this->stream === false) $this->stream = ""; // We are done here. return true; } } } $this->arrayEnd = true; return false; }
php
private function trimStream() { // Get the current position after we have found the element. $position = strpos($this->stream, $this->loader->getElement()) + 1; while($this->getStream()) { $streamLength = mb_strlen($this->stream); for($i = $position; $i < $streamLength; $i++) { if(!ctype_space($this->stream{$i}) && $this->stream{$i} == '[' ) { // The stream will now read in the entire object $this->stream = substr($this->stream, ++$i); // Edge case where array was last char in string if($this->stream === false) $this->stream = ""; // We are done here. return true; } } } $this->arrayEnd = true; return false; }
[ "private", "function", "trimStream", "(", ")", "{", "// Get the current position after we have found the element.", "$", "position", "=", "strpos", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "loader", "->", "getElement", "(", ")", ")", "+", "1", ";", "while", "(", "$", "this", "->", "getStream", "(", ")", ")", "{", "$", "streamLength", "=", "mb_strlen", "(", "$", "this", "->", "stream", ")", ";", "for", "(", "$", "i", "=", "$", "position", ";", "$", "i", "<", "$", "streamLength", ";", "$", "i", "++", ")", "{", "if", "(", "!", "ctype_space", "(", "$", "this", "->", "stream", "{", "$", "i", "}", ")", "&&", "$", "this", "->", "stream", "{", "$", "i", "}", "==", "'['", ")", "{", "// The stream will now read in the entire object", "$", "this", "->", "stream", "=", "substr", "(", "$", "this", "->", "stream", ",", "++", "$", "i", ")", ";", "// Edge case where array was last char in string", "if", "(", "$", "this", "->", "stream", "===", "false", ")", "$", "this", "->", "stream", "=", "\"\"", ";", "// We are done here.", "return", "true", ";", "}", "}", "}", "$", "this", "->", "arrayEnd", "=", "true", ";", "return", "false", ";", "}" ]
Trim the current stream so that everything that is before the current object has been removed.
[ "Trim", "the", "current", "stream", "so", "that", "everything", "that", "is", "before", "the", "current", "object", "has", "been", "removed", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L131-L155
229,664
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.eatWhitespace
private function eatWhitespace() { // Eat up array until next object is found. while($this->getStream() && !$this->arrayEnd) { for($i = 0; $i < strlen($this->stream); $i++) { if($this->stream{$i} == "{") { // Remove the old part of the object $this->stream = substr($this->stream, $i); $this->openingBrackets = 0; $this->closingBrackets = 0; return true; } else if ($this->stream{$i} == "]") { $this->arrayEnd = true; return false; } } } $this->arrayEnd = true; return false; }
php
private function eatWhitespace() { // Eat up array until next object is found. while($this->getStream() && !$this->arrayEnd) { for($i = 0; $i < strlen($this->stream); $i++) { if($this->stream{$i} == "{") { // Remove the old part of the object $this->stream = substr($this->stream, $i); $this->openingBrackets = 0; $this->closingBrackets = 0; return true; } else if ($this->stream{$i} == "]") { $this->arrayEnd = true; return false; } } } $this->arrayEnd = true; return false; }
[ "private", "function", "eatWhitespace", "(", ")", "{", "// Eat up array until next object is found.", "while", "(", "$", "this", "->", "getStream", "(", ")", "&&", "!", "$", "this", "->", "arrayEnd", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "this", "->", "stream", ")", ";", "$", "i", "++", ")", "{", "if", "(", "$", "this", "->", "stream", "{", "$", "i", "}", "==", "\"{\"", ")", "{", "// Remove the old part of the object", "$", "this", "->", "stream", "=", "substr", "(", "$", "this", "->", "stream", ",", "$", "i", ")", ";", "$", "this", "->", "openingBrackets", "=", "0", ";", "$", "this", "->", "closingBrackets", "=", "0", ";", "return", "true", ";", "}", "else", "if", "(", "$", "this", "->", "stream", "{", "$", "i", "}", "==", "\"]\"", ")", "{", "$", "this", "->", "arrayEnd", "=", "true", ";", "return", "false", ";", "}", "}", "}", "$", "this", "->", "arrayEnd", "=", "true", ";", "return", "false", ";", "}" ]
This will eat all whitespace before the start of an object and set everything to the proper state. This also will eat up any , that occurs between two objects.
[ "This", "will", "eat", "all", "whitespace", "before", "the", "start", "of", "an", "object", "and", "set", "everything", "to", "the", "proper", "state", ".", "This", "also", "will", "eat", "up", "any", "that", "occurs", "between", "two", "objects", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L162-L182
229,665
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.readObject
private function readObject() { $inString = false; while ($this->getStream() || !$this->arrayEnd) { for(; $this->cursor < strlen($this->stream); $this->cursor++) { $this->jumpCursor(); switch($this->stream{$this->cursor}) { case '"': $inString = !$inString; break; case "{": if($inString) break; $this->openingBrackets++; break; case "}": if($inString) break; $this->closingBrackets++; break; } // If condition is met return data back to user for manipulation. if($this->openingBrackets == $this->closingBrackets && $this->openingBrackets != 0) { return true; } } } return false; }
php
private function readObject() { $inString = false; while ($this->getStream() || !$this->arrayEnd) { for(; $this->cursor < strlen($this->stream); $this->cursor++) { $this->jumpCursor(); switch($this->stream{$this->cursor}) { case '"': $inString = !$inString; break; case "{": if($inString) break; $this->openingBrackets++; break; case "}": if($inString) break; $this->closingBrackets++; break; } // If condition is met return data back to user for manipulation. if($this->openingBrackets == $this->closingBrackets && $this->openingBrackets != 0) { return true; } } } return false; }
[ "private", "function", "readObject", "(", ")", "{", "$", "inString", "=", "false", ";", "while", "(", "$", "this", "->", "getStream", "(", ")", "||", "!", "$", "this", "->", "arrayEnd", ")", "{", "for", "(", ";", "$", "this", "->", "cursor", "<", "strlen", "(", "$", "this", "->", "stream", ")", ";", "$", "this", "->", "cursor", "++", ")", "{", "$", "this", "->", "jumpCursor", "(", ")", ";", "switch", "(", "$", "this", "->", "stream", "{", "$", "this", "->", "cursor", "}", ")", "{", "case", "'\"'", ":", "$", "inString", "=", "!", "$", "inString", ";", "break", ";", "case", "\"{\"", ":", "if", "(", "$", "inString", ")", "break", ";", "$", "this", "->", "openingBrackets", "++", ";", "break", ";", "case", "\"}\"", ":", "if", "(", "$", "inString", ")", "break", ";", "$", "this", "->", "closingBrackets", "++", ";", "break", ";", "}", "// If condition is met return data back to user for manipulation.", "if", "(", "$", "this", "->", "openingBrackets", "==", "$", "this", "->", "closingBrackets", "&&", "$", "this", "->", "openingBrackets", "!=", "0", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Find the next full object and when it's ready return true. @return bool
[ "Find", "the", "next", "full", "object", "and", "when", "it", "s", "ready", "return", "true", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L190-L222
229,666
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.jumpCursor
private function jumpCursor() { // Ensure we actually have something to check in the stream before and after possible jump. if(!isset($this->stream{$this->cursor}) || !isset($this->stream{$this->cursor + 2})) $this->getStream(); if($this->stream{$this->cursor} == "\\") { $this->cursor += 2; $this->jumpCursor(); } }
php
private function jumpCursor() { // Ensure we actually have something to check in the stream before and after possible jump. if(!isset($this->stream{$this->cursor}) || !isset($this->stream{$this->cursor + 2})) $this->getStream(); if($this->stream{$this->cursor} == "\\") { $this->cursor += 2; $this->jumpCursor(); } }
[ "private", "function", "jumpCursor", "(", ")", "{", "// Ensure we actually have something to check in the stream before and after possible jump.", "if", "(", "!", "isset", "(", "$", "this", "->", "stream", "{", "$", "this", "->", "cursor", "}", ")", "||", "!", "isset", "(", "$", "this", "->", "stream", "{", "$", "this", "->", "cursor", "+", "2", "}", ")", ")", "$", "this", "->", "getStream", "(", ")", ";", "if", "(", "$", "this", "->", "stream", "{", "$", "this", "->", "cursor", "}", "==", "\"\\\\\"", ")", "{", "$", "this", "->", "cursor", "+=", "2", ";", "$", "this", "->", "jumpCursor", "(", ")", ";", "}", "}" ]
Keep jumping over the cursor while the current cursor is pointing to \ if not return.
[ "Keep", "jumping", "over", "the", "cursor", "while", "the", "current", "cursor", "is", "pointing", "to", "\\", "if", "not", "return", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L228-L237
229,667
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.packageJSON
private function packageJSON() { return new JsonObject( trim(substr($this->stream, 0, ++$this->cursor)), ++$this->object_num ); }
php
private function packageJSON() { return new JsonObject( trim(substr($this->stream, 0, ++$this->cursor)), ++$this->object_num ); }
[ "private", "function", "packageJSON", "(", ")", "{", "return", "new", "JsonObject", "(", "trim", "(", "substr", "(", "$", "this", "->", "stream", ",", "0", ",", "++", "$", "this", "->", "cursor", ")", ")", ",", "++", "$", "this", "->", "object_num", ")", ";", "}" ]
Package up the data and return it to the user. Allows for us to easily add more properties to this object at a later time without messing up code. @return JsonObject
[ "Package", "up", "the", "data", "and", "return", "it", "to", "the", "user", ".", "Allows", "for", "us", "to", "easily", "add", "more", "properties", "to", "this", "object", "at", "a", "later", "time", "without", "messing", "up", "code", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L246-L251
229,668
michaeljs1990/jmem
src/Jmem/Parser/Parser.php
Parser.sanitize
private function sanitize() { $this->stream = substr($this->stream, $this->cursor); // At end of string create a new one if($this->stream === false) $this->stream = ""; // Set brackets back to defaults. $this->openingBrackets = $this->closingBrackets = 0; // reset cursor. Moving it to where we left off // Before we cut down the string size. $this->cursor = 0; }
php
private function sanitize() { $this->stream = substr($this->stream, $this->cursor); // At end of string create a new one if($this->stream === false) $this->stream = ""; // Set brackets back to defaults. $this->openingBrackets = $this->closingBrackets = 0; // reset cursor. Moving it to where we left off // Before we cut down the string size. $this->cursor = 0; }
[ "private", "function", "sanitize", "(", ")", "{", "$", "this", "->", "stream", "=", "substr", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "cursor", ")", ";", "// At end of string create a new one", "if", "(", "$", "this", "->", "stream", "===", "false", ")", "$", "this", "->", "stream", "=", "\"\"", ";", "// Set brackets back to defaults.", "$", "this", "->", "openingBrackets", "=", "$", "this", "->", "closingBrackets", "=", "0", ";", "// reset cursor. Moving it to where we left off", "// Before we cut down the string size.", "$", "this", "->", "cursor", "=", "0", ";", "}" ]
Place the object back into a sane state. Needed for cleanup after we have delivered the object to the user.
[ "Place", "the", "object", "back", "into", "a", "sane", "state", ".", "Needed", "for", "cleanup", "after", "we", "have", "delivered", "the", "object", "to", "the", "user", "." ]
3252fa2cccc90e564cf7295abf8625e07b52f908
https://github.com/michaeljs1990/jmem/blob/3252fa2cccc90e564cf7295abf8625e07b52f908/src/Jmem/Parser/Parser.php#L258-L270
229,669
milesj/utility
View/Helper/OpenGraphHelper.php
OpenGraphHelper.html
public function html(array $options = array(), array $ns = array()) { if ($ns) { foreach ($ns as $key => $url) { $this->ns($key, $url); } } return $this->Html->tag('html', null, $this->_namespaces + $options); }
php
public function html(array $options = array(), array $ns = array()) { if ($ns) { foreach ($ns as $key => $url) { $this->ns($key, $url); } } return $this->Html->tag('html', null, $this->_namespaces + $options); }
[ "public", "function", "html", "(", "array", "$", "options", "=", "array", "(", ")", ",", "array", "$", "ns", "=", "array", "(", ")", ")", "{", "if", "(", "$", "ns", ")", "{", "foreach", "(", "$", "ns", "as", "$", "key", "=>", "$", "url", ")", "{", "$", "this", "->", "ns", "(", "$", "key", ",", "$", "url", ")", ";", "}", "}", "return", "$", "this", "->", "Html", "->", "tag", "(", "'html'", ",", "null", ",", "$", "this", "->", "_namespaces", "+", "$", "options", ")", ";", "}" ]
Render an HTML tag with OG namespaces. @param array $options @param array $ns @return string
[ "Render", "an", "HTML", "tag", "with", "OG", "namespaces", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/View/Helper/OpenGraphHelper.php#L58-L66
229,670
milesj/utility
View/Helper/OpenGraphHelper.php
OpenGraphHelper.tag
public function tag($tag, $value, array $options = array()) { if ($options) { $this->_tags[$tag][] = array('value' => $value) + $options; } else { $this->_tags[$tag] = $value; } return $this; }
php
public function tag($tag, $value, array $options = array()) { if ($options) { $this->_tags[$tag][] = array('value' => $value) + $options; } else { $this->_tags[$tag] = $value; } return $this; }
[ "public", "function", "tag", "(", "$", "tag", ",", "$", "value", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "options", ")", "{", "$", "this", "->", "_tags", "[", "$", "tag", "]", "[", "]", "=", "array", "(", "'value'", "=>", "$", "value", ")", "+", "$", "options", ";", "}", "else", "{", "$", "this", "->", "_tags", "[", "$", "tag", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Output a tag. @param string $tag @param string $value @param array $options @return OpenGraphHelper
[ "Output", "a", "tag", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/View/Helper/OpenGraphHelper.php#L227-L235
229,671
milesj/utility
View/Helper/OpenGraphHelper.php
OpenGraphHelper.ns
public function ns($key, $url) { if (strpos($key, 'xmlns') !== 0) { $key = 'xmlns:' . $key; } $this->_namespaces[$key] = $url; return $this; }
php
public function ns($key, $url) { if (strpos($key, 'xmlns') !== 0) { $key = 'xmlns:' . $key; } $this->_namespaces[$key] = $url; return $this; }
[ "public", "function", "ns", "(", "$", "key", ",", "$", "url", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'xmlns'", ")", "!==", "0", ")", "{", "$", "key", "=", "'xmlns:'", ".", "$", "key", ";", "}", "$", "this", "->", "_namespaces", "[", "$", "key", "]", "=", "$", "url", ";", "return", "$", "this", ";", "}" ]
Add a namespace. @param string $key @param string $url @return OpenGraphHelper
[ "Add", "a", "namespace", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/View/Helper/OpenGraphHelper.php#L244-L252
229,672
milesj/utility
View/Helper/OpenGraphHelper.php
OpenGraphHelper.fetch
public function fetch() { if ($this->_tags) { foreach ($this->_tags as $tag => $values) { $options = array('block' => 'openGraph', 'inline' => false); if (is_array($values)) { foreach ($values as $value) { if (isset($value['value'])) { $options['property'] = $tag; $options['content'] = $value['value']; $this->Html->meta(null, null, $options); unset($value['value']); } foreach ($value as $key => $val) { $options['property'] = $tag . ':' . $key; if (is_array($val)) { foreach ($val as $v) { $options['content'] = $v; $this->Html->meta(null, null, $options); } } else { $options['content'] = $val; $this->Html->meta(null, null, $options); } } } } else { $options['property'] = $tag; $options['content'] = $values; $this->Html->meta(null, null, $options); } } } return $this->_View->fetch('openGraph'); }
php
public function fetch() { if ($this->_tags) { foreach ($this->_tags as $tag => $values) { $options = array('block' => 'openGraph', 'inline' => false); if (is_array($values)) { foreach ($values as $value) { if (isset($value['value'])) { $options['property'] = $tag; $options['content'] = $value['value']; $this->Html->meta(null, null, $options); unset($value['value']); } foreach ($value as $key => $val) { $options['property'] = $tag . ':' . $key; if (is_array($val)) { foreach ($val as $v) { $options['content'] = $v; $this->Html->meta(null, null, $options); } } else { $options['content'] = $val; $this->Html->meta(null, null, $options); } } } } else { $options['property'] = $tag; $options['content'] = $values; $this->Html->meta(null, null, $options); } } } return $this->_View->fetch('openGraph'); }
[ "public", "function", "fetch", "(", ")", "{", "if", "(", "$", "this", "->", "_tags", ")", "{", "foreach", "(", "$", "this", "->", "_tags", "as", "$", "tag", "=>", "$", "values", ")", "{", "$", "options", "=", "array", "(", "'block'", "=>", "'openGraph'", ",", "'inline'", "=>", "false", ")", ";", "if", "(", "is_array", "(", "$", "values", ")", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'value'", "]", ")", ")", "{", "$", "options", "[", "'property'", "]", "=", "$", "tag", ";", "$", "options", "[", "'content'", "]", "=", "$", "value", "[", "'value'", "]", ";", "$", "this", "->", "Html", "->", "meta", "(", "null", ",", "null", ",", "$", "options", ")", ";", "unset", "(", "$", "value", "[", "'value'", "]", ")", ";", "}", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "options", "[", "'property'", "]", "=", "$", "tag", ".", "':'", ".", "$", "key", ";", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "foreach", "(", "$", "val", "as", "$", "v", ")", "{", "$", "options", "[", "'content'", "]", "=", "$", "v", ";", "$", "this", "->", "Html", "->", "meta", "(", "null", ",", "null", ",", "$", "options", ")", ";", "}", "}", "else", "{", "$", "options", "[", "'content'", "]", "=", "$", "val", ";", "$", "this", "->", "Html", "->", "meta", "(", "null", ",", "null", ",", "$", "options", ")", ";", "}", "}", "}", "}", "else", "{", "$", "options", "[", "'property'", "]", "=", "$", "tag", ";", "$", "options", "[", "'content'", "]", "=", "$", "values", ";", "$", "this", "->", "Html", "->", "meta", "(", "null", ",", "null", ",", "$", "options", ")", ";", "}", "}", "}", "return", "$", "this", "->", "_View", "->", "fetch", "(", "'openGraph'", ")", ";", "}" ]
Append the meta tags to the openGraph block. @return string
[ "Append", "the", "meta", "tags", "to", "the", "openGraph", "block", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/View/Helper/OpenGraphHelper.php#L259-L301
229,673
fuelphp/common
src/Debug.php
Debug.setNestingLevel
public function setNestingLevel($level = null) { if (func_num_args() and is_numeric($level) and $level > 0) { $this->maxNestingLevel = $level; } return $this->maxNestingLevel; }
php
public function setNestingLevel($level = null) { if (func_num_args() and is_numeric($level) and $level > 0) { $this->maxNestingLevel = $level; } return $this->maxNestingLevel; }
[ "public", "function", "setNestingLevel", "(", "$", "level", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "and", "is_numeric", "(", "$", "level", ")", "and", "$", "level", ">", "0", ")", "{", "$", "this", "->", "maxNestingLevel", "=", "$", "level", ";", "}", "return", "$", "this", "->", "maxNestingLevel", ";", "}" ]
Setter for maxNestingLevel @param int Maximum nesting level for dump output @return int The current nesting level
[ "Setter", "for", "maxNestingLevel" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Debug.php#L67-L75
229,674
fuelphp/common
src/Debug.php
Debug.setOpenToggle
public function setOpenToggle($toggle = null) { if (func_num_args() and is_bool($toggle)) { $this->jsOpenToggle = $toggle; } return $this->jsOpenToggle; }
php
public function setOpenToggle($toggle = null) { if (func_num_args() and is_bool($toggle)) { $this->jsOpenToggle = $toggle; } return $this->jsOpenToggle; }
[ "public", "function", "setOpenToggle", "(", "$", "toggle", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "and", "is_bool", "(", "$", "toggle", ")", ")", "{", "$", "this", "->", "jsOpenToggle", "=", "$", "toggle", ";", "}", "return", "$", "this", "->", "jsOpenToggle", ";", "}" ]
Setter for jsToggleOpen @param bool true for Open by default, false for closed @return bool The current toggle state
[ "Setter", "for", "jsToggleOpen" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Debug.php#L84-L92
229,675
bobthecow/BobthecowMustacheBundle
DependencyInjection/BobthecowMustacheExtension.php
BobthecowMustacheExtension.load
public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('mustache.xml'); foreach ($configs as &$config) { if (isset($config['globals'])) { foreach ($config['globals'] as $name => $value) { if (is_array($value) && isset($value['key'])) { $config['globals'][$name] = array( 'key' => $name, 'value' => $config['globals'][$name], ); } } } } $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $def = $container->getDefinition('mustache'); if (isset($config['loader_id'])) { $loader = new Reference($config['loader_id']); } else { $loader = new Reference('mustache.loader'); } $def->addMethodCall('setLoader', array($loader)); if (isset($config['partials_loader_id'])) { $partialsLoader = new Reference($config['partials_loader_id']); } else { $partialsLoader = $loader; } $def->addMethodCall('setPartialsLoader', array($partialsLoader)); if (!empty($config['globals'])) { $def = $container->getDefinition('mustache'); foreach ($config['globals'] as $key => $global) { if (isset($global['type']) && 'service' === $global['type']) { $def->addMethodCall('addHelper', array($key, new Reference($global['id']))); } else { $def->addMethodCall('addHelper', array($key, $global['value'])); } } } unset($config['globals'], $config['loader_id'], $config['partials_loader_id']); $container->setParameter('mustache.options', $config); $this->addClassesToCompile(array( 'Mustache_Context', 'Mustache_HelperCollection', 'Mustache_Loader', 'Mustache_Loader_FilesystemLoader', 'Mustache_Engine', 'Mustache_Template', )); }
php
public function load(array $configs, ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('mustache.xml'); foreach ($configs as &$config) { if (isset($config['globals'])) { foreach ($config['globals'] as $name => $value) { if (is_array($value) && isset($value['key'])) { $config['globals'][$name] = array( 'key' => $name, 'value' => $config['globals'][$name], ); } } } } $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $def = $container->getDefinition('mustache'); if (isset($config['loader_id'])) { $loader = new Reference($config['loader_id']); } else { $loader = new Reference('mustache.loader'); } $def->addMethodCall('setLoader', array($loader)); if (isset($config['partials_loader_id'])) { $partialsLoader = new Reference($config['partials_loader_id']); } else { $partialsLoader = $loader; } $def->addMethodCall('setPartialsLoader', array($partialsLoader)); if (!empty($config['globals'])) { $def = $container->getDefinition('mustache'); foreach ($config['globals'] as $key => $global) { if (isset($global['type']) && 'service' === $global['type']) { $def->addMethodCall('addHelper', array($key, new Reference($global['id']))); } else { $def->addMethodCall('addHelper', array($key, $global['value'])); } } } unset($config['globals'], $config['loader_id'], $config['partials_loader_id']); $container->setParameter('mustache.options', $config); $this->addClassesToCompile(array( 'Mustache_Context', 'Mustache_HelperCollection', 'Mustache_Loader', 'Mustache_Loader_FilesystemLoader', 'Mustache_Engine', 'Mustache_Template', )); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'mustache.xml'", ")", ";", "foreach", "(", "$", "configs", "as", "&", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'globals'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'globals'", "]", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "isset", "(", "$", "value", "[", "'key'", "]", ")", ")", "{", "$", "config", "[", "'globals'", "]", "[", "$", "name", "]", "=", "array", "(", "'key'", "=>", "$", "name", ",", "'value'", "=>", "$", "config", "[", "'globals'", "]", "[", "$", "name", "]", ",", ")", ";", "}", "}", "}", "}", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "configs", ",", "$", "container", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "def", "=", "$", "container", "->", "getDefinition", "(", "'mustache'", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'loader_id'", "]", ")", ")", "{", "$", "loader", "=", "new", "Reference", "(", "$", "config", "[", "'loader_id'", "]", ")", ";", "}", "else", "{", "$", "loader", "=", "new", "Reference", "(", "'mustache.loader'", ")", ";", "}", "$", "def", "->", "addMethodCall", "(", "'setLoader'", ",", "array", "(", "$", "loader", ")", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'partials_loader_id'", "]", ")", ")", "{", "$", "partialsLoader", "=", "new", "Reference", "(", "$", "config", "[", "'partials_loader_id'", "]", ")", ";", "}", "else", "{", "$", "partialsLoader", "=", "$", "loader", ";", "}", "$", "def", "->", "addMethodCall", "(", "'setPartialsLoader'", ",", "array", "(", "$", "partialsLoader", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'globals'", "]", ")", ")", "{", "$", "def", "=", "$", "container", "->", "getDefinition", "(", "'mustache'", ")", ";", "foreach", "(", "$", "config", "[", "'globals'", "]", "as", "$", "key", "=>", "$", "global", ")", "{", "if", "(", "isset", "(", "$", "global", "[", "'type'", "]", ")", "&&", "'service'", "===", "$", "global", "[", "'type'", "]", ")", "{", "$", "def", "->", "addMethodCall", "(", "'addHelper'", ",", "array", "(", "$", "key", ",", "new", "Reference", "(", "$", "global", "[", "'id'", "]", ")", ")", ")", ";", "}", "else", "{", "$", "def", "->", "addMethodCall", "(", "'addHelper'", ",", "array", "(", "$", "key", ",", "$", "global", "[", "'value'", "]", ")", ")", ";", "}", "}", "}", "unset", "(", "$", "config", "[", "'globals'", "]", ",", "$", "config", "[", "'loader_id'", "]", ",", "$", "config", "[", "'partials_loader_id'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'mustache.options'", ",", "$", "config", ")", ";", "$", "this", "->", "addClassesToCompile", "(", "array", "(", "'Mustache_Context'", ",", "'Mustache_HelperCollection'", ",", "'Mustache_Loader'", ",", "'Mustache_Loader_FilesystemLoader'", ",", "'Mustache_Engine'", ",", "'Mustache_Template'", ",", ")", ")", ";", "}" ]
Responds to the mustache configuration parameter. @param array $configs @param ContainerBuilder $container
[ "Responds", "to", "the", "mustache", "configuration", "parameter", "." ]
d90265318f52bb3c003df49c7e7b8b0eed24e754
https://github.com/bobthecow/BobthecowMustacheBundle/blob/d90265318f52bb3c003df49c7e7b8b0eed24e754/DependencyInjection/BobthecowMustacheExtension.php#L31-L89
229,676
Codegyre/RoboCI
src/Command/Travis/Prepare.php
Prepare.ciTravisPrepare
public function ciTravisPrepare() { $config = new TravisConfig(); foreach ($config['php'] as $php) { $generator = new EnvGenerator($config, $php); $generator->createDockerFile(); $generator->createStartScript(); $generator->createRunScript(); $generator->createEnvConfig(); } $this->say("Make sure it is available when executing travis:run"); }
php
public function ciTravisPrepare() { $config = new TravisConfig(); foreach ($config['php'] as $php) { $generator = new EnvGenerator($config, $php); $generator->createDockerFile(); $generator->createStartScript(); $generator->createRunScript(); $generator->createEnvConfig(); } $this->say("Make sure it is available when executing travis:run"); }
[ "public", "function", "ciTravisPrepare", "(", ")", "{", "$", "config", "=", "new", "TravisConfig", "(", ")", ";", "foreach", "(", "$", "config", "[", "'php'", "]", "as", "$", "php", ")", "{", "$", "generator", "=", "new", "EnvGenerator", "(", "$", "config", ",", "$", "php", ")", ";", "$", "generator", "->", "createDockerFile", "(", ")", ";", "$", "generator", "->", "createStartScript", "(", ")", ";", "$", "generator", "->", "createRunScript", "(", ")", ";", "$", "generator", "->", "createEnvConfig", "(", ")", ";", "}", "$", "this", "->", "say", "(", "\"Make sure it is available when executing travis:run\"", ")", ";", "}" ]
Generates .roboci environments from Travis CI
[ "Generates", ".", "roboci", "environments", "from", "Travis", "CI" ]
886f340d7d8ca808607da9a41d2e6ba18075bdf1
https://github.com/Codegyre/RoboCI/blob/886f340d7d8ca808607da9a41d2e6ba18075bdf1/src/Command/Travis/Prepare.php#L25-L37
229,677
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.cleanup
public function cleanup(Model $model) { if ($model->id) { $this->resetCache($model, $model->id); } foreach ($this->_cached as $key => $value) { $this->deleteCache($model, $key); } }
php
public function cleanup(Model $model) { if ($model->id) { $this->resetCache($model, $model->id); } foreach ($this->_cached as $key => $value) { $this->deleteCache($model, $key); } }
[ "public", "function", "cleanup", "(", "Model", "$", "model", ")", "{", "if", "(", "$", "model", "->", "id", ")", "{", "$", "this", "->", "resetCache", "(", "$", "model", ",", "$", "model", "->", "id", ")", ";", "}", "foreach", "(", "$", "this", "->", "_cached", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "$", "key", ")", ";", "}", "}" ]
When this behavior is unloaded, delete all associated cache. @param Model $model
[ "When", "this", "behavior", "is", "unloaded", "delete", "all", "associated", "cache", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L148-L156
229,678
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.afterSave
public function afterSave(Model $model, $created, $options = array()) { $id = $model->id; $settings = $this->settings[$model->alias]; $events = $settings['events']; // Use slug if that's the primary if ($model->primaryKey === 'slug') { $method = $settings['methodKeys']['getBySlug']; } else { $method = $settings['methodKeys']['getById']; } // Refresh the cache during update/create if ($id && $method && (($created && $events['onCreate']) || (!$created && $events['onUpdate']))) { $cacheKey = array($model->alias . '::' . $method, $id); if (method_exists($model, $method)) { $this->deleteCache($model, $cacheKey); call_user_func(array($model, $method), $id); } else { $this->writeCache($model, $cacheKey, array($model->read(null, $id))); } } if ($getList = $settings['methodKeys']['getList']) { $this->deleteCache($model, array($model->alias . '::' . $getList)); } if ($getCount = $settings['methodKeys']['getCount']) { $this->deleteCache($model, array($model->alias . '::' . $getCount)); } return true; }
php
public function afterSave(Model $model, $created, $options = array()) { $id = $model->id; $settings = $this->settings[$model->alias]; $events = $settings['events']; // Use slug if that's the primary if ($model->primaryKey === 'slug') { $method = $settings['methodKeys']['getBySlug']; } else { $method = $settings['methodKeys']['getById']; } // Refresh the cache during update/create if ($id && $method && (($created && $events['onCreate']) || (!$created && $events['onUpdate']))) { $cacheKey = array($model->alias . '::' . $method, $id); if (method_exists($model, $method)) { $this->deleteCache($model, $cacheKey); call_user_func(array($model, $method), $id); } else { $this->writeCache($model, $cacheKey, array($model->read(null, $id))); } } if ($getList = $settings['methodKeys']['getList']) { $this->deleteCache($model, array($model->alias . '::' . $getList)); } if ($getCount = $settings['methodKeys']['getCount']) { $this->deleteCache($model, array($model->alias . '::' . $getCount)); } return true; }
[ "public", "function", "afterSave", "(", "Model", "$", "model", ",", "$", "created", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "id", "=", "$", "model", "->", "id", ";", "$", "settings", "=", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", ";", "$", "events", "=", "$", "settings", "[", "'events'", "]", ";", "// Use slug if that's the primary", "if", "(", "$", "model", "->", "primaryKey", "===", "'slug'", ")", "{", "$", "method", "=", "$", "settings", "[", "'methodKeys'", "]", "[", "'getBySlug'", "]", ";", "}", "else", "{", "$", "method", "=", "$", "settings", "[", "'methodKeys'", "]", "[", "'getById'", "]", ";", "}", "// Refresh the cache during update/create", "if", "(", "$", "id", "&&", "$", "method", "&&", "(", "(", "$", "created", "&&", "$", "events", "[", "'onCreate'", "]", ")", "||", "(", "!", "$", "created", "&&", "$", "events", "[", "'onUpdate'", "]", ")", ")", ")", "{", "$", "cacheKey", "=", "array", "(", "$", "model", "->", "alias", ".", "'::'", ".", "$", "method", ",", "$", "id", ")", ";", "if", "(", "method_exists", "(", "$", "model", ",", "$", "method", ")", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "$", "cacheKey", ")", ";", "call_user_func", "(", "array", "(", "$", "model", ",", "$", "method", ")", ",", "$", "id", ")", ";", "}", "else", "{", "$", "this", "->", "writeCache", "(", "$", "model", ",", "$", "cacheKey", ",", "array", "(", "$", "model", "->", "read", "(", "null", ",", "$", "id", ")", ")", ")", ";", "}", "}", "if", "(", "$", "getList", "=", "$", "settings", "[", "'methodKeys'", "]", "[", "'getList'", "]", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "array", "(", "$", "model", "->", "alias", ".", "'::'", ".", "$", "getList", ")", ")", ";", "}", "if", "(", "$", "getCount", "=", "$", "settings", "[", "'methodKeys'", "]", "[", "'getCount'", "]", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "array", "(", "$", "model", "->", "alias", ".", "'::'", ".", "$", "getCount", ")", ")", ";", "}", "return", "true", ";", "}" ]
Once a record has been updated or created, cache the results if the specific events allow it. @param Model $model @param bool $created @param array $options @return bool
[ "Once", "a", "record", "has", "been", "updated", "or", "created", "cache", "the", "results", "if", "the", "specific", "events", "allow", "it", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L281-L315
229,679
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.afterDelete
public function afterDelete(Model $model) { if ($this->settings[$model->alias]['events']['onDelete']) { $this->resetCache($model, $model->id); } return true; }
php
public function afterDelete(Model $model) { if ($this->settings[$model->alias]['events']['onDelete']) { $this->resetCache($model, $model->id); } return true; }
[ "public", "function", "afterDelete", "(", "Model", "$", "model", ")", "{", "if", "(", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "[", "'events'", "]", "[", "'onDelete'", "]", ")", "{", "$", "this", "->", "resetCache", "(", "$", "model", ",", "$", "model", "->", "id", ")", ";", "}", "return", "true", ";", "}" ]
Once a record has been deleted, remove the cached result. @param Model $model @return bool
[ "Once", "a", "record", "has", "been", "deleted", "remove", "the", "cached", "result", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L323-L329
229,680
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getAll
public function getAll(Model $model) { return $model->find('all', array( 'order' => array($model->alias . '.' . $model->displayField => 'ASC'), 'cache' => $model->alias . '::getAll', 'cacheExpires' => $this->getExpiration($model) )); }
php
public function getAll(Model $model) { return $model->find('all', array( 'order' => array($model->alias . '.' . $model->displayField => 'ASC'), 'cache' => $model->alias . '::getAll', 'cacheExpires' => $this->getExpiration($model) )); }
[ "public", "function", "getAll", "(", "Model", "$", "model", ")", "{", "return", "$", "model", "->", "find", "(", "'all'", ",", "array", "(", "'order'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'.'", ".", "$", "model", "->", "displayField", "=>", "'ASC'", ")", ",", "'cache'", "=>", "$", "model", "->", "alias", ".", "'::getAll'", ",", "'cacheExpires'", "=>", "$", "this", "->", "getExpiration", "(", "$", "model", ")", ")", ")", ";", "}" ]
Convenience model method for returning all records. @param Model $model @return array
[ "Convenience", "model", "method", "for", "returning", "all", "records", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L413-L419
229,681
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getList
public function getList(Model $model) { return $model->find('list', array( 'order' => array($model->alias . '.' . $model->displayField => 'ASC'), 'cache' => $model->alias . '::getList', 'cacheExpires' => $this->getExpiration($model) )); }
php
public function getList(Model $model) { return $model->find('list', array( 'order' => array($model->alias . '.' . $model->displayField => 'ASC'), 'cache' => $model->alias . '::getList', 'cacheExpires' => $this->getExpiration($model) )); }
[ "public", "function", "getList", "(", "Model", "$", "model", ")", "{", "return", "$", "model", "->", "find", "(", "'list'", ",", "array", "(", "'order'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'.'", ".", "$", "model", "->", "displayField", "=>", "'ASC'", ")", ",", "'cache'", "=>", "$", "model", "->", "alias", ".", "'::getList'", ",", "'cacheExpires'", "=>", "$", "this", "->", "getExpiration", "(", "$", "model", ")", ")", ")", ";", "}" ]
Convenience model method for returning all records as a list. @param Model $model @return array
[ "Convenience", "model", "method", "for", "returning", "all", "records", "as", "a", "list", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L427-L433
229,682
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getCount
public function getCount(Model $model) { return $model->find('count', array( 'cache' => $model->alias . '::getCount', 'cacheExpires' => $this->getExpiration($model) )); }
php
public function getCount(Model $model) { return $model->find('count', array( 'cache' => $model->alias . '::getCount', 'cacheExpires' => $this->getExpiration($model) )); }
[ "public", "function", "getCount", "(", "Model", "$", "model", ")", "{", "return", "$", "model", "->", "find", "(", "'count'", ",", "array", "(", "'cache'", "=>", "$", "model", "->", "alias", ".", "'::getCount'", ",", "'cacheExpires'", "=>", "$", "this", "->", "getExpiration", "(", "$", "model", ")", ")", ")", ";", "}" ]
Convenience model method for returning a count of all records. @param Model $model @return array
[ "Convenience", "model", "method", "for", "returning", "a", "count", "of", "all", "records", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L441-L446
229,683
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getById
public function getById(Model $model, $id) { return $model->find('first', array( 'conditions' => array($model->alias . '.' . $model->primaryKey => $id), 'contain' => array_keys($model->belongsTo), 'cache' => array($model->alias . '::getById', $id), 'cacheExpires' => $this->getExpiration($model) )); }
php
public function getById(Model $model, $id) { return $model->find('first', array( 'conditions' => array($model->alias . '.' . $model->primaryKey => $id), 'contain' => array_keys($model->belongsTo), 'cache' => array($model->alias . '::getById', $id), 'cacheExpires' => $this->getExpiration($model) )); }
[ "public", "function", "getById", "(", "Model", "$", "model", ",", "$", "id", ")", "{", "return", "$", "model", "->", "find", "(", "'first'", ",", "array", "(", "'conditions'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'.'", ".", "$", "model", "->", "primaryKey", "=>", "$", "id", ")", ",", "'contain'", "=>", "array_keys", "(", "$", "model", "->", "belongsTo", ")", ",", "'cache'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'::getById'", ",", "$", "id", ")", ",", "'cacheExpires'", "=>", "$", "this", "->", "getExpiration", "(", "$", "model", ")", ")", ")", ";", "}" ]
Convenience model method for returning a record by ID. @param Model $model @param int $id @return array
[ "Convenience", "model", "method", "for", "returning", "a", "record", "by", "ID", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L455-L462
229,684
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getBySlug
public function getBySlug(Model $model, $slug) { return $model->find('first', array( 'conditions' => array($model->alias . '.slug' => $slug), 'contain' => array_keys($model->belongsTo), 'cache' => array($model->alias . '::getBySlug', $slug), 'cacheExpires' => $this->getExpiration($model) )); }
php
public function getBySlug(Model $model, $slug) { return $model->find('first', array( 'conditions' => array($model->alias . '.slug' => $slug), 'contain' => array_keys($model->belongsTo), 'cache' => array($model->alias . '::getBySlug', $slug), 'cacheExpires' => $this->getExpiration($model) )); }
[ "public", "function", "getBySlug", "(", "Model", "$", "model", ",", "$", "slug", ")", "{", "return", "$", "model", "->", "find", "(", "'first'", ",", "array", "(", "'conditions'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'.slug'", "=>", "$", "slug", ")", ",", "'contain'", "=>", "array_keys", "(", "$", "model", "->", "belongsTo", ")", ",", "'cache'", "=>", "array", "(", "$", "model", "->", "alias", ".", "'::getBySlug'", ",", "$", "slug", ")", ",", "'cacheExpires'", "=>", "$", "this", "->", "getExpiration", "(", "$", "model", ")", ")", ")", ";", "}" ]
Convenience model method for returning a record by slug. @param Model $model @param string $slug @return array
[ "Convenience", "model", "method", "for", "returning", "a", "record", "by", "slug", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L471-L478
229,685
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.getExpiration
public function getExpiration(Model $model, $expires = null) { if (!$expires) { if ($time = $this->settings[$model->alias]['expires']) { $expires = $time; } else { $expires = '+5 minutes'; } } return $expires; }
php
public function getExpiration(Model $model, $expires = null) { if (!$expires) { if ($time = $this->settings[$model->alias]['expires']) { $expires = $time; } else { $expires = '+5 minutes'; } } return $expires; }
[ "public", "function", "getExpiration", "(", "Model", "$", "model", ",", "$", "expires", "=", "null", ")", "{", "if", "(", "!", "$", "expires", ")", "{", "if", "(", "$", "time", "=", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "[", "'expires'", "]", ")", "{", "$", "expires", "=", "$", "time", ";", "}", "else", "{", "$", "expires", "=", "'+5 minutes'", ";", "}", "}", "return", "$", "expires", ";", "}" ]
Return the expiration time for cache. Either used the passed value, or the settings default. @param Model $model @param mixed $expires @return int|string
[ "Return", "the", "expiration", "time", "for", "cache", ".", "Either", "used", "the", "passed", "value", "or", "the", "settings", "default", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L487-L497
229,686
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.writeCache
public function writeCache(Model $model, $keys, $value, $expires = null) { $key = $this->cacheKey($model, $keys); Cache::set('duration', $this->getExpiration($model, $expires), $this->settings[$model->alias]['cacheConfig']); $this->_cached[$key] = $value; return Cache::write($key, $value, $this->settings[$model->alias]['cacheConfig']); }
php
public function writeCache(Model $model, $keys, $value, $expires = null) { $key = $this->cacheKey($model, $keys); Cache::set('duration', $this->getExpiration($model, $expires), $this->settings[$model->alias]['cacheConfig']); $this->_cached[$key] = $value; return Cache::write($key, $value, $this->settings[$model->alias]['cacheConfig']); }
[ "public", "function", "writeCache", "(", "Model", "$", "model", ",", "$", "keys", ",", "$", "value", ",", "$", "expires", "=", "null", ")", "{", "$", "key", "=", "$", "this", "->", "cacheKey", "(", "$", "model", ",", "$", "keys", ")", ";", "Cache", "::", "set", "(", "'duration'", ",", "$", "this", "->", "getExpiration", "(", "$", "model", ",", "$", "expires", ")", ",", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "[", "'cacheConfig'", "]", ")", ";", "$", "this", "->", "_cached", "[", "$", "key", "]", "=", "$", "value", ";", "return", "Cache", "::", "write", "(", "$", "key", ",", "$", "value", ",", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "[", "'cacheConfig'", "]", ")", ";", "}" ]
Write data to the cache. Be sure to parse the cache key and validate the config and expires. @param Model $model @param array|string $keys @param mixed $value @param int|string $expires @return bool
[ "Write", "data", "to", "the", "cache", ".", "Be", "sure", "to", "parse", "the", "cache", "key", "and", "validate", "the", "config", "and", "expires", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L527-L535
229,687
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.resetCache
public function resetCache(Model $model, $id = null) { $alias = $model->alias; if ($getList = $this->settings[$alias]['methodKeys']['getList']) { $this->deleteCache($model, array($alias . '::' . $getList)); } if ($getCount = $this->settings[$alias]['methodKeys']['getCount']) { $this->deleteCache($model, array($alias . '::' . $getCount)); } if (!$id) { return false; } else if (!is_array($id)) { $id = array('id' => $id); } $resetHooks = $this->settings[$alias]['resetHooks']; if ($resetHooks) { foreach ($resetHooks as $key => $args) { $continue = true; $keys = array($alias . '::' . $key); if (is_array($args)) { foreach ($args as $field) { if (isset($id[$field])) { $keys[] = $id[$field]; } else { $continue = false; break; } } } if ($continue) { $this->deleteCache($model, $keys); } } } return true; }
php
public function resetCache(Model $model, $id = null) { $alias = $model->alias; if ($getList = $this->settings[$alias]['methodKeys']['getList']) { $this->deleteCache($model, array($alias . '::' . $getList)); } if ($getCount = $this->settings[$alias]['methodKeys']['getCount']) { $this->deleteCache($model, array($alias . '::' . $getCount)); } if (!$id) { return false; } else if (!is_array($id)) { $id = array('id' => $id); } $resetHooks = $this->settings[$alias]['resetHooks']; if ($resetHooks) { foreach ($resetHooks as $key => $args) { $continue = true; $keys = array($alias . '::' . $key); if (is_array($args)) { foreach ($args as $field) { if (isset($id[$field])) { $keys[] = $id[$field]; } else { $continue = false; break; } } } if ($continue) { $this->deleteCache($model, $keys); } } } return true; }
[ "public", "function", "resetCache", "(", "Model", "$", "model", ",", "$", "id", "=", "null", ")", "{", "$", "alias", "=", "$", "model", "->", "alias", ";", "if", "(", "$", "getList", "=", "$", "this", "->", "settings", "[", "$", "alias", "]", "[", "'methodKeys'", "]", "[", "'getList'", "]", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "array", "(", "$", "alias", ".", "'::'", ".", "$", "getList", ")", ")", ";", "}", "if", "(", "$", "getCount", "=", "$", "this", "->", "settings", "[", "$", "alias", "]", "[", "'methodKeys'", "]", "[", "'getCount'", "]", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "array", "(", "$", "alias", ".", "'::'", ".", "$", "getCount", ")", ")", ";", "}", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "else", "if", "(", "!", "is_array", "(", "$", "id", ")", ")", "{", "$", "id", "=", "array", "(", "'id'", "=>", "$", "id", ")", ";", "}", "$", "resetHooks", "=", "$", "this", "->", "settings", "[", "$", "alias", "]", "[", "'resetHooks'", "]", ";", "if", "(", "$", "resetHooks", ")", "{", "foreach", "(", "$", "resetHooks", "as", "$", "key", "=>", "$", "args", ")", "{", "$", "continue", "=", "true", ";", "$", "keys", "=", "array", "(", "$", "alias", ".", "'::'", ".", "$", "key", ")", ";", "if", "(", "is_array", "(", "$", "args", ")", ")", "{", "foreach", "(", "$", "args", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "id", "[", "$", "field", "]", ")", ")", "{", "$", "keys", "[", "]", "=", "$", "id", "[", "$", "field", "]", ";", "}", "else", "{", "$", "continue", "=", "false", ";", "break", ";", "}", "}", "}", "if", "(", "$", "continue", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "$", "keys", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Global function to reset specific cache keys within each model. By default, reset the getById and getList method keys. If the ID passed is an array of IDs, run through each hook and reset those caches only if each field exists. @param Model $model @param string|array $id @return bool
[ "Global", "function", "to", "reset", "specific", "cache", "keys", "within", "each", "model", ".", "By", "default", "reset", "the", "getById", "and", "getList", "method", "keys", ".", "If", "the", "ID", "passed", "is", "an", "array", "of", "IDs", "run", "through", "each", "hook", "and", "reset", "those", "caches", "only", "if", "each", "field", "exists", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L560-L603
229,688
milesj/utility
Model/Behavior/CacheableBehavior.php
CacheableBehavior.clearCache
public function clearCache(Model $model) { if ($this->_cached) { foreach ($this->_cached as $key => $value) { $this->deleteCache($model, $key); } } return Cache::clear(false, $this->settings[$model->alias]['cacheConfig']); }
php
public function clearCache(Model $model) { if ($this->_cached) { foreach ($this->_cached as $key => $value) { $this->deleteCache($model, $key); } } return Cache::clear(false, $this->settings[$model->alias]['cacheConfig']); }
[ "public", "function", "clearCache", "(", "Model", "$", "model", ")", "{", "if", "(", "$", "this", "->", "_cached", ")", "{", "foreach", "(", "$", "this", "->", "_cached", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "deleteCache", "(", "$", "model", ",", "$", "key", ")", ";", "}", "}", "return", "Cache", "::", "clear", "(", "false", ",", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "[", "'cacheConfig'", "]", ")", ";", "}" ]
Clear all the currently cached items. @param Model $model @return bool
[ "Clear", "all", "the", "currently", "cached", "items", "." ]
146318ff0a882917defab7f4918b0d198eb5a3c0
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/CacheableBehavior.php#L611-L619
229,689
fuelphp/common
src/DataContainer.php
DataContainer.setParent
public function setParent(DataContainer $parent = null) { $this->parent = $parent; if ($this->parent) { $this->enableParent(); } else { $this->disableParent(); } return $this; }
php
public function setParent(DataContainer $parent = null) { $this->parent = $parent; if ($this->parent) { $this->enableParent(); } else { $this->disableParent(); } return $this; }
[ "public", "function", "setParent", "(", "DataContainer", "$", "parent", "=", "null", ")", "{", "$", "this", "->", "parent", "=", "$", "parent", ";", "if", "(", "$", "this", "->", "parent", ")", "{", "$", "this", "->", "enableParent", "(", ")", ";", "}", "else", "{", "$", "this", "->", "disableParent", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the parent of this container, to support inheritance @param DataContainer $parent the parent container object @return $this @since 2.0.0
[ "Set", "the", "parent", "of", "this", "container", "to", "support", "inheritance" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L83-L97
229,690
fuelphp/common
src/DataContainer.php
DataContainer.setContents
public function setContents(array $data) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->data = $data; $this->isModified = true; return $this; }
php
public function setContents(array $data) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->data = $data; $this->isModified = true; return $this; }
[ "public", "function", "setContents", "(", "array", "$", "data", ")", "{", "if", "(", "$", "this", "->", "readOnly", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Changing values on this Data Container is not allowed.'", ")", ";", "}", "$", "this", "->", "data", "=", "$", "data", ";", "$", "this", "->", "isModified", "=", "true", ";", "return", "$", "this", ";", "}" ]
Replace the container's data. @param array $data new data @return $this @throws RuntimeException @since 2.0.0
[ "Replace", "the", "container", "s", "data", "." ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L158-L170
229,691
fuelphp/common
src/DataContainer.php
DataContainer.getContents
public function getContents() { if ($this->parentEnabled) { return Arr::merge($this->parent->getContents(), $this->data); } else { return $this->data; } }
php
public function getContents() { if ($this->parentEnabled) { return Arr::merge($this->parent->getContents(), $this->data); } else { return $this->data; } }
[ "public", "function", "getContents", "(", ")", "{", "if", "(", "$", "this", "->", "parentEnabled", ")", "{", "return", "Arr", "::", "merge", "(", "$", "this", "->", "parent", "->", "getContents", "(", ")", ",", "$", "this", "->", "data", ")", ";", "}", "else", "{", "return", "$", "this", "->", "data", ";", "}", "}" ]
Get the container's data @return array container's data @since 2.0.0
[ "Get", "the", "container", "s", "data" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L178-L188
229,692
fuelphp/common
src/DataContainer.php
DataContainer.has
public function has($key) { $result = Arr::has($this->data, $key); if ( ! $result and $this->parentEnabled) { $result = $this->parent->has($key); } return $result; }
php
public function has($key) { $result = Arr::has($this->data, $key); if ( ! $result and $this->parentEnabled) { $result = $this->parent->has($key); } return $result; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "result", "=", "Arr", "::", "has", "(", "$", "this", "->", "data", ",", "$", "key", ")", ";", "if", "(", "!", "$", "result", "and", "$", "this", "->", "parentEnabled", ")", "{", "$", "result", "=", "$", "this", "->", "parent", "->", "has", "(", "$", "key", ")", ";", "}", "return", "$", "result", ";", "}" ]
Check if a key was set upon this bag's data @param string $key @return bool @since 2.0.0
[ "Check", "if", "a", "key", "was", "set", "upon", "this", "bag", "s", "data" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L264-L274
229,693
fuelphp/common
src/DataContainer.php
DataContainer.get
public function get($key = null, $default = null) { $fail = uniqid('__FAIL__', true); $result = Arr::get($this->data, $key, $fail); if ($result === $fail) { if ($this->parentEnabled) { $result = $this->parent->get($key, $default); } else { $result = result($default); } } return $result; }
php
public function get($key = null, $default = null) { $fail = uniqid('__FAIL__', true); $result = Arr::get($this->data, $key, $fail); if ($result === $fail) { if ($this->parentEnabled) { $result = $this->parent->get($key, $default); } else { $result = result($default); } } return $result; }
[ "public", "function", "get", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "fail", "=", "uniqid", "(", "'__FAIL__'", ",", "true", ")", ";", "$", "result", "=", "Arr", "::", "get", "(", "$", "this", "->", "data", ",", "$", "key", ",", "$", "fail", ")", ";", "if", "(", "$", "result", "===", "$", "fail", ")", "{", "if", "(", "$", "this", "->", "parentEnabled", ")", "{", "$", "result", "=", "$", "this", "->", "parent", "->", "get", "(", "$", "key", ",", "$", "default", ")", ";", "}", "else", "{", "$", "result", "=", "result", "(", "$", "default", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Get a key's value from this bag's data @param string $key @param mixed $default @return mixed @since 2.0.0
[ "Get", "a", "key", "s", "value", "from", "this", "bag", "s", "data" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L292-L311
229,694
fuelphp/common
src/DataContainer.php
DataContainer.set
public function set($key, $value) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->isModified = true; if ($key === null) { $this->data[] = $value; return $this; } Arr::set($this->data, $key, $value); return $this; }
php
public function set($key, $value) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->isModified = true; if ($key === null) { $this->data[] = $value; return $this; } Arr::set($this->data, $key, $value); return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "readOnly", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Changing values on this Data Container is not allowed.'", ")", ";", "}", "$", "this", "->", "isModified", "=", "true", ";", "if", "(", "$", "key", "===", "null", ")", "{", "$", "this", "->", "data", "[", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}", "Arr", "::", "set", "(", "$", "this", "->", "data", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set a config value @param string $key @param mixed $value @throws \RuntimeException @since 2.0.0
[ "Set", "a", "config", "value" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L329-L348
229,695
fuelphp/common
src/DataContainer.php
DataContainer.delete
public function delete($key) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->isModified = true; if (($result = Arr::delete($this->data, $key)) === false and $this->parentEnabled) { $result = $this->parent->delete($key); } return $result; }
php
public function delete($key) { if ($this->readOnly) { throw new \RuntimeException('Changing values on this Data Container is not allowed.'); } $this->isModified = true; if (($result = Arr::delete($this->data, $key)) === false and $this->parentEnabled) { $result = $this->parent->delete($key); } return $result; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "readOnly", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Changing values on this Data Container is not allowed.'", ")", ";", "}", "$", "this", "->", "isModified", "=", "true", ";", "if", "(", "(", "$", "result", "=", "Arr", "::", "delete", "(", "$", "this", "->", "data", ",", "$", "key", ")", ")", "===", "false", "and", "$", "this", "->", "parentEnabled", ")", "{", "$", "result", "=", "$", "this", "->", "parent", "->", "delete", "(", "$", "key", ")", ";", "}", "return", "$", "result", ";", "}" ]
Delete data from the container @param string $key key to delete @return boolean delete success boolean @since 2.0.0
[ "Delete", "data", "from", "the", "container" ]
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/DataContainer.php#L357-L372
229,696
odan/database
src/Database/UpdateQuery.php
UpdateQuery.increment
public function increment(string $column, int $amount = 1): self { $this->values[$column] = new RawExp($this->quoter->quoteName($column) . '+' . $this->quoter->quoteValue($amount)); return $this; }
php
public function increment(string $column, int $amount = 1): self { $this->values[$column] = new RawExp($this->quoter->quoteName($column) . '+' . $this->quoter->quoteValue($amount)); return $this; }
[ "public", "function", "increment", "(", "string", "$", "column", ",", "int", "$", "amount", "=", "1", ")", ":", "self", "{", "$", "this", "->", "values", "[", "$", "column", "]", "=", "new", "RawExp", "(", "$", "this", "->", "quoter", "->", "quoteName", "(", "$", "column", ")", ".", "'+'", ".", "$", "this", "->", "quoter", "->", "quoteValue", "(", "$", "amount", ")", ")", ";", "return", "$", "this", ";", "}" ]
Incrementing or decrementing the value of a given column. @param string $column The column to modify @param int $amount [optional] The amount by which the column should be incremented @return self
[ "Incrementing", "or", "decrementing", "the", "value", "of", "a", "given", "column", "." ]
e514fb45ab72718a77b34ed2c44906f5159e8278
https://github.com/odan/database/blob/e514fb45ab72718a77b34ed2c44906f5159e8278/src/Database/UpdateQuery.php#L210-L215
229,697
netgen/NetgenOpenGraphBundle
bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php
NetgenOpenGraphRuntime.renderOpenGraphTags
public function renderOpenGraphTags(Content $content) { try { return $this->tagRenderer->render( $this->getOpenGraphTags($content) ); } catch (Exception $e) { if ($this->throwExceptions || !$this->logger instanceof LoggerInterface) { throw $e; } $this->logger->error($e->getMessage()); } return ''; }
php
public function renderOpenGraphTags(Content $content) { try { return $this->tagRenderer->render( $this->getOpenGraphTags($content) ); } catch (Exception $e) { if ($this->throwExceptions || !$this->logger instanceof LoggerInterface) { throw $e; } $this->logger->error($e->getMessage()); } return ''; }
[ "public", "function", "renderOpenGraphTags", "(", "Content", "$", "content", ")", "{", "try", "{", "return", "$", "this", "->", "tagRenderer", "->", "render", "(", "$", "this", "->", "getOpenGraphTags", "(", "$", "content", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "throwExceptions", "||", "!", "$", "this", "->", "logger", "instanceof", "LoggerInterface", ")", "{", "throw", "$", "e", ";", "}", "$", "this", "->", "logger", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "''", ";", "}" ]
Renders Open Graph tags for provided content. @param \eZ\Publish\API\Repository\Values\Content\Content $content @return string
[ "Renders", "Open", "Graph", "tags", "for", "provided", "content", "." ]
fcaad267742492cfa4049adbf075343c262c4767
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php#L67-L82
229,698
netgen/NetgenOpenGraphBundle
bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php
NetgenOpenGraphRuntime.getOpenGraphTags
public function getOpenGraphTags(Content $content) { try { return $this->tagCollector->collect($content); } catch (Exception $e) { if ($this->throwExceptions || !$this->logger instanceof LoggerInterface) { throw $e; } $this->logger->error($e->getMessage()); } return array(); }
php
public function getOpenGraphTags(Content $content) { try { return $this->tagCollector->collect($content); } catch (Exception $e) { if ($this->throwExceptions || !$this->logger instanceof LoggerInterface) { throw $e; } $this->logger->error($e->getMessage()); } return array(); }
[ "public", "function", "getOpenGraphTags", "(", "Content", "$", "content", ")", "{", "try", "{", "return", "$", "this", "->", "tagCollector", "->", "collect", "(", "$", "content", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "throwExceptions", "||", "!", "$", "this", "->", "logger", "instanceof", "LoggerInterface", ")", "{", "throw", "$", "e", ";", "}", "$", "this", "->", "logger", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Returns Open Graph tags for provided content. @param \eZ\Publish\API\Repository\Values\Content\Content $content @return \Netgen\Bundle\OpenGraphBundle\MetaTag\Item[]
[ "Returns", "Open", "Graph", "tags", "for", "provided", "content", "." ]
fcaad267742492cfa4049adbf075343c262c4767
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/Templating/Twig/Extension/NetgenOpenGraphRuntime.php#L91-L104
229,699
Codegyre/RoboCI
RoboFile.php
RoboFile.changed
public function changed($change) { $this->taskChangelog() ->version($this->getVersion()) ->change($change) ->run(); }
php
public function changed($change) { $this->taskChangelog() ->version($this->getVersion()) ->change($change) ->run(); }
[ "public", "function", "changed", "(", "$", "change", ")", "{", "$", "this", "->", "taskChangelog", "(", ")", "->", "version", "(", "$", "this", "->", "getVersion", "(", ")", ")", "->", "change", "(", "$", "change", ")", "->", "run", "(", ")", ";", "}" ]
define public methods as commands
[ "define", "public", "methods", "as", "commands" ]
886f340d7d8ca808607da9a41d2e6ba18075bdf1
https://github.com/Codegyre/RoboCI/blob/886f340d7d8ca808607da9a41d2e6ba18075bdf1/RoboFile.php#L11-L17