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
partition
stringclasses
1 value
Scoilnet/PhpSDK
scoilnetsdk/OAuth2/OAuthClient.php
OAuthClient.setCookieFromSession
protected function setCookieFromSession($session = NULL) { if (!$this->getVariable('cookie_support')) return; $cookie_name = $this->getSessionCookieName(); $value = 'deleted'; $expires = time() - 3600; $base_domain = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN); if ($session) { $value = '"' . http_build_query($session, NULL, '&') . '"'; $base_domain = isset($session['base_domain']) ? $session['base_domain'] : $base_domain; $expires = isset($session['expires']) ? $session['expires'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN); } // Prepend dot if a domain is found. if ($base_domain) $base_domain = '.' . $base_domain; // If an existing cookie is not set, we dont need to delete it. if ($value == 'deleted' && empty($_COOKIE[$cookie_name])) return; if (headers_sent()) error_log('Could not set cookie. Headers already sent.'); else setcookie($cookie_name, $value, $expires, '/', $base_domain); }
php
protected function setCookieFromSession($session = NULL) { if (!$this->getVariable('cookie_support')) return; $cookie_name = $this->getSessionCookieName(); $value = 'deleted'; $expires = time() - 3600; $base_domain = $this->getVariable('base_domain', self::DEFAULT_BASE_DOMAIN); if ($session) { $value = '"' . http_build_query($session, NULL, '&') . '"'; $base_domain = isset($session['base_domain']) ? $session['base_domain'] : $base_domain; $expires = isset($session['expires']) ? $session['expires'] : time() + $this->getVariable('expires_in', self::DEFAULT_EXPIRES_IN); } // Prepend dot if a domain is found. if ($base_domain) $base_domain = '.' . $base_domain; // If an existing cookie is not set, we dont need to delete it. if ($value == 'deleted' && empty($_COOKIE[$cookie_name])) return; if (headers_sent()) error_log('Could not set cookie. Headers already sent.'); else setcookie($cookie_name, $value, $expires, '/', $base_domain); }
[ "protected", "function", "setCookieFromSession", "(", "$", "session", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "getVariable", "(", "'cookie_support'", ")", ")", "return", ";", "$", "cookie_name", "=", "$", "this", "->", "getSessionCookieName", "(", ")", ";", "$", "value", "=", "'deleted'", ";", "$", "expires", "=", "time", "(", ")", "-", "3600", ";", "$", "base_domain", "=", "$", "this", "->", "getVariable", "(", "'base_domain'", ",", "self", "::", "DEFAULT_BASE_DOMAIN", ")", ";", "if", "(", "$", "session", ")", "{", "$", "value", "=", "'\"'", ".", "http_build_query", "(", "$", "session", ",", "NULL", ",", "'&'", ")", ".", "'\"'", ";", "$", "base_domain", "=", "isset", "(", "$", "session", "[", "'base_domain'", "]", ")", "?", "$", "session", "[", "'base_domain'", "]", ":", "$", "base_domain", ";", "$", "expires", "=", "isset", "(", "$", "session", "[", "'expires'", "]", ")", "?", "$", "session", "[", "'expires'", "]", ":", "time", "(", ")", "+", "$", "this", "->", "getVariable", "(", "'expires_in'", ",", "self", "::", "DEFAULT_EXPIRES_IN", ")", ";", "}", "// Prepend dot if a domain is found.\r", "if", "(", "$", "base_domain", ")", "$", "base_domain", "=", "'.'", ".", "$", "base_domain", ";", "// If an existing cookie is not set, we dont need to delete it.\r", "if", "(", "$", "value", "==", "'deleted'", "&&", "empty", "(", "$", "_COOKIE", "[", "$", "cookie_name", "]", ")", ")", "return", ";", "if", "(", "headers_sent", "(", ")", ")", "error_log", "(", "'Could not set cookie. Headers already sent.'", ")", ";", "else", "setcookie", "(", "$", "cookie_name", ",", "$", "value", ",", "$", "expires", ",", "'/'", ",", "$", "base_domain", ")", ";", "}" ]
Set a JS Cookie based on the _passed in_ session. It does not use the currently stored session - you need to explicitly pass it in. @param $session The session to use for setting the cookie.
[ "Set", "a", "JS", "Cookie", "based", "on", "the", "_passed", "in_", "session", "." ]
c2d033b020015b3c9c8a741bff857e7d599f18c0
https://github.com/Scoilnet/PhpSDK/blob/c2d033b020015b3c9c8a741bff857e7d599f18c0/scoilnetsdk/OAuth2/OAuthClient.php#L564-L590
train
Scoilnet/PhpSDK
scoilnetsdk/OAuth2/OAuthClient.php
OAuthClient.generateSignature
protected function generateSignature($params, $secret) { // Work with sorted data. ksort($params); // Generate the base string. $base_string = ''; foreach ($params as $key => $value) { $base_string .= $key . '=' . $value; } $base_string .= $secret; return md5($base_string); }
php
protected function generateSignature($params, $secret) { // Work with sorted data. ksort($params); // Generate the base string. $base_string = ''; foreach ($params as $key => $value) { $base_string .= $key . '=' . $value; } $base_string .= $secret; return md5($base_string); }
[ "protected", "function", "generateSignature", "(", "$", "params", ",", "$", "secret", ")", "{", "// Work with sorted data.\r", "ksort", "(", "$", "params", ")", ";", "// Generate the base string.\r", "$", "base_string", "=", "''", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "base_string", ".=", "$", "key", ".", "'='", ".", "$", "value", ";", "}", "$", "base_string", ".=", "$", "secret", ";", "return", "md5", "(", "$", "base_string", ")", ";", "}" ]
Generate a signature for the given params and secret. @param $params The parameters to sign. @param $secret The secret to sign with. @return The generated signature
[ "Generate", "a", "signature", "for", "the", "given", "params", "and", "secret", "." ]
c2d033b020015b3c9c8a741bff857e7d599f18c0
https://github.com/Scoilnet/PhpSDK/blob/c2d033b020015b3c9c8a741bff857e7d599f18c0/scoilnetsdk/OAuth2/OAuthClient.php#L718-L730
train
mullanaphy/variable
src/PHY/Variable/Int.php
Int.toMinutes
public function toMinutes() { $time = $this->get(); if (!$time) { $time = '00:00'; } else { $time = sprintf('%02d:%02d', (int)(floor($time / 60)), (int)($time % 60)); } return $this; }
php
public function toMinutes() { $time = $this->get(); if (!$time) { $time = '00:00'; } else { $time = sprintf('%02d:%02d', (int)(floor($time / 60)), (int)($time % 60)); } return $this; }
[ "public", "function", "toMinutes", "(", ")", "{", "$", "time", "=", "$", "this", "->", "get", "(", ")", ";", "if", "(", "!", "$", "time", ")", "{", "$", "time", "=", "'00:00'", ";", "}", "else", "{", "$", "time", "=", "sprintf", "(", "'%02d:%02d'", ",", "(", "int", ")", "(", "floor", "(", "$", "time", "/", "60", ")", ")", ",", "(", "int", ")", "(", "$", "time", "%", "60", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Convert an int as seconds into Minutes. @return string
[ "Convert", "an", "int", "as", "seconds", "into", "Minutes", "." ]
e4eb274a1799a25e33e5e21cd260603c74628031
https://github.com/mullanaphy/variable/blob/e4eb274a1799a25e33e5e21cd260603c74628031/src/PHY/Variable/Int.php#L53-L62
train
ScaraMVC/Framework
src/Scara/Http/View.php
View.createBlade
public function createBlade($views, $cache) { $this->_blade = new Blade($views, $cache); $this->_view = $this->_blade->view(); }
php
public function createBlade($views, $cache) { $this->_blade = new Blade($views, $cache); $this->_view = $this->_blade->view(); }
[ "public", "function", "createBlade", "(", "$", "views", ",", "$", "cache", ")", "{", "$", "this", "->", "_blade", "=", "new", "Blade", "(", "$", "views", ",", "$", "cache", ")", ";", "$", "this", "->", "_view", "=", "$", "this", "->", "_blade", "->", "view", "(", ")", ";", "}" ]
Creates a new Blade instance. @param string $views - The views path @param string $cache - The cache path @return void
[ "Creates", "a", "new", "Blade", "instance", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/View.php#L70-L74
train
ScaraMVC/Framework
src/Scara/Http/View.php
View.compile
public function compile($path) { $this->parseContent($path, $this->_data); return $this->_factory->render(); }
php
public function compile($path) { $this->parseContent($path, $this->_data); return $this->_factory->render(); }
[ "public", "function", "compile", "(", "$", "path", ")", "{", "$", "this", "->", "parseContent", "(", "$", "path", ",", "$", "this", "->", "_data", ")", ";", "return", "$", "this", "->", "_factory", "->", "render", "(", ")", ";", "}" ]
Compiles the view. @param string $path - The path of the view @return string
[ "Compiles", "the", "view", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/View.php#L83-L88
train
ScaraMVC/Framework
src/Scara/Http/View.php
View.with
public function with($key, $value = null) { if (is_array($key)) { $this->_data = array_merge($this->_data, $key); } else { $this->_data[$key] = $value; } return $this; }
php
public function with($key, $value = null) { if (is_array($key)) { $this->_data = array_merge($this->_data, $key); } else { $this->_data[$key] = $value; } return $this; }
[ "public", "function", "with", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "_data", "=", "array_merge", "(", "$", "this", "->", "_data", ",", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Adds data to pass onto the view. @param string $key - The key of the data to pass through @param string $value - The $key's value @return \Scara\Http\View
[ "Adds", "data", "to", "pass", "onto", "the", "view", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/View.php#L110-L119
train
ScaraMVC/Framework
src/Scara/Http/View.php
View.renderView
public static function renderView($path, $dataName = '', $data = '') { $view = new self(); if (!empty($dataName)) { $view->with($dataName, $data); } return $view->render($path, false); }
php
public static function renderView($path, $dataName = '', $data = '') { $view = new self(); if (!empty($dataName)) { $view->with($dataName, $data); } return $view->render($path, false); }
[ "public", "static", "function", "renderView", "(", "$", "path", ",", "$", "dataName", "=", "''", ",", "$", "data", "=", "''", ")", "{", "$", "view", "=", "new", "self", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "dataName", ")", ")", "{", "$", "view", "->", "with", "(", "$", "dataName", ",", "$", "data", ")", ";", "}", "return", "$", "view", "->", "render", "(", "$", "path", ",", "false", ")", ";", "}" ]
Static function to render a view. @param string $path @param string $data @param string $data @return mixed
[ "Static", "function", "to", "render", "a", "view", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/View.php#L159-L167
train
ScaraMVC/Framework
src/Scara/Http/View.php
View.parseContent
private function parseContent($path, $data) { $path = str_replace('.', '/', $path); $this->_factory = $this->_view->make($path, $data); }
php
private function parseContent($path, $data) { $path = str_replace('.', '/', $path); $this->_factory = $this->_view->make($path, $data); }
[ "private", "function", "parseContent", "(", "$", "path", ",", "$", "data", ")", "{", "$", "path", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "path", ")", ";", "$", "this", "->", "_factory", "=", "$", "this", "->", "_view", "->", "make", "(", "$", "path", ",", "$", "data", ")", ";", "}" ]
Parses the view using the Blade Factory. @param string $path - The path of the view to parse @param string $data - Data to pass on to the view @return void
[ "Parses", "the", "view", "using", "the", "Blade", "Factory", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/View.php#L189-L193
train
SetBased/php-abc-page-core
src/CorePage.php
CorePage.echoPageLeader
protected function echoPageLeader(): void { echo '<!DOCTYPE html>'; echo Html::generateTag('html', ['xmlns' => 'http://www.w3.org/1999/xhtml', 'xml:lang' => Abc::$babel->getCode(), 'lang' => Abc::$babel->getCode()]); echo '<head>'; // Echo the meta tags. Abc::$assets->echoMetaTags(); // Echo the title of the XHTML document. Abc::$assets->echoPageTitle(); // Echo style sheets (if any). Abc::$assets->echoCascadingStyleSheets(); echo '</head><body>'; }
php
protected function echoPageLeader(): void { echo '<!DOCTYPE html>'; echo Html::generateTag('html', ['xmlns' => 'http://www.w3.org/1999/xhtml', 'xml:lang' => Abc::$babel->getCode(), 'lang' => Abc::$babel->getCode()]); echo '<head>'; // Echo the meta tags. Abc::$assets->echoMetaTags(); // Echo the title of the XHTML document. Abc::$assets->echoPageTitle(); // Echo style sheets (if any). Abc::$assets->echoCascadingStyleSheets(); echo '</head><body>'; }
[ "protected", "function", "echoPageLeader", "(", ")", ":", "void", "{", "echo", "'<!DOCTYPE html>'", ";", "echo", "Html", "::", "generateTag", "(", "'html'", ",", "[", "'xmlns'", "=>", "'http://www.w3.org/1999/xhtml'", ",", "'xml:lang'", "=>", "Abc", "::", "$", "babel", "->", "getCode", "(", ")", ",", "'lang'", "=>", "Abc", "::", "$", "babel", "->", "getCode", "(", ")", "]", ")", ";", "echo", "'<head>'", ";", "// Echo the meta tags.", "Abc", "::", "$", "assets", "->", "echoMetaTags", "(", ")", ";", "// Echo the title of the XHTML document.", "Abc", "::", "$", "assets", "->", "echoPageTitle", "(", ")", ";", "// Echo style sheets (if any).", "Abc", "::", "$", "assets", "->", "echoCascadingStyleSheets", "(", ")", ";", "echo", "'</head><body>'", ";", "}" ]
Echos the XHTML document leader, i.e. the start html tag, the head element, and start body tag.
[ "Echos", "the", "XHTML", "document", "leader", "i", ".", "e", ".", "the", "start", "html", "tag", "the", "head", "element", "and", "start", "body", "tag", "." ]
189d624d96cd70d99f8a838ee87d7afcd77d1576
https://github.com/SetBased/php-abc-page-core/blob/189d624d96cd70d99f8a838ee87d7afcd77d1576/src/CorePage.php#L109-L128
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.assignFields
protected function assignFields($fields) { foreach ($fields as $field) { if (!$field instanceof FieldInterface) { throw new ModelException(sprintf('Field must be an instance of FieldInterface, got "%s"', $this->getType($field))); } $field->table($this->table); $this->fields[$field->name()] = $field; } }
php
protected function assignFields($fields) { foreach ($fields as $field) { if (!$field instanceof FieldInterface) { throw new ModelException(sprintf('Field must be an instance of FieldInterface, got "%s"', $this->getType($field))); } $field->table($this->table); $this->fields[$field->name()] = $field; } }
[ "protected", "function", "assignFields", "(", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "!", "$", "field", "instanceof", "FieldInterface", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Field must be an instance of FieldInterface, got \"%s\"'", ",", "$", "this", "->", "getType", "(", "$", "field", ")", ")", ")", ";", "}", "$", "field", "->", "table", "(", "$", "this", "->", "table", ")", ";", "$", "this", "->", "fields", "[", "$", "field", "->", "name", "(", ")", "]", "=", "$", "field", ";", "}", "}" ]
Assigns fields to model @param array $fields @throws ModelException
[ "Assigns", "fields", "to", "model" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L78-L88
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.assignIndexes
protected function assignIndexes($indexes) { foreach ($indexes as $index) { if (!$index instanceof IndexInterface) { throw new ModelException(sprintf('Index must be an instance of IndexInterface, got "%s"', $this->getType($index))); } foreach ($index->fields() as $key => $field) { $field = $index->type() == 'foreign' ? $key : $field; $this->assertField($field); } if ($index->type() !== 'foreign') { $index->table($this->table); } $this->indexes[$index->name()] = $index; } }
php
protected function assignIndexes($indexes) { foreach ($indexes as $index) { if (!$index instanceof IndexInterface) { throw new ModelException(sprintf('Index must be an instance of IndexInterface, got "%s"', $this->getType($index))); } foreach ($index->fields() as $key => $field) { $field = $index->type() == 'foreign' ? $key : $field; $this->assertField($field); } if ($index->type() !== 'foreign') { $index->table($this->table); } $this->indexes[$index->name()] = $index; } }
[ "protected", "function", "assignIndexes", "(", "$", "indexes", ")", "{", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "!", "$", "index", "instanceof", "IndexInterface", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Index must be an instance of IndexInterface, got \"%s\"'", ",", "$", "this", "->", "getType", "(", "$", "index", ")", ")", ")", ";", "}", "foreach", "(", "$", "index", "->", "fields", "(", ")", "as", "$", "key", "=>", "$", "field", ")", "{", "$", "field", "=", "$", "index", "->", "type", "(", ")", "==", "'foreign'", "?", "$", "key", ":", "$", "field", ";", "$", "this", "->", "assertField", "(", "$", "field", ")", ";", "}", "if", "(", "$", "index", "->", "type", "(", ")", "!==", "'foreign'", ")", "{", "$", "index", "->", "table", "(", "$", "this", "->", "table", ")", ";", "}", "$", "this", "->", "indexes", "[", "$", "index", "->", "name", "(", ")", "]", "=", "$", "index", ";", "}", "}" ]
Assigns indexes to model @param array $indexes @throws ModelException
[ "Assigns", "indexes", "to", "model" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L97-L116
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.assignRelations
protected function assignRelations($relations) { foreach ($relations as $relation) { if (!$relation instanceof RelationInterface) { throw new ModelException(sprintf('Relation must be an instance of RelationInterface, got "%s"', $this->getType($relation))); } foreach (array_keys($relation->keys()) as $field) { $this->assertField($field); } $this->relations[$relation->name()] = $relation; } }
php
protected function assignRelations($relations) { foreach ($relations as $relation) { if (!$relation instanceof RelationInterface) { throw new ModelException(sprintf('Relation must be an instance of RelationInterface, got "%s"', $this->getType($relation))); } foreach (array_keys($relation->keys()) as $field) { $this->assertField($field); } $this->relations[$relation->name()] = $relation; } }
[ "protected", "function", "assignRelations", "(", "$", "relations", ")", "{", "foreach", "(", "$", "relations", "as", "$", "relation", ")", "{", "if", "(", "!", "$", "relation", "instanceof", "RelationInterface", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Relation must be an instance of RelationInterface, got \"%s\"'", ",", "$", "this", "->", "getType", "(", "$", "relation", ")", ")", ")", ";", "}", "foreach", "(", "array_keys", "(", "$", "relation", "->", "keys", "(", ")", ")", "as", "$", "field", ")", "{", "$", "this", "->", "assertField", "(", "$", "field", ")", ";", "}", "$", "this", "->", "relations", "[", "$", "relation", "->", "name", "(", ")", "]", "=", "$", "relation", ";", "}", "}" ]
Assigns relations to model @param array $relations @throws ModelException
[ "Assigns", "relations", "to", "model" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L125-L138
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.assertField
protected function assertField($field) { if (!$this->hasField($field)) { throw new ModelException(sprintf('Unknown field, field "%s" not found in model "%s"', $field, $this->entity)); } }
php
protected function assertField($field) { if (!$this->hasField($field)) { throw new ModelException(sprintf('Unknown field, field "%s" not found in model "%s"', $field, $this->entity)); } }
[ "protected", "function", "assertField", "(", "$", "field", ")", "{", "if", "(", "!", "$", "this", "->", "hasField", "(", "$", "field", ")", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Unknown field, field \"%s\" not found in model \"%s\"'", ",", "$", "field", ",", "$", "this", "->", "entity", ")", ")", ";", "}", "}" ]
Asserts if model has field @param string $field @throws ModelException
[ "Asserts", "if", "model", "has", "field" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L205-L210
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.primaryFields
public function primaryFields() { $result = []; foreach ($this->indexes as $index) { if (!$index->isPrimary()) { continue; } foreach ($index->fields() as $field) { $result[] = $this->field($field); } } return $result; }
php
public function primaryFields() { $result = []; foreach ($this->indexes as $index) { if (!$index->isPrimary()) { continue; } foreach ($index->fields() as $field) { $result[] = $this->field($field); } } return $result; }
[ "public", "function", "primaryFields", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "indexes", "as", "$", "index", ")", "{", "if", "(", "!", "$", "index", "->", "isPrimary", "(", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "index", "->", "fields", "(", ")", "as", "$", "field", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "field", "(", "$", "field", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns array containing names of primary indexes @return FieldInterface[]
[ "Returns", "array", "containing", "names", "of", "primary", "indexes" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L232-L246
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.indexFields
public function indexFields() { $fields = []; foreach ($this->indexes as $index) { $fields = array_merge($fields, $index->fields()); } $result = []; foreach (array_unique($fields) as $field) { $result[] = $this->field($field); } return $result; }
php
public function indexFields() { $fields = []; foreach ($this->indexes as $index) { $fields = array_merge($fields, $index->fields()); } $result = []; foreach (array_unique($fields) as $field) { $result[] = $this->field($field); } return $result; }
[ "public", "function", "indexFields", "(", ")", "{", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "indexes", "as", "$", "index", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "$", "index", "->", "fields", "(", ")", ")", ";", "}", "$", "result", "=", "[", "]", ";", "foreach", "(", "array_unique", "(", "$", "fields", ")", "as", "$", "field", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "field", "(", "$", "field", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns array of fields from indexes @return FieldInterface[]
[ "Returns", "array", "of", "fields", "from", "indexes" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L253-L266
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.index
public function index($index) { if (empty($this->indexes[$index])) { throw new ModelException(sprintf('Unknown index, index "%s" not found in model "%s"', $index, $this->entity)); } return $this->indexes[$index]; }
php
public function index($index) { if (empty($this->indexes[$index])) { throw new ModelException(sprintf('Unknown index, index "%s" not found in model "%s"', $index, $this->entity)); } return $this->indexes[$index]; }
[ "public", "function", "index", "(", "$", "index", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "indexes", "[", "$", "index", "]", ")", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Unknown index, index \"%s\" not found in model \"%s\"'", ",", "$", "index", ",", "$", "this", "->", "entity", ")", ")", ";", "}", "return", "$", "this", "->", "indexes", "[", "$", "index", "]", ";", "}" ]
Returns index definition @param string $index @return IndexInterface[] @throws ModelException
[ "Returns", "index", "definition" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L299-L306
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.referredIn
public function referredIn($field) { $result = []; foreach ($this->relations as $relation) { if (false === $i = array_search($field, $relation->localKeys())) { continue; } $result[$relation->foreignKeys()[$i]] = $relation; } return $result; }
php
public function referredIn($field) { $result = []; foreach ($this->relations as $relation) { if (false === $i = array_search($field, $relation->localKeys())) { continue; } $result[$relation->foreignKeys()[$i]] = $relation; } return $result; }
[ "public", "function", "referredIn", "(", "$", "field", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "relations", "as", "$", "relation", ")", "{", "if", "(", "false", "===", "$", "i", "=", "array_search", "(", "$", "field", ",", "$", "relation", "->", "localKeys", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "result", "[", "$", "relation", "->", "foreignKeys", "(", ")", "[", "$", "i", "]", "]", "=", "$", "relation", ";", "}", "return", "$", "result", ";", "}" ]
Returns all relation where field is listed as local key @param string $field @return RelationInterface[]
[ "Returns", "all", "relation", "where", "field", "is", "listed", "as", "local", "key" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L315-L327
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.relation
public function relation($relationName) { if (!$relation = $this->findRelationByName($relationName)) { throw new ModelException(sprintf('Unknown relation, relation "%s" not found in model "%s"', $relationName, $this->entity)); } return $relation; }
php
public function relation($relationName) { if (!$relation = $this->findRelationByName($relationName)) { throw new ModelException(sprintf('Unknown relation, relation "%s" not found in model "%s"', $relationName, $this->entity)); } return $relation; }
[ "public", "function", "relation", "(", "$", "relationName", ")", "{", "if", "(", "!", "$", "relation", "=", "$", "this", "->", "findRelationByName", "(", "$", "relationName", ")", ")", "{", "throw", "new", "ModelException", "(", "sprintf", "(", "'Unknown relation, relation \"%s\" not found in model \"%s\"'", ",", "$", "relationName", ",", "$", "this", "->", "entity", ")", ")", ";", "}", "return", "$", "relation", ";", "}" ]
Returns relation definition for passed entity class @param string $relationName @return RelationInterface @throws ModelException
[ "Returns", "relation", "definition", "for", "passed", "entity", "class" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L369-L376
train
mossphp/moss-storage
Moss/Storage/Model/Model.php
Model.findRelationByName
protected function findRelationByName($relationName) { foreach ($this->relations as $relation) { if ($relation->name() == $relationName || $relation->entity() == $relationName) { return $relation; } } return null; }
php
protected function findRelationByName($relationName) { foreach ($this->relations as $relation) { if ($relation->name() == $relationName || $relation->entity() == $relationName) { return $relation; } } return null; }
[ "protected", "function", "findRelationByName", "(", "$", "relationName", ")", "{", "foreach", "(", "$", "this", "->", "relations", "as", "$", "relation", ")", "{", "if", "(", "$", "relation", "->", "name", "(", ")", "==", "$", "relationName", "||", "$", "relation", "->", "entity", "(", ")", "==", "$", "relationName", ")", "{", "return", "$", "relation", ";", "}", "}", "return", "null", ";", "}" ]
Finds relation by its name @param string $relationName @return RelationInterface
[ "Finds", "relation", "by", "its", "name" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/Model.php#L385-L394
train
squareproton/Bond
src/Bond/Container.php
Container.remove
public function remove() { $removed = 0; foreach( func_get_args() as $arg ){ // is this a container? if( $arg instanceof Container ) { $originalCount = $this->count(); $this->collection = array_diff_key( $this->collection, $arg->collection ); $removed += ( $originalCount - $this->count() ); } else { // use array search $search = $this->search( $arg, true ); foreach( $search as $value ){ if( $value !== false ){ $removed++; $this->offsetUnset( $value ); } } } } $this->rewind(); return $removed; }
php
public function remove() { $removed = 0; foreach( func_get_args() as $arg ){ // is this a container? if( $arg instanceof Container ) { $originalCount = $this->count(); $this->collection = array_diff_key( $this->collection, $arg->collection ); $removed += ( $originalCount - $this->count() ); } else { // use array search $search = $this->search( $arg, true ); foreach( $search as $value ){ if( $value !== false ){ $removed++; $this->offsetUnset( $value ); } } } } $this->rewind(); return $removed; }
[ "public", "function", "remove", "(", ")", "{", "$", "removed", "=", "0", ";", "foreach", "(", "func_get_args", "(", ")", "as", "$", "arg", ")", "{", "// is this a container?", "if", "(", "$", "arg", "instanceof", "Container", ")", "{", "$", "originalCount", "=", "$", "this", "->", "count", "(", ")", ";", "$", "this", "->", "collection", "=", "array_diff_key", "(", "$", "this", "->", "collection", ",", "$", "arg", "->", "collection", ")", ";", "$", "removed", "+=", "(", "$", "originalCount", "-", "$", "this", "->", "count", "(", ")", ")", ";", "}", "else", "{", "// use array search", "$", "search", "=", "$", "this", "->", "search", "(", "$", "arg", ",", "true", ")", ";", "foreach", "(", "$", "search", "as", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "false", ")", "{", "$", "removed", "++", ";", "$", "this", "->", "offsetUnset", "(", "$", "value", ")", ";", "}", "}", "}", "}", "$", "this", "->", "rewind", "(", ")", ";", "return", "$", "removed", ";", "}" ]
Remove entities from collection @param ContainerableInterface|Container|ContainerableInterface[] @return int Number removed
[ "Remove", "entities", "from", "collection" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L161-L192
train
squareproton/Bond
src/Bond/Container.php
Container.mapCombine
public function mapCombine( $keys, $values ) { return array_combine( array_map( $keys, $this->collection ), array_map( $values, $this->collection ) ); }
php
public function mapCombine( $keys, $values ) { return array_combine( array_map( $keys, $this->collection ), array_map( $values, $this->collection ) ); }
[ "public", "function", "mapCombine", "(", "$", "keys", ",", "$", "values", ")", "{", "return", "array_combine", "(", "array_map", "(", "$", "keys", ",", "$", "this", "->", "collection", ")", ",", "array_map", "(", "$", "values", ",", "$", "this", "->", "collection", ")", ")", ";", "}" ]
MapCombine. Like array map but takes a callback for the array keys @param callback. Specifies the keys of the return array @param callback. Specifies the values of the return array @return array
[ "MapCombine", ".", "Like", "array", "map", "but", "takes", "a", "callback", "for", "the", "array", "keys" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L287-L293
train
squareproton/Bond
src/Bond/Container.php
Container.pluck
public function pluck( $property, $ifEmptyDefaultToContainer = false ) { $mapper = $this->getPropertyMapper($property); $isAllObjects = true; $output = []; foreach( $this->collection as $obj ) { $propertyValue = $mapper->get($obj); $isAllObjects = $isAllObjects and is_object($propertyValue); $output[] = $propertyValue; } if( $output ) { if( $isAllObjects ) { try { return new Container($output); } catch ( \Exception $e ) { } } } elseif( $ifEmptyDefaultToContainer) { return new Container(); } return $output; }
php
public function pluck( $property, $ifEmptyDefaultToContainer = false ) { $mapper = $this->getPropertyMapper($property); $isAllObjects = true; $output = []; foreach( $this->collection as $obj ) { $propertyValue = $mapper->get($obj); $isAllObjects = $isAllObjects and is_object($propertyValue); $output[] = $propertyValue; } if( $output ) { if( $isAllObjects ) { try { return new Container($output); } catch ( \Exception $e ) { } } } elseif( $ifEmptyDefaultToContainer) { return new Container(); } return $output; }
[ "public", "function", "pluck", "(", "$", "property", ",", "$", "ifEmptyDefaultToContainer", "=", "false", ")", "{", "$", "mapper", "=", "$", "this", "->", "getPropertyMapper", "(", "$", "property", ")", ";", "$", "isAllObjects", "=", "true", ";", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "collection", "as", "$", "obj", ")", "{", "$", "propertyValue", "=", "$", "mapper", "->", "get", "(", "$", "obj", ")", ";", "$", "isAllObjects", "=", "$", "isAllObjects", "and", "is_object", "(", "$", "propertyValue", ")", ";", "$", "output", "[", "]", "=", "$", "propertyValue", ";", "}", "if", "(", "$", "output", ")", "{", "if", "(", "$", "isAllObjects", ")", "{", "try", "{", "return", "new", "Container", "(", "$", "output", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "}", "}", "elseif", "(", "$", "ifEmptyDefaultToContainer", ")", "{", "return", "new", "Container", "(", ")", ";", "}", "return", "$", "output", ";", "}" ]
Pluck a property from the collection @param string Property @return mixed Bond\Container | mixed[]
[ "Pluck", "a", "property", "from", "the", "collection" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L311-L335
train
squareproton/Bond
src/Bond/Container.php
Container.generateSortByPropertyClosure
private function generateSortByPropertyClosure( $property, $direction = SORT_ASC ) { if( $direction === SORT_DESC ) { $aLTb = 1; $aGTb = -1; } else { $aLTb = -1; $aGTb = 1; } $mapper = $this->getPropertyMapper($property); return function ( $a, $b ) use ( $mapper, $aLTb, $aGTb ) { $propertyA = $mapper->get($a); $propertyB = $mapper->get($b); if( $propertyA === $propertyB ) { return 0; } return ( $propertyA < $propertyB ) ? $aLTb : $aGTb; }; }
php
private function generateSortByPropertyClosure( $property, $direction = SORT_ASC ) { if( $direction === SORT_DESC ) { $aLTb = 1; $aGTb = -1; } else { $aLTb = -1; $aGTb = 1; } $mapper = $this->getPropertyMapper($property); return function ( $a, $b ) use ( $mapper, $aLTb, $aGTb ) { $propertyA = $mapper->get($a); $propertyB = $mapper->get($b); if( $propertyA === $propertyB ) { return 0; } return ( $propertyA < $propertyB ) ? $aLTb : $aGTb; }; }
[ "private", "function", "generateSortByPropertyClosure", "(", "$", "property", ",", "$", "direction", "=", "SORT_ASC", ")", "{", "if", "(", "$", "direction", "===", "SORT_DESC", ")", "{", "$", "aLTb", "=", "1", ";", "$", "aGTb", "=", "-", "1", ";", "}", "else", "{", "$", "aLTb", "=", "-", "1", ";", "$", "aGTb", "=", "1", ";", "}", "$", "mapper", "=", "$", "this", "->", "getPropertyMapper", "(", "$", "property", ")", ";", "return", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "mapper", ",", "$", "aLTb", ",", "$", "aGTb", ")", "{", "$", "propertyA", "=", "$", "mapper", "->", "get", "(", "$", "a", ")", ";", "$", "propertyB", "=", "$", "mapper", "->", "get", "(", "$", "b", ")", ";", "if", "(", "$", "propertyA", "===", "$", "propertyB", ")", "{", "return", "0", ";", "}", "return", "(", "$", "propertyA", "<", "$", "propertyB", ")", "?", "$", "aLTb", ":", "$", "aGTb", ";", "}", ";", "}" ]
Return a user defined sort comparison function that is property mapper aware. @param string Property to sort on. @param const SORT_DESC | SORT_ASC Sort direction @return callable
[ "Return", "a", "user", "defined", "sort", "comparison", "function", "that", "is", "property", "mapper", "aware", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L343-L365
train
squareproton/Bond
src/Bond/Container.php
Container.generateGetPropertyClosure
private function generateGetPropertyClosure( $property ) { $mapper = $this->getPropertyMapper($property); return function( $obj ) use ( $mapper ) { return $mapper->get($obj); }; }
php
private function generateGetPropertyClosure( $property ) { $mapper = $this->getPropertyMapper($property); return function( $obj ) use ( $mapper ) { return $mapper->get($obj); }; }
[ "private", "function", "generateGetPropertyClosure", "(", "$", "property", ")", "{", "$", "mapper", "=", "$", "this", "->", "getPropertyMapper", "(", "$", "property", ")", ";", "return", "function", "(", "$", "obj", ")", "use", "(", "$", "mapper", ")", "{", "return", "$", "mapper", "->", "get", "(", "$", "obj", ")", ";", "}", ";", "}" ]
Returns a callable to access a object property @param string $property @return callable
[ "Returns", "a", "callable", "to", "access", "a", "object", "property" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L372-L378
train
squareproton/Bond
src/Bond/Container.php
Container.sortByProperty
public function sortByProperty( $property, $direction = null ) { $this->sort( $this->generateSortByPropertyClosure( $property, $direction ) ); return $this; }
php
public function sortByProperty( $property, $direction = null ) { $this->sort( $this->generateSortByPropertyClosure( $property, $direction ) ); return $this; }
[ "public", "function", "sortByProperty", "(", "$", "property", ",", "$", "direction", "=", "null", ")", "{", "$", "this", "->", "sort", "(", "$", "this", "->", "generateSortByPropertyClosure", "(", "$", "property", ",", "$", "direction", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sort container by property @param property $property @param SORT_ASC|SORT_DESC $direction @return Container
[ "Sort", "container", "by", "property" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L386-L390
train
squareproton/Bond
src/Bond/Container.php
Container.checkEntity
private function checkEntity( $obj ) { if( $class = $this->classGet() and !( $obj instanceof $class ) ) { throw new \InvalidArgumentException( sprintf( 'Obj %s is not compatible with Container of class %s', get_class( $obj ), $class ) ); } return true; }
php
private function checkEntity( $obj ) { if( $class = $this->classGet() and !( $obj instanceof $class ) ) { throw new \InvalidArgumentException( sprintf( 'Obj %s is not compatible with Container of class %s', get_class( $obj ), $class ) ); } return true; }
[ "private", "function", "checkEntity", "(", "$", "obj", ")", "{", "if", "(", "$", "class", "=", "$", "this", "->", "classGet", "(", ")", "and", "!", "(", "$", "obj", "instanceof", "$", "class", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Obj %s is not compatible with Container of class %s'", ",", "get_class", "(", "$", "obj", ")", ",", "$", "class", ")", ")", ";", "}", "return", "true", ";", "}" ]
Check an entity implments ContainerInterface. It should be the same type of entities already in collection. @param mixed $obj @return bool
[ "Check", "an", "entity", "implments", "ContainerInterface", ".", "It", "should", "be", "the", "same", "type", "of", "entities", "already", "in", "collection", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L458-L470
train
squareproton/Bond
src/Bond/Container.php
Container.checkEntityArray
private function checkEntityArray( array $entityArray, &$error = null ) { // get class if( $existing = $this->classGet() ) { foreach( $entityArray as $value ) { if( !( $value instanceof $existing ) ) { $error = "Can't add entity of class `".get_class( $value )."` to container of class `{$existing}`."; return false; } } } $error = ''; return true; }
php
private function checkEntityArray( array $entityArray, &$error = null ) { // get class if( $existing = $this->classGet() ) { foreach( $entityArray as $value ) { if( !( $value instanceof $existing ) ) { $error = "Can't add entity of class `".get_class( $value )."` to container of class `{$existing}`."; return false; } } } $error = ''; return true; }
[ "private", "function", "checkEntityArray", "(", "array", "$", "entityArray", ",", "&", "$", "error", "=", "null", ")", "{", "// get class", "if", "(", "$", "existing", "=", "$", "this", "->", "classGet", "(", ")", ")", "{", "foreach", "(", "$", "entityArray", "as", "$", "value", ")", "{", "if", "(", "!", "(", "$", "value", "instanceof", "$", "existing", ")", ")", "{", "$", "error", "=", "\"Can't add entity of class `\"", ".", "get_class", "(", "$", "value", ")", ".", "\"` to container of class `{$existing}`.\"", ";", "return", "false", ";", "}", "}", "}", "$", "error", "=", "''", ";", "return", "true", ";", "}" ]
Check if a array of Entity's is compatible with this container @param array $entityArray @return bool
[ "Check", "if", "a", "array", "of", "Entity", "s", "is", "compatible", "with", "this", "container" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L477-L490
train
squareproton/Bond
src/Bond/Container.php
Container.contains
public function contains() { $output = true; $args = func_get_args(); // support a arbritary number objects against which to test while( list(,$value) = each($args) and $output ) { // is entity if( $value instanceof Container ) { $numChecking = count( $value ); $numContained = count( array_intersect_key( $value->collection, $this->collection ) ); $testResult = $numChecking === $numContained; } elseif ( is_object($value) ) { $testResult = false !== array_search( $value, $this->collection, true ); // is null or null like. See, http://en.wikipedia.org/wiki/Empty_set. All containers contain the empty container } elseif ( is_null( $value ) or $value === array() ){ $testResult = true; // is a array or container } elseif ( is_array( $value ) ) { $testResult = true; while( list(,$entity) = each( $value ) and $testResult ) { $testResult = ( $this->search( $entity ) !== false or !$entity ); } // something else } else { throw new BadTypeException( $value, 'Container|array|obj' ); } $output = ( $output and $testResult ); } return $output; }
php
public function contains() { $output = true; $args = func_get_args(); // support a arbritary number objects against which to test while( list(,$value) = each($args) and $output ) { // is entity if( $value instanceof Container ) { $numChecking = count( $value ); $numContained = count( array_intersect_key( $value->collection, $this->collection ) ); $testResult = $numChecking === $numContained; } elseif ( is_object($value) ) { $testResult = false !== array_search( $value, $this->collection, true ); // is null or null like. See, http://en.wikipedia.org/wiki/Empty_set. All containers contain the empty container } elseif ( is_null( $value ) or $value === array() ){ $testResult = true; // is a array or container } elseif ( is_array( $value ) ) { $testResult = true; while( list(,$entity) = each( $value ) and $testResult ) { $testResult = ( $this->search( $entity ) !== false or !$entity ); } // something else } else { throw new BadTypeException( $value, 'Container|array|obj' ); } $output = ( $output and $testResult ); } return $output; }
[ "public", "function", "contains", "(", ")", "{", "$", "output", "=", "true", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "// support a arbritary number objects against which to test", "while", "(", "list", "(", ",", "$", "value", ")", "=", "each", "(", "$", "args", ")", "and", "$", "output", ")", "{", "// is entity", "if", "(", "$", "value", "instanceof", "Container", ")", "{", "$", "numChecking", "=", "count", "(", "$", "value", ")", ";", "$", "numContained", "=", "count", "(", "array_intersect_key", "(", "$", "value", "->", "collection", ",", "$", "this", "->", "collection", ")", ")", ";", "$", "testResult", "=", "$", "numChecking", "===", "$", "numContained", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "testResult", "=", "false", "!==", "array_search", "(", "$", "value", ",", "$", "this", "->", "collection", ",", "true", ")", ";", "// is null or null like. See, http://en.wikipedia.org/wiki/Empty_set. All containers contain the empty container", "}", "elseif", "(", "is_null", "(", "$", "value", ")", "or", "$", "value", "===", "array", "(", ")", ")", "{", "$", "testResult", "=", "true", ";", "// is a array or container", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "testResult", "=", "true", ";", "while", "(", "list", "(", ",", "$", "entity", ")", "=", "each", "(", "$", "value", ")", "and", "$", "testResult", ")", "{", "$", "testResult", "=", "(", "$", "this", "->", "search", "(", "$", "entity", ")", "!==", "false", "or", "!", "$", "entity", ")", ";", "}", "// something else", "}", "else", "{", "throw", "new", "BadTypeException", "(", "$", "value", ",", "'Container|array|obj'", ")", ";", "}", "$", "output", "=", "(", "$", "output", "and", "$", "testResult", ")", ";", "}", "return", "$", "output", ";", "}" ]
Does this container contain the following entities @param ContainerableInterface|Container|ContainerableInterface[] @return boolean
[ "Does", "this", "container", "contain", "the", "following", "entities" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L535-L579
train
squareproton/Bond
src/Bond/Container.php
Container.arrayHelperMethod
private function arrayHelperMethod( $fn, array $args ) { $class = $this->classGet(); $fnArguments = array( $this->collection ); foreach( $args as $container ) { // validate the arguments if( !( $container instanceof $this ) ) { throw new \InvalidArgumentException("You can only `{$fn}` containers."); } $containerClass = $container->classGet(); if( isset($class) and isset( $containerClass ) and ( $class !== $containerClass ) ) { throw new IncompatibleContainerException("Container -> `{$containerClass}` not compatible with `{$class}`"); } $fnArguments[] = $container->collection; } $output = $this->newContainer( call_user_func_array( $fn, $fnArguments ) ); return $output; }
php
private function arrayHelperMethod( $fn, array $args ) { $class = $this->classGet(); $fnArguments = array( $this->collection ); foreach( $args as $container ) { // validate the arguments if( !( $container instanceof $this ) ) { throw new \InvalidArgumentException("You can only `{$fn}` containers."); } $containerClass = $container->classGet(); if( isset($class) and isset( $containerClass ) and ( $class !== $containerClass ) ) { throw new IncompatibleContainerException("Container -> `{$containerClass}` not compatible with `{$class}`"); } $fnArguments[] = $container->collection; } $output = $this->newContainer( call_user_func_array( $fn, $fnArguments ) ); return $output; }
[ "private", "function", "arrayHelperMethod", "(", "$", "fn", ",", "array", "$", "args", ")", "{", "$", "class", "=", "$", "this", "->", "classGet", "(", ")", ";", "$", "fnArguments", "=", "array", "(", "$", "this", "->", "collection", ")", ";", "foreach", "(", "$", "args", "as", "$", "container", ")", "{", "// validate the arguments", "if", "(", "!", "(", "$", "container", "instanceof", "$", "this", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"You can only `{$fn}` containers.\"", ")", ";", "}", "$", "containerClass", "=", "$", "container", "->", "classGet", "(", ")", ";", "if", "(", "isset", "(", "$", "class", ")", "and", "isset", "(", "$", "containerClass", ")", "and", "(", "$", "class", "!==", "$", "containerClass", ")", ")", "{", "throw", "new", "IncompatibleContainerException", "(", "\"Container -> `{$containerClass}` not compatible with `{$class}`\"", ")", ";", "}", "$", "fnArguments", "[", "]", "=", "$", "container", "->", "collection", ";", "}", "$", "output", "=", "$", "this", "->", "newContainer", "(", "call_user_func_array", "(", "$", "fn", ",", "$", "fnArguments", ")", ")", ";", "return", "$", "output", ";", "}" ]
Validation and execution helper method for intersect and diff. @param $fn Callback like object @return Container
[ "Validation", "and", "execution", "helper", "method", "for", "intersect", "and", "diff", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L617-L646
train
squareproton/Bond
src/Bond/Container.php
Container.randomGet
public function randomGet( $n = null, $returnContainer = false, $removeFromContainer = false ) { $n = $n === null ? 1 : (int) $n; // anything to give? if( 0 === $containerSize = $this->count() ) { if( $returnContainer or $n > 1 ) { return $this->newContainer(); } return null; } // single entity if( $n === 1 ) { $key = array_rand( $this->collection ); $entity = $this->collection[$key]; if( $removeFromContainer ) { unset( $this->collection[$key] ); } return $returnContainer ? $this->newContainer( $entity ) : $entity ; } $output = $this->newContainer(); // to protected against the peculiar, $n = 0 still returns one element if( $n > 1 ) { // asking for more than we've got? if( $n <= $containerSize ) { $keys = array_flip( array_rand( $this->collection, $n ) ); $output->add( array_intersect_key( $this->collection, $keys ) ); if( $removeFromContainer ) { $this->collection = array_diff_key( $this->collection, $keys ); } } else { $output->add( $this ); if( $removeFromContainer ) { $this->truncate(); } } } return $output; }
php
public function randomGet( $n = null, $returnContainer = false, $removeFromContainer = false ) { $n = $n === null ? 1 : (int) $n; // anything to give? if( 0 === $containerSize = $this->count() ) { if( $returnContainer or $n > 1 ) { return $this->newContainer(); } return null; } // single entity if( $n === 1 ) { $key = array_rand( $this->collection ); $entity = $this->collection[$key]; if( $removeFromContainer ) { unset( $this->collection[$key] ); } return $returnContainer ? $this->newContainer( $entity ) : $entity ; } $output = $this->newContainer(); // to protected against the peculiar, $n = 0 still returns one element if( $n > 1 ) { // asking for more than we've got? if( $n <= $containerSize ) { $keys = array_flip( array_rand( $this->collection, $n ) ); $output->add( array_intersect_key( $this->collection, $keys ) ); if( $removeFromContainer ) { $this->collection = array_diff_key( $this->collection, $keys ); } } else { $output->add( $this ); if( $removeFromContainer ) { $this->truncate(); } } } return $output; }
[ "public", "function", "randomGet", "(", "$", "n", "=", "null", ",", "$", "returnContainer", "=", "false", ",", "$", "removeFromContainer", "=", "false", ")", "{", "$", "n", "=", "$", "n", "===", "null", "?", "1", ":", "(", "int", ")", "$", "n", ";", "// anything to give?", "if", "(", "0", "===", "$", "containerSize", "=", "$", "this", "->", "count", "(", ")", ")", "{", "if", "(", "$", "returnContainer", "or", "$", "n", ">", "1", ")", "{", "return", "$", "this", "->", "newContainer", "(", ")", ";", "}", "return", "null", ";", "}", "// single entity", "if", "(", "$", "n", "===", "1", ")", "{", "$", "key", "=", "array_rand", "(", "$", "this", "->", "collection", ")", ";", "$", "entity", "=", "$", "this", "->", "collection", "[", "$", "key", "]", ";", "if", "(", "$", "removeFromContainer", ")", "{", "unset", "(", "$", "this", "->", "collection", "[", "$", "key", "]", ")", ";", "}", "return", "$", "returnContainer", "?", "$", "this", "->", "newContainer", "(", "$", "entity", ")", ":", "$", "entity", ";", "}", "$", "output", "=", "$", "this", "->", "newContainer", "(", ")", ";", "// to protected against the peculiar, $n = 0 still returns one element", "if", "(", "$", "n", ">", "1", ")", "{", "// asking for more than we've got?", "if", "(", "$", "n", "<=", "$", "containerSize", ")", "{", "$", "keys", "=", "array_flip", "(", "array_rand", "(", "$", "this", "->", "collection", ",", "$", "n", ")", ")", ";", "$", "output", "->", "add", "(", "array_intersect_key", "(", "$", "this", "->", "collection", ",", "$", "keys", ")", ")", ";", "if", "(", "$", "removeFromContainer", ")", "{", "$", "this", "->", "collection", "=", "array_diff_key", "(", "$", "this", "->", "collection", ",", "$", "keys", ")", ";", "}", "}", "else", "{", "$", "output", "->", "add", "(", "$", "this", ")", ";", "if", "(", "$", "removeFromContainer", ")", "{", "$", "this", "->", "truncate", "(", ")", ";", "}", "}", "}", "return", "$", "output", ";", "}" ]
Return a random number of entities from this collection. If n = 1 you will recieve a entity otherwise you will get a container @param int @param bool Force a container to always be returned @param bool Remove the items from the container as they are returned @return ContainerableInterface|Container
[ "Return", "a", "random", "number", "of", "entities", "from", "this", "collection", ".", "If", "n", "=", "1", "you", "will", "recieve", "a", "entity", "otherwise", "you", "will", "get", "a", "container" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L727-L775
train
squareproton/Bond
src/Bond/Container.php
Container.findByFilterComponents
public function findByFilterComponents( $qty, array $filterComponents ) { // don't use $this copy because we might not be returning a object of exactly the same type $output = $this->copy(); // nothing to filter - return what we've got if( !$filterComponents ) { return $output; } // first attempt - this definately works $filterClosure = function( $obj ) use ( $filterComponents ) { $pass = true; foreach( $filterComponents as $filter ) { // try { $filterResult = $filter->check( $obj ); // } catch ( BadPropertyException $e ) { // print_r( $obj ); // die(); // } if( in_array( $filter->operation, array( 'AND', '', null ) ) ) { $pass = ( $pass and $filterResult ); } elseif( $filter->operation === 'OR' ) { $pass = ( $pass or $filterResult ); } else { throw new \UnknownFilterOperatorException( "I don't know how to handle this operation yet. Sorry." ); } } return $pass; }; // go filter $output->filter( $filterClosure ); // qty outputs if( $qty === FindFilterComponentFactory::FIND_ALL ) { return $output; } switch( $count = count( $output ) ) { case 0: return null; case 1: return $output->pop(); } throw new IncompatibleQtyException( "{$count} entities found - can't return 'one'" ); }
php
public function findByFilterComponents( $qty, array $filterComponents ) { // don't use $this copy because we might not be returning a object of exactly the same type $output = $this->copy(); // nothing to filter - return what we've got if( !$filterComponents ) { return $output; } // first attempt - this definately works $filterClosure = function( $obj ) use ( $filterComponents ) { $pass = true; foreach( $filterComponents as $filter ) { // try { $filterResult = $filter->check( $obj ); // } catch ( BadPropertyException $e ) { // print_r( $obj ); // die(); // } if( in_array( $filter->operation, array( 'AND', '', null ) ) ) { $pass = ( $pass and $filterResult ); } elseif( $filter->operation === 'OR' ) { $pass = ( $pass or $filterResult ); } else { throw new \UnknownFilterOperatorException( "I don't know how to handle this operation yet. Sorry." ); } } return $pass; }; // go filter $output->filter( $filterClosure ); // qty outputs if( $qty === FindFilterComponentFactory::FIND_ALL ) { return $output; } switch( $count = count( $output ) ) { case 0: return null; case 1: return $output->pop(); } throw new IncompatibleQtyException( "{$count} entities found - can't return 'one'" ); }
[ "public", "function", "findByFilterComponents", "(", "$", "qty", ",", "array", "$", "filterComponents", ")", "{", "// don't use $this copy because we might not be returning a object of exactly the same type", "$", "output", "=", "$", "this", "->", "copy", "(", ")", ";", "// nothing to filter - return what we've got", "if", "(", "!", "$", "filterComponents", ")", "{", "return", "$", "output", ";", "}", "// first attempt - this definately works", "$", "filterClosure", "=", "function", "(", "$", "obj", ")", "use", "(", "$", "filterComponents", ")", "{", "$", "pass", "=", "true", ";", "foreach", "(", "$", "filterComponents", "as", "$", "filter", ")", "{", "// try {", "$", "filterResult", "=", "$", "filter", "->", "check", "(", "$", "obj", ")", ";", "// } catch ( BadPropertyException $e ) {", "// print_r( $obj );", "// die();", "// }", "if", "(", "in_array", "(", "$", "filter", "->", "operation", ",", "array", "(", "'AND'", ",", "''", ",", "null", ")", ")", ")", "{", "$", "pass", "=", "(", "$", "pass", "and", "$", "filterResult", ")", ";", "}", "elseif", "(", "$", "filter", "->", "operation", "===", "'OR'", ")", "{", "$", "pass", "=", "(", "$", "pass", "or", "$", "filterResult", ")", ";", "}", "else", "{", "throw", "new", "\\", "UnknownFilterOperatorException", "(", "\"I don't know how to handle this operation yet. Sorry.\"", ")", ";", "}", "}", "return", "$", "pass", ";", "}", ";", "// go filter", "$", "output", "->", "filter", "(", "$", "filterClosure", ")", ";", "// qty outputs", "if", "(", "$", "qty", "===", "FindFilterComponentFactory", "::", "FIND_ALL", ")", "{", "return", "$", "output", ";", "}", "switch", "(", "$", "count", "=", "count", "(", "$", "output", ")", ")", "{", "case", "0", ":", "return", "null", ";", "case", "1", ":", "return", "$", "output", "->", "pop", "(", ")", ";", "}", "throw", "new", "IncompatibleQtyException", "(", "\"{$count} entities found - can't return 'one'\"", ")", ";", "}" ]
Filter a container @param FindFilterComponentFactory::FIND_ALL | FindFilterComponentFactory::FIND_ONE $qty @param Bond\Container\FindFilterComponent[] @return object|Container
[ "Filter", "a", "container" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L838-L893
train
squareproton/Bond
src/Bond/Container.php
Container.classSet
public function classSet( $input ) { if( is_object( $input ) ) { if( $input instanceof self ) { $class = $input->classGet(); } else { $class = get_class( $input ); } } else { $class = $input; } $currentClass = $this->classGet(); if( $currentClass ) { if( $class !== $currentClass ) { throw new \LogicException( "Container has a class already ({$currentClass}) and it differs from your new one ({$class})" ); } return false; } $this->class = $class; return true; }
php
public function classSet( $input ) { if( is_object( $input ) ) { if( $input instanceof self ) { $class = $input->classGet(); } else { $class = get_class( $input ); } } else { $class = $input; } $currentClass = $this->classGet(); if( $currentClass ) { if( $class !== $currentClass ) { throw new \LogicException( "Container has a class already ({$currentClass}) and it differs from your new one ({$class})" ); } return false; } $this->class = $class; return true; }
[ "public", "function", "classSet", "(", "$", "input", ")", "{", "if", "(", "is_object", "(", "$", "input", ")", ")", "{", "if", "(", "$", "input", "instanceof", "self", ")", "{", "$", "class", "=", "$", "input", "->", "classGet", "(", ")", ";", "}", "else", "{", "$", "class", "=", "get_class", "(", "$", "input", ")", ";", "}", "}", "else", "{", "$", "class", "=", "$", "input", ";", "}", "$", "currentClass", "=", "$", "this", "->", "classGet", "(", ")", ";", "if", "(", "$", "currentClass", ")", "{", "if", "(", "$", "class", "!==", "$", "currentClass", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Container has a class already ({$currentClass}) and it differs from your new one ({$class})\"", ")", ";", "}", "return", "false", ";", "}", "$", "this", "->", "class", "=", "$", "class", ";", "return", "true", ";", "}" ]
Set a containers class @param string|Object|Repository|Container class @return bool
[ "Set", "a", "containers", "class" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L900-L922
train
squareproton/Bond
src/Bond/Container.php
Container.classGet
private function classGet() { return isset( $this->class ) ? $this->class : ( ( $firstElement = $this->firstElementGet() ) ? ( $this->class = get_class( $firstElement ) ) : null ) ; }
php
private function classGet() { return isset( $this->class ) ? $this->class : ( ( $firstElement = $this->firstElementGet() ) ? ( $this->class = get_class( $firstElement ) ) : null ) ; }
[ "private", "function", "classGet", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "class", ")", "?", "$", "this", "->", "class", ":", "(", "(", "$", "firstElement", "=", "$", "this", "->", "firstElementGet", "(", ")", ")", "?", "(", "$", "this", "->", "class", "=", "get_class", "(", "$", "firstElement", ")", ")", ":", "null", ")", ";", "}" ]
Get the class of this container. @return string Class | null
[ "Get", "the", "class", "of", "this", "container", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L928-L938
train
squareproton/Bond
src/Bond/Container.php
Container.splitByClass
public function splitByClass() { $classes = array(); foreach( $this->collection as $key => $entity ) { $classes[get_class($entity)][] = $key; } ksort( $classes ); $output = array(); foreach( $classes as $class => $splHashes ) { $container = $this->newContainer(); $container->class = $class; $container->collection = array_intersect_key( $this->collection, array_flip( $splHashes ) ); $output[$class] = $container; } return $output; }
php
public function splitByClass() { $classes = array(); foreach( $this->collection as $key => $entity ) { $classes[get_class($entity)][] = $key; } ksort( $classes ); $output = array(); foreach( $classes as $class => $splHashes ) { $container = $this->newContainer(); $container->class = $class; $container->collection = array_intersect_key( $this->collection, array_flip( $splHashes ) ); $output[$class] = $container; } return $output; }
[ "public", "function", "splitByClass", "(", ")", "{", "$", "classes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "collection", "as", "$", "key", "=>", "$", "entity", ")", "{", "$", "classes", "[", "get_class", "(", "$", "entity", ")", "]", "[", "]", "=", "$", "key", ";", "}", "ksort", "(", "$", "classes", ")", ";", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", "=>", "$", "splHashes", ")", "{", "$", "container", "=", "$", "this", "->", "newContainer", "(", ")", ";", "$", "container", "->", "class", "=", "$", "class", ";", "$", "container", "->", "collection", "=", "array_intersect_key", "(", "$", "this", "->", "collection", ",", "array_flip", "(", "$", "splHashes", ")", ")", ";", "$", "output", "[", "$", "class", "]", "=", "$", "container", ";", "}", "return", "$", "output", ";", "}" ]
Split by class @return array of containers
[ "Split", "by", "class" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L944-L965
train
squareproton/Bond
src/Bond/Container.php
Container.implode
public function implode( $glue, $propertyOrClosure = null ) { if( null === $propertyOrClosure ) { $pieces = $this->map('strval'); } elseif ( $propertyOrClosure instanceof \Closure ) { $pieces = $this->map( $propertyOrClosure ); } else { $pieces = $this->map( $this->generateGetPropertyClosure( $propertyOrClosure ) ); } return implode( $glue, $pieces ); }
php
public function implode( $glue, $propertyOrClosure = null ) { if( null === $propertyOrClosure ) { $pieces = $this->map('strval'); } elseif ( $propertyOrClosure instanceof \Closure ) { $pieces = $this->map( $propertyOrClosure ); } else { $pieces = $this->map( $this->generateGetPropertyClosure( $propertyOrClosure ) ); } return implode( $glue, $pieces ); }
[ "public", "function", "implode", "(", "$", "glue", ",", "$", "propertyOrClosure", "=", "null", ")", "{", "if", "(", "null", "===", "$", "propertyOrClosure", ")", "{", "$", "pieces", "=", "$", "this", "->", "map", "(", "'strval'", ")", ";", "}", "elseif", "(", "$", "propertyOrClosure", "instanceof", "\\", "Closure", ")", "{", "$", "pieces", "=", "$", "this", "->", "map", "(", "$", "propertyOrClosure", ")", ";", "}", "else", "{", "$", "pieces", "=", "$", "this", "->", "map", "(", "$", "this", "->", "generateGetPropertyClosure", "(", "$", "propertyOrClosure", ")", ")", ";", "}", "return", "implode", "(", "$", "glue", ",", "$", "pieces", ")", ";", "}" ]
Seems like I'm more and more imploding groups of entities on something @param string $glue @param mixed $propertyOrClosure
[ "Seems", "like", "I", "m", "more", "and", "more", "imploding", "groups", "of", "entities", "on", "something" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L990-L1000
train
squareproton/Bond
src/Bond/Container.php
Container.newContainer
public function newContainer() { $refl = new ReflectionClass($this); $container = $refl->newInstanceArgs(func_get_args()); $container->classSet($this->class); $container->propertyMapper = $this->propertyMapper; return $container; }
php
public function newContainer() { $refl = new ReflectionClass($this); $container = $refl->newInstanceArgs(func_get_args()); $container->classSet($this->class); $container->propertyMapper = $this->propertyMapper; return $container; }
[ "public", "function", "newContainer", "(", ")", "{", "$", "refl", "=", "new", "ReflectionClass", "(", "$", "this", ")", ";", "$", "container", "=", "$", "refl", "->", "newInstanceArgs", "(", "func_get_args", "(", ")", ")", ";", "$", "container", "->", "classSet", "(", "$", "this", "->", "class", ")", ";", "$", "container", "->", "propertyMapper", "=", "$", "this", "->", "propertyMapper", ";", "return", "$", "container", ";", "}" ]
Generate a new empty container of the same type as what is currently instantiated @param string
[ "Generate", "a", "new", "empty", "container", "of", "the", "same", "type", "as", "what", "is", "currently", "instantiated" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container.php#L1006-L1013
train
t-kanstantsin/fileupload
src/FileManager.php
FileManager.init
public function init(): void { parent::init(); if (!($this->contentFS instanceof Filesystem)) { throw new InvalidConfigException(sprintf('ContentFS must be instance of %s.', Filesystem::class)); } if (!($this->cacheFS instanceof Filesystem)) { throw new InvalidConfigException(sprintf('CacheFS must be instance of %s.', Filesystem::class)); } $this->iconGenerator = IconGenerator::build($this->iconSet); $this->formatterFactory = new FormatterFactory((array) $this->formatterConfigArray); $this->aliasFactory = AliasFactory::build($this->defaultAlias); $this->aliasFactory->addMultiple($this->aliasArray); }
php
public function init(): void { parent::init(); if (!($this->contentFS instanceof Filesystem)) { throw new InvalidConfigException(sprintf('ContentFS must be instance of %s.', Filesystem::class)); } if (!($this->cacheFS instanceof Filesystem)) { throw new InvalidConfigException(sprintf('CacheFS must be instance of %s.', Filesystem::class)); } $this->iconGenerator = IconGenerator::build($this->iconSet); $this->formatterFactory = new FormatterFactory((array) $this->formatterConfigArray); $this->aliasFactory = AliasFactory::build($this->defaultAlias); $this->aliasFactory->addMultiple($this->aliasArray); }
[ "public", "function", "init", "(", ")", ":", "void", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "!", "(", "$", "this", "->", "contentFS", "instanceof", "Filesystem", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "sprintf", "(", "'ContentFS must be instance of %s.'", ",", "Filesystem", "::", "class", ")", ")", ";", "}", "if", "(", "!", "(", "$", "this", "->", "cacheFS", "instanceof", "Filesystem", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "sprintf", "(", "'CacheFS must be instance of %s.'", ",", "Filesystem", "::", "class", ")", ")", ";", "}", "$", "this", "->", "iconGenerator", "=", "IconGenerator", "::", "build", "(", "$", "this", "->", "iconSet", ")", ";", "$", "this", "->", "formatterFactory", "=", "new", "FormatterFactory", "(", "(", "array", ")", "$", "this", "->", "formatterConfigArray", ")", ";", "$", "this", "->", "aliasFactory", "=", "AliasFactory", "::", "build", "(", "$", "this", "->", "defaultAlias", ")", ";", "$", "this", "->", "aliasFactory", "->", "addMultiple", "(", "$", "this", "->", "aliasArray", ")", ";", "}" ]
Check initialization parameters and parse configs @throws config\InvalidConfigException
[ "Check", "initialization", "parameters", "and", "parse", "configs" ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/FileManager.php#L78-L93
train
t-kanstantsin/fileupload
src/FileManager.php
FileManager.getFilePath
public function getFilePath(IFile $file, string $format, array $formatterConfig = []): ?string { $alias = $this->getAliasConfig($file->getModelAlias()); $formatter = $this->buildFormatter($file, $format, $formatterConfig); $targetPath = $alias->getAssetPath($file, $format); if (!$this->cacheFile($file, $formatter, $targetPath)) { return null; } return $targetPath; }
php
public function getFilePath(IFile $file, string $format, array $formatterConfig = []): ?string { $alias = $this->getAliasConfig($file->getModelAlias()); $formatter = $this->buildFormatter($file, $format, $formatterConfig); $targetPath = $alias->getAssetPath($file, $format); if (!$this->cacheFile($file, $formatter, $targetPath)) { return null; } return $targetPath; }
[ "public", "function", "getFilePath", "(", "IFile", "$", "file", ",", "string", "$", "format", ",", "array", "$", "formatterConfig", "=", "[", "]", ")", ":", "?", "string", "{", "$", "alias", "=", "$", "this", "->", "getAliasConfig", "(", "$", "file", "->", "getModelAlias", "(", ")", ")", ";", "$", "formatter", "=", "$", "this", "->", "buildFormatter", "(", "$", "file", ",", "$", "format", ",", "$", "formatterConfig", ")", ";", "$", "targetPath", "=", "$", "alias", "->", "getAssetPath", "(", "$", "file", ",", "$", "format", ")", ";", "if", "(", "!", "$", "this", "->", "cacheFile", "(", "$", "file", ",", "$", "formatter", ",", "$", "targetPath", ")", ")", "{", "return", "null", ";", "}", "return", "$", "targetPath", ";", "}" ]
Caches file and returns url to it. @param IFile $file @param string $format @param array $formatterConfig @return string|null path to image in cacheFS or null if fails @throws \InvalidArgumentException @throws \RuntimeException @throws \League\Flysystem\FileNotFoundException @throws InvalidConfigException
[ "Caches", "file", "and", "returns", "url", "to", "it", "." ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/FileManager.php#L156-L167
train
t-kanstantsin/fileupload
src/FileManager.php
FileManager.cacheFile
protected function cacheFile(IFile $file, FileFormatter $formatter, string $targetPath): bool { if ($file instanceof ICacheStateful && $file->getIsCached($formatter->name)) { return true; } return (new Saver($file, $this->cacheFS, $targetPath))->save($formatter); }
php
protected function cacheFile(IFile $file, FileFormatter $formatter, string $targetPath): bool { if ($file instanceof ICacheStateful && $file->getIsCached($formatter->name)) { return true; } return (new Saver($file, $this->cacheFS, $targetPath))->save($formatter); }
[ "protected", "function", "cacheFile", "(", "IFile", "$", "file", ",", "FileFormatter", "$", "formatter", ",", "string", "$", "targetPath", ")", ":", "bool", "{", "if", "(", "$", "file", "instanceof", "ICacheStateful", "&&", "$", "file", "->", "getIsCached", "(", "$", "formatter", "->", "name", ")", ")", "{", "return", "true", ";", "}", "return", "(", "new", "Saver", "(", "$", "file", ",", "$", "this", "->", "cacheFS", ",", "$", "targetPath", ")", ")", "->", "save", "(", "$", "formatter", ")", ";", "}" ]
Caches file available in web. @param IFile $file @param FileFormatter $formatter @param string $targetPath @return bool @throws \InvalidArgumentException @throws InvalidConfigException @throws \League\Flysystem\FileNotFoundException
[ "Caches", "file", "available", "in", "web", "." ]
d6317a9b9b36d992f09affe3900ef7d7ddfd855f
https://github.com/t-kanstantsin/fileupload/blob/d6317a9b9b36d992f09affe3900ef7d7ddfd855f/src/FileManager.php#L180-L187
train
polusphp/polus-middleware
src/HttpError.php
HttpError.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $response = $handler->handle($request); $code = $response->getStatusCode(); $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors); if (in_array($code, $allowedCodes)) { if (!$response->getBody()->getSize()) { $format = FormatNegotiator::getPreferredFormat($request); if (isset($this->renderer[$code])) { $content = $this->renderer[$code]($format); } else { $content = $this->defaultRenderer($code, $format); } if (is_array($content)) { $content = json_encode($content); } $body = $this->streamFactory->createStream($content); $response = $response->withBody($body); $response = $response->withStatus($code); if ($format === 'json') { $response = $response->withHeader('content-type', 'application/json'); } else { $response = $response->withHeader('content-type', 'text/html; charset=utf-8'); } } } return $response; }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $response = $handler->handle($request); $code = $response->getStatusCode(); $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors); if (in_array($code, $allowedCodes)) { if (!$response->getBody()->getSize()) { $format = FormatNegotiator::getPreferredFormat($request); if (isset($this->renderer[$code])) { $content = $this->renderer[$code]($format); } else { $content = $this->defaultRenderer($code, $format); } if (is_array($content)) { $content = json_encode($content); } $body = $this->streamFactory->createStream($content); $response = $response->withBody($body); $response = $response->withStatus($code); if ($format === 'json') { $response = $response->withHeader('content-type', 'application/json'); } else { $response = $response->withHeader('content-type', 'text/html; charset=utf-8'); } } } return $response; }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "$", "response", "=", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "$", "code", "=", "$", "response", "->", "getStatusCode", "(", ")", ";", "$", "allowedCodes", "=", "array_keys", "(", "$", "this", "->", "renderer", ")", "+", "array_keys", "(", "$", "this", "->", "defaultErrors", ")", ";", "if", "(", "in_array", "(", "$", "code", ",", "$", "allowedCodes", ")", ")", "{", "if", "(", "!", "$", "response", "->", "getBody", "(", ")", "->", "getSize", "(", ")", ")", "{", "$", "format", "=", "FormatNegotiator", "::", "getPreferredFormat", "(", "$", "request", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "renderer", "[", "$", "code", "]", ")", ")", "{", "$", "content", "=", "$", "this", "->", "renderer", "[", "$", "code", "]", "(", "$", "format", ")", ";", "}", "else", "{", "$", "content", "=", "$", "this", "->", "defaultRenderer", "(", "$", "code", ",", "$", "format", ")", ";", "}", "if", "(", "is_array", "(", "$", "content", ")", ")", "{", "$", "content", "=", "json_encode", "(", "$", "content", ")", ";", "}", "$", "body", "=", "$", "this", "->", "streamFactory", "->", "createStream", "(", "$", "content", ")", ";", "$", "response", "=", "$", "response", "->", "withBody", "(", "$", "body", ")", ";", "$", "response", "=", "$", "response", "->", "withStatus", "(", "$", "code", ")", ";", "if", "(", "$", "format", "===", "'json'", ")", "{", "$", "response", "=", "$", "response", "->", "withHeader", "(", "'content-type'", ",", "'application/json'", ")", ";", "}", "else", "{", "$", "response", "=", "$", "response", "->", "withHeader", "(", "'content-type'", ",", "'text/html; charset=utf-8'", ")", ";", "}", "}", "}", "return", "$", "response", ";", "}" ]
Execute the middleware.
[ "Execute", "the", "middleware", "." ]
c265c51fbdf6b2c5ed85686415b47a1fbf720c57
https://github.com/polusphp/polus-middleware/blob/c265c51fbdf6b2c5ed85686415b47a1fbf720c57/src/HttpError.php#L89-L122
train
ARCANESOFT/Auth
src/ViewComposers/Dashboard/OnlineUsersCountComposer.php
OnlineUsersCountComposer.getOnlineUsers
private function getOnlineUsers() { $date = Carbon::now()->subMinutes( config('arcanesoft.auth.track-activity.minutes', 5) ); return $this->getCachedUsers()->filter(function (User $user) use ($date) { return ! is_null($user->last_activity) && $user->last_activity->gte($date); }); }
php
private function getOnlineUsers() { $date = Carbon::now()->subMinutes( config('arcanesoft.auth.track-activity.minutes', 5) ); return $this->getCachedUsers()->filter(function (User $user) use ($date) { return ! is_null($user->last_activity) && $user->last_activity->gte($date); }); }
[ "private", "function", "getOnlineUsers", "(", ")", "{", "$", "date", "=", "Carbon", "::", "now", "(", ")", "->", "subMinutes", "(", "config", "(", "'arcanesoft.auth.track-activity.minutes'", ",", "5", ")", ")", ";", "return", "$", "this", "->", "getCachedUsers", "(", ")", "->", "filter", "(", "function", "(", "User", "$", "user", ")", "use", "(", "$", "date", ")", "{", "return", "!", "is_null", "(", "$", "user", "->", "last_activity", ")", "&&", "$", "user", "->", "last_activity", "->", "gte", "(", "$", "date", ")", ";", "}", ")", ";", "}" ]
Get the online users. @return \Illuminate\Database\Eloquent\Collection
[ "Get", "the", "online", "users", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/ViewComposers/Dashboard/OnlineUsersCountComposer.php#L45-L54
train
AnonymPHP/Anonym-Route
ModelDispatcher.php
ModelDispatcher.model
public function model($name = '', $namespace = null) { if (null === $name) { $namespace = $this->namespace; } $namespace = $this->resolveNamespace($namespace); $model = $this->model = $this->createModelInstance($namespace, $name); return $model; }
php
public function model($name = '', $namespace = null) { if (null === $name) { $namespace = $this->namespace; } $namespace = $this->resolveNamespace($namespace); $model = $this->model = $this->createModelInstance($namespace, $name); return $model; }
[ "public", "function", "model", "(", "$", "name", "=", "''", ",", "$", "namespace", "=", "null", ")", "{", "if", "(", "null", "===", "$", "name", ")", "{", "$", "namespace", "=", "$", "this", "->", "namespace", ";", "}", "$", "namespace", "=", "$", "this", "->", "resolveNamespace", "(", "$", "namespace", ")", ";", "$", "model", "=", "$", "this", "->", "model", "=", "$", "this", "->", "createModelInstance", "(", "$", "namespace", ",", "$", "name", ")", ";", "return", "$", "model", ";", "}" ]
create and return model instance @param string $name @param null $namespace @return mixed
[ "create", "and", "return", "model", "instance" ]
bb7f8004fbbd2998af8b0061f404f026f11466ab
https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ModelDispatcher.php#L40-L50
train
fulgurio/LightCMSBundle
Extension/LightCMSTwigExtension.php
LightCMSTwigExtension.getDataForBreadcrumb
public function getDataForBreadcrumb(Page $page) { $parent = $page->getParent(); if ($parent) { $data = array(); if ($parent->getParent()) { $data = array_merge($this->getDataForBreadcrumb($parent), $data); } $data[] = $parent; return $data; } return NULL; }
php
public function getDataForBreadcrumb(Page $page) { $parent = $page->getParent(); if ($parent) { $data = array(); if ($parent->getParent()) { $data = array_merge($this->getDataForBreadcrumb($parent), $data); } $data[] = $parent; return $data; } return NULL; }
[ "public", "function", "getDataForBreadcrumb", "(", "Page", "$", "page", ")", "{", "$", "parent", "=", "$", "page", "->", "getParent", "(", ")", ";", "if", "(", "$", "parent", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "parent", "->", "getParent", "(", ")", ")", "{", "$", "data", "=", "array_merge", "(", "$", "this", "->", "getDataForBreadcrumb", "(", "$", "parent", ")", ",", "$", "data", ")", ";", "}", "$", "data", "[", "]", "=", "$", "parent", ";", "return", "$", "data", ";", "}", "return", "NULL", ";", "}" ]
Get breadcrumb data @param Page $page @return array|NULL
[ "Get", "breadcrumb", "data" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Extension/LightCMSTwigExtension.php#L87-L101
train
fulgurio/LightCMSBundle
Extension/LightCMSTwigExtension.php
LightCMSTwigExtension.allowChildren
public function allowChildren(Page $page) { $models = $this->container->getParameter('fulgurio_light_cms.models'); return $models[$page->getModel()]['allow_children']; }
php
public function allowChildren(Page $page) { $models = $this->container->getParameter('fulgurio_light_cms.models'); return $models[$page->getModel()]['allow_children']; }
[ "public", "function", "allowChildren", "(", "Page", "$", "page", ")", "{", "$", "models", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fulgurio_light_cms.models'", ")", ";", "return", "$", "models", "[", "$", "page", "->", "getModel", "(", ")", "]", "[", "'allow_children'", "]", ";", "}" ]
Check if page model allow children @param Page $page
[ "Check", "if", "page", "model", "allow", "children" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Extension/LightCMSTwigExtension.php#L108-L112
train
fulgurio/LightCMSBundle
Extension/LightCMSTwigExtension.php
LightCMSTwigExtension.needTranslatedPages
public function needTranslatedPages(Page $page) { // Route page if (!$page->getParent() || !is_null($page->getSourceId())) { return FALSE; } if ($this->container->hasParameter('fulgurio_light_cms.languages')) { $availableLangs = $this->container->getParameter('fulgurio_light_cms.languages'); $nbAvailableLangs = count($availableLangs); $availableTranslatedPages = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findBy(array('source_id' => $page->getId()), array('lang' => 'ASC')); $nbAvailableTranslatedPages = count($availableTranslatedPages); $availableTranslatedParents = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findBy(array('source_id' => $page->getParent()->getId()), array('lang' => 'ASC')); $nbAvailableTranslatedParents = count($availableTranslatedParents); // If we create a new page if ($page->getParent()->getMetaValue('is_home') == '1' && $nbAvailableLangs != $availableTranslatedPages) { $langs = array_flip($availableLangs); foreach ($availableTranslatedPages as $availableTranslatedPage) { unset($langs[$availableTranslatedPage->getLang()]); } foreach ($langs as $lang => $value) { if ($lang == $page->getLang()) { unset($langs[$lang]); } else { $langs[$lang] = $page->getParent()->getId(); } } return $langs; } // Normal children page else if ($nbAvailableTranslatedPages != $nbAvailableTranslatedParents && $nbAvailableTranslatedParents < $nbAvailableLangs) { $langs = array_flip($availableLangs); foreach ($availableTranslatedPages as $availableTranslatedPage) { unset($langs[$availableTranslatedPage->getLang()]); } foreach ($availableTranslatedParents as $availableTranslatedParent) { if (isset($langs[$availableTranslatedParent->getLang()])) { $langs[$availableTranslatedParent->getLang()] = $availableTranslatedParent->getId(); } } foreach ($langs as $lang => $value) { if (is_null($value) || $lang == $page->getLang()) { unset($langs[$lang]); } } return $langs; } } return FALSE; }
php
public function needTranslatedPages(Page $page) { // Route page if (!$page->getParent() || !is_null($page->getSourceId())) { return FALSE; } if ($this->container->hasParameter('fulgurio_light_cms.languages')) { $availableLangs = $this->container->getParameter('fulgurio_light_cms.languages'); $nbAvailableLangs = count($availableLangs); $availableTranslatedPages = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findBy(array('source_id' => $page->getId()), array('lang' => 'ASC')); $nbAvailableTranslatedPages = count($availableTranslatedPages); $availableTranslatedParents = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findBy(array('source_id' => $page->getParent()->getId()), array('lang' => 'ASC')); $nbAvailableTranslatedParents = count($availableTranslatedParents); // If we create a new page if ($page->getParent()->getMetaValue('is_home') == '1' && $nbAvailableLangs != $availableTranslatedPages) { $langs = array_flip($availableLangs); foreach ($availableTranslatedPages as $availableTranslatedPage) { unset($langs[$availableTranslatedPage->getLang()]); } foreach ($langs as $lang => $value) { if ($lang == $page->getLang()) { unset($langs[$lang]); } else { $langs[$lang] = $page->getParent()->getId(); } } return $langs; } // Normal children page else if ($nbAvailableTranslatedPages != $nbAvailableTranslatedParents && $nbAvailableTranslatedParents < $nbAvailableLangs) { $langs = array_flip($availableLangs); foreach ($availableTranslatedPages as $availableTranslatedPage) { unset($langs[$availableTranslatedPage->getLang()]); } foreach ($availableTranslatedParents as $availableTranslatedParent) { if (isset($langs[$availableTranslatedParent->getLang()])) { $langs[$availableTranslatedParent->getLang()] = $availableTranslatedParent->getId(); } } foreach ($langs as $lang => $value) { if (is_null($value) || $lang == $page->getLang()) { unset($langs[$lang]); } } return $langs; } } return FALSE; }
[ "public", "function", "needTranslatedPages", "(", "Page", "$", "page", ")", "{", "// Route page", "if", "(", "!", "$", "page", "->", "getParent", "(", ")", "||", "!", "is_null", "(", "$", "page", "->", "getSourceId", "(", ")", ")", ")", "{", "return", "FALSE", ";", "}", "if", "(", "$", "this", "->", "container", "->", "hasParameter", "(", "'fulgurio_light_cms.languages'", ")", ")", "{", "$", "availableLangs", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fulgurio_light_cms.languages'", ")", ";", "$", "nbAvailableLangs", "=", "count", "(", "$", "availableLangs", ")", ";", "$", "availableTranslatedPages", "=", "$", "this", "->", "doctrine", "->", "getRepository", "(", "'FulgurioLightCMSBundle:Page'", ")", "->", "findBy", "(", "array", "(", "'source_id'", "=>", "$", "page", "->", "getId", "(", ")", ")", ",", "array", "(", "'lang'", "=>", "'ASC'", ")", ")", ";", "$", "nbAvailableTranslatedPages", "=", "count", "(", "$", "availableTranslatedPages", ")", ";", "$", "availableTranslatedParents", "=", "$", "this", "->", "doctrine", "->", "getRepository", "(", "'FulgurioLightCMSBundle:Page'", ")", "->", "findBy", "(", "array", "(", "'source_id'", "=>", "$", "page", "->", "getParent", "(", ")", "->", "getId", "(", ")", ")", ",", "array", "(", "'lang'", "=>", "'ASC'", ")", ")", ";", "$", "nbAvailableTranslatedParents", "=", "count", "(", "$", "availableTranslatedParents", ")", ";", "// If we create a new page", "if", "(", "$", "page", "->", "getParent", "(", ")", "->", "getMetaValue", "(", "'is_home'", ")", "==", "'1'", "&&", "$", "nbAvailableLangs", "!=", "$", "availableTranslatedPages", ")", "{", "$", "langs", "=", "array_flip", "(", "$", "availableLangs", ")", ";", "foreach", "(", "$", "availableTranslatedPages", "as", "$", "availableTranslatedPage", ")", "{", "unset", "(", "$", "langs", "[", "$", "availableTranslatedPage", "->", "getLang", "(", ")", "]", ")", ";", "}", "foreach", "(", "$", "langs", "as", "$", "lang", "=>", "$", "value", ")", "{", "if", "(", "$", "lang", "==", "$", "page", "->", "getLang", "(", ")", ")", "{", "unset", "(", "$", "langs", "[", "$", "lang", "]", ")", ";", "}", "else", "{", "$", "langs", "[", "$", "lang", "]", "=", "$", "page", "->", "getParent", "(", ")", "->", "getId", "(", ")", ";", "}", "}", "return", "$", "langs", ";", "}", "// Normal children page", "else", "if", "(", "$", "nbAvailableTranslatedPages", "!=", "$", "nbAvailableTranslatedParents", "&&", "$", "nbAvailableTranslatedParents", "<", "$", "nbAvailableLangs", ")", "{", "$", "langs", "=", "array_flip", "(", "$", "availableLangs", ")", ";", "foreach", "(", "$", "availableTranslatedPages", "as", "$", "availableTranslatedPage", ")", "{", "unset", "(", "$", "langs", "[", "$", "availableTranslatedPage", "->", "getLang", "(", ")", "]", ")", ";", "}", "foreach", "(", "$", "availableTranslatedParents", "as", "$", "availableTranslatedParent", ")", "{", "if", "(", "isset", "(", "$", "langs", "[", "$", "availableTranslatedParent", "->", "getLang", "(", ")", "]", ")", ")", "{", "$", "langs", "[", "$", "availableTranslatedParent", "->", "getLang", "(", ")", "]", "=", "$", "availableTranslatedParent", "->", "getId", "(", ")", ";", "}", "}", "foreach", "(", "$", "langs", "as", "$", "lang", "=>", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", "||", "$", "lang", "==", "$", "page", "->", "getLang", "(", ")", ")", "{", "unset", "(", "$", "langs", "[", "$", "lang", "]", ")", ";", "}", "}", "return", "$", "langs", ";", "}", "}", "return", "FALSE", ";", "}" ]
Get parent page to copy page for translation @param Page $page @return multitype:number
[ "Get", "parent", "page", "to", "copy", "page", "for", "translation" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Extension/LightCMSTwigExtension.php#L119-L181
train
fulgurio/LightCMSBundle
Extension/LightCMSTwigExtension.php
LightCMSTwigExtension.thumb
public function thumb($media, $size = 'small') { $thumbSizes = $this->container->getParameter('fulgurio_light_cms.thumbs'); return LightCMSUtils::getThumbFilename($media->getFullPath(), $media->getMediaType(), $thumbSizes[$size]); }
php
public function thumb($media, $size = 'small') { $thumbSizes = $this->container->getParameter('fulgurio_light_cms.thumbs'); return LightCMSUtils::getThumbFilename($media->getFullPath(), $media->getMediaType(), $thumbSizes[$size]); }
[ "public", "function", "thumb", "(", "$", "media", ",", "$", "size", "=", "'small'", ")", "{", "$", "thumbSizes", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'fulgurio_light_cms.thumbs'", ")", ";", "return", "LightCMSUtils", "::", "getThumbFilename", "(", "$", "media", "->", "getFullPath", "(", ")", ",", "$", "media", "->", "getMediaType", "(", ")", ",", "$", "thumbSizes", "[", "$", "size", "]", ")", ";", "}" ]
Get thumb of a picture @param Page $page
[ "Get", "thumb", "of", "a", "picture" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Extension/LightCMSTwigExtension.php#L188-L192
train
fulgurio/LightCMSBundle
Extension/LightCMSTwigExtension.php
LightCMSTwigExtension.getPagesMenu
public function getPagesMenu($menuName, $lang = NULL) { // $currentUser = $this->securityContext->getToken()->getUser(); // if ($currentUser != 'anon.') // { // $roles = $currentUser->getRoles(); // } // else // { // $roles = array(); // } $pages = $this->doctrine->getRepository('FulgurioLightCMSBundle:PageMenu')->findPagesOfMenu($menuName, $lang); $availablePages = array(); foreach ($pages as &$page) { // $pageAccesses = $page->getAccess(); // if (empty($pageAccesses)) // { // $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page)); $availablePages[] = $page; // } // else if (is_object($currentUser)) // { // foreach ($pageAccesses as $pageAccess) // { // if ($currentUser->hasRole($pageAccess)) // { // $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page)); // $availablePages[] = $page; // break; // } // } // } } return $availablePages; }
php
public function getPagesMenu($menuName, $lang = NULL) { // $currentUser = $this->securityContext->getToken()->getUser(); // if ($currentUser != 'anon.') // { // $roles = $currentUser->getRoles(); // } // else // { // $roles = array(); // } $pages = $this->doctrine->getRepository('FulgurioLightCMSBundle:PageMenu')->findPagesOfMenu($menuName, $lang); $availablePages = array(); foreach ($pages as &$page) { // $pageAccesses = $page->getAccess(); // if (empty($pageAccesses)) // { // $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page)); $availablePages[] = $page; // } // else if (is_object($currentUser)) // { // foreach ($pageAccesses as $pageAccess) // { // if ($currentUser->hasRole($pageAccess)) // { // $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page)); // $availablePages[] = $page; // break; // } // } // } } return $availablePages; }
[ "public", "function", "getPagesMenu", "(", "$", "menuName", ",", "$", "lang", "=", "NULL", ")", "{", "// $currentUser = $this->securityContext->getToken()->getUser();", "// if ($currentUser != 'anon.')", "// {", "// $roles = $currentUser->getRoles();", "// }", "// else", "// {", "// $roles = array();", "// }", "$", "pages", "=", "$", "this", "->", "doctrine", "->", "getRepository", "(", "'FulgurioLightCMSBundle:PageMenu'", ")", "->", "findPagesOfMenu", "(", "$", "menuName", ",", "$", "lang", ")", ";", "$", "availablePages", "=", "array", "(", ")", ";", "foreach", "(", "$", "pages", "as", "&", "$", "page", ")", "{", "// $pageAccesses = $page->getAccess();", "// if (empty($pageAccesses))", "// {", "// $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page));", "$", "availablePages", "[", "]", "=", "$", "page", ";", "// }", "// else if (is_object($currentUser))", "// {", "// foreach ($pageAccesses as $pageAccess)", "// {", "// if ($currentUser->hasRole($pageAccess))", "// {", "// $page->setAllowedChildren($this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->getAllowedChildren($roles, $page));", "// $availablePages[] = $page;", "// break;", "// }", "// }", "// }", "}", "return", "$", "availablePages", ";", "}" ]
Get page menu to display @param string $menuName @param string $lang @return array
[ "Get", "page", "menu", "to", "display" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Extension/LightCMSTwigExtension.php#L201-L236
train
koolkode/k2
src/Instrument/InstrumentorLoader.php
InstrumentorLoader.getHash
public function getHash() { $data = []; foreach($this->instrumentors as $instrumentor) { $data[get_class($instrumentor)] = NULL; if($instrumentor instanceof CachingInstrumentorInterface) { $data[get_class($instrumentor)] = $instrumentor->getHash(); } else { $data[get_class($instrumentor)] = NULL; } } ksort($data); if($this->needsSort) { sort($this->nameBlacklist); sort($this->supertypeBlacklist); $this->needsSort = false; } $prefix = md5(implode('|', $this->nameBlacklist)); $prefix .= md5(implode('|', $this->supertypeBlacklist)); return $prefix . md5(implode('|', array_keys($data)) . '*' . implode('|', array_filter($data, function($el) { return $el !== NULL; }))); }
php
public function getHash() { $data = []; foreach($this->instrumentors as $instrumentor) { $data[get_class($instrumentor)] = NULL; if($instrumentor instanceof CachingInstrumentorInterface) { $data[get_class($instrumentor)] = $instrumentor->getHash(); } else { $data[get_class($instrumentor)] = NULL; } } ksort($data); if($this->needsSort) { sort($this->nameBlacklist); sort($this->supertypeBlacklist); $this->needsSort = false; } $prefix = md5(implode('|', $this->nameBlacklist)); $prefix .= md5(implode('|', $this->supertypeBlacklist)); return $prefix . md5(implode('|', array_keys($data)) . '*' . implode('|', array_filter($data, function($el) { return $el !== NULL; }))); }
[ "public", "function", "getHash", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "instrumentors", "as", "$", "instrumentor", ")", "{", "$", "data", "[", "get_class", "(", "$", "instrumentor", ")", "]", "=", "NULL", ";", "if", "(", "$", "instrumentor", "instanceof", "CachingInstrumentorInterface", ")", "{", "$", "data", "[", "get_class", "(", "$", "instrumentor", ")", "]", "=", "$", "instrumentor", "->", "getHash", "(", ")", ";", "}", "else", "{", "$", "data", "[", "get_class", "(", "$", "instrumentor", ")", "]", "=", "NULL", ";", "}", "}", "ksort", "(", "$", "data", ")", ";", "if", "(", "$", "this", "->", "needsSort", ")", "{", "sort", "(", "$", "this", "->", "nameBlacklist", ")", ";", "sort", "(", "$", "this", "->", "supertypeBlacklist", ")", ";", "$", "this", "->", "needsSort", "=", "false", ";", "}", "$", "prefix", "=", "md5", "(", "implode", "(", "'|'", ",", "$", "this", "->", "nameBlacklist", ")", ")", ";", "$", "prefix", ".=", "md5", "(", "implode", "(", "'|'", ",", "$", "this", "->", "supertypeBlacklist", ")", ")", ";", "return", "$", "prefix", ".", "md5", "(", "implode", "(", "'|'", ",", "array_keys", "(", "$", "data", ")", ")", ".", "'*'", ".", "implode", "(", "'|'", ",", "array_filter", "(", "$", "data", ",", "function", "(", "$", "el", ")", "{", "return", "$", "el", "!==", "NULL", ";", "}", ")", ")", ")", ";", "}" ]
Get a hash computed from the the fully-qualified names of all registered instrumentors. @return string
[ "Get", "a", "hash", "computed", "from", "the", "the", "fully", "-", "qualified", "names", "of", "all", "registered", "instrumentors", "." ]
c425a1bc7d2f8c567b1b0cc724ca9e8be7087397
https://github.com/koolkode/k2/blob/c425a1bc7d2f8c567b1b0cc724ca9e8be7087397/src/Instrument/InstrumentorLoader.php#L72-L106
train
koolkode/k2
src/Instrument/InstrumentorLoader.php
InstrumentorLoader.getLastModified
public function getLastModified() { $mtime = 0; foreach($this->instrumentors as $instrumentor) { $mtime = max($mtime, filemtime((new \ReflectionClass($instrumentor))->getFileName())); if($instrumentor instanceof CachingInstrumentorInterface) { $mtime = max($mtime, $instrumentor->getLastModified()); } } return (int)$mtime; }
php
public function getLastModified() { $mtime = 0; foreach($this->instrumentors as $instrumentor) { $mtime = max($mtime, filemtime((new \ReflectionClass($instrumentor))->getFileName())); if($instrumentor instanceof CachingInstrumentorInterface) { $mtime = max($mtime, $instrumentor->getLastModified()); } } return (int)$mtime; }
[ "public", "function", "getLastModified", "(", ")", "{", "$", "mtime", "=", "0", ";", "foreach", "(", "$", "this", "->", "instrumentors", "as", "$", "instrumentor", ")", "{", "$", "mtime", "=", "max", "(", "$", "mtime", ",", "filemtime", "(", "(", "new", "\\", "ReflectionClass", "(", "$", "instrumentor", ")", ")", "->", "getFileName", "(", ")", ")", ")", ";", "if", "(", "$", "instrumentor", "instanceof", "CachingInstrumentorInterface", ")", "{", "$", "mtime", "=", "max", "(", "$", "mtime", ",", "$", "instrumentor", "->", "getLastModified", "(", ")", ")", ";", "}", "}", "return", "(", "int", ")", "$", "mtime", ";", "}" ]
Get the most-recent modification time computed from all registered instrumentors. @return integer
[ "Get", "the", "most", "-", "recent", "modification", "time", "computed", "from", "all", "registered", "instrumentors", "." ]
c425a1bc7d2f8c567b1b0cc724ca9e8be7087397
https://github.com/koolkode/k2/blob/c425a1bc7d2f8c567b1b0cc724ca9e8be7087397/src/Instrument/InstrumentorLoader.php#L113-L128
train
prolic/HumusMvc
src/HumusMvc/Dispatcher.php
Dispatcher.isDispatchable
public function isDispatchable(Request $request) { $className = $this->getControllerClass($request); if (($this->_defaultModule != $this->_curModule) || $this->getParam('prefixDefaultModule')) { $className = $this->formatClassName($this->_curModule, $className); } if (class_exists($className)) { return true; } return false; }
php
public function isDispatchable(Request $request) { $className = $this->getControllerClass($request); if (($this->_defaultModule != $this->_curModule) || $this->getParam('prefixDefaultModule')) { $className = $this->formatClassName($this->_curModule, $className); } if (class_exists($className)) { return true; } return false; }
[ "public", "function", "isDispatchable", "(", "Request", "$", "request", ")", "{", "$", "className", "=", "$", "this", "->", "getControllerClass", "(", "$", "request", ")", ";", "if", "(", "(", "$", "this", "->", "_defaultModule", "!=", "$", "this", "->", "_curModule", ")", "||", "$", "this", "->", "getParam", "(", "'prefixDefaultModule'", ")", ")", "{", "$", "className", "=", "$", "this", "->", "formatClassName", "(", "$", "this", "->", "_curModule", ",", "$", "className", ")", ";", "}", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns TRUE if the Zend_Controller_Request_Abstract object can be dispatched to a controller. Use this method wisely. By default, the dispatcher will fall back to the default controller (either in the module specified or the global default) if a given controller does not exist. This method returning false does not necessarily indicate the dispatcher will not still dispatch the call. @param Request $action @return boolean
[ "Returns", "TRUE", "if", "the", "Zend_Controller_Request_Abstract", "object", "can", "be", "dispatched", "to", "a", "controller", "." ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Dispatcher.php#L73-L85
train
libreworks/caridea-session
src/Values.php
Values.init
protected function init(): bool { if (!isset($_SESSION[$this->name])) { $_SESSION[$this->name] = []; } return true; }
php
protected function init(): bool { if (!isset($_SESSION[$this->name])) { $_SESSION[$this->name] = []; } return true; }
[ "protected", "function", "init", "(", ")", ":", "bool", "{", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "name", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "this", "->", "name", "]", "=", "[", "]", ";", "}", "return", "true", ";", "}" ]
Initializes the session. @return bool Always `true`
[ "Initializes", "the", "session", "." ]
cb2a7c0cdcd172edbf267e5c69b396708b425f47
https://github.com/libreworks/caridea-session/blob/cb2a7c0cdcd172edbf267e5c69b396708b425f47/src/Values.php#L180-L186
train
SlaxWeb/Config
src/Handler.php
Handler.set
public function set(string $key, $value): bool { if (is_string($key) === false || $key === "") { return false; } $this->_configValues[$key] = $value; return true; }
php
public function set(string $key, $value): bool { if (is_string($key) === false || $key === "") { return false; } $this->_configValues[$key] = $value; return true; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "value", ")", ":", "bool", "{", "if", "(", "is_string", "(", "$", "key", ")", "===", "false", "||", "$", "key", "===", "\"\"", ")", "{", "return", "false", ";", "}", "$", "this", "->", "_configValues", "[", "$", "key", "]", "=", "$", "value", ";", "return", "true", ";", "}" ]
Set config item Set a new config item, ro overwrite an existing item. @param string $key Config item key @param mixed $value Config item value @return bool
[ "Set", "config", "item" ]
92e75c3538d3903e00f5c52507bc0a322c4d1f11
https://github.com/SlaxWeb/Config/blob/92e75c3538d3903e00f5c52507bc0a322c4d1f11/src/Handler.php#L85-L93
train
SlaxWeb/Config
src/Handler.php
Handler.get
public function get(string $key) { return isset($this->_configValues[$key]) ? $this->_configValues[$key] : null; }
php
public function get(string $key) { return isset($this->_configValues[$key]) ? $this->_configValues[$key] : null; }
[ "public", "function", "get", "(", "string", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "_configValues", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_configValues", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get config item Get a config item from the internal config container. On a missing key, return null. @param string $key Config item key @return mixed
[ "Get", "config", "item" ]
92e75c3538d3903e00f5c52507bc0a322c4d1f11
https://github.com/SlaxWeb/Config/blob/92e75c3538d3903e00f5c52507bc0a322c4d1f11/src/Handler.php#L104-L109
train
SlaxWeb/Config
src/Handler.php
Handler.remove
public function remove(string $key): bool { if (isset($this->_configValues[$key]) === false) { return false; } unset($this->_configValues[$key]); return true; }
php
public function remove(string $key): bool { if (isset($this->_configValues[$key]) === false) { return false; } unset($this->_configValues[$key]); return true; }
[ "public", "function", "remove", "(", "string", "$", "key", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "_configValues", "[", "$", "key", "]", ")", "===", "false", ")", "{", "return", "false", ";", "}", "unset", "(", "$", "this", "->", "_configValues", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}" ]
Remove config item Check if an item with provided key exists, and remove it. @param string $key Config item key @return bool
[ "Remove", "config", "item" ]
92e75c3538d3903e00f5c52507bc0a322c4d1f11
https://github.com/SlaxWeb/Config/blob/92e75c3538d3903e00f5c52507bc0a322c4d1f11/src/Handler.php#L119-L127
train
SlaxWeb/Config
src/Handler.php
Handler.prependResourceName
public function prependResourceName( array $loadedConfig, string $resName ): array { $prefixedConf = []; foreach ($loadedConfig as $key => $value) { $prefixedConf["{$resName}.{$key}"] = $value; } return $prefixedConf; }
php
public function prependResourceName( array $loadedConfig, string $resName ): array { $prefixedConf = []; foreach ($loadedConfig as $key => $value) { $prefixedConf["{$resName}.{$key}"] = $value; } return $prefixedConf; }
[ "public", "function", "prependResourceName", "(", "array", "$", "loadedConfig", ",", "string", "$", "resName", ")", ":", "array", "{", "$", "prefixedConf", "=", "[", "]", ";", "foreach", "(", "$", "loadedConfig", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "prefixedConf", "[", "\"{$resName}.{$key}\"", "]", "=", "$", "value", ";", "}", "return", "$", "prefixedConf", ";", "}" ]
Prepend resource name to keys Prepends the resource name to the keys defined in loaded configuration array. @param array $loadedConfig The loaded config @param string $resName Resource name, that is prepended to the keys @return array Loaded config with keys prepended by resource name
[ "Prepend", "resource", "name", "to", "keys" ]
92e75c3538d3903e00f5c52507bc0a322c4d1f11
https://github.com/SlaxWeb/Config/blob/92e75c3538d3903e00f5c52507bc0a322c4d1f11/src/Handler.php#L152-L161
train
SlaxWeb/Config
src/Handler.php
Handler._getAbsPath
protected function _getAbsPath(string $resName): string { foreach ($this->_resDir as $dir) { $absPath = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $resName; if (file_exists($absPath)) { return $absPath; } } return ""; }
php
protected function _getAbsPath(string $resName): string { foreach ($this->_resDir as $dir) { $absPath = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $resName; if (file_exists($absPath)) { return $absPath; } } return ""; }
[ "protected", "function", "_getAbsPath", "(", "string", "$", "resName", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "_resDir", "as", "$", "dir", ")", "{", "$", "absPath", "=", "rtrim", "(", "$", "dir", ",", "DIRECTORY_SEPARATOR", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "resName", ";", "if", "(", "file_exists", "(", "$", "absPath", ")", ")", "{", "return", "$", "absPath", ";", "}", "}", "return", "\"\"", ";", "}" ]
Get resource absolute path Iterate the Resource Location array and return the absolute path of the resource. Return empty string if resource does not exist in any of the directories. @param string $resName Name of the resource @return string
[ "Get", "resource", "absolute", "path" ]
92e75c3538d3903e00f5c52507bc0a322c4d1f11
https://github.com/SlaxWeb/Config/blob/92e75c3538d3903e00f5c52507bc0a322c4d1f11/src/Handler.php#L199-L212
train
enikeishik/ufoframework
src/Ufo/Core/Result.php
Result.changeHeader
public function changeHeader(string $name, string $value): void { // if (!array_key_exists($name, $this->headers)) { // throw new NotFoundException(); // } $this->headers[$name] = $value; }
php
public function changeHeader(string $name, string $value): void { // if (!array_key_exists($name, $this->headers)) { // throw new NotFoundException(); // } $this->headers[$name] = $value; }
[ "public", "function", "changeHeader", "(", "string", "$", "name", ",", "string", "$", "value", ")", ":", "void", "{", "// if (!array_key_exists($name, $this->headers)) {", "// throw new NotFoundException();", "// }", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "}" ]
Changes header value. @param string $name @param string $value @return void
[ "Changes", "header", "value", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Result.php#L107-L113
train
enikeishik/ufoframework
src/Ufo/Core/Result.php
Result.changeHeaders
public function changeHeaders(callable $callback): void { foreach ($this->headers as $name => $value) { $this->headers[$name] = call_user_func($callback, $name, $value); } }
php
public function changeHeaders(callable $callback): void { foreach ($this->headers as $name => $value) { $this->headers[$name] = call_user_func($callback, $name, $value); } }
[ "public", "function", "changeHeaders", "(", "callable", "$", "callback", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "call_user_func", "(", "$", "callback", ",", "$", "name", ",", "$", "value", ")", ";", "}", "}" ]
Changes headers using callback function. @param callable $callback @return void
[ "Changes", "headers", "using", "callback", "function", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Result.php#L120-L125
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Resource/ResourceFactory.php
ResourceFactory.applyEntity
public function applyEntity(Resource $resource, EntityInterface $entity) { $this->validateResourceTypes($resource->getEntityType(), $entity->getType()); $document->pushData($entity); return $this; }
php
public function applyEntity(Resource $resource, EntityInterface $entity) { $this->validateResourceTypes($resource->getEntityType(), $entity->getType()); $document->pushData($entity); return $this; }
[ "public", "function", "applyEntity", "(", "Resource", "$", "resource", ",", "EntityInterface", "$", "entity", ")", "{", "$", "this", "->", "validateResourceTypes", "(", "$", "resource", "->", "getEntityType", "(", ")", ",", "$", "entity", "->", "getType", "(", ")", ")", ";", "$", "document", "->", "pushData", "(", "$", "entity", ")", ";", "return", "$", "this", ";", "}" ]
Applies an entity or entity identifier to a resource. @param Resource $document The primary resource. @param EntityInterface $entity The entity or entity identifier to add. @return self
[ "Applies", "an", "entity", "or", "entity", "identifier", "to", "a", "resource", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/ResourceFactory.php#L73-L78
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Resource/ResourceFactory.php
ResourceFactory.applyRelationships
public function applyRelationships(Entity $owner, $data) { $this->validateData($data); $meta = $this->mf->getMetadataForType($owner->getType()); foreach ($meta->getRelationships() as $key => $relationship) { if (!isset($data[$key]) || !$data[$key] instanceof EntityInterface) { continue; } $this->applyRelationship($owner, $key, $data[$key]); } return $this; }
php
public function applyRelationships(Entity $owner, $data) { $this->validateData($data); $meta = $this->mf->getMetadataForType($owner->getType()); foreach ($meta->getRelationships() as $key => $relationship) { if (!isset($data[$key]) || !$data[$key] instanceof EntityInterface) { continue; } $this->applyRelationship($owner, $key, $data[$key]); } return $this; }
[ "public", "function", "applyRelationships", "(", "Entity", "$", "owner", ",", "$", "data", ")", "{", "$", "this", "->", "validateData", "(", "$", "data", ")", ";", "$", "meta", "=", "$", "this", "->", "mf", "->", "getMetadataForType", "(", "$", "owner", "->", "getType", "(", ")", ")", ";", "foreach", "(", "$", "meta", "->", "getRelationships", "(", ")", "as", "$", "key", "=>", "$", "relationship", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "key", "]", ")", "||", "!", "$", "data", "[", "$", "key", "]", "instanceof", "EntityInterface", ")", "{", "continue", ";", "}", "$", "this", "->", "applyRelationship", "(", "$", "owner", ",", "$", "key", ",", "$", "data", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Applies an array or array-like set of relationship data to an entity. Each array member must be a EntityInterface object keyed by the relationship field key. @param Entity $owner The owning entity. @param array|\ArrayAccess $data The resource data to apply. @return self
[ "Applies", "an", "array", "or", "array", "-", "like", "set", "of", "relationship", "data", "to", "an", "entity", ".", "Each", "array", "member", "must", "be", "a", "EntityInterface", "object", "keyed", "by", "the", "relationship", "field", "key", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/ResourceFactory.php#L88-L99
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Resource/ResourceFactory.php
ResourceFactory.applyRelationship
public function applyRelationship(Entity $owner, $fieldKey, EntityInterface $related) { $meta = $this->em->getMetadataForType($owner->getType()); if (false === $meta->hasRelationship($fieldKey)) { throw new InvalidArgumentException('The resource "%s" does not contain relationship field "%s"', $owner->getType(), $fieldKey); } $relMeta = $meta->getRelationship($fieldKey); $this->validateResourceTypes($relMeta->getEntityType(), $related->getType()); $relationship = $this->createRelationship($fieldKey, $relMeta->getType()); $relationship->pushData($related); $owner->addRelationship($relationship); return $this; }
php
public function applyRelationship(Entity $owner, $fieldKey, EntityInterface $related) { $meta = $this->em->getMetadataForType($owner->getType()); if (false === $meta->hasRelationship($fieldKey)) { throw new InvalidArgumentException('The resource "%s" does not contain relationship field "%s"', $owner->getType(), $fieldKey); } $relMeta = $meta->getRelationship($fieldKey); $this->validateResourceTypes($relMeta->getEntityType(), $related->getType()); $relationship = $this->createRelationship($fieldKey, $relMeta->getType()); $relationship->pushData($related); $owner->addRelationship($relationship); return $this; }
[ "public", "function", "applyRelationship", "(", "Entity", "$", "owner", ",", "$", "fieldKey", ",", "EntityInterface", "$", "related", ")", "{", "$", "meta", "=", "$", "this", "->", "em", "->", "getMetadataForType", "(", "$", "owner", "->", "getType", "(", ")", ")", ";", "if", "(", "false", "===", "$", "meta", "->", "hasRelationship", "(", "$", "fieldKey", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The resource \"%s\" does not contain relationship field \"%s\"'", ",", "$", "owner", "->", "getType", "(", ")", ",", "$", "fieldKey", ")", ";", "}", "$", "relMeta", "=", "$", "meta", "->", "getRelationship", "(", "$", "fieldKey", ")", ";", "$", "this", "->", "validateResourceTypes", "(", "$", "relMeta", "->", "getEntityType", "(", ")", ",", "$", "related", "->", "getType", "(", ")", ")", ";", "$", "relationship", "=", "$", "this", "->", "createRelationship", "(", "$", "fieldKey", ",", "$", "relMeta", "->", "getType", "(", ")", ")", ";", "$", "relationship", "->", "pushData", "(", "$", "related", ")", ";", "$", "owner", "->", "addRelationship", "(", "$", "relationship", ")", ";", "return", "$", "this", ";", "}" ]
Applies a single relationship to an owning resource via a related resource object. @param Entity $owner The owning entity to apply the relationship to. @param string $fieldKey The relationship field key. @param EntityInterface $related The related EntityInterface to add to the owner. @throws InvalidArgumentException If the relationship field key does not exist on the owner. @return self
[ "Applies", "a", "single", "relationship", "to", "an", "owning", "resource", "via", "a", "related", "resource", "object", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/ResourceFactory.php#L110-L123
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Resource/ResourceFactory.php
ResourceFactory.applyAttributes
public function applyAttributes(Resource $entity, $data) { $this->validateData($data); $meta = $this->em->getMetadataFor($entity->getType()); foreach ($meta->getAttributes() as $key => $attribute) { if (!isset($data[$key])) { continue; } $this->applyAttribute($entity, $key, $data[$key]); } return $this; }
php
public function applyAttributes(Resource $entity, $data) { $this->validateData($data); $meta = $this->em->getMetadataFor($entity->getType()); foreach ($meta->getAttributes() as $key => $attribute) { if (!isset($data[$key])) { continue; } $this->applyAttribute($entity, $key, $data[$key]); } return $this; }
[ "public", "function", "applyAttributes", "(", "Resource", "$", "entity", ",", "$", "data", ")", "{", "$", "this", "->", "validateData", "(", "$", "data", ")", ";", "$", "meta", "=", "$", "this", "->", "em", "->", "getMetadataFor", "(", "$", "entity", "->", "getType", "(", ")", ")", ";", "foreach", "(", "$", "meta", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$", "attribute", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "applyAttribute", "(", "$", "entity", ",", "$", "key", ",", "$", "data", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Applies an array or array-like set of attribute data to an entity. Each array member must be keyed by the attribute field key. @param Entity $entity The entity to apply the attributes to. @param array|\ArrayAccess $data The attribute data to apply. @return self
[ "Applies", "an", "array", "or", "array", "-", "like", "set", "of", "attribute", "data", "to", "an", "entity", ".", "Each", "array", "member", "must", "be", "keyed", "by", "the", "attribute", "field", "key", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/ResourceFactory.php#L133-L144
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Resource/ResourceFactory.php
ResourceFactory.applyAttribute
public function applyAttribute(Entity $entity, $fieldKey, $value) { $entity->addAttribute($this->createAttribute($fieldKey, $value)); return $this; }
php
public function applyAttribute(Entity $entity, $fieldKey, $value) { $entity->addAttribute($this->createAttribute($fieldKey, $value)); return $this; }
[ "public", "function", "applyAttribute", "(", "Entity", "$", "entity", ",", "$", "fieldKey", ",", "$", "value", ")", "{", "$", "entity", "->", "addAttribute", "(", "$", "this", "->", "createAttribute", "(", "$", "fieldKey", ",", "$", "value", ")", ")", ";", "return", "$", "this", ";", "}" ]
Applies a single attribute value to a resource. @param Entity $entity The entity to apply the attribute value to. @param string $fieldKey The attribute field key. @param mixed $value The attribute value. @return self
[ "Applies", "a", "single", "attribute", "value", "to", "a", "resource", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Resource/ResourceFactory.php#L155-L159
train
Palmabit-IT/library
src/Palmabit/Library/Repository/EloquentBaseRepository.php
EloquentBaseRepository.update
public function update($id, array $data) { $obj = $this->find($id); Event::fire('repository.updating', [$obj, $data]); $obj->update($data); return $obj; }
php
public function update($id, array $data) { $obj = $this->find($id); Event::fire('repository.updating', [$obj, $data]); $obj->update($data); return $obj; }
[ "public", "function", "update", "(", "$", "id", ",", "array", "$", "data", ")", "{", "$", "obj", "=", "$", "this", "->", "find", "(", "$", "id", ")", ";", "Event", "::", "fire", "(", "'repository.updating'", ",", "[", "$", "obj", ",", "$", "data", "]", ")", ";", "$", "obj", "->", "update", "(", "$", "data", ")", ";", "return", "$", "obj", ";", "}" ]
Update a new object @param id @param array $data @return mixed @throws \Illuminate\Database\Eloquent\ModelNotFoundException
[ "Update", "a", "new", "object" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Repository/EloquentBaseRepository.php#L43-L49
train
Palmabit-IT/library
src/Palmabit/Library/Repository/EloquentBaseRepository.php
EloquentBaseRepository.delete
public function delete($id) { $obj = $this->find($id); Event::fire('repository.deleting', [$obj]); return $obj->delete(); }
php
public function delete($id) { $obj = $this->find($id); Event::fire('repository.deleting', [$obj]); return $obj->delete(); }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "obj", "=", "$", "this", "->", "find", "(", "$", "id", ")", ";", "Event", "::", "fire", "(", "'repository.deleting'", ",", "[", "$", "obj", "]", ")", ";", "return", "$", "obj", "->", "delete", "(", ")", ";", "}" ]
Deletes a new object @param $id @return mixed @throws \Illuminate\Database\Eloquent\ModelNotFoundException
[ "Deletes", "a", "new", "object" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Repository/EloquentBaseRepository.php#L57-L62
train
shgysk8zer0/core_api
traits/socket_common.php
Socket_Common.socketCreatePair
final public function socketCreatePair($domain, $type, $protocol, array &$fd) { return socket_create_pair($domain, $type, $protocol, $fd); }
php
final public function socketCreatePair($domain, $type, $protocol, array &$fd) { return socket_create_pair($domain, $type, $protocol, $fd); }
[ "final", "public", "function", "socketCreatePair", "(", "$", "domain", ",", "$", "type", ",", "$", "protocol", ",", "array", "&", "$", "fd", ")", "{", "return", "socket_create_pair", "(", "$", "domain", ",", "$", "type", ",", "$", "protocol", ",", "$", "fd", ")", ";", "}" ]
Creates a pair of indistinguishable sockets and stores them in an array @param int $domain The protocol family to be used by the socket @param int $type The type of communication to be used by the socket @param int $protocol The specific protocol within the specified domain @param array $fd Reference to an array in which the two socket resources will be inserted
[ "Creates", "a", "pair", "of", "indistinguishable", "sockets", "and", "stores", "them", "in", "an", "array" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/socket_common.php#L37-L40
train
shgysk8zer0/core_api
traits/socket_common.php
Socket_Common.socketSetOption
final public function socketSetOption($optname, $optval, $level = SOL_SOCKET) { return socket_set_option($this->socket, $level, $optname, $optval); }
php
final public function socketSetOption($optname, $optval, $level = SOL_SOCKET) { return socket_set_option($this->socket, $level, $optname, $optval); }
[ "final", "public", "function", "socketSetOption", "(", "$", "optname", ",", "$", "optval", ",", "$", "level", "=", "SOL_SOCKET", ")", "{", "return", "socket_set_option", "(", "$", "this", "->", "socket", ",", "$", "level", ",", "$", "optname", ",", "$", "optval", ")", ";", "}" ]
Sets socket options for the socket @param int $optname Same as those for the socket_get_option() function @param mixed $optval The option value @param int $level The protocol level at which the option resides
[ "Sets", "socket", "options", "for", "the", "socket" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/socket_common.php#L72-L75
train
shgysk8zer0/core_api
traits/socket_common.php
Socket_Common.socketSend
final public function socketSend($buff, $len, $flags = MSG_OOB) { return socket_send( $this->socket, $buff, is_int($len) ? $len : strlen($buff), $flags ); }
php
final public function socketSend($buff, $len, $flags = MSG_OOB) { return socket_send( $this->socket, $buff, is_int($len) ? $len : strlen($buff), $flags ); }
[ "final", "public", "function", "socketSend", "(", "$", "buff", ",", "$", "len", ",", "$", "flags", "=", "MSG_OOB", ")", "{", "return", "socket_send", "(", "$", "this", "->", "socket", ",", "$", "buff", ",", "is_int", "(", "$", "len", ")", "?", "$", "len", ":", "strlen", "(", "$", "buff", ")", ",", "$", "flags", ")", ";", "}" ]
Sends data to a connected socket @param string $buff A buffer containing the data that will be sent @param int $len The number of bytes that will be sent @param int $flags MSG_(OOB|EOR|EOF|DOUNTROUTE) joined with the binary OR (|) operator @return int The number of bytes sent
[ "Sends", "data", "to", "a", "connected", "socket" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/socket_common.php#L163-L171
train
shgysk8zer0/core_api
traits/socket_common.php
Socket_Common.socketSendto
final public function socketSendto($buf, $len, $flags, $addr, $port = 0) { return socket_sendto($this->socket, $buf, $len, $flags, $addr, $port); }
php
final public function socketSendto($buf, $len, $flags, $addr, $port = 0) { return socket_sendto($this->socket, $buf, $len, $flags, $addr, $port); }
[ "final", "public", "function", "socketSendto", "(", "$", "buf", ",", "$", "len", ",", "$", "flags", ",", "$", "addr", ",", "$", "port", "=", "0", ")", "{", "return", "socket_sendto", "(", "$", "this", "->", "socket", ",", "$", "buf", ",", "$", "len", ",", "$", "flags", ",", "$", "addr", ",", "$", "port", ")", ";", "}" ]
Sends a message to a socket, whether it is connected or not @param string $buf The sent data @param int $len len bytes from buf will be sent @param int $flags MSG_(OOB|EOR|EOF|DONTROUTE) joined with the binary OR (|) operator @param int $addr IP address of the remote host @param int $port The remote port number at which the data will be sent @return int
[ "Sends", "a", "message", "to", "a", "socket", "whether", "it", "is", "connected", "or", "not" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/socket_common.php#L195-L198
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.listAction
public function listAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Storage'); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $rep StorageRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Storage'); return $this->render('AnimeDbCatalogBundle:Storage:list.html.twig', [ 'storages' => $rep->getList(), ], $response); }
php
public function listAction(Request $request) { $response = $this->getCacheTimeKeeper()->getResponse('AnimeDbCatalogBundle:Storage'); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $rep StorageRepository */ $rep = $this->getDoctrine()->getRepository('AnimeDbCatalogBundle:Storage'); return $this->render('AnimeDbCatalogBundle:Storage:list.html.twig', [ 'storages' => $rep->getList(), ], $response); }
[ "public", "function", "listAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", "'AnimeDbCatalogBundle:Storage'", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "/* @var $rep StorageRepository */", "$", "rep", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'AnimeDbCatalogBundle:Storage'", ")", ";", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Storage:list.html.twig'", ",", "[", "'storages'", "=>", "$", "rep", "->", "getList", "(", ")", ",", "]", ",", "$", "response", ")", ";", "}" ]
Storage list. @param Request $request @return Response
[ "Storage", "list", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L42-L56
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.changeAction
public function changeAction(Storage $storage, Request $request) { $response = $this->getCacheTimeKeeper()->getResponse($storage->getDateUpdate()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $form Form */ $form = $this->createForm(new StorageForm(), $storage); if ($request->getMethod() == 'POST') { $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); } } return $this->render('AnimeDbCatalogBundle:Storage:change.html.twig', [ 'storage' => $storage, 'form' => $form->createView(), ], $response); }
php
public function changeAction(Storage $storage, Request $request) { $response = $this->getCacheTimeKeeper()->getResponse($storage->getDateUpdate()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $form Form */ $form = $this->createForm(new StorageForm(), $storage); if ($request->getMethod() == 'POST') { $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); } } return $this->render('AnimeDbCatalogBundle:Storage:change.html.twig', [ 'storage' => $storage, 'form' => $form->createView(), ], $response); }
[ "public", "function", "changeAction", "(", "Storage", "$", "storage", ",", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", "$", "storage", "->", "getDateUpdate", "(", ")", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "/* @var $form Form */", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "StorageForm", "(", ")", ",", "$", "storage", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "==", "'POST'", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "storage", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'storage_list'", ")", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Storage:change.html.twig'", ",", "[", "'storage'", "=>", "$", "storage", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "]", ",", "$", "response", ")", ";", "}" ]
Change storage. @param Storage $storage @param Request $request @return Response
[ "Change", "storage", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L66-L92
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.addAction
public function addAction(Request $request) { $storage = new Storage(); /* @var $form Form */ $form = $this->createForm(new StorageForm(), $storage); if ($request->getMethod() == 'POST') { $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); } } return $this->render('AnimeDbCatalogBundle:Storage:add.html.twig', [ 'form' => $form->createView(), 'guide' => $this->get('anime_db.api.client')->getSiteUrl(self::GUIDE_LINK), ]); }
php
public function addAction(Request $request) { $storage = new Storage(); /* @var $form Form */ $form = $this->createForm(new StorageForm(), $storage); if ($request->getMethod() == 'POST') { $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); } } return $this->render('AnimeDbCatalogBundle:Storage:add.html.twig', [ 'form' => $form->createView(), 'guide' => $this->get('anime_db.api.client')->getSiteUrl(self::GUIDE_LINK), ]); }
[ "public", "function", "addAction", "(", "Request", "$", "request", ")", "{", "$", "storage", "=", "new", "Storage", "(", ")", ";", "/* @var $form Form */", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "StorageForm", "(", ")", ",", "$", "storage", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "==", "'POST'", ")", "{", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "storage", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'storage_list'", ")", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Storage:add.html.twig'", ",", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", "'guide'", "=>", "$", "this", "->", "get", "(", "'anime_db.api.client'", ")", "->", "getSiteUrl", "(", "self", "::", "GUIDE_LINK", ")", ",", "]", ")", ";", "}" ]
Add storage. @param Request $request @return Response
[ "Add", "storage", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L101-L123
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.deleteAction
public function deleteAction(Storage $storage) { $em = $this->getDoctrine()->getManager(); $em->remove($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); }
php
public function deleteAction(Storage $storage) { $em = $this->getDoctrine()->getManager(); $em->remove($storage); $em->flush(); return $this->redirect($this->generateUrl('storage_list')); }
[ "public", "function", "deleteAction", "(", "Storage", "$", "storage", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "storage", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'storage_list'", ")", ")", ";", "}" ]
Delete storage. @param Storage $storage @return Response
[ "Delete", "storage", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L132-L139
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.getPathAction
public function getPathAction(Request $request) { /* @var $response JsonResponse */ $response = $this->getCacheTimeKeeper() ->getResponse('AnimeDbCatalogBundle:Storage', -1, new JsonResponse()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $storage Storage */ $storage = $this->getDoctrine()->getManager() ->find('AnimeDbCatalogBundle:Storage', $request->get('id')); return $response->setData([ 'required' => $storage->isPathRequired(), 'path' => $storage->getPath(), ]); }
php
public function getPathAction(Request $request) { /* @var $response JsonResponse */ $response = $this->getCacheTimeKeeper() ->getResponse('AnimeDbCatalogBundle:Storage', -1, new JsonResponse()); // response was not modified for this request if ($response->isNotModified($request)) { return $response; } /* @var $storage Storage */ $storage = $this->getDoctrine()->getManager() ->find('AnimeDbCatalogBundle:Storage', $request->get('id')); return $response->setData([ 'required' => $storage->isPathRequired(), 'path' => $storage->getPath(), ]); }
[ "public", "function", "getPathAction", "(", "Request", "$", "request", ")", "{", "/* @var $response JsonResponse */", "$", "response", "=", "$", "this", "->", "getCacheTimeKeeper", "(", ")", "->", "getResponse", "(", "'AnimeDbCatalogBundle:Storage'", ",", "-", "1", ",", "new", "JsonResponse", "(", ")", ")", ";", "// response was not modified for this request", "if", "(", "$", "response", "->", "isNotModified", "(", "$", "request", ")", ")", "{", "return", "$", "response", ";", "}", "/* @var $storage Storage */", "$", "storage", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "find", "(", "'AnimeDbCatalogBundle:Storage'", ",", "$", "request", "->", "get", "(", "'id'", ")", ")", ";", "return", "$", "response", "->", "setData", "(", "[", "'required'", "=>", "$", "storage", "->", "isPathRequired", "(", ")", ",", "'path'", "=>", "$", "storage", "->", "getPath", "(", ")", ",", "]", ")", ";", "}" ]
Get storage path. @param Request $request @return Response
[ "Get", "storage", "path", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L148-L166
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.scanAction
public function scanAction(Storage $storage) { $this->get('anime_db.storage.scan_executor')->export($storage); return $this->render('AnimeDbCatalogBundle:Storage:scan.html.twig', [ 'storage' => $storage, ]); }
php
public function scanAction(Storage $storage) { $this->get('anime_db.storage.scan_executor')->export($storage); return $this->render('AnimeDbCatalogBundle:Storage:scan.html.twig', [ 'storage' => $storage, ]); }
[ "public", "function", "scanAction", "(", "Storage", "$", "storage", ")", "{", "$", "this", "->", "get", "(", "'anime_db.storage.scan_executor'", ")", "->", "export", "(", "$", "storage", ")", ";", "return", "$", "this", "->", "render", "(", "'AnimeDbCatalogBundle:Storage:scan.html.twig'", ",", "[", "'storage'", "=>", "$", "storage", ",", "]", ")", ";", "}" ]
Scan storage. @param Storage $storage @return Response
[ "Scan", "storage", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L175-L182
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.scanOutputAction
public function scanOutputAction(Storage $storage, Request $request) { $filename = $this->container->getParameter('anime_db.catalog.storage.scan_output'); $filename = sprintf($filename, $storage->getId()); if (!file_exists($filename)) { throw $this->createNotFoundException('Log file is not found'); } $log = file_get_contents($filename); $is_end = $this->isEndOfLog($log); // force stop scan progress if ($is_end) { $this->get('anime_db.storage.scan_executor')->forceStopScan($storage); } return LogResponse::logOffset($log, $request->query->get('offset', 0), $is_end); }
php
public function scanOutputAction(Storage $storage, Request $request) { $filename = $this->container->getParameter('anime_db.catalog.storage.scan_output'); $filename = sprintf($filename, $storage->getId()); if (!file_exists($filename)) { throw $this->createNotFoundException('Log file is not found'); } $log = file_get_contents($filename); $is_end = $this->isEndOfLog($log); // force stop scan progress if ($is_end) { $this->get('anime_db.storage.scan_executor')->forceStopScan($storage); } return LogResponse::logOffset($log, $request->query->get('offset', 0), $is_end); }
[ "public", "function", "scanOutputAction", "(", "Storage", "$", "storage", ",", "Request", "$", "request", ")", "{", "$", "filename", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'anime_db.catalog.storage.scan_output'", ")", ";", "$", "filename", "=", "sprintf", "(", "$", "filename", ",", "$", "storage", "->", "getId", "(", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Log file is not found'", ")", ";", "}", "$", "log", "=", "file_get_contents", "(", "$", "filename", ")", ";", "$", "is_end", "=", "$", "this", "->", "isEndOfLog", "(", "$", "log", ")", ";", "// force stop scan progress", "if", "(", "$", "is_end", ")", "{", "$", "this", "->", "get", "(", "'anime_db.storage.scan_executor'", ")", "->", "forceStopScan", "(", "$", "storage", ")", ";", "}", "return", "LogResponse", "::", "logOffset", "(", "$", "log", ",", "$", "request", "->", "query", "->", "get", "(", "'offset'", ",", "0", ")", ",", "$", "is_end", ")", ";", "}" ]
Get storage scan output. @param Storage $storage @param Request $request @return JsonResponse
[ "Get", "storage", "scan", "output", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L192-L209
train
anime-db/catalog-bundle
src/Controller/StorageController.php
StorageController.scanProgressAction
public function scanProgressAction(Storage $storage) { $filename = $this->container->getParameter('anime_db.catalog.storage.scan_progress'); $filename = sprintf($filename, $storage->getId()); if (!file_exists($filename)) { throw $this->createNotFoundException('The progress status cannot be read'); } $log = trim(file_get_contents($filename), " \r\n%"); return new JsonResponse(['status' => ($log != '' ? intval($log) : 100)]); }
php
public function scanProgressAction(Storage $storage) { $filename = $this->container->getParameter('anime_db.catalog.storage.scan_progress'); $filename = sprintf($filename, $storage->getId()); if (!file_exists($filename)) { throw $this->createNotFoundException('The progress status cannot be read'); } $log = trim(file_get_contents($filename), " \r\n%"); return new JsonResponse(['status' => ($log != '' ? intval($log) : 100)]); }
[ "public", "function", "scanProgressAction", "(", "Storage", "$", "storage", ")", "{", "$", "filename", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'anime_db.catalog.storage.scan_progress'", ")", ";", "$", "filename", "=", "sprintf", "(", "$", "filename", ",", "$", "storage", "->", "getId", "(", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'The progress status cannot be read'", ")", ";", "}", "$", "log", "=", "trim", "(", "file_get_contents", "(", "$", "filename", ")", ",", "\" \\r\\n%\"", ")", ";", "return", "new", "JsonResponse", "(", "[", "'status'", "=>", "(", "$", "log", "!=", "''", "?", "intval", "(", "$", "log", ")", ":", "100", ")", "]", ")", ";", "}" ]
Get storage scan progress. @param Storage $storage @return JsonResponse
[ "Get", "storage", "scan", "progress", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Controller/StorageController.php#L237-L248
train
yii2module/yii2-offline
src/console/controllers/DefaultController.php
DefaultController.actionIndex
public function actionIndex($option = null) { if(!ConfigHelper::isDetected()) { Question::confirm('Config not detected! Restore?', 1); ConfigHelper::restoreConfig(); } $option = Question::displayWithQuit('Set offline state', ['Enable', 'Disable'], $option); $result = ConfigHelper::setState($option == 'e'); $optionStr = $option == 'e' ? 'enabled' : 'disabled'; if($result === null) { Output::block("Already $optionStr!"); } elseif($result) { Output::block("Success $optionStr!"); } else { Output::block("Error set state!"); } }
php
public function actionIndex($option = null) { if(!ConfigHelper::isDetected()) { Question::confirm('Config not detected! Restore?', 1); ConfigHelper::restoreConfig(); } $option = Question::displayWithQuit('Set offline state', ['Enable', 'Disable'], $option); $result = ConfigHelper::setState($option == 'e'); $optionStr = $option == 'e' ? 'enabled' : 'disabled'; if($result === null) { Output::block("Already $optionStr!"); } elseif($result) { Output::block("Success $optionStr!"); } else { Output::block("Error set state!"); } }
[ "public", "function", "actionIndex", "(", "$", "option", "=", "null", ")", "{", "if", "(", "!", "ConfigHelper", "::", "isDetected", "(", ")", ")", "{", "Question", "::", "confirm", "(", "'Config not detected! Restore?'", ",", "1", ")", ";", "ConfigHelper", "::", "restoreConfig", "(", ")", ";", "}", "$", "option", "=", "Question", "::", "displayWithQuit", "(", "'Set offline state'", ",", "[", "'Enable'", ",", "'Disable'", "]", ",", "$", "option", ")", ";", "$", "result", "=", "ConfigHelper", "::", "setState", "(", "$", "option", "==", "'e'", ")", ";", "$", "optionStr", "=", "$", "option", "==", "'e'", "?", "'enabled'", ":", "'disabled'", ";", "if", "(", "$", "result", "===", "null", ")", "{", "Output", "::", "block", "(", "\"Already $optionStr!\"", ")", ";", "}", "elseif", "(", "$", "result", ")", "{", "Output", "::", "block", "(", "\"Success $optionStr!\"", ")", ";", "}", "else", "{", "Output", "::", "block", "(", "\"Error set state!\"", ")", ";", "}", "}" ]
Set offline mode
[ "Set", "offline", "mode" ]
7fea792d704d1ba0b99c4428dd356dd94d32c3d4
https://github.com/yii2module/yii2-offline/blob/7fea792d704d1ba0b99c4428dd356dd94d32c3d4/src/console/controllers/DefaultController.php#L16-L34
train
kreta/SimpleApiDocBundle
src/Kreta/SimpleApiDocBundle/Extractor/ApiDocExtractor.php
ApiDocExtractor.buildInput
public function buildInput(ApiDoc $annotation, $data = null) { $annotationReflection = new \ReflectionClass('Nelmio\ApiDocBundle\Annotation\ApiDoc'); $inputReflection = $annotationReflection->getProperty('input'); $inputReflection->setAccessible(true); if (!(isset($data['input']) || $data['input'] === null) || empty($data['input'])) { if ($annotation->toArray()['method'] === 'POST' || $annotation->toArray()['method'] === 'PUT') { $actionName = $annotation->getRoute()->getDefault('_controller'); $controllerClass = substr($actionName, 0, strpos($actionName, '::')); $reflectionClass = new \ReflectionClass(substr($controllerClass, strpos($controllerClass, ':'))); $class = str_replace('Controller', '', $reflectionClass->getShortName()); $inputType = 'Kreta\\Component\\' . $class . '\\Form\\Type\\' . $class . 'Type'; if (class_exists($inputType)) { $inputReflection->setValue($annotation, $inputType); } } } else { $inputReflection->setValue($annotation, $data['input']); } return $annotation; }
php
public function buildInput(ApiDoc $annotation, $data = null) { $annotationReflection = new \ReflectionClass('Nelmio\ApiDocBundle\Annotation\ApiDoc'); $inputReflection = $annotationReflection->getProperty('input'); $inputReflection->setAccessible(true); if (!(isset($data['input']) || $data['input'] === null) || empty($data['input'])) { if ($annotation->toArray()['method'] === 'POST' || $annotation->toArray()['method'] === 'PUT') { $actionName = $annotation->getRoute()->getDefault('_controller'); $controllerClass = substr($actionName, 0, strpos($actionName, '::')); $reflectionClass = new \ReflectionClass(substr($controllerClass, strpos($controllerClass, ':'))); $class = str_replace('Controller', '', $reflectionClass->getShortName()); $inputType = 'Kreta\\Component\\' . $class . '\\Form\\Type\\' . $class . 'Type'; if (class_exists($inputType)) { $inputReflection->setValue($annotation, $inputType); } } } else { $inputReflection->setValue($annotation, $data['input']); } return $annotation; }
[ "public", "function", "buildInput", "(", "ApiDoc", "$", "annotation", ",", "$", "data", "=", "null", ")", "{", "$", "annotationReflection", "=", "new", "\\", "ReflectionClass", "(", "'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc'", ")", ";", "$", "inputReflection", "=", "$", "annotationReflection", "->", "getProperty", "(", "'input'", ")", ";", "$", "inputReflection", "->", "setAccessible", "(", "true", ")", ";", "if", "(", "!", "(", "isset", "(", "$", "data", "[", "'input'", "]", ")", "||", "$", "data", "[", "'input'", "]", "===", "null", ")", "||", "empty", "(", "$", "data", "[", "'input'", "]", ")", ")", "{", "if", "(", "$", "annotation", "->", "toArray", "(", ")", "[", "'method'", "]", "===", "'POST'", "||", "$", "annotation", "->", "toArray", "(", ")", "[", "'method'", "]", "===", "'PUT'", ")", "{", "$", "actionName", "=", "$", "annotation", "->", "getRoute", "(", ")", "->", "getDefault", "(", "'_controller'", ")", ";", "$", "controllerClass", "=", "substr", "(", "$", "actionName", ",", "0", ",", "strpos", "(", "$", "actionName", ",", "'::'", ")", ")", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "substr", "(", "$", "controllerClass", ",", "strpos", "(", "$", "controllerClass", ",", "':'", ")", ")", ")", ";", "$", "class", "=", "str_replace", "(", "'Controller'", ",", "''", ",", "$", "reflectionClass", "->", "getShortName", "(", ")", ")", ";", "$", "inputType", "=", "'Kreta\\\\Component\\\\'", ".", "$", "class", ".", "'\\\\Form\\\\Type\\\\'", ".", "$", "class", ".", "'Type'", ";", "if", "(", "class_exists", "(", "$", "inputType", ")", ")", "{", "$", "inputReflection", "->", "setValue", "(", "$", "annotation", ",", "$", "inputType", ")", ";", "}", "}", "}", "else", "{", "$", "inputReflection", "->", "setValue", "(", "$", "annotation", ",", "$", "data", "[", "'input'", "]", ")", ";", "}", "return", "$", "annotation", ";", "}" ]
Method that adds the input property of ApiDoc getting the form type's fully qualified name. @param ApiDoc $annotation The annotation @param array|null $data The data given @return ApiDoc
[ "Method", "that", "adds", "the", "input", "property", "of", "ApiDoc", "getting", "the", "form", "type", "s", "fully", "qualified", "name", "." ]
786aa9310cdf087253f65f68165a0a0c8ad5c816
https://github.com/kreta/SimpleApiDocBundle/blob/786aa9310cdf087253f65f68165a0a0c8ad5c816/src/Kreta/SimpleApiDocBundle/Extractor/ApiDocExtractor.php#L106-L128
train
kreta/SimpleApiDocBundle
src/Kreta/SimpleApiDocBundle/Extractor/ApiDocExtractor.php
ApiDocExtractor.buildOutput
public function buildOutput(ApiDoc $annotation, $data = null) { $annotationReflection = new \ReflectionClass('Nelmio\ApiDocBundle\Annotation\ApiDoc'); $outputReflection = $annotationReflection->getProperty('output'); $outputReflection->setAccessible(true); if (!(isset($data['output']) || $data['output'] === null) || empty($data['output'])) { if ($annotation->toArray()['method'] === 'POST' || $annotation->toArray()['method'] === 'PUT') { $actionName = $annotation->getRoute()->getDefault('_controller'); $reflectionMethod = new \ReflectionMethod($actionName); $phpdoc = $reflectionMethod->getDocComment(); $return = substr($phpdoc, strpos($phpdoc, '@return')); $returnType = str_replace(['@return \\', '*', '[]', 'array<\\', '>'], '', $return); $returnType = substr($returnType, 0, strpos($returnType, strstr($returnType, "\n"))); $returnType = preg_replace("/\r\n|\r|\n|\\/\\s+/", '', $returnType); if (class_exists($returnType) || interface_exists($returnType)) { $outputReflection->setValue($annotation, $returnType); } } } else { $outputReflection->setValue($annotation, $data['output']); } return $annotation; }
php
public function buildOutput(ApiDoc $annotation, $data = null) { $annotationReflection = new \ReflectionClass('Nelmio\ApiDocBundle\Annotation\ApiDoc'); $outputReflection = $annotationReflection->getProperty('output'); $outputReflection->setAccessible(true); if (!(isset($data['output']) || $data['output'] === null) || empty($data['output'])) { if ($annotation->toArray()['method'] === 'POST' || $annotation->toArray()['method'] === 'PUT') { $actionName = $annotation->getRoute()->getDefault('_controller'); $reflectionMethod = new \ReflectionMethod($actionName); $phpdoc = $reflectionMethod->getDocComment(); $return = substr($phpdoc, strpos($phpdoc, '@return')); $returnType = str_replace(['@return \\', '*', '[]', 'array<\\', '>'], '', $return); $returnType = substr($returnType, 0, strpos($returnType, strstr($returnType, "\n"))); $returnType = preg_replace("/\r\n|\r|\n|\\/\\s+/", '', $returnType); if (class_exists($returnType) || interface_exists($returnType)) { $outputReflection->setValue($annotation, $returnType); } } } else { $outputReflection->setValue($annotation, $data['output']); } return $annotation; }
[ "public", "function", "buildOutput", "(", "ApiDoc", "$", "annotation", ",", "$", "data", "=", "null", ")", "{", "$", "annotationReflection", "=", "new", "\\", "ReflectionClass", "(", "'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc'", ")", ";", "$", "outputReflection", "=", "$", "annotationReflection", "->", "getProperty", "(", "'output'", ")", ";", "$", "outputReflection", "->", "setAccessible", "(", "true", ")", ";", "if", "(", "!", "(", "isset", "(", "$", "data", "[", "'output'", "]", ")", "||", "$", "data", "[", "'output'", "]", "===", "null", ")", "||", "empty", "(", "$", "data", "[", "'output'", "]", ")", ")", "{", "if", "(", "$", "annotation", "->", "toArray", "(", ")", "[", "'method'", "]", "===", "'POST'", "||", "$", "annotation", "->", "toArray", "(", ")", "[", "'method'", "]", "===", "'PUT'", ")", "{", "$", "actionName", "=", "$", "annotation", "->", "getRoute", "(", ")", "->", "getDefault", "(", "'_controller'", ")", ";", "$", "reflectionMethod", "=", "new", "\\", "ReflectionMethod", "(", "$", "actionName", ")", ";", "$", "phpdoc", "=", "$", "reflectionMethod", "->", "getDocComment", "(", ")", ";", "$", "return", "=", "substr", "(", "$", "phpdoc", ",", "strpos", "(", "$", "phpdoc", ",", "'@return'", ")", ")", ";", "$", "returnType", "=", "str_replace", "(", "[", "'@return \\\\'", ",", "'*'", ",", "'[]'", ",", "'array<\\\\'", ",", "'>'", "]", ",", "''", ",", "$", "return", ")", ";", "$", "returnType", "=", "substr", "(", "$", "returnType", ",", "0", ",", "strpos", "(", "$", "returnType", ",", "strstr", "(", "$", "returnType", ",", "\"\\n\"", ")", ")", ")", ";", "$", "returnType", "=", "preg_replace", "(", "\"/\\r\\n|\\r|\\n|\\\\/\\\\s+/\"", ",", "''", ",", "$", "returnType", ")", ";", "if", "(", "class_exists", "(", "$", "returnType", ")", "||", "interface_exists", "(", "$", "returnType", ")", ")", "{", "$", "outputReflection", "->", "setValue", "(", "$", "annotation", ",", "$", "returnType", ")", ";", "}", "}", "}", "else", "{", "$", "outputReflection", "->", "setValue", "(", "$", "annotation", ",", "$", "data", "[", "'output'", "]", ")", ";", "}", "return", "$", "annotation", ";", "}" ]
Method that adds the output property of ApiDoc getting the model's fully qualified name. @param ApiDoc $annotation The annotation @param array|null $data The data given @return ApiDoc
[ "Method", "that", "adds", "the", "output", "property", "of", "ApiDoc", "getting", "the", "model", "s", "fully", "qualified", "name", "." ]
786aa9310cdf087253f65f68165a0a0c8ad5c816
https://github.com/kreta/SimpleApiDocBundle/blob/786aa9310cdf087253f65f68165a0a0c8ad5c816/src/Kreta/SimpleApiDocBundle/Extractor/ApiDocExtractor.php#L139-L163
train
ddrv-test/firmapi-core
src/Object/Rubric.php
Rubric.checkExists
protected function checkExists($id) { $filter = array( 'fields' => array( array( 'field' => 'id', 'compare' => '=', 'value' => $id, ), ), ); $exists = $this->rubric->count($filter); return $exists?true:false; }
php
protected function checkExists($id) { $filter = array( 'fields' => array( array( 'field' => 'id', 'compare' => '=', 'value' => $id, ), ), ); $exists = $this->rubric->count($filter); return $exists?true:false; }
[ "protected", "function", "checkExists", "(", "$", "id", ")", "{", "$", "filter", "=", "array", "(", "'fields'", "=>", "array", "(", "array", "(", "'field'", "=>", "'id'", ",", "'compare'", "=>", "'='", ",", "'value'", "=>", "$", "id", ",", ")", ",", ")", ",", ")", ";", "$", "exists", "=", "$", "this", "->", "rubric", "->", "count", "(", "$", "filter", ")", ";", "return", "$", "exists", "?", "true", ":", "false", ";", "}" ]
Check for exists @param string $id @return boolean
[ "Check", "for", "exists" ]
8f8843f0fb134568e7764cabd5039e15c579976d
https://github.com/ddrv-test/firmapi-core/blob/8f8843f0fb134568e7764cabd5039e15c579976d/src/Object/Rubric.php#L94-L107
train
shgysk8zer0/core_api
traits/syntax_highlighter.php
Syntax_Highlighter.unhighlightString
final public function unhighlightString( $contents = '', $update_file = false, array $replacements = array('<br />' => PHP_EOL, '<br>' => PHP_EOL, '&nbsp;' => ' ') ) { $contents = str_replace(array_keys($replacements), array_values($replacements), $contents); $contents = strip_tags($contents); $contents = html_entity_decode($contents); $contents = trim($contents) . PHP_EOL; if ($update_file === true) { $this->filePutContents("$contents", null); } return $contents; }
php
final public function unhighlightString( $contents = '', $update_file = false, array $replacements = array('<br />' => PHP_EOL, '<br>' => PHP_EOL, '&nbsp;' => ' ') ) { $contents = str_replace(array_keys($replacements), array_values($replacements), $contents); $contents = strip_tags($contents); $contents = html_entity_decode($contents); $contents = trim($contents) . PHP_EOL; if ($update_file === true) { $this->filePutContents("$contents", null); } return $contents; }
[ "final", "public", "function", "unhighlightString", "(", "$", "contents", "=", "''", ",", "$", "update_file", "=", "false", ",", "array", "$", "replacements", "=", "array", "(", "'<br />'", "=>", "PHP_EOL", ",", "'<br>'", "=>", "PHP_EOL", ",", "'&nbsp;'", "=>", "' '", ")", ")", "{", "$", "contents", "=", "str_replace", "(", "array_keys", "(", "$", "replacements", ")", ",", "array_values", "(", "$", "replacements", ")", ",", "$", "contents", ")", ";", "$", "contents", "=", "strip_tags", "(", "$", "contents", ")", ";", "$", "contents", "=", "html_entity_decode", "(", "$", "contents", ")", ";", "$", "contents", "=", "trim", "(", "$", "contents", ")", ".", "PHP_EOL", ";", "if", "(", "$", "update_file", "===", "true", ")", "{", "$", "this", "->", "filePutContents", "(", "\"$contents\"", ",", "null", ")", ";", "}", "return", "$", "contents", ";", "}" ]
Inverse of highlight function. Attempts to convert HTML to regular string @param string $contents HTML encoded, syntax-highlighted string @param bool $update_file Whether or not to update file's content @param array $replacements Associative array of things to replace @return string Non-HTML version of string
[ "Inverse", "of", "highlight", "function", ".", "Attempts", "to", "convert", "HTML", "to", "regular", "string" ]
9e9b8baf761af874b95256ad2462e55fbb2b2e58
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/syntax_highlighter.php#L60-L74
train
chalasr/RCHCapistranoBundle
Generator/StagingGenerator.php
StagingGenerator.write
public function write() { foreach ($this->parameters as $prop => $value) { $placeHolders[] = sprintf('<%s>', $prop); $replacements[] = $value; } $content = str_replace($placeHolders, $replacements, self::$template); fwrite($this->file, $this->addHeaders($content)); }
php
public function write() { foreach ($this->parameters as $prop => $value) { $placeHolders[] = sprintf('<%s>', $prop); $replacements[] = $value; } $content = str_replace($placeHolders, $replacements, self::$template); fwrite($this->file, $this->addHeaders($content)); }
[ "public", "function", "write", "(", ")", "{", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "prop", "=>", "$", "value", ")", "{", "$", "placeHolders", "[", "]", "=", "sprintf", "(", "'<%s>'", ",", "$", "prop", ")", ";", "$", "replacements", "[", "]", "=", "$", "value", ";", "}", "$", "content", "=", "str_replace", "(", "$", "placeHolders", ",", "$", "replacements", ",", "self", "::", "$", "template", ")", ";", "fwrite", "(", "$", "this", "->", "file", ",", "$", "this", "->", "addHeaders", "(", "$", "content", ")", ")", ";", "}" ]
Write staging in file. @param string $staging Generated staging
[ "Write", "staging", "in", "file", "." ]
c4a4cbaa2bc05f33bf431fd3afe6cac39947640e
https://github.com/chalasr/RCHCapistranoBundle/blob/c4a4cbaa2bc05f33bf431fd3afe6cac39947640e/Generator/StagingGenerator.php#L57-L67
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FB.setObjectFilter
public static function setObjectFilter($Class, $Filter) { $instance = FirePHP::getInstance(true); $instance->setObjectFilter($Class, $Filter); }
php
public static function setObjectFilter($Class, $Filter) { $instance = FirePHP::getInstance(true); $instance->setObjectFilter($Class, $Filter); }
[ "public", "static", "function", "setObjectFilter", "(", "$", "Class", ",", "$", "Filter", ")", "{", "$", "instance", "=", "FirePHP", "::", "getInstance", "(", "true", ")", ";", "$", "instance", "->", "setObjectFilter", "(", "$", "Class", ",", "$", "Filter", ")", ";", "}" ]
Specify a filter to be used when encoding an object Filters are used to exclude object members. @see FirePHP->setObjectFilter() @param string $Class The class name of the object @param array $Filter An array or members to exclude @return void
[ "Specify", "a", "filter", "to", "be", "used", "when", "encoding", "an", "object" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L170-L174
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FB.send
public static function send() { $instance = FirePHP::getInstance(true); $args = func_get_args(); return call_user_func_array(array($instance,'fb'),$args); }
php
public static function send() { $instance = FirePHP::getInstance(true); $args = func_get_args(); return call_user_func_array(array($instance,'fb'),$args); }
[ "public", "static", "function", "send", "(", ")", "{", "$", "instance", "=", "FirePHP", "::", "getInstance", "(", "true", ")", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "instance", ",", "'fb'", ")", ",", "$", "args", ")", ";", "}" ]
Log object to firebug @see http://www.firephp.org/Wiki/Reference/Fb @param mixed $Object @return true @throws Exception
[ "Log", "object", "to", "firebug" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L209-L214
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FB.group
public static function group($Name, $Options=null) { $instance = FirePHP::getInstance(true); return $instance->group($Name, $Options); }
php
public static function group($Name, $Options=null) { $instance = FirePHP::getInstance(true); return $instance->group($Name, $Options); }
[ "public", "static", "function", "group", "(", "$", "Name", ",", "$", "Options", "=", "null", ")", "{", "$", "instance", "=", "FirePHP", "::", "getInstance", "(", "true", ")", ";", "return", "$", "instance", "->", "group", "(", "$", "Name", ",", "$", "Options", ")", ";", "}" ]
Start a group for following messages Options: Collapsed: [true|false] Color: [#RRGGBB|ColorName] @param string $Name @param array $Options OPTIONAL Instructions on how to log the group @return true
[ "Start", "a", "group", "for", "following", "messages" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L227-L231
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.getInstance
public static function getInstance($AutoCreate = false) { if ($AutoCreate===true && !self::$instance) { self::init(); } return self::$instance; }
php
public static function getInstance($AutoCreate = false) { if ($AutoCreate===true && !self::$instance) { self::init(); } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "$", "AutoCreate", "=", "false", ")", "{", "if", "(", "$", "AutoCreate", "===", "true", "&&", "!", "self", "::", "$", "instance", ")", "{", "self", "::", "init", "(", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Gets singleton instance of FirePHP @param boolean $AutoCreate @return FirePHP
[ "Gets", "singleton", "instance", "of", "FirePHP" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L557-L563
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.setLogToInsightConsole
public function setLogToInsightConsole($console) { if(is_string($console)) { if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); } $this->logToInsightConsole = $this->to('request')->console($console); } else { $this->logToInsightConsole = $console; } }
php
public function setLogToInsightConsole($console) { if(is_string($console)) { if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); } $this->logToInsightConsole = $this->to('request')->console($console); } else { $this->logToInsightConsole = $console; } }
[ "public", "function", "setLogToInsightConsole", "(", "$", "console", ")", "{", "if", "(", "is_string", "(", "$", "console", ")", ")", "{", "if", "(", "get_class", "(", "$", "this", ")", "!=", "'FirePHP_Insight'", "&&", "!", "is_subclass_of", "(", "$", "this", ",", "'FirePHP_Insight'", ")", ")", "{", "throw", "new", "Exception", "(", "'FirePHP instance not an instance or subclass of FirePHP_Insight!'", ")", ";", "}", "$", "this", "->", "logToInsightConsole", "=", "$", "this", "->", "to", "(", "'request'", ")", "->", "console", "(", "$", "console", ")", ";", "}", "else", "{", "$", "this", "->", "logToInsightConsole", "=", "$", "console", ";", "}", "}" ]
Set an Insight console to direct all logging calls to @param object $console The console object to log to @return void
[ "Set", "an", "Insight", "console", "to", "direct", "all", "logging", "calls", "to" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L592-L602
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.setOption
public function setOption($Name, $Value) { if (!isset($this->options[$Name])) { throw $this->newException('Unknown option: ' . $Name); } $this->options[$Name] = $Value; }
php
public function setOption($Name, $Value) { if (!isset($this->options[$Name])) { throw $this->newException('Unknown option: ' . $Name); } $this->options[$Name] = $Value; }
[ "public", "function", "setOption", "(", "$", "Name", ",", "$", "Value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "Name", "]", ")", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Unknown option: '", ".", "$", "Name", ")", ";", "}", "$", "this", "->", "options", "[", "$", "Name", "]", "=", "$", "Value", ";", "}" ]
Set an option for the library @param string $Name @param mixed $Value @throws Exception @return void
[ "Set", "an", "option", "for", "the", "library" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L675-L681
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.getOption
public function getOption($Name) { if (!isset($this->options[$Name])) { throw $this->newException('Unknown option: ' . $Name); } return $this->options[$Name]; }
php
public function getOption($Name) { if (!isset($this->options[$Name])) { throw $this->newException('Unknown option: ' . $Name); } return $this->options[$Name]; }
[ "public", "function", "getOption", "(", "$", "Name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "Name", "]", ")", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Unknown option: '", ".", "$", "Name", ")", ";", "}", "return", "$", "this", "->", "options", "[", "$", "Name", "]", ";", "}" ]
Get an option from the library @param string $Name @throws Exception @return mixed
[ "Get", "an", "option", "from", "the", "library" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L690-L696
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.errorHandler
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { // Don't throw exception if error reporting is switched off if (error_reporting() == 0) { return; } // Only throw exceptions for errors we are asking for if (error_reporting() & $errno) { $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); if ($this->throwErrorExceptions) { throw $exception; } else { $this->fb($exception); } } }
php
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { // Don't throw exception if error reporting is switched off if (error_reporting() == 0) { return; } // Only throw exceptions for errors we are asking for if (error_reporting() & $errno) { $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); if ($this->throwErrorExceptions) { throw $exception; } else { $this->fb($exception); } } }
[ "public", "function", "errorHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ",", "$", "errcontext", ")", "{", "// Don't throw exception if error reporting is switched off", "if", "(", "error_reporting", "(", ")", "==", "0", ")", "{", "return", ";", "}", "// Only throw exceptions for errors we are asking for", "if", "(", "error_reporting", "(", ")", "&", "$", "errno", ")", "{", "$", "exception", "=", "new", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "if", "(", "$", "this", "->", "throwErrorExceptions", ")", "{", "throw", "$", "exception", ";", "}", "else", "{", "$", "this", "->", "fb", "(", "$", "exception", ")", ";", "}", "}", "}" ]
FirePHP's error handler Throws exception for each php error that will occur. @param int $errno @param string $errstr @param string $errfile @param int $errline @param array $errcontext
[ "FirePHP", "s", "error", "handler" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L728-L744
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.exceptionHandler
function exceptionHandler($Exception) { $this->inExceptionHandler = true; header('HTTP/1.1 500 Internal Server Error'); try { $this->fb($Exception); } catch (Exception $e) { echo 'We had an exception: ' . $e; } $this->inExceptionHandler = false; }
php
function exceptionHandler($Exception) { $this->inExceptionHandler = true; header('HTTP/1.1 500 Internal Server Error'); try { $this->fb($Exception); } catch (Exception $e) { echo 'We had an exception: ' . $e; } $this->inExceptionHandler = false; }
[ "function", "exceptionHandler", "(", "$", "Exception", ")", "{", "$", "this", "->", "inExceptionHandler", "=", "true", ";", "header", "(", "'HTTP/1.1 500 Internal Server Error'", ")", ";", "try", "{", "$", "this", "->", "fb", "(", "$", "Exception", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "echo", "'We had an exception: '", ".", "$", "e", ";", "}", "$", "this", "->", "inExceptionHandler", "=", "false", ";", "}" ]
FirePHP's exception handler Logs all exceptions to your firebug console and then stops the script. @param Exception $Exception @throws Exception
[ "FirePHP", "s", "exception", "handler" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L766-L779
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.registerAssertionHandler
public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) { $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; $this->throwAssertionExceptions = $throwAssertionExceptions; if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); } return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); }
php
public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) { $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; $this->throwAssertionExceptions = $throwAssertionExceptions; if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); } return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); }
[ "public", "function", "registerAssertionHandler", "(", "$", "convertAssertionErrorsToExceptions", "=", "true", ",", "$", "throwAssertionExceptions", "=", "false", ")", "{", "$", "this", "->", "convertAssertionErrorsToExceptions", "=", "$", "convertAssertionErrorsToExceptions", ";", "$", "this", "->", "throwAssertionExceptions", "=", "$", "throwAssertionExceptions", ";", "if", "(", "$", "throwAssertionExceptions", "&&", "!", "$", "convertAssertionErrorsToExceptions", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'", ")", ";", "}", "return", "assert_options", "(", "ASSERT_CALLBACK", ",", "array", "(", "$", "this", ",", "'assertionHandler'", ")", ")", ";", "}" ]
Register FirePHP driver as your assert callback @param boolean $convertAssertionErrorsToExceptions @param boolean $throwAssertionExceptions @return mixed Returns the original setting or FALSE on errors
[ "Register", "FirePHP", "driver", "as", "your", "assert", "callback" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L788-L798
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.assertionHandler
public function assertionHandler($file, $line, $code) { if ($this->convertAssertionErrorsToExceptions) { $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); if ($this->throwAssertionExceptions) { throw $exception; } else { $this->fb($exception); } } else { $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); } }
php
public function assertionHandler($file, $line, $code) { if ($this->convertAssertionErrorsToExceptions) { $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); if ($this->throwAssertionExceptions) { throw $exception; } else { $this->fb($exception); } } else { $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); } }
[ "public", "function", "assertionHandler", "(", "$", "file", ",", "$", "line", ",", "$", "code", ")", "{", "if", "(", "$", "this", "->", "convertAssertionErrorsToExceptions", ")", "{", "$", "exception", "=", "new", "ErrorException", "(", "'Assertion Failed - Code[ '", ".", "$", "code", ".", "' ]'", ",", "0", ",", "null", ",", "$", "file", ",", "$", "line", ")", ";", "if", "(", "$", "this", "->", "throwAssertionExceptions", ")", "{", "throw", "$", "exception", ";", "}", "else", "{", "$", "this", "->", "fb", "(", "$", "exception", ")", ";", "}", "}", "else", "{", "$", "this", "->", "fb", "(", "$", "code", ",", "'Assertion Failed'", ",", "FirePHP", "::", "ERROR", ",", "array", "(", "'File'", "=>", "$", "file", ",", "'Line'", "=>", "$", "line", ")", ")", ";", "}", "}" ]
FirePHP's assertion handler Logs all assertions to your firebug console and then stops the script. @param string $file File source of assertion @param int $line Line source of assertion @param mixed $code Assertion code
[ "FirePHP", "s", "assertion", "handler" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L809-L824
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.group
public function group($Name, $Options = null) { if (!$Name) { throw $this->newException('You must specify a label for the group!'); } if ($Options) { if (!is_array($Options)) { throw $this->newException('Options must be defined as an array!'); } if (array_key_exists('Collapsed', $Options)) { $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; } } return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); }
php
public function group($Name, $Options = null) { if (!$Name) { throw $this->newException('You must specify a label for the group!'); } if ($Options) { if (!is_array($Options)) { throw $this->newException('Options must be defined as an array!'); } if (array_key_exists('Collapsed', $Options)) { $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; } } return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); }
[ "public", "function", "group", "(", "$", "Name", ",", "$", "Options", "=", "null", ")", "{", "if", "(", "!", "$", "Name", ")", "{", "throw", "$", "this", "->", "newException", "(", "'You must specify a label for the group!'", ")", ";", "}", "if", "(", "$", "Options", ")", "{", "if", "(", "!", "is_array", "(", "$", "Options", ")", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Options must be defined as an array!'", ")", ";", "}", "if", "(", "array_key_exists", "(", "'Collapsed'", ",", "$", "Options", ")", ")", "{", "$", "Options", "[", "'Collapsed'", "]", "=", "(", "$", "Options", "[", "'Collapsed'", "]", ")", "?", "'true'", ":", "'false'", ";", "}", "}", "return", "$", "this", "->", "fb", "(", "null", ",", "$", "Name", ",", "FirePHP", "::", "GROUP_START", ",", "$", "Options", ")", ";", "}" ]
Start a group for following messages. Options: Collapsed: [true|false] Color: [#RRGGBB|ColorName] @param string $Name @param array $Options OPTIONAL Instructions on how to log the group @return true @throws Exception
[ "Start", "a", "group", "for", "following", "messages", "." ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L838-L855
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.dump
public function dump($Key, $Variable, $Options = array()) { if (!is_string($Key)) { throw $this->newException('Key passed to dump() is not a string'); } if (strlen($Key)>100) { throw $this->newException('Key passed to dump() is longer than 100 characters'); } if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) { throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); } return $this->fb($Variable, $Key, FirePHP::DUMP, $Options); }
php
public function dump($Key, $Variable, $Options = array()) { if (!is_string($Key)) { throw $this->newException('Key passed to dump() is not a string'); } if (strlen($Key)>100) { throw $this->newException('Key passed to dump() is longer than 100 characters'); } if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) { throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); } return $this->fb($Variable, $Key, FirePHP::DUMP, $Options); }
[ "public", "function", "dump", "(", "$", "Key", ",", "$", "Variable", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "Key", ")", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Key passed to dump() is not a string'", ")", ";", "}", "if", "(", "strlen", "(", "$", "Key", ")", ">", "100", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Key passed to dump() is longer than 100 characters'", ")", ";", "}", "if", "(", "!", "preg_match_all", "(", "'/^[a-zA-Z0-9-_\\.:]*$/'", ",", "$", "Key", ",", "$", "m", ")", ")", "{", "throw", "$", "this", "->", "newException", "(", "'Key passed to dump() contains invalid characters [a-zA-Z0-9-_\\.:]'", ")", ";", "}", "return", "$", "this", "->", "fb", "(", "$", "Variable", ",", "$", "Key", ",", "FirePHP", "::", "DUMP", ",", "$", "Options", ")", ";", "}" ]
Dumps key and variable to firebug server panel @see FirePHP::DUMP @param string $Key @param mixed $Variable @return true @throws Exception
[ "Dumps", "key", "and", "variable", "to", "firebug", "server", "panel" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L933-L945
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.table
public function table($Label, $Table, $Options = array()) { return $this->fb($Table, $Label, FirePHP::TABLE, $Options); }
php
public function table($Label, $Table, $Options = array()) { return $this->fb($Table, $Label, FirePHP::TABLE, $Options); }
[ "public", "function", "table", "(", "$", "Label", ",", "$", "Table", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "fb", "(", "$", "Table", ",", "$", "Label", ",", "FirePHP", "::", "TABLE", ",", "$", "Options", ")", ";", "}" ]
Log a table in the firebug console @see FirePHP::TABLE @param string $Label @param string $Table @return true @throws Exception
[ "Log", "a", "table", "in", "the", "firebug", "console" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L969-L972
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.to
public static function to() { $instance = self::getInstance(); if (!method_exists($instance, "_to")) { throw new Exception("FirePHP::to() implementation not loaded"); } $args = func_get_args(); return call_user_func_array(array($instance, '_to'), $args); }
php
public static function to() { $instance = self::getInstance(); if (!method_exists($instance, "_to")) { throw new Exception("FirePHP::to() implementation not loaded"); } $args = func_get_args(); return call_user_func_array(array($instance, '_to'), $args); }
[ "public", "static", "function", "to", "(", ")", "{", "$", "instance", "=", "self", "::", "getInstance", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "instance", ",", "\"_to\"", ")", ")", "{", "throw", "new", "Exception", "(", "\"FirePHP::to() implementation not loaded\"", ")", ";", "}", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "instance", ",", "'_to'", ")", ",", "$", "args", ")", ";", "}" ]
Insight API wrapper @see Insight_Helper::to()
[ "Insight", "API", "wrapper" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L979-L987
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP.detectClientExtension
public function detectClientExtension() { // Check if FirePHP is installed on client via User-Agent header if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && version_compare($m[1][0],'0.0.6','>=')) { return true; } else // Check if FirePHP is installed on client via X-FirePHP-Version header if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && version_compare($m[1][0],'0.0.6','>=')) { return true; } return false; }
php
public function detectClientExtension() { // Check if FirePHP is installed on client via User-Agent header if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && version_compare($m[1][0],'0.0.6','>=')) { return true; } else // Check if FirePHP is installed on client via X-FirePHP-Version header if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && version_compare($m[1][0],'0.0.6','>=')) { return true; } return false; }
[ "public", "function", "detectClientExtension", "(", ")", "{", "// Check if FirePHP is installed on client via User-Agent header", "if", "(", "@", "preg_match_all", "(", "'/\\sFirePHP\\/([\\.\\d]*)\\s?/si'", ",", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "m", ")", "&&", "version_compare", "(", "$", "m", "[", "1", "]", "[", "0", "]", ",", "'0.0.6'", ",", "'>='", ")", ")", "{", "return", "true", ";", "}", "else", "// Check if FirePHP is installed on client via X-FirePHP-Version header", "if", "(", "@", "preg_match_all", "(", "'/^([\\.\\d]*)$/si'", ",", "$", "this", "->", "getRequestHeader", "(", "\"X-FirePHP-Version\"", ")", ",", "$", "m", ")", "&&", "version_compare", "(", "$", "m", "[", "1", "]", "[", "0", "]", ",", "'0.0.6'", ",", "'>='", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if FirePHP is installed on client @return boolean
[ "Check", "if", "FirePHP", "is", "installed", "on", "client" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L1009-L1022
train
KDF5000/EasyThink
src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php
FirePHP._escapeTrace
protected function _escapeTrace($Trace) { if (!$Trace) return $Trace; for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { if (isset($Trace[$i]['file'])) { $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); } if (isset($Trace[$i]['args'])) { $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); } } return $Trace; }
php
protected function _escapeTrace($Trace) { if (!$Trace) return $Trace; for( $i=0 ; $i<sizeof($Trace) ; $i++ ) { if (isset($Trace[$i]['file'])) { $Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']); } if (isset($Trace[$i]['args'])) { $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); } } return $Trace; }
[ "protected", "function", "_escapeTrace", "(", "$", "Trace", ")", "{", "if", "(", "!", "$", "Trace", ")", "return", "$", "Trace", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "sizeof", "(", "$", "Trace", ")", ";", "$", "i", "++", ")", "{", "if", "(", "isset", "(", "$", "Trace", "[", "$", "i", "]", "[", "'file'", "]", ")", ")", "{", "$", "Trace", "[", "$", "i", "]", "[", "'file'", "]", "=", "$", "this", "->", "_escapeTraceFile", "(", "$", "Trace", "[", "$", "i", "]", "[", "'file'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "Trace", "[", "$", "i", "]", "[", "'args'", "]", ")", ")", "{", "$", "Trace", "[", "$", "i", "]", "[", "'args'", "]", "=", "$", "this", "->", "encodeObject", "(", "$", "Trace", "[", "$", "i", "]", "[", "'args'", "]", ")", ";", "}", "}", "return", "$", "Trace", ";", "}" ]
Escape trace path for windows systems @param array $Trace @return array
[ "Escape", "trace", "path", "for", "windows", "systems" ]
86efc9c8a0d504e01e2fea55868227fdc8928841
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Behavior/FireShowPageTraceBehavior.php#L1360-L1372
train