repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getBackupURL
public function getBackupURL($backupId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId.'/url'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->url)) { return $response->url; } return $response; }
php
public function getBackupURL($backupId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups/'.$backupId.'/url'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->url)) { return $response->url; } return $response; }
[ "public", "function", "getBackupURL", "(", "$", "backupId", ")", "{", "if", "(", "$", "this", "->", "connector", "->", "getURL", "(", ")", "===", "null", ")", "{", "return", "'Cannot find site URL from configuration.'", ";", "}", "$", "url", "=", "$", "this", "->", "connector", "->", "getURL", "(", ")", ".", "self", "::", "VERSION", ".", "$", "this", "->", "connector", "->", "getSiteID", "(", ")", ".", "'/backups/'", ".", "$", "backupId", ".", "'/url'", ";", "$", "params", "=", "[", "]", ";", "$", "response", "=", "$", "this", "->", "connector", "->", "connecting", "(", "$", "url", ",", "$", "params", ",", "'GET'", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "url", ")", ")", "{", "return", "$", "response", "->", "url", ";", "}", "return", "$", "response", ";", "}" ]
Get backup URL. @param string $backupId Backup ID. @return string
[ "Get", "backup", "URL", "." ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L117-L130
train
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getSiteDetails
public function getSiteDetails($siteId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$siteId; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); return $response; }
php
public function getSiteDetails($siteId) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$siteId; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); return $response; }
[ "public", "function", "getSiteDetails", "(", "$", "siteId", ")", "{", "if", "(", "$", "this", "->", "connector", "->", "getURL", "(", ")", "===", "null", ")", "{", "return", "'Cannot find site URL from configuration.'", ";", "}", "$", "url", "=", "$", "this", "->", "connector", "->", "getURL", "(", ")", ".", "self", "::", "VERSION", ".", "$", "siteId", ";", "$", "params", "=", "[", "]", ";", "$", "response", "=", "$", "this", "->", "connector", "->", "connecting", "(", "$", "url", ",", "$", "params", ",", "'GET'", ")", ";", "return", "$", "response", ";", "}" ]
Get site details @param int $siteId Site ID. @return mixed|string
[ "Get", "site", "details" ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L161-L171
train
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.listBackups
public function listBackups() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->backups)) { return $response->backups; } return $response; }
php
public function listBackups() { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $url = $this->connector->getURL().self::VERSION.$this->connector->getSiteID().'/backups'; $params = []; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->backups)) { return $response->backups; } return $response; }
[ "public", "function", "listBackups", "(", ")", "{", "if", "(", "$", "this", "->", "connector", "->", "getURL", "(", ")", "===", "null", ")", "{", "return", "'Cannot find site URL from configuration.'", ";", "}", "$", "url", "=", "$", "this", "->", "connector", "->", "getURL", "(", ")", ".", "self", "::", "VERSION", ".", "$", "this", "->", "connector", "->", "getSiteID", "(", ")", ".", "'/backups'", ";", "$", "params", "=", "[", "]", ";", "$", "response", "=", "$", "this", "->", "connector", "->", "connecting", "(", "$", "url", ",", "$", "params", ",", "'GET'", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "backups", ")", ")", "{", "return", "$", "response", "->", "backups", ";", "}", "return", "$", "response", ";", "}" ]
List all backups in for specific site in site factory. @return mixed
[ "List", "all", "backups", "in", "for", "specific", "site", "in", "site", "factory", "." ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L178-L192
train
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.getLastBackupTime
public function getLastBackupTime() { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { $timestamp = $backups[0]->timestamp; return $timestamp; } return 'There is no backup available.'; } return $backups; }
php
public function getLastBackupTime() { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { $timestamp = $backups[0]->timestamp; return $timestamp; } return 'There is no backup available.'; } return $backups; }
[ "public", "function", "getLastBackupTime", "(", ")", "{", "$", "backups", "=", "$", "this", "->", "listBackups", "(", ")", ";", "if", "(", "is_array", "(", "$", "backups", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "backups", ")", ")", "{", "$", "timestamp", "=", "$", "backups", "[", "0", "]", "->", "timestamp", ";", "return", "$", "timestamp", ";", "}", "return", "'There is no backup available.'", ";", "}", "return", "$", "backups", ";", "}" ]
Get the last backup timestamp. @return mixed|string
[ "Get", "the", "last", "backup", "timestamp", "." ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L199-L213
train
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.backupSuccessIndicator
public function backupSuccessIndicator($label) { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { if ($backups[0]->label === $label) { return true; } return false; } return false; } }
php
public function backupSuccessIndicator($label) { $backups = $this->listBackups(); if (is_array($backups)) { if (!empty($backups)) { if ($backups[0]->label === $label) { return true; } return false; } return false; } }
[ "public", "function", "backupSuccessIndicator", "(", "$", "label", ")", "{", "$", "backups", "=", "$", "this", "->", "listBackups", "(", ")", ";", "if", "(", "is_array", "(", "$", "backups", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "backups", ")", ")", "{", "if", "(", "$", "backups", "[", "0", "]", "->", "label", "===", "$", "label", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "return", "false", ";", "}", "}" ]
Indicate when required backup is generated. @param string $label Backup label. @return bool
[ "Indicate", "when", "required", "backup", "is", "generated", "." ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L222-L236
train
rujiali/acquia-site-factory-cli
src/AppBundle/Connector/ConnectorSites.php
ConnectorSites.listSites
public function listSites($limit, $page, $canary = false) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $params = [ 'limit' => $limit, 'page' => $page, 'canary' => $canary, ]; $url = $this->connector->getURL().self::VERSION; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->sites)) { return $response->sites; } return $response; }
php
public function listSites($limit, $page, $canary = false) { if ($this->connector->getURL() === null) { return 'Cannot find site URL from configuration.'; } $params = [ 'limit' => $limit, 'page' => $page, 'canary' => $canary, ]; $url = $this->connector->getURL().self::VERSION; $response = $this->connector->connecting($url, $params, 'GET'); if (isset($response->sites)) { return $response->sites; } return $response; }
[ "public", "function", "listSites", "(", "$", "limit", ",", "$", "page", ",", "$", "canary", "=", "false", ")", "{", "if", "(", "$", "this", "->", "connector", "->", "getURL", "(", ")", "===", "null", ")", "{", "return", "'Cannot find site URL from configuration.'", ";", "}", "$", "params", "=", "[", "'limit'", "=>", "$", "limit", ",", "'page'", "=>", "$", "page", ",", "'canary'", "=>", "$", "canary", ",", "]", ";", "$", "url", "=", "$", "this", "->", "connector", "->", "getURL", "(", ")", ".", "self", "::", "VERSION", ";", "$", "response", "=", "$", "this", "->", "connector", "->", "connecting", "(", "$", "url", ",", "$", "params", ",", "'GET'", ")", ";", "if", "(", "isset", "(", "$", "response", "->", "sites", ")", ")", "{", "return", "$", "response", "->", "sites", ";", "}", "return", "$", "response", ";", "}" ]
List sites. @param int $limit Limit number. @param int $page Page number. @param boolean $canary No value necessary. @return string
[ "List", "sites", "." ]
c9dbb9dfd71408adff0ea26db94678a61c584df6
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorSites.php#L263-L282
train
anklimsk/cakephp-console-installer
Console/Helper/StateShellHelper.php
StateShellHelper.output
public function output($args) { $args += ['', '', 63]; $this->_consoleOutput->write($this->_getState($args[0], $args[1], $args[2])); }
php
public function output($args) { $args += ['', '', 63]; $this->_consoleOutput->write($this->_getState($args[0], $args[1], $args[2])); }
[ "public", "function", "output", "(", "$", "args", ")", "{", "$", "args", "+=", "[", "''", ",", "''", ",", "63", "]", ";", "$", "this", "->", "_consoleOutput", "->", "write", "(", "$", "this", "->", "_getState", "(", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ",", "$", "args", "[", "2", "]", ")", ")", ";", "}" ]
This method should output formatted message. @param array $args The arguments for the `StateShellHelper::_getState()`. @return void
[ "This", "method", "should", "output", "formatted", "message", "." ]
76136550e856ff4f8fd3634b77633f86510f63e9
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/Console/Helper/StateShellHelper.php#L69-L72
train
chilimatic/chilimatic-framework
lib/database/sql/mysql/Tool.php
Tool.mysql_aes_encrypt
static public function mysql_aes_encrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $val = str_pad($val, (16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1))), chr(16 - (strlen($val) % 16))); return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); }
php
static public function mysql_aes_encrypt($val, $ky) { if (empty($ky) && empty($val)) return null; $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; for ($a = 0; $a < strlen($ky); $a++) { $key[$a % 16] = chr(ord($key[$a % 16]) ^ ord($ky[$a])); } $mode = MCRYPT_MODE_ECB; $enc = MCRYPT_RIJNDAEL_128; $val = str_pad($val, (16 * (floor(strlen($val) / 16) + (strlen($val) % 16 == 0 ? 2 : 1))), chr(16 - (strlen($val) % 16))); return mcrypt_encrypt($enc, $key, $val, $mode, mcrypt_create_iv(mcrypt_get_iv_size($enc, $mode), MCRYPT_DEV_URANDOM)); }
[ "static", "public", "function", "mysql_aes_encrypt", "(", "$", "val", ",", "$", "ky", ")", "{", "if", "(", "empty", "(", "$", "ky", ")", "&&", "empty", "(", "$", "val", ")", ")", "return", "null", ";", "$", "key", "=", "\"\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"", ";", "for", "(", "$", "a", "=", "0", ";", "$", "a", "<", "strlen", "(", "$", "ky", ")", ";", "$", "a", "++", ")", "{", "$", "key", "[", "$", "a", "%", "16", "]", "=", "chr", "(", "ord", "(", "$", "key", "[", "$", "a", "%", "16", "]", ")", "^", "ord", "(", "$", "ky", "[", "$", "a", "]", ")", ")", ";", "}", "$", "mode", "=", "MCRYPT_MODE_ECB", ";", "$", "enc", "=", "MCRYPT_RIJNDAEL_128", ";", "$", "val", "=", "str_pad", "(", "$", "val", ",", "(", "16", "*", "(", "floor", "(", "strlen", "(", "$", "val", ")", "/", "16", ")", "+", "(", "strlen", "(", "$", "val", ")", "%", "16", "==", "0", "?", "2", ":", "1", ")", ")", ")", ",", "chr", "(", "16", "-", "(", "strlen", "(", "$", "val", ")", "%", "16", ")", ")", ")", ";", "return", "mcrypt_encrypt", "(", "$", "enc", ",", "$", "key", ",", "$", "val", ",", "$", "mode", ",", "mcrypt_create_iv", "(", "mcrypt_get_iv_size", "(", "$", "enc", ",", "$", "mode", ")", ",", "MCRYPT_DEV_URANDOM", ")", ")", ";", "}" ]
aes mysql encryption @param string $val @param string $ky @return null|string
[ "aes", "mysql", "encryption" ]
8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Tool.php#L75-L89
train
schpill/thin
src/Url/Rule.php
Rule.resolveUrl
public function resolveUrl($url, &$parameters) { $parameters = array(); $patternSegments = $this->segments; $patternSegmentNum = count($patternSegments); $urlSegments = Helper::segmentizeUrl($url); /* * If the number of URL segments is more than the number of pattern segments - return false */ if (count($urlSegments) > count($patternSegments)) return false; /* * Compare pattern and URL segments */ foreach ($patternSegments as $index => $patternSegment) { $patternSegmentLower = mb_strtolower($patternSegment); if (strpos($patternSegment, ':') !== 0) { /* * Static segment */ if (!array_key_exists($index, $urlSegments) || $patternSegmentLower != mb_strtolower($urlSegments[$index])) return false; } else { /* * Dynamic segment. Initialize the parameter */ $paramName = Helper::getParameterName($patternSegment); $parameters[$paramName] = false; /* * Determine whether it is optional */ $optional = Helper::segmentIsOptional($patternSegment); /* * Check if the optional segment has no required segments following it */ if ($optional && $index < $patternSegmentNum - 1) { for ($i = $index + 1; $i < $patternSegmentNum; $i++) { if (!Helper::segmentIsOptional($patternSegments[$i])) { $optional = false; break; } } } /* * If the segment is optional and there is no corresponding value in the URL, assign the default value (if provided) * and skip to the next segment. */ $urlSegmentExists = array_key_exists($index, $urlSegments); if ($optional && !$urlSegmentExists) { $parameters[$paramName] = Helper::getSegmentDefaultValue($patternSegment); continue; } /* * If the segment is not optional and there is no corresponding value in the URL, return false */ if (!$optional && !$urlSegmentExists) return false; /* * Validate the value with the regular expression */ $regexp = Helper::getSegmentRegExp($patternSegment); if ($regexp) { try { if (!preg_match($regexp, $urlSegments[$index])) return false; } catch (\Exception $ex) {} } /* * Set the parameter value */ $parameters[$paramName] = $urlSegments[$index]; } } return true; }
php
public function resolveUrl($url, &$parameters) { $parameters = array(); $patternSegments = $this->segments; $patternSegmentNum = count($patternSegments); $urlSegments = Helper::segmentizeUrl($url); /* * If the number of URL segments is more than the number of pattern segments - return false */ if (count($urlSegments) > count($patternSegments)) return false; /* * Compare pattern and URL segments */ foreach ($patternSegments as $index => $patternSegment) { $patternSegmentLower = mb_strtolower($patternSegment); if (strpos($patternSegment, ':') !== 0) { /* * Static segment */ if (!array_key_exists($index, $urlSegments) || $patternSegmentLower != mb_strtolower($urlSegments[$index])) return false; } else { /* * Dynamic segment. Initialize the parameter */ $paramName = Helper::getParameterName($patternSegment); $parameters[$paramName] = false; /* * Determine whether it is optional */ $optional = Helper::segmentIsOptional($patternSegment); /* * Check if the optional segment has no required segments following it */ if ($optional && $index < $patternSegmentNum - 1) { for ($i = $index + 1; $i < $patternSegmentNum; $i++) { if (!Helper::segmentIsOptional($patternSegments[$i])) { $optional = false; break; } } } /* * If the segment is optional and there is no corresponding value in the URL, assign the default value (if provided) * and skip to the next segment. */ $urlSegmentExists = array_key_exists($index, $urlSegments); if ($optional && !$urlSegmentExists) { $parameters[$paramName] = Helper::getSegmentDefaultValue($patternSegment); continue; } /* * If the segment is not optional and there is no corresponding value in the URL, return false */ if (!$optional && !$urlSegmentExists) return false; /* * Validate the value with the regular expression */ $regexp = Helper::getSegmentRegExp($patternSegment); if ($regexp) { try { if (!preg_match($regexp, $urlSegments[$index])) return false; } catch (\Exception $ex) {} } /* * Set the parameter value */ $parameters[$paramName] = $urlSegments[$index]; } } return true; }
[ "public", "function", "resolveUrl", "(", "$", "url", ",", "&", "$", "parameters", ")", "{", "$", "parameters", "=", "array", "(", ")", ";", "$", "patternSegments", "=", "$", "this", "->", "segments", ";", "$", "patternSegmentNum", "=", "count", "(", "$", "patternSegments", ")", ";", "$", "urlSegments", "=", "Helper", "::", "segmentizeUrl", "(", "$", "url", ")", ";", "/*\n * If the number of URL segments is more than the number of pattern segments - return false\n */", "if", "(", "count", "(", "$", "urlSegments", ")", ">", "count", "(", "$", "patternSegments", ")", ")", "return", "false", ";", "/*\n * Compare pattern and URL segments\n */", "foreach", "(", "$", "patternSegments", "as", "$", "index", "=>", "$", "patternSegment", ")", "{", "$", "patternSegmentLower", "=", "mb_strtolower", "(", "$", "patternSegment", ")", ";", "if", "(", "strpos", "(", "$", "patternSegment", ",", "':'", ")", "!==", "0", ")", "{", "/*\n * Static segment\n */", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "urlSegments", ")", "||", "$", "patternSegmentLower", "!=", "mb_strtolower", "(", "$", "urlSegments", "[", "$", "index", "]", ")", ")", "return", "false", ";", "}", "else", "{", "/*\n * Dynamic segment. Initialize the parameter\n */", "$", "paramName", "=", "Helper", "::", "getParameterName", "(", "$", "patternSegment", ")", ";", "$", "parameters", "[", "$", "paramName", "]", "=", "false", ";", "/*\n * Determine whether it is optional\n */", "$", "optional", "=", "Helper", "::", "segmentIsOptional", "(", "$", "patternSegment", ")", ";", "/*\n * Check if the optional segment has no required segments following it\n */", "if", "(", "$", "optional", "&&", "$", "index", "<", "$", "patternSegmentNum", "-", "1", ")", "{", "for", "(", "$", "i", "=", "$", "index", "+", "1", ";", "$", "i", "<", "$", "patternSegmentNum", ";", "$", "i", "++", ")", "{", "if", "(", "!", "Helper", "::", "segmentIsOptional", "(", "$", "patternSegments", "[", "$", "i", "]", ")", ")", "{", "$", "optional", "=", "false", ";", "break", ";", "}", "}", "}", "/*\n * If the segment is optional and there is no corresponding value in the URL, assign the default value (if provided)\n * and skip to the next segment.\n */", "$", "urlSegmentExists", "=", "array_key_exists", "(", "$", "index", ",", "$", "urlSegments", ")", ";", "if", "(", "$", "optional", "&&", "!", "$", "urlSegmentExists", ")", "{", "$", "parameters", "[", "$", "paramName", "]", "=", "Helper", "::", "getSegmentDefaultValue", "(", "$", "patternSegment", ")", ";", "continue", ";", "}", "/*\n * If the segment is not optional and there is no corresponding value in the URL, return false\n */", "if", "(", "!", "$", "optional", "&&", "!", "$", "urlSegmentExists", ")", "return", "false", ";", "/*\n * Validate the value with the regular expression\n */", "$", "regexp", "=", "Helper", "::", "getSegmentRegExp", "(", "$", "patternSegment", ")", ";", "if", "(", "$", "regexp", ")", "{", "try", "{", "if", "(", "!", "preg_match", "(", "$", "regexp", ",", "$", "urlSegments", "[", "$", "index", "]", ")", ")", "return", "false", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "}", "}", "/*\n * Set the parameter value\n */", "$", "parameters", "[", "$", "paramName", "]", "=", "$", "urlSegments", "[", "$", "index", "]", ";", "}", "}", "return", "true", ";", "}" ]
Checks whether a given URL matches a given pattern. @param string $url The URL to check. @param array $parameters A reference to a PHP array variable to return the parameter list fetched from URL. @return boolean Returns true if the URL matches the pattern. Otherwise returns false.
[ "Checks", "whether", "a", "given", "URL", "matches", "a", "given", "pattern", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L83-L169
train
schpill/thin
src/Url/Rule.php
Rule.name
public function name($name = null) { if ($name === null) return $this->ruleName; $this->ruleName = $name; return $this; }
php
public function name($name = null) { if ($name === null) return $this->ruleName; $this->ruleName = $name; return $this; }
[ "public", "function", "name", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "return", "$", "this", "->", "ruleName", ";", "$", "this", "->", "ruleName", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
Unique route name @param string $name Unique name for the router object @return object Self
[ "Unique", "route", "name" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L177-L184
train
schpill/thin
src/Url/Rule.php
Rule.pattern
public function pattern($pattern = null) { if ($pattern === null) return $this->rulePattern; $this->rulePattern = $pattern; return $this; }
php
public function pattern($pattern = null) { if ($pattern === null) return $this->rulePattern; $this->rulePattern = $pattern; return $this; }
[ "public", "function", "pattern", "(", "$", "pattern", "=", "null", ")", "{", "if", "(", "$", "pattern", "===", "null", ")", "return", "$", "this", "->", "rulePattern", ";", "$", "this", "->", "rulePattern", "=", "$", "pattern", ";", "return", "$", "this", ";", "}" ]
Route match pattern @param string $pattern Pattern used to match this rule @return object Self
[ "Route", "match", "pattern" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L192-L199
train
schpill/thin
src/Url/Rule.php
Rule.afterMatch
public function afterMatch($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "The after match callback provided is not valid. Given (%s)", gettype($callback) ) ); } $this->afterMatchCallback = $callback; return $this; } return $this->afterMatchCallback; }
php
public function afterMatch($callback = null) { if ($callback !== null) { if (!is_callable($callback)) { throw new InvalidArgumentException( sprintf( "The after match callback provided is not valid. Given (%s)", gettype($callback) ) ); } $this->afterMatchCallback = $callback; return $this; } return $this->afterMatchCallback; }
[ "public", "function", "afterMatch", "(", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "!==", "null", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"The after match callback provided is not valid. Given (%s)\"", ",", "gettype", "(", "$", "callback", ")", ")", ")", ";", "}", "$", "this", "->", "afterMatchCallback", "=", "$", "callback", ";", "return", "$", "this", ";", "}", "return", "$", "this", "->", "afterMatchCallback", ";", "}" ]
After match callback @param callback $callback Callback function to be used to modify params after a successful match @throws InvalidArgumentException When supplied argument is not a valid callback @return callback
[ "After", "match", "callback" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Url/Rule.php#L236-L254
train
znframework/package-hypertext
BuilderExtends.php
BuilderExtends.openCloseTag
protected function openCloseTag($string) { if( $this->tag === true ) { $script = $this->getScriptClass(); $string = $script->open() . $string . $script->close(); } $this->tag = false; return $string; }
php
protected function openCloseTag($string) { if( $this->tag === true ) { $script = $this->getScriptClass(); $string = $script->open() . $string . $script->close(); } $this->tag = false; return $string; }
[ "protected", "function", "openCloseTag", "(", "$", "string", ")", "{", "if", "(", "$", "this", "->", "tag", "===", "true", ")", "{", "$", "script", "=", "$", "this", "->", "getScriptClass", "(", ")", ";", "$", "string", "=", "$", "script", "->", "open", "(", ")", ".", "$", "string", ".", "$", "script", "->", "close", "(", ")", ";", "}", "$", "this", "->", "tag", "=", "false", ";", "return", "$", "string", ";", "}" ]
Protected script open close tag
[ "Protected", "script", "open", "close", "tag" ]
12bbc3bd47a2fae735f638a3e01cc82c1b9c9005
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/BuilderExtends.php#L64-L76
train
znframework/package-hypertext
BuilderExtends.php
BuilderExtends.isCallableOption
protected function isCallableOption($callback, $parameter) { $option = 'function(' . $parameter . '){' . PHP_EOL; $option .= Buffering\Callback::do($callback); $option .= '}'; return $option; }
php
protected function isCallableOption($callback, $parameter) { $option = 'function(' . $parameter . '){' . PHP_EOL; $option .= Buffering\Callback::do($callback); $option .= '}'; return $option; }
[ "protected", "function", "isCallableOption", "(", "$", "callback", ",", "$", "parameter", ")", "{", "$", "option", "=", "'function('", ".", "$", "parameter", ".", "'){'", ".", "PHP_EOL", ";", "$", "option", ".=", "Buffering", "\\", "Callback", "::", "do", "(", "$", "callback", ")", ";", "$", "option", ".=", "'}'", ";", "return", "$", "option", ";", "}" ]
Protected is callable option
[ "Protected", "is", "callable", "option" ]
12bbc3bd47a2fae735f638a3e01cc82c1b9c9005
https://github.com/znframework/package-hypertext/blob/12bbc3bd47a2fae735f638a3e01cc82c1b9c9005/BuilderExtends.php#L81-L88
train
wdbo/webdocbook
src/WebDocBook/Controller/WebDocBookController.php
WebDocBookController.docbookdocAction
public function docbookdocAction() { $title = _T('User manual'); $md_parser = $this->wdb->getMarkdownParser(); // user manual $path = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:user_manual', ''); $update = Helper::getDateTimeFromTimestamp(filemtime($path)); $file_content = file_get_contents($path); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $user_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $user_manual_content= $md_content->getBody(); // MD manual $path_md = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:md_manual', ''); $update_md = Helper::getDateTimeFromTimestamp(filemtime($path_md)); $file_content = file_get_contents($path_md); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $md_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $md_manual_content = $md_content->getBody(); // about content $about_content = $this->wdb->display( '', 'credits', array('page_tools'=>'false') ); // global page $page_infos = array( 'name' => $title, 'path' => 'docbookdoc', 'update' => $update_md > $update ? $update_md : $update ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => array(), 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'user_manual', array( 'user_manual_content' => $user_manual_content, 'md_manual_content' => $md_manual_content, 'user_manual_menu' => $user_manual_menu, 'md_manual_menu' => $md_manual_menu, 'about_content' => $about_content, 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, ) ); return array('default', $content, $tpl_params); }
php
public function docbookdocAction() { $title = _T('User manual'); $md_parser = $this->wdb->getMarkdownParser(); // user manual $path = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:user_manual', ''); $update = Helper::getDateTimeFromTimestamp(filemtime($path)); $file_content = file_get_contents($path); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $user_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $user_manual_content= $md_content->getBody(); // MD manual $path_md = Kernel::getPath('webdocbook_assets') . Kernel::getConfig('pages:md_manual', ''); $update_md = Helper::getDateTimeFromTimestamp(filemtime($path_md)); $file_content = file_get_contents($path_md); $md_content = $md_parser->transformString($file_content); $output_bag = $md_parser->get('OutputFormatBag'); $md_manual_menu = $output_bag->getHelper() ->getToc($md_content, $output_bag->getFormater()); $md_manual_content = $md_content->getBody(); // about content $about_content = $this->wdb->display( '', 'credits', array('page_tools'=>'false') ); // global page $page_infos = array( 'name' => $title, 'path' => 'docbookdoc', 'update' => $update_md > $update ? $update_md : $update ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => array(), 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'user_manual', array( 'user_manual_content' => $user_manual_content, 'md_manual_content' => $md_manual_content, 'user_manual_menu' => $user_manual_menu, 'md_manual_menu' => $md_manual_menu, 'about_content' => $about_content, 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, ) ); return array('default', $content, $tpl_params); }
[ "public", "function", "docbookdocAction", "(", ")", "{", "$", "title", "=", "_T", "(", "'User manual'", ")", ";", "$", "md_parser", "=", "$", "this", "->", "wdb", "->", "getMarkdownParser", "(", ")", ";", "// user manual", "$", "path", "=", "Kernel", "::", "getPath", "(", "'webdocbook_assets'", ")", ".", "Kernel", "::", "getConfig", "(", "'pages:user_manual'", ",", "''", ")", ";", "$", "update", "=", "Helper", "::", "getDateTimeFromTimestamp", "(", "filemtime", "(", "$", "path", ")", ")", ";", "$", "file_content", "=", "file_get_contents", "(", "$", "path", ")", ";", "$", "md_content", "=", "$", "md_parser", "->", "transformString", "(", "$", "file_content", ")", ";", "$", "output_bag", "=", "$", "md_parser", "->", "get", "(", "'OutputFormatBag'", ")", ";", "$", "user_manual_menu", "=", "$", "output_bag", "->", "getHelper", "(", ")", "->", "getToc", "(", "$", "md_content", ",", "$", "output_bag", "->", "getFormater", "(", ")", ")", ";", "$", "user_manual_content", "=", "$", "md_content", "->", "getBody", "(", ")", ";", "// MD manual", "$", "path_md", "=", "Kernel", "::", "getPath", "(", "'webdocbook_assets'", ")", ".", "Kernel", "::", "getConfig", "(", "'pages:md_manual'", ",", "''", ")", ";", "$", "update_md", "=", "Helper", "::", "getDateTimeFromTimestamp", "(", "filemtime", "(", "$", "path_md", ")", ")", ";", "$", "file_content", "=", "file_get_contents", "(", "$", "path_md", ")", ";", "$", "md_content", "=", "$", "md_parser", "->", "transformString", "(", "$", "file_content", ")", ";", "$", "output_bag", "=", "$", "md_parser", "->", "get", "(", "'OutputFormatBag'", ")", ";", "$", "md_manual_menu", "=", "$", "output_bag", "->", "getHelper", "(", ")", "->", "getToc", "(", "$", "md_content", ",", "$", "output_bag", "->", "getFormater", "(", ")", ")", ";", "$", "md_manual_content", "=", "$", "md_content", "->", "getBody", "(", ")", ";", "// about content", "$", "about_content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'credits'", ",", "array", "(", "'page_tools'", "=>", "'false'", ")", ")", ";", "// global page", "$", "page_infos", "=", "array", "(", "'name'", "=>", "$", "title", ",", "'path'", "=>", "'docbookdoc'", ",", "'update'", "=>", "$", "update_md", ">", "$", "update", "?", "$", "update_md", ":", "$", "update", ")", ";", "$", "tpl_params", "=", "array", "(", "'breadcrumbs'", "=>", "array", "(", "$", "title", ")", ",", "'title'", "=>", "$", "title", ",", "'page'", "=>", "array", "(", ")", ",", "'page_tools'", "=>", "'false'", ")", ";", "$", "content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'user_manual'", ",", "array", "(", "'user_manual_content'", "=>", "$", "user_manual_content", ",", "'md_manual_content'", "=>", "$", "md_manual_content", ",", "'user_manual_menu'", "=>", "$", "user_manual_menu", ",", "'md_manual_menu'", "=>", "$", "md_manual_menu", ",", "'about_content'", "=>", "$", "about_content", ",", "'page'", "=>", "$", "page_infos", ",", "'page_tools'", "=>", "'false'", ",", "'page_title'", "=>", "'true'", ",", "'title'", "=>", "$", "title", ",", ")", ")", ";", "return", "array", "(", "'default'", ",", "$", "content", ",", "$", "tpl_params", ")", ";", "}" ]
The internal documentation action @return array
[ "The", "internal", "documentation", "action" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/WebDocBookController.php#L91-L150
train
wdbo/webdocbook
src/WebDocBook/Controller/WebDocBookController.php
WebDocBookController.adminAction
public function adminAction() { $allowed = Kernel::getConfig('expose_admin', false, 'user_config'); $saveadmin = $this->wdb->getUser()->getSession()->get('saveadmin'); $this->wdb->getUser()->getSession()->remove('saveadmin'); if ( (!$allowed || ('true' !== $allowed && '1' !== $allowed)) && (is_null($saveadmin) || $saveadmin != time()) ) { throw new NotFoundException('Forbidden access!'); } $user_config_file = Kernel::getPath('user_config_filepath', true); $user_config = Kernel::get('user_config'); $title = _T('Administration panel'); $page_infos = array( 'name' => $title, 'path' => 'admin', ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => $page_infos, 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'admin_panel', array( 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, 'user_config_file'=> $user_config_file, 'user_config' => $user_config, 'config' => Kernel::getConfig(), ) ); return array('default', $content, $tpl_params); }
php
public function adminAction() { $allowed = Kernel::getConfig('expose_admin', false, 'user_config'); $saveadmin = $this->wdb->getUser()->getSession()->get('saveadmin'); $this->wdb->getUser()->getSession()->remove('saveadmin'); if ( (!$allowed || ('true' !== $allowed && '1' !== $allowed)) && (is_null($saveadmin) || $saveadmin != time()) ) { throw new NotFoundException('Forbidden access!'); } $user_config_file = Kernel::getPath('user_config_filepath', true); $user_config = Kernel::get('user_config'); $title = _T('Administration panel'); $page_infos = array( 'name' => $title, 'path' => 'admin', ); $tpl_params = array( 'breadcrumbs' => array($title), 'title' => $title, 'page' => $page_infos, 'page_tools' => 'false' ); $content = $this->wdb->display( '', 'admin_panel', array( 'page' => $page_infos, 'page_tools' => 'false', 'page_title' => 'true', 'title' => $title, 'user_config_file'=> $user_config_file, 'user_config' => $user_config, 'config' => Kernel::getConfig(), ) ); return array('default', $content, $tpl_params); }
[ "public", "function", "adminAction", "(", ")", "{", "$", "allowed", "=", "Kernel", "::", "getConfig", "(", "'expose_admin'", ",", "false", ",", "'user_config'", ")", ";", "$", "saveadmin", "=", "$", "this", "->", "wdb", "->", "getUser", "(", ")", "->", "getSession", "(", ")", "->", "get", "(", "'saveadmin'", ")", ";", "$", "this", "->", "wdb", "->", "getUser", "(", ")", "->", "getSession", "(", ")", "->", "remove", "(", "'saveadmin'", ")", ";", "if", "(", "(", "!", "$", "allowed", "||", "(", "'true'", "!==", "$", "allowed", "&&", "'1'", "!==", "$", "allowed", ")", ")", "&&", "(", "is_null", "(", "$", "saveadmin", ")", "||", "$", "saveadmin", "!=", "time", "(", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'Forbidden access!'", ")", ";", "}", "$", "user_config_file", "=", "Kernel", "::", "getPath", "(", "'user_config_filepath'", ",", "true", ")", ";", "$", "user_config", "=", "Kernel", "::", "get", "(", "'user_config'", ")", ";", "$", "title", "=", "_T", "(", "'Administration panel'", ")", ";", "$", "page_infos", "=", "array", "(", "'name'", "=>", "$", "title", ",", "'path'", "=>", "'admin'", ",", ")", ";", "$", "tpl_params", "=", "array", "(", "'breadcrumbs'", "=>", "array", "(", "$", "title", ")", ",", "'title'", "=>", "$", "title", ",", "'page'", "=>", "$", "page_infos", ",", "'page_tools'", "=>", "'false'", ")", ";", "$", "content", "=", "$", "this", "->", "wdb", "->", "display", "(", "''", ",", "'admin_panel'", ",", "array", "(", "'page'", "=>", "$", "page_infos", ",", "'page_tools'", "=>", "'false'", ",", "'page_title'", "=>", "'true'", ",", "'title'", "=>", "$", "title", ",", "'user_config_file'", "=>", "$", "user_config_file", ",", "'user_config'", "=>", "$", "user_config", ",", "'config'", "=>", "Kernel", "::", "getConfig", "(", ")", ",", ")", ")", ";", "return", "array", "(", "'default'", ",", "$", "content", ",", "$", "tpl_params", ")", ";", "}" ]
Admin panel action @return array @throws \WebDocBook\Exception\NotFoundException
[ "Admin", "panel", "action" ]
7d4e806f674b6222c9a3e85bfed34e72bc9d584e
https://github.com/wdbo/webdocbook/blob/7d4e806f674b6222c9a3e85bfed34e72bc9d584e/src/WebDocBook/Controller/WebDocBookController.php#L157-L198
train
jasny/iterator-stream
src/CsvOutputStream.php
CsvOutputStream.write
public function write(iterable $data, ?array $headers = null): void { $this->assertAttached(); $this->begin($headers); foreach ($data as $element) { $this->writeElement($element); } $this->end(); }
php
public function write(iterable $data, ?array $headers = null): void { $this->assertAttached(); $this->begin($headers); foreach ($data as $element) { $this->writeElement($element); } $this->end(); }
[ "public", "function", "write", "(", "iterable", "$", "data", ",", "?", "array", "$", "headers", "=", "null", ")", ":", "void", "{", "$", "this", "->", "assertAttached", "(", ")", ";", "$", "this", "->", "begin", "(", "$", "headers", ")", ";", "foreach", "(", "$", "data", "as", "$", "element", ")", "{", "$", "this", "->", "writeElement", "(", "$", "element", ")", ";", "}", "$", "this", "->", "end", "(", ")", ";", "}" ]
Write to traversable data to stream. @param iterable $data @param string[]|null $headers @return void
[ "Write", "to", "traversable", "data", "to", "stream", "." ]
a4d63eb2825956a879740cc44addd6170f7a481d
https://github.com/jasny/iterator-stream/blob/a4d63eb2825956a879740cc44addd6170f7a481d/src/CsvOutputStream.php#L90-L101
train
alekitto/metadata
lib/Factory/MetadataFactory.php
MetadataFactory.setMetadataClass
public function setMetadataClass(string $metadataClass): void { if (! class_exists($metadataClass) || ! (new \ReflectionClass($metadataClass))->implementsInterface(ClassMetadataInterface::class)) { throw InvalidArgumentException::create(InvalidArgumentException::INVALID_METADATA_CLASS, $metadataClass); } $this->metadataClass = $metadataClass; }
php
public function setMetadataClass(string $metadataClass): void { if (! class_exists($metadataClass) || ! (new \ReflectionClass($metadataClass))->implementsInterface(ClassMetadataInterface::class)) { throw InvalidArgumentException::create(InvalidArgumentException::INVALID_METADATA_CLASS, $metadataClass); } $this->metadataClass = $metadataClass; }
[ "public", "function", "setMetadataClass", "(", "string", "$", "metadataClass", ")", ":", "void", "{", "if", "(", "!", "class_exists", "(", "$", "metadataClass", ")", "||", "!", "(", "new", "\\", "ReflectionClass", "(", "$", "metadataClass", ")", ")", "->", "implementsInterface", "(", "ClassMetadataInterface", "::", "class", ")", ")", "{", "throw", "InvalidArgumentException", "::", "create", "(", "InvalidArgumentException", "::", "INVALID_METADATA_CLASS", ",", "$", "metadataClass", ")", ";", "}", "$", "this", "->", "metadataClass", "=", "$", "metadataClass", ";", "}" ]
Set the metadata class to be created by this factory. @param string $metadataClass
[ "Set", "the", "metadata", "class", "to", "be", "created", "by", "this", "factory", "." ]
0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c
https://github.com/alekitto/metadata/blob/0422ac8d7fe72d5fa8cc51b6f1e173866e8afb2c/lib/Factory/MetadataFactory.php#L23-L30
train
oliwierptak/Everon1
src/Everon/Logger.php
Logger.write
protected function write($message, $level, array $parameters) { if ($this->enabled === false) { return null; } if ($this->log_request_identifier === null) { $this->log_request_identifier = "MISSING_REQUEST_ID"; } $ExceptionToTrace = $message; if ($message instanceof \Exception) { $message = (string) $message; //casting to string will append exception name } $LogDate = ($this->getFactory()->buildDateTime(null, $this->getLogDateTimeZone())); $Filename = $this->getFilenameByLevel($level); if ($Filename->isFile() && $Filename->isWritable() === false) { return $LogDate; } $this->logRotate($Filename); $this->write_count++; $request_id = substr($this->log_request_identifier, 0, 6); $trace_id = substr(md5(uniqid()), 0, 6); $write_count = $this->write_count; $id = "$request_id/$trace_id ($write_count)"; $message = empty($parameters) === false ? vsprintf($message, $parameters) : $message; $message = $LogDate->format($this->getLogDateFormat())." ${id} ".$message; if ($ExceptionToTrace instanceof \Exception) { $trace = $ExceptionToTrace->getTraceAsString().$this->getPreviousTraceDump($ExceptionToTrace->getPrevious()); if ($trace !== '') { $message .= "\n".$trace."\n"; } } if (is_dir($Filename->getPath()) === false) { @mkdir($Filename->getPath(), 0775, true); } @error_log($message."\n", 3, $Filename->getPathname()); return $LogDate; }
php
protected function write($message, $level, array $parameters) { if ($this->enabled === false) { return null; } if ($this->log_request_identifier === null) { $this->log_request_identifier = "MISSING_REQUEST_ID"; } $ExceptionToTrace = $message; if ($message instanceof \Exception) { $message = (string) $message; //casting to string will append exception name } $LogDate = ($this->getFactory()->buildDateTime(null, $this->getLogDateTimeZone())); $Filename = $this->getFilenameByLevel($level); if ($Filename->isFile() && $Filename->isWritable() === false) { return $LogDate; } $this->logRotate($Filename); $this->write_count++; $request_id = substr($this->log_request_identifier, 0, 6); $trace_id = substr(md5(uniqid()), 0, 6); $write_count = $this->write_count; $id = "$request_id/$trace_id ($write_count)"; $message = empty($parameters) === false ? vsprintf($message, $parameters) : $message; $message = $LogDate->format($this->getLogDateFormat())." ${id} ".$message; if ($ExceptionToTrace instanceof \Exception) { $trace = $ExceptionToTrace->getTraceAsString().$this->getPreviousTraceDump($ExceptionToTrace->getPrevious()); if ($trace !== '') { $message .= "\n".$trace."\n"; } } if (is_dir($Filename->getPath()) === false) { @mkdir($Filename->getPath(), 0775, true); } @error_log($message."\n", 3, $Filename->getPathname()); return $LogDate; }
[ "protected", "function", "write", "(", "$", "message", ",", "$", "level", ",", "array", "$", "parameters", ")", "{", "if", "(", "$", "this", "->", "enabled", "===", "false", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "log_request_identifier", "===", "null", ")", "{", "$", "this", "->", "log_request_identifier", "=", "\"MISSING_REQUEST_ID\"", ";", "}", "$", "ExceptionToTrace", "=", "$", "message", ";", "if", "(", "$", "message", "instanceof", "\\", "Exception", ")", "{", "$", "message", "=", "(", "string", ")", "$", "message", ";", "//casting to string will append exception name", "}", "$", "LogDate", "=", "(", "$", "this", "->", "getFactory", "(", ")", "->", "buildDateTime", "(", "null", ",", "$", "this", "->", "getLogDateTimeZone", "(", ")", ")", ")", ";", "$", "Filename", "=", "$", "this", "->", "getFilenameByLevel", "(", "$", "level", ")", ";", "if", "(", "$", "Filename", "->", "isFile", "(", ")", "&&", "$", "Filename", "->", "isWritable", "(", ")", "===", "false", ")", "{", "return", "$", "LogDate", ";", "}", "$", "this", "->", "logRotate", "(", "$", "Filename", ")", ";", "$", "this", "->", "write_count", "++", ";", "$", "request_id", "=", "substr", "(", "$", "this", "->", "log_request_identifier", ",", "0", ",", "6", ")", ";", "$", "trace_id", "=", "substr", "(", "md5", "(", "uniqid", "(", ")", ")", ",", "0", ",", "6", ")", ";", "$", "write_count", "=", "$", "this", "->", "write_count", ";", "$", "id", "=", "\"$request_id/$trace_id ($write_count)\"", ";", "$", "message", "=", "empty", "(", "$", "parameters", ")", "===", "false", "?", "vsprintf", "(", "$", "message", ",", "$", "parameters", ")", ":", "$", "message", ";", "$", "message", "=", "$", "LogDate", "->", "format", "(", "$", "this", "->", "getLogDateFormat", "(", ")", ")", ".", "\" ${id} \"", ".", "$", "message", ";", "if", "(", "$", "ExceptionToTrace", "instanceof", "\\", "Exception", ")", "{", "$", "trace", "=", "$", "ExceptionToTrace", "->", "getTraceAsString", "(", ")", ".", "$", "this", "->", "getPreviousTraceDump", "(", "$", "ExceptionToTrace", "->", "getPrevious", "(", ")", ")", ";", "if", "(", "$", "trace", "!==", "''", ")", "{", "$", "message", ".=", "\"\\n\"", ".", "$", "trace", ".", "\"\\n\"", ";", "}", "}", "if", "(", "is_dir", "(", "$", "Filename", "->", "getPath", "(", ")", ")", "===", "false", ")", "{", "@", "mkdir", "(", "$", "Filename", "->", "getPath", "(", ")", ",", "0775", ",", "true", ")", ";", "}", "@", "error_log", "(", "$", "message", ".", "\"\\n\"", ",", "3", ",", "$", "Filename", "->", "getPathname", "(", ")", ")", ";", "return", "$", "LogDate", ";", "}" ]
Don't generate errors and only write to log file when possible @param $message \Exception or string @param $level @param $parameters @return \DateTime @throws Exception\Logger
[ "Don", "t", "generate", "errors", "and", "only", "write", "to", "log", "file", "when", "possible" ]
ac93793d1fa517a8394db5f00062f1925dc218a3
https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Logger.php#L72-L119
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.enableComponent
public function enableComponent($name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } $this->components[$name] = true; return $this; }
php
public function enableComponent($name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } $this->components[$name] = true; return $this; }
[ "public", "function", "enableComponent", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "components", ")", ")", "{", "throw", "new", "NotValidCompoenentException", "(", "$", "name", ".", "' component is not valid'", ")", ";", "}", "$", "this", "->", "components", "[", "$", "name", "]", "=", "true", ";", "return", "$", "this", ";", "}" ]
Enable named component for compiler @param string $name component name @return $this
[ "Enable", "named", "component", "for", "compiler" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L101-L110
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.enableAll
public function enableAll(array $except = []) { // Check if excluded components name are exists or not foreach ($except as $name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } } // Enable components foreach ($this->components as $name => &$status) { $status = !in_array($name, $except, true); } return $this; }
php
public function enableAll(array $except = []) { // Check if excluded components name are exists or not foreach ($except as $name) { if (!array_key_exists($name, $this->components)) { throw new NotValidCompoenentException($name . ' component is not valid'); } } // Enable components foreach ($this->components as $name => &$status) { $status = !in_array($name, $except, true); } return $this; }
[ "public", "function", "enableAll", "(", "array", "$", "except", "=", "[", "]", ")", "{", "// Check if excluded components name are exists or not", "foreach", "(", "$", "except", "as", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "components", ")", ")", "{", "throw", "new", "NotValidCompoenentException", "(", "$", "name", ".", "' component is not valid'", ")", ";", "}", "}", "// Enable components", "foreach", "(", "$", "this", "->", "components", "as", "$", "name", "=>", "&", "$", "status", ")", "{", "$", "status", "=", "!", "in_array", "(", "$", "name", ",", "$", "except", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Enable all components except listed ones @param string[] $except list of components that will be not enabled @return $this
[ "Enable", "all", "components", "except", "listed", "ones" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L119-L134
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.compile
public function compile($force = false) { $jsOutputPath = $this->outputPath['js'] . '/bootstrap.min.js'; $cssOutputPath = $this->outputPath['css'] . '/bootstrap.min.css'; if ($force === true || !$this->filesystem->exists($jsOutputPath)) { $this->filesystem->makeDirectory(dirname($jsOutputPath), 0755, true, true); $this->filesystem->put($jsOutputPath, $this->minifyJs()); $this->lineToOutput('Compiled <info>JavaScript</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } if ($force === true || !$this->filesystem->exists($cssOutputPath)) { $this->filesystem->makeDirectory(dirname($cssOutputPath), 0755, true, true); $this->filesystem->put($cssOutputPath, $this->minifyCss()); $this->lineToOutput('Compiled <info>StyleSheet</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } }
php
public function compile($force = false) { $jsOutputPath = $this->outputPath['js'] . '/bootstrap.min.js'; $cssOutputPath = $this->outputPath['css'] . '/bootstrap.min.css'; if ($force === true || !$this->filesystem->exists($jsOutputPath)) { $this->filesystem->makeDirectory(dirname($jsOutputPath), 0755, true, true); $this->filesystem->put($jsOutputPath, $this->minifyJs()); $this->lineToOutput('Compiled <info>JavaScript</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } if ($force === true || !$this->filesystem->exists($cssOutputPath)) { $this->filesystem->makeDirectory(dirname($cssOutputPath), 0755, true, true); $this->filesystem->put($cssOutputPath, $this->minifyCss()); $this->lineToOutput('Compiled <info>StyleSheet</info> was successfully written to <info>' . $jsOutputPath . '</info> file'); } }
[ "public", "function", "compile", "(", "$", "force", "=", "false", ")", "{", "$", "jsOutputPath", "=", "$", "this", "->", "outputPath", "[", "'js'", "]", ".", "'/bootstrap.min.js'", ";", "$", "cssOutputPath", "=", "$", "this", "->", "outputPath", "[", "'css'", "]", ".", "'/bootstrap.min.css'", ";", "if", "(", "$", "force", "===", "true", "||", "!", "$", "this", "->", "filesystem", "->", "exists", "(", "$", "jsOutputPath", ")", ")", "{", "$", "this", "->", "filesystem", "->", "makeDirectory", "(", "dirname", "(", "$", "jsOutputPath", ")", ",", "0755", ",", "true", ",", "true", ")", ";", "$", "this", "->", "filesystem", "->", "put", "(", "$", "jsOutputPath", ",", "$", "this", "->", "minifyJs", "(", ")", ")", ";", "$", "this", "->", "lineToOutput", "(", "'Compiled <info>JavaScript</info> was successfully written to <info>'", ".", "$", "jsOutputPath", ".", "'</info> file'", ")", ";", "}", "if", "(", "$", "force", "===", "true", "||", "!", "$", "this", "->", "filesystem", "->", "exists", "(", "$", "cssOutputPath", ")", ")", "{", "$", "this", "->", "filesystem", "->", "makeDirectory", "(", "dirname", "(", "$", "cssOutputPath", ")", ",", "0755", ",", "true", ",", "true", ")", ";", "$", "this", "->", "filesystem", "->", "put", "(", "$", "cssOutputPath", ",", "$", "this", "->", "minifyCss", "(", ")", ")", ";", "$", "this", "->", "lineToOutput", "(", "'Compiled <info>StyleSheet</info> was successfully written to <info>'", ".", "$", "jsOutputPath", ".", "'</info> file'", ")", ";", "}", "}" ]
Compile enabled components @param bool $force if TRUE cache will be invalidated and new compiled resources will be created @return void @throws \ViKon\Bootstrap\Exception\CompilerException
[ "Compile", "enabled", "components" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L194-L210
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.minifyJs
protected function minifyJs() { $minifier = new Minify\JS(); // Components $this->addJsToMinifier($minifier, 'dropdowns', 'dropdown'); // Components w/ JavaScript $this->addJsToMinifier($minifier, 'modals', 'modal'); $this->addJsToMinifier($minifier, 'tooltip'); $this->addJsToMinifier($minifier, 'popovers', 'popover'); $this->addJsToMinifier($minifier, 'carousel'); // Pure JavaScript components $this->addJsToMinifier($minifier, 'affix'); $this->addJsToMinifier($minifier, 'alert'); $this->addJsToMinifier($minifier, 'button'); $this->addJsToMinifier($minifier, 'collapse'); $this->addJsToMinifier($minifier, 'scrollspy'); $this->addJsToMinifier($minifier, 'tab'); $this->addJsToMinifier($minifier, 'transition'); return $minifier->minify(); }
php
protected function minifyJs() { $minifier = new Minify\JS(); // Components $this->addJsToMinifier($minifier, 'dropdowns', 'dropdown'); // Components w/ JavaScript $this->addJsToMinifier($minifier, 'modals', 'modal'); $this->addJsToMinifier($minifier, 'tooltip'); $this->addJsToMinifier($minifier, 'popovers', 'popover'); $this->addJsToMinifier($minifier, 'carousel'); // Pure JavaScript components $this->addJsToMinifier($minifier, 'affix'); $this->addJsToMinifier($minifier, 'alert'); $this->addJsToMinifier($minifier, 'button'); $this->addJsToMinifier($minifier, 'collapse'); $this->addJsToMinifier($minifier, 'scrollspy'); $this->addJsToMinifier($minifier, 'tab'); $this->addJsToMinifier($minifier, 'transition'); return $minifier->minify(); }
[ "protected", "function", "minifyJs", "(", ")", "{", "$", "minifier", "=", "new", "Minify", "\\", "JS", "(", ")", ";", "// Components", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'dropdowns'", ",", "'dropdown'", ")", ";", "// Components w/ JavaScript", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'modals'", ",", "'modal'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'tooltip'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'popovers'", ",", "'popover'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'carousel'", ")", ";", "// Pure JavaScript components", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'affix'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'alert'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'button'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'collapse'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'scrollspy'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'tab'", ")", ";", "$", "this", "->", "addJsToMinifier", "(", "$", "minifier", ",", "'transition'", ")", ";", "return", "$", "minifier", "->", "minify", "(", ")", ";", "}" ]
Minify JS components to single string @return string
[ "Minify", "JS", "components", "to", "single", "string" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L217-L240
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.addJsToMinifier
protected function addJsToMinifier(Minify\JS $minify, $componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { $minify->add(base_path("vendor/twbs/bootstrap/js/{$fileName}.js")); } }
php
protected function addJsToMinifier(Minify\JS $minify, $componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { $minify->add(base_path("vendor/twbs/bootstrap/js/{$fileName}.js")); } }
[ "protected", "function", "addJsToMinifier", "(", "Minify", "\\", "JS", "$", "minify", ",", "$", "componentName", ",", "$", "fileName", "=", "null", ")", "{", "if", "(", "$", "fileName", "===", "null", ")", "{", "$", "fileName", "=", "$", "componentName", ";", "}", "// Add component data to minifier if it is enabled", "if", "(", "$", "this", "->", "components", "[", "$", "componentName", "]", "===", "true", ")", "{", "$", "minify", "->", "add", "(", "base_path", "(", "\"vendor/twbs/bootstrap/js/{$fileName}.js\"", ")", ")", ";", "}", "}" ]
Add components javascript file to minifier if component is enabled @param \MatthiasMullie\Minify\JS $minify minifier instance @param string $componentName valid component name @param string|null $fileName file name (if not set component name is used) @return void
[ "Add", "components", "javascript", "file", "to", "minifier", "if", "component", "is", "enabled" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L251-L261
train
vi-kon/laravel-bootstrap
src/ViKon/Bootstrap/Compiler.php
Compiler.prepareCssForLess
protected function prepareCssForLess($componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { return "@import \"{$fileName}.less\";"; } return ''; }
php
protected function prepareCssForLess($componentName, $fileName = null) { if ($fileName === null) { $fileName = $componentName; } // Add component data to minifier if it is enabled if ($this->components[$componentName] === true) { return "@import \"{$fileName}.less\";"; } return ''; }
[ "protected", "function", "prepareCssForLess", "(", "$", "componentName", ",", "$", "fileName", "=", "null", ")", "{", "if", "(", "$", "fileName", "===", "null", ")", "{", "$", "fileName", "=", "$", "componentName", ";", "}", "// Add component data to minifier if it is enabled", "if", "(", "$", "this", "->", "components", "[", "$", "componentName", "]", "===", "true", ")", "{", "return", "\"@import \\\"{$fileName}.less\\\";\"", ";", "}", "return", "''", ";", "}" ]
Prepare components less file for less processor's input if component is enabled @param string $componentName valid component name @param string|null $fileName file name (if not set component name is used) @return string
[ "Prepare", "components", "less", "file", "for", "less", "processor", "s", "input", "if", "component", "is", "enabled" ]
f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd
https://github.com/vi-kon/laravel-bootstrap/blob/f4bdfd19241ad19344bef3d2bdbf3658bbbb2ddd/src/ViKon/Bootstrap/Compiler.php#L358-L370
train
rackberg/para
src/EventSubscriber/AddEnvironmentVariableEventSubscriber.php
AddEnvironmentVariableEventSubscriber.addEnvironmentVariable
public function addEnvironmentVariable(PostProcessCreationEvent $event) { // Get the current set environment variables. $env = $event->getProcess()->getEnv(); // Add the "para_project" environment variable $env['para_project'] = $event->getProject()->getName(); // Save the environment variables in the process. $event->getProcess()->setEnv($env); }
php
public function addEnvironmentVariable(PostProcessCreationEvent $event) { // Get the current set environment variables. $env = $event->getProcess()->getEnv(); // Add the "para_project" environment variable $env['para_project'] = $event->getProject()->getName(); // Save the environment variables in the process. $event->getProcess()->setEnv($env); }
[ "public", "function", "addEnvironmentVariable", "(", "PostProcessCreationEvent", "$", "event", ")", "{", "// Get the current set environment variables.", "$", "env", "=", "$", "event", "->", "getProcess", "(", ")", "->", "getEnv", "(", ")", ";", "// Add the \"para_project\" environment variable", "$", "env", "[", "'para_project'", "]", "=", "$", "event", "->", "getProject", "(", ")", "->", "getName", "(", ")", ";", "// Save the environment variables in the process.", "$", "event", "->", "getProcess", "(", ")", "->", "setEnv", "(", "$", "env", ")", ";", "}" ]
This callback method adds an environment variable to a created process. @param \Para\Event\PostProcessCreationEvent $event
[ "This", "callback", "method", "adds", "an", "environment", "variable", "to", "a", "created", "process", "." ]
e0ef1356ed2979670eb7c670d88921406cade46e
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/EventSubscriber/AddEnvironmentVariableEventSubscriber.php#L37-L47
train
inc2734/wp-awesome-components
src/Awesome_Components.php
Awesome_Components._media_buttons
public function _media_buttons( $editor_id = 'content' ) { $post_type = get_post_type(); if ( ! $post_type ) { return; } $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object || ! $post_type_object->public ) { return; } ?> <button type="button" id="button-wp-awesome-components" class="button" href="#" data-editor="<?php echo esc_attr( $editor_id ); ?>"> <span class="dashicons dashicons-editor-kitchensink"></span> <?php esc_html_e( 'Add Components', 'inc2734-wp-awesome-components' ); ?> </button> <?php }
php
public function _media_buttons( $editor_id = 'content' ) { $post_type = get_post_type(); if ( ! $post_type ) { return; } $post_type_object = get_post_type_object( $post_type ); if ( ! $post_type_object || ! $post_type_object->public ) { return; } ?> <button type="button" id="button-wp-awesome-components" class="button" href="#" data-editor="<?php echo esc_attr( $editor_id ); ?>"> <span class="dashicons dashicons-editor-kitchensink"></span> <?php esc_html_e( 'Add Components', 'inc2734-wp-awesome-components' ); ?> </button> <?php }
[ "public", "function", "_media_buttons", "(", "$", "editor_id", "=", "'content'", ")", "{", "$", "post_type", "=", "get_post_type", "(", ")", ";", "if", "(", "!", "$", "post_type", ")", "{", "return", ";", "}", "$", "post_type_object", "=", "get_post_type_object", "(", "$", "post_type", ")", ";", "if", "(", "!", "$", "post_type_object", "||", "!", "$", "post_type_object", "->", "public", ")", "{", "return", ";", "}", "?>\n\n\t\t<button type=\"button\" id=\"button-wp-awesome-components\" class=\"button\" href=\"#\" data-editor=\"<?php", "echo", "esc_attr", "(", "$", "editor_id", ")", ";", "?>\">\n\t\t\t<span class=\"dashicons dashicons-editor-kitchensink\"></span>\n\t\t\t<?php", "esc_html_e", "(", "'Add Components'", ",", "'inc2734-wp-awesome-components'", ")", ";", "?>\n\t\t</button>\n\t\t<?php", "}" ]
Added "Add components" button @param string $editor_id @return void
[ "Added", "Add", "components", "button" ]
45ce014943db141350a001d4138921b1c7bec0a2
https://github.com/inc2734/wp-awesome-components/blob/45ce014943db141350a001d4138921b1c7bec0a2/src/Awesome_Components.php#L32-L49
train
inc2734/wp-awesome-components
src/Awesome_Components.php
Awesome_Components._edit_form_after_editor
public function _edit_form_after_editor() { $post_type = get_post_type(); if ( ! $post_type ) { return; } if ( false === get_post_type_object( $post_type )->public ) { return; } ob_start(); include( __DIR__ . '/view/modal.php' ); // @codingStandardsIgnoreStart echo ob_get_clean(); // @codingStandardsIgnoreEnd }
php
public function _edit_form_after_editor() { $post_type = get_post_type(); if ( ! $post_type ) { return; } if ( false === get_post_type_object( $post_type )->public ) { return; } ob_start(); include( __DIR__ . '/view/modal.php' ); // @codingStandardsIgnoreStart echo ob_get_clean(); // @codingStandardsIgnoreEnd }
[ "public", "function", "_edit_form_after_editor", "(", ")", "{", "$", "post_type", "=", "get_post_type", "(", ")", ";", "if", "(", "!", "$", "post_type", ")", "{", "return", ";", "}", "if", "(", "false", "===", "get_post_type_object", "(", "$", "post_type", ")", "->", "public", ")", "{", "return", ";", "}", "ob_start", "(", ")", ";", "include", "(", "__DIR__", ".", "'/view/modal.php'", ")", ";", "// @codingStandardsIgnoreStart", "echo", "ob_get_clean", "(", ")", ";", "// @codingStandardsIgnoreEnd", "}" ]
Added modal html @return void
[ "Added", "modal", "html" ]
45ce014943db141350a001d4138921b1c7bec0a2
https://github.com/inc2734/wp-awesome-components/blob/45ce014943db141350a001d4138921b1c7bec0a2/src/Awesome_Components.php#L56-L72
train
gplcart/file_manager
models/Command.php
Command.getHandlers
public function getHandlers() { $commands = &gplcart_static('module.file_manager.handlers'); if (isset($commands)) { return $commands; } $commands = (array) gplcart_config_get(__DIR__ . '/../config/commands.php'); foreach ($commands as $id => &$command) { $command['command_id'] = $id; } $this->hook->attach('module.file_manager.handlers', $commands, $this); return $commands; }
php
public function getHandlers() { $commands = &gplcart_static('module.file_manager.handlers'); if (isset($commands)) { return $commands; } $commands = (array) gplcart_config_get(__DIR__ . '/../config/commands.php'); foreach ($commands as $id => &$command) { $command['command_id'] = $id; } $this->hook->attach('module.file_manager.handlers', $commands, $this); return $commands; }
[ "public", "function", "getHandlers", "(", ")", "{", "$", "commands", "=", "&", "gplcart_static", "(", "'module.file_manager.handlers'", ")", ";", "if", "(", "isset", "(", "$", "commands", ")", ")", "{", "return", "$", "commands", ";", "}", "$", "commands", "=", "(", "array", ")", "gplcart_config_get", "(", "__DIR__", ".", "'/../config/commands.php'", ")", ";", "foreach", "(", "$", "commands", "as", "$", "id", "=>", "&", "$", "command", ")", "{", "$", "command", "[", "'command_id'", "]", "=", "$", "id", ";", "}", "$", "this", "->", "hook", "->", "attach", "(", "'module.file_manager.handlers'", ",", "$", "commands", ",", "$", "this", ")", ";", "return", "$", "commands", ";", "}" ]
Returns an array of supported commands @return array
[ "Returns", "an", "array", "of", "supported", "commands" ]
45424e93eafea75d31af6410ac9cf110f08e500a
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L41-L57
train
gplcart/file_manager
models/Command.php
Command.get
public function get($command) { $commands = $this->getHandlers(); return empty($commands[$command]) ? array() : $commands[$command]; }
php
public function get($command) { $commands = $this->getHandlers(); return empty($commands[$command]) ? array() : $commands[$command]; }
[ "public", "function", "get", "(", "$", "command", ")", "{", "$", "commands", "=", "$", "this", "->", "getHandlers", "(", ")", ";", "return", "empty", "(", "$", "commands", "[", "$", "command", "]", ")", "?", "array", "(", ")", ":", "$", "commands", "[", "$", "command", "]", ";", "}" ]
Returns a single command @param string $command @return array
[ "Returns", "a", "single", "command" ]
45424e93eafea75d31af6410ac9cf110f08e500a
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L64-L68
train
gplcart/file_manager
models/Command.php
Command.getAllowed
public function getAllowed($file) { $commands = array(); foreach ($this->getHandlers() as $id => $command) { if ($this->isAllowed($command, $file)) { $commands[$id] = $command; } } return $commands; }
php
public function getAllowed($file) { $commands = array(); foreach ($this->getHandlers() as $id => $command) { if ($this->isAllowed($command, $file)) { $commands[$id] = $command; } } return $commands; }
[ "public", "function", "getAllowed", "(", "$", "file", ")", "{", "$", "commands", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getHandlers", "(", ")", "as", "$", "id", "=>", "$", "command", ")", "{", "if", "(", "$", "this", "->", "isAllowed", "(", "$", "command", ",", "$", "file", ")", ")", "{", "$", "commands", "[", "$", "id", "]", "=", "$", "command", ";", "}", "}", "return", "$", "commands", ";", "}" ]
Returns an array of allowed commands for the given file @param SplFileInfo|array $file @return array
[ "Returns", "an", "array", "of", "allowed", "commands", "for", "the", "given", "file" ]
45424e93eafea75d31af6410ac9cf110f08e500a
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L75-L86
train
gplcart/file_manager
models/Command.php
Command.callHandler
public function callHandler(array $command, $method, $args = array()) { try { $handlers = $this->getHandlers(); return Handler::call($handlers, $command['command_id'], $method, $args); } catch (Exception $ex) { return $ex->getMessage(); } }
php
public function callHandler(array $command, $method, $args = array()) { try { $handlers = $this->getHandlers(); return Handler::call($handlers, $command['command_id'], $method, $args); } catch (Exception $ex) { return $ex->getMessage(); } }
[ "public", "function", "callHandler", "(", "array", "$", "command", ",", "$", "method", ",", "$", "args", "=", "array", "(", ")", ")", "{", "try", "{", "$", "handlers", "=", "$", "this", "->", "getHandlers", "(", ")", ";", "return", "Handler", "::", "call", "(", "$", "handlers", ",", "$", "command", "[", "'command_id'", "]", ",", "$", "method", ",", "$", "args", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "ex", "->", "getMessage", "(", ")", ";", "}", "}" ]
Call a command handler @param array $command @param string $method @param array $args @return mixed
[ "Call", "a", "command", "handler" ]
45424e93eafea75d31af6410ac9cf110f08e500a
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L112-L120
train
gplcart/file_manager
models/Command.php
Command.submit
public function submit(array $command, array $args) { $result = (array) $this->callHandler($command, 'submit', $args); $result += array('redirect' => '', 'message' => '', 'severity' => ''); return $result; }
php
public function submit(array $command, array $args) { $result = (array) $this->callHandler($command, 'submit', $args); $result += array('redirect' => '', 'message' => '', 'severity' => ''); return $result; }
[ "public", "function", "submit", "(", "array", "$", "command", ",", "array", "$", "args", ")", "{", "$", "result", "=", "(", "array", ")", "$", "this", "->", "callHandler", "(", "$", "command", ",", "'submit'", ",", "$", "args", ")", ";", "$", "result", "+=", "array", "(", "'redirect'", "=>", "''", ",", "'message'", "=>", "''", ",", "'severity'", "=>", "''", ")", ";", "return", "$", "result", ";", "}" ]
Submit a command @param array $command @param array $args @return array
[ "Submit", "a", "command" ]
45424e93eafea75d31af6410ac9cf110f08e500a
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/models/Command.php#L128-L133
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getUrl
public function getUrl() { $query = $this->getQueryString(); return sprintf('%s://%s/%s/%s%s', $this->getScheme(), trim($this->getHost(), '/'), trim($this->config->getRootEndpoint(), '/'), $this->getEntityType(), empty($query) ? '' : sprintf('?%s', $query) ); }
php
public function getUrl() { $query = $this->getQueryString(); return sprintf('%s://%s/%s/%s%s', $this->getScheme(), trim($this->getHost(), '/'), trim($this->config->getRootEndpoint(), '/'), $this->getEntityType(), empty($query) ? '' : sprintf('?%s', $query) ); }
[ "public", "function", "getUrl", "(", ")", "{", "$", "query", "=", "$", "this", "->", "getQueryString", "(", ")", ";", "return", "sprintf", "(", "'%s://%s/%s/%s%s'", ",", "$", "this", "->", "getScheme", "(", ")", ",", "trim", "(", "$", "this", "->", "getHost", "(", ")", ",", "'/'", ")", ",", "trim", "(", "$", "this", "->", "config", "->", "getRootEndpoint", "(", ")", ",", "'/'", ")", ",", "$", "this", "->", "getEntityType", "(", ")", ",", "empty", "(", "$", "query", ")", "?", "''", ":", "sprintf", "(", "'?%s'", ",", "$", "query", ")", ")", ";", "}" ]
Generates the request URL based on its current object state. @todo Add support for inclusions and other items. @return string
[ "Generates", "the", "request", "URL", "based", "on", "its", "current", "object", "state", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L150-L160
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getQueryString
public function getQueryString() { $query = []; if (!empty($this->pagination)) { $query[self::PARAM_PAGINATION] = $this->pagination; } if (!empty($this->filters)) { $query[self::PARAM_FILTERING] = $this->filters; } foreach ($this->fields as $modelType => $fields) { $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields); } $sort = []; foreach ($this->sorting as $key => $direction) { $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key); } if (!empty($sort)) { $query[self::PARAM_SORTING] = implode(',', $sort); } return http_build_query($query); }
php
public function getQueryString() { $query = []; if (!empty($this->pagination)) { $query[self::PARAM_PAGINATION] = $this->pagination; } if (!empty($this->filters)) { $query[self::PARAM_FILTERING] = $this->filters; } foreach ($this->fields as $modelType => $fields) { $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields); } $sort = []; foreach ($this->sorting as $key => $direction) { $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key); } if (!empty($sort)) { $query[self::PARAM_SORTING] = implode(',', $sort); } return http_build_query($query); }
[ "public", "function", "getQueryString", "(", ")", "{", "$", "query", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "pagination", ")", ")", "{", "$", "query", "[", "self", "::", "PARAM_PAGINATION", "]", "=", "$", "this", "->", "pagination", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", ")", ")", "{", "$", "query", "[", "self", "::", "PARAM_FILTERING", "]", "=", "$", "this", "->", "filters", ";", "}", "foreach", "(", "$", "this", "->", "fields", "as", "$", "modelType", "=>", "$", "fields", ")", "{", "$", "query", "[", "self", "::", "PARAM_FIELDSETS", "]", "[", "$", "modelType", "]", "=", "implode", "(", "','", ",", "$", "fields", ")", ";", "}", "$", "sort", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "sorting", "as", "$", "key", "=>", "$", "direction", ")", "{", "$", "sort", "[", "]", "=", "(", "1", "===", "$", "direction", ")", "?", "$", "key", ":", "sprintf", "(", "'-%s'", ",", "$", "key", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "sort", ")", ")", "{", "$", "query", "[", "self", "::", "PARAM_SORTING", "]", "=", "implode", "(", "','", ",", "$", "sort", ")", ";", "}", "return", "http_build_query", "(", "$", "query", ")", ";", "}" ]
Gets the query string based on the current object properties. @return string
[ "Gets", "the", "query", "string", "based", "on", "the", "current", "object", "properties", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L227-L247
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.isAutocomplete
public function isAutocomplete() { if (false === $this->hasFilter(self::FILTER_AUTOCOMPLETE)) { return false; } $autocomplete = $this->getFilter(self::FILTER_AUTOCOMPLETE); return isset($autocomplete[self::FILTER_AUTOCOMPLETE_KEY]) && isset($autocomplete[self::FILTER_AUTOCOMPLETE_VALUE]); }
php
public function isAutocomplete() { if (false === $this->hasFilter(self::FILTER_AUTOCOMPLETE)) { return false; } $autocomplete = $this->getFilter(self::FILTER_AUTOCOMPLETE); return isset($autocomplete[self::FILTER_AUTOCOMPLETE_KEY]) && isset($autocomplete[self::FILTER_AUTOCOMPLETE_VALUE]); }
[ "public", "function", "isAutocomplete", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "hasFilter", "(", "self", "::", "FILTER_AUTOCOMPLETE", ")", ")", "{", "return", "false", ";", "}", "$", "autocomplete", "=", "$", "this", "->", "getFilter", "(", "self", "::", "FILTER_AUTOCOMPLETE", ")", ";", "return", "isset", "(", "$", "autocomplete", "[", "self", "::", "FILTER_AUTOCOMPLETE_KEY", "]", ")", "&&", "isset", "(", "$", "autocomplete", "[", "self", "::", "FILTER_AUTOCOMPLETE_VALUE", "]", ")", ";", "}" ]
Determines if this has an autocomplete filter enabled. @return bool
[ "Determines", "if", "this", "has", "an", "autocomplete", "filter", "enabled", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L323-L330
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getAutocompleteKey
public function getAutocompleteKey() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_KEY]; }
php
public function getAutocompleteKey() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_KEY]; }
[ "public", "function", "getAutocompleteKey", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "isAutocomplete", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "getFilter", "(", "self", "::", "FILTER_AUTOCOMPLETE", ")", "[", "self", "::", "FILTER_AUTOCOMPLETE_KEY", "]", ";", "}" ]
Gets the autocomplete attribute key. @return string|null
[ "Gets", "the", "autocomplete", "attribute", "key", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L337-L343
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getAutocompleteValue
public function getAutocompleteValue() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_VALUE]; }
php
public function getAutocompleteValue() { if (false === $this->isAutocomplete()) { return null; } return $this->getFilter(self::FILTER_AUTOCOMPLETE)[self::FILTER_AUTOCOMPLETE_VALUE]; }
[ "public", "function", "getAutocompleteValue", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "isAutocomplete", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "getFilter", "(", "self", "::", "FILTER_AUTOCOMPLETE", ")", "[", "self", "::", "FILTER_AUTOCOMPLETE_VALUE", "]", ";", "}" ]
Gets the autocomplete search value. @return string|null
[ "Gets", "the", "autocomplete", "search", "value", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L350-L356
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.isQuery
public function isQuery() { if (false === $this->hasFilter(self::FILTER_QUERY)) { return false; } $query = $this->getFilter(self::FILTER_QUERY); return isset($query[self::FILTER_QUERY_CRITERIA]); }
php
public function isQuery() { if (false === $this->hasFilter(self::FILTER_QUERY)) { return false; } $query = $this->getFilter(self::FILTER_QUERY); return isset($query[self::FILTER_QUERY_CRITERIA]); }
[ "public", "function", "isQuery", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "hasFilter", "(", "self", "::", "FILTER_QUERY", ")", ")", "{", "return", "false", ";", "}", "$", "query", "=", "$", "this", "->", "getFilter", "(", "self", "::", "FILTER_QUERY", ")", ";", "return", "isset", "(", "$", "query", "[", "self", "::", "FILTER_QUERY_CRITERIA", "]", ")", ";", "}" ]
Determines if this has the database query filter enabled. @return bool
[ "Determines", "if", "this", "has", "the", "database", "query", "filter", "enabled", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L363-L370
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getQueryCriteria
public function getQueryCriteria() { if (false === $this->isQuery()) { return []; } $queryKey = self::FILTER_QUERY; $criteriaKey = self::FILTER_QUERY_CRITERIA; $decoded = @json_decode($this->getFilter($queryKey)[$criteriaKey], true); if (!is_array($decoded)) { $param = sprintf('%s[%s][%s]', self::PARAM_FILTERING, $queryKey, $criteriaKey); throw RestException::invalidQueryParam($param, 'Was the value sent as valid JSON?'); } return $decoded; }
php
public function getQueryCriteria() { if (false === $this->isQuery()) { return []; } $queryKey = self::FILTER_QUERY; $criteriaKey = self::FILTER_QUERY_CRITERIA; $decoded = @json_decode($this->getFilter($queryKey)[$criteriaKey], true); if (!is_array($decoded)) { $param = sprintf('%s[%s][%s]', self::PARAM_FILTERING, $queryKey, $criteriaKey); throw RestException::invalidQueryParam($param, 'Was the value sent as valid JSON?'); } return $decoded; }
[ "public", "function", "getQueryCriteria", "(", ")", "{", "if", "(", "false", "===", "$", "this", "->", "isQuery", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "queryKey", "=", "self", "::", "FILTER_QUERY", ";", "$", "criteriaKey", "=", "self", "::", "FILTER_QUERY_CRITERIA", ";", "$", "decoded", "=", "@", "json_decode", "(", "$", "this", "->", "getFilter", "(", "$", "queryKey", ")", "[", "$", "criteriaKey", "]", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "decoded", ")", ")", "{", "$", "param", "=", "sprintf", "(", "'%s[%s][%s]'", ",", "self", "::", "PARAM_FILTERING", ",", "$", "queryKey", ",", "$", "criteriaKey", ")", ";", "throw", "RestException", "::", "invalidQueryParam", "(", "$", "param", ",", "'Was the value sent as valid JSON?'", ")", ";", "}", "return", "$", "decoded", ";", "}" ]
Gets the query criteria value. @return array
[ "Gets", "the", "query", "criteria", "value", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L377-L392
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getFilter
public function getFilter($key) { if (!isset($this->filters[$key])) { return null; } return $this->filters[$key]; }
php
public function getFilter($key) { if (!isset($this->filters[$key])) { return null; } return $this->filters[$key]; }
[ "public", "function", "getFilter", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "filters", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "filters", "[", "$", "key", "]", ";", "}" ]
Gets a specific filter, by key. @param string $key @return mixed|null
[ "Gets", "a", "specific", "filter", "by", "key", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L519-L525
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.parsePath
private function parsePath($path) { $parts = explode('/', trim($path, '/')); for ($i = 0; $i < 1; $i++) { // All paths must contain /{workspace_entityType} if (false === $this->issetNotEmpty($i, $parts)) { throw RestException::invalidEndpoint($path); } } $this->extractEntityType($parts); $this->extractIdentifier($parts); $this->extractRelationship($parts); return $this; }
php
private function parsePath($path) { $parts = explode('/', trim($path, '/')); for ($i = 0; $i < 1; $i++) { // All paths must contain /{workspace_entityType} if (false === $this->issetNotEmpty($i, $parts)) { throw RestException::invalidEndpoint($path); } } $this->extractEntityType($parts); $this->extractIdentifier($parts); $this->extractRelationship($parts); return $this; }
[ "private", "function", "parsePath", "(", "$", "path", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "path", ",", "'/'", ")", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "1", ";", "$", "i", "++", ")", "{", "// All paths must contain /{workspace_entityType}", "if", "(", "false", "===", "$", "this", "->", "issetNotEmpty", "(", "$", "i", ",", "$", "parts", ")", ")", "{", "throw", "RestException", "::", "invalidEndpoint", "(", "$", "path", ")", ";", "}", "}", "$", "this", "->", "extractEntityType", "(", "$", "parts", ")", ";", "$", "this", "->", "extractIdentifier", "(", "$", "parts", ")", ";", "$", "this", "->", "extractRelationship", "(", "$", "parts", ")", ";", "return", "$", "this", ";", "}" ]
Parses the incoming request path and sets appropriate properties on this RestRequest object. @param string $path @return self @throws RestException
[ "Parses", "the", "incoming", "request", "path", "and", "sets", "appropriate", "properties", "on", "this", "RestRequest", "object", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L580-L593
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.extractRelationship
private function extractRelationship(array $parts) { if (isset($parts[2])) { if ('relationships' === $parts[2]) { if (!isset($parts[3])) { throw RestException::invalidRelationshipEndpoint($this->parsedUri['path']); } $this->relationship = [ 'type' => 'self', 'field' => $parts[3], ]; } else { $this->relationship = [ 'type' => 'related', 'field' => $parts[2], ]; } } return $this; }
php
private function extractRelationship(array $parts) { if (isset($parts[2])) { if ('relationships' === $parts[2]) { if (!isset($parts[3])) { throw RestException::invalidRelationshipEndpoint($this->parsedUri['path']); } $this->relationship = [ 'type' => 'self', 'field' => $parts[3], ]; } else { $this->relationship = [ 'type' => 'related', 'field' => $parts[2], ]; } } return $this; }
[ "private", "function", "extractRelationship", "(", "array", "$", "parts", ")", "{", "if", "(", "isset", "(", "$", "parts", "[", "2", "]", ")", ")", "{", "if", "(", "'relationships'", "===", "$", "parts", "[", "2", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "parts", "[", "3", "]", ")", ")", "{", "throw", "RestException", "::", "invalidRelationshipEndpoint", "(", "$", "this", "->", "parsedUri", "[", "'path'", "]", ")", ";", "}", "$", "this", "->", "relationship", "=", "[", "'type'", "=>", "'self'", ",", "'field'", "=>", "$", "parts", "[", "3", "]", ",", "]", ";", "}", "else", "{", "$", "this", "->", "relationship", "=", "[", "'type'", "=>", "'related'", ",", "'field'", "=>", "$", "parts", "[", "2", "]", ",", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
Extracts the entity relationship properties from an array of path parts. @param array $parts @return self
[ "Extracts", "the", "entity", "relationship", "properties", "from", "an", "array", "of", "path", "parts", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L627-L646
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.parseQueryString
private function parseQueryString($queryString) { parse_str($queryString, $parsed); $supported = $this->getSupportedParams(); foreach ($parsed as $param => $value) { if (!isset($supported[$param])) { throw RestException::unsupportedQueryParam($param, array_keys($supported)); } } $this->extractInclusions($parsed); $this->extractSorting($parsed); $this->extractFields($parsed); $this->extractPagination($parsed); $this->extractFilters($parsed); return $this; }
php
private function parseQueryString($queryString) { parse_str($queryString, $parsed); $supported = $this->getSupportedParams(); foreach ($parsed as $param => $value) { if (!isset($supported[$param])) { throw RestException::unsupportedQueryParam($param, array_keys($supported)); } } $this->extractInclusions($parsed); $this->extractSorting($parsed); $this->extractFields($parsed); $this->extractPagination($parsed); $this->extractFilters($parsed); return $this; }
[ "private", "function", "parseQueryString", "(", "$", "queryString", ")", "{", "parse_str", "(", "$", "queryString", ",", "$", "parsed", ")", ";", "$", "supported", "=", "$", "this", "->", "getSupportedParams", "(", ")", ";", "foreach", "(", "$", "parsed", "as", "$", "param", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "supported", "[", "$", "param", "]", ")", ")", "{", "throw", "RestException", "::", "unsupportedQueryParam", "(", "$", "param", ",", "array_keys", "(", "$", "supported", ")", ")", ";", "}", "}", "$", "this", "->", "extractInclusions", "(", "$", "parsed", ")", ";", "$", "this", "->", "extractSorting", "(", "$", "parsed", ")", ";", "$", "this", "->", "extractFields", "(", "$", "parsed", ")", ";", "$", "this", "->", "extractPagination", "(", "$", "parsed", ")", ";", "$", "this", "->", "extractFilters", "(", "$", "parsed", ")", ";", "return", "$", "this", ";", "}" ]
Parses the incoming request query string and sets appropriate properties on this RestRequest object. @param string $queryString @return self @throws RestException
[ "Parses", "the", "incoming", "request", "query", "string", "and", "sets", "appropriate", "properties", "on", "this", "RestRequest", "object", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L655-L672
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.extractInclusions
private function extractInclusions(array $params) { if (false === $this->issetNotEmpty(self::PARAM_INCLUSIONS, $params)) { if (true === $this->config->includeAllByDefault()) { $this->inclusions = ['*' => true]; } return $this; } $inclusions = explode(',', $params[self::PARAM_INCLUSIONS]); foreach ($inclusions as $inclusion) { if (false !== stristr($inclusion, '.')) { throw RestException::invalidParamValue(self::PARAM_INCLUSIONS, sprintf('Inclusion via a relationship path, e.g. "%s" is currently not supported.', $inclusion)); } $this->inclusions[$inclusion] = true; } return $this; }
php
private function extractInclusions(array $params) { if (false === $this->issetNotEmpty(self::PARAM_INCLUSIONS, $params)) { if (true === $this->config->includeAllByDefault()) { $this->inclusions = ['*' => true]; } return $this; } $inclusions = explode(',', $params[self::PARAM_INCLUSIONS]); foreach ($inclusions as $inclusion) { if (false !== stristr($inclusion, '.')) { throw RestException::invalidParamValue(self::PARAM_INCLUSIONS, sprintf('Inclusion via a relationship path, e.g. "%s" is currently not supported.', $inclusion)); } $this->inclusions[$inclusion] = true; } return $this; }
[ "private", "function", "extractInclusions", "(", "array", "$", "params", ")", "{", "if", "(", "false", "===", "$", "this", "->", "issetNotEmpty", "(", "self", "::", "PARAM_INCLUSIONS", ",", "$", "params", ")", ")", "{", "if", "(", "true", "===", "$", "this", "->", "config", "->", "includeAllByDefault", "(", ")", ")", "{", "$", "this", "->", "inclusions", "=", "[", "'*'", "=>", "true", "]", ";", "}", "return", "$", "this", ";", "}", "$", "inclusions", "=", "explode", "(", "','", ",", "$", "params", "[", "self", "::", "PARAM_INCLUSIONS", "]", ")", ";", "foreach", "(", "$", "inclusions", "as", "$", "inclusion", ")", "{", "if", "(", "false", "!==", "stristr", "(", "$", "inclusion", ",", "'.'", ")", ")", "{", "throw", "RestException", "::", "invalidParamValue", "(", "self", "::", "PARAM_INCLUSIONS", ",", "sprintf", "(", "'Inclusion via a relationship path, e.g. \"%s\" is currently not supported.'", ",", "$", "inclusion", ")", ")", ";", "}", "$", "this", "->", "inclusions", "[", "$", "inclusion", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Extracts relationship inclusions from an array of query params. @param array $params @return self
[ "Extracts", "relationship", "inclusions", "from", "an", "array", "of", "query", "params", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L680-L696
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.extractSorting
private function extractSorting(array $params) { if (false === $this->issetNotEmpty(self::PARAM_SORTING, $params)) { return $this; } $sort = explode(',', $params[self::PARAM_SORTING]); $this->sorting = []; foreach ($sort as $field) { $direction = 1; if (0 === strpos($field, '-')) { $direction = -1; $field = str_replace('-', '', $field); } $this->sorting[$field] = $direction; } return $this; }
php
private function extractSorting(array $params) { if (false === $this->issetNotEmpty(self::PARAM_SORTING, $params)) { return $this; } $sort = explode(',', $params[self::PARAM_SORTING]); $this->sorting = []; foreach ($sort as $field) { $direction = 1; if (0 === strpos($field, '-')) { $direction = -1; $field = str_replace('-', '', $field); } $this->sorting[$field] = $direction; } return $this; }
[ "private", "function", "extractSorting", "(", "array", "$", "params", ")", "{", "if", "(", "false", "===", "$", "this", "->", "issetNotEmpty", "(", "self", "::", "PARAM_SORTING", ",", "$", "params", ")", ")", "{", "return", "$", "this", ";", "}", "$", "sort", "=", "explode", "(", "','", ",", "$", "params", "[", "self", "::", "PARAM_SORTING", "]", ")", ";", "$", "this", "->", "sorting", "=", "[", "]", ";", "foreach", "(", "$", "sort", "as", "$", "field", ")", "{", "$", "direction", "=", "1", ";", "if", "(", "0", "===", "strpos", "(", "$", "field", ",", "'-'", ")", ")", "{", "$", "direction", "=", "-", "1", ";", "$", "field", "=", "str_replace", "(", "'-'", ",", "''", ",", "$", "field", ")", ";", "}", "$", "this", "->", "sorting", "[", "$", "field", "]", "=", "$", "direction", ";", "}", "return", "$", "this", ";", "}" ]
Extracts sorting criteria from an array of query params. @param array $params @return self
[ "Extracts", "sorting", "criteria", "from", "an", "array", "of", "query", "params", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L704-L720
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.extractFields
private function extractFields(array $params) { if (false === $this->issetNotEmpty(self::PARAM_FIELDSETS, $params)) { return $this; } $fields = $params[self::PARAM_FIELDSETS]; if (!is_array($fields)) { throw RestException::invalidQueryParam(self::PARAM_FIELDSETS, 'The field parameter must be an array of entity type keys to fields.'); } foreach ($fields as $entityType => $string) { $this->fields[$entityType] = explode(',', $string); } return $this; }
php
private function extractFields(array $params) { if (false === $this->issetNotEmpty(self::PARAM_FIELDSETS, $params)) { return $this; } $fields = $params[self::PARAM_FIELDSETS]; if (!is_array($fields)) { throw RestException::invalidQueryParam(self::PARAM_FIELDSETS, 'The field parameter must be an array of entity type keys to fields.'); } foreach ($fields as $entityType => $string) { $this->fields[$entityType] = explode(',', $string); } return $this; }
[ "private", "function", "extractFields", "(", "array", "$", "params", ")", "{", "if", "(", "false", "===", "$", "this", "->", "issetNotEmpty", "(", "self", "::", "PARAM_FIELDSETS", ",", "$", "params", ")", ")", "{", "return", "$", "this", ";", "}", "$", "fields", "=", "$", "params", "[", "self", "::", "PARAM_FIELDSETS", "]", ";", "if", "(", "!", "is_array", "(", "$", "fields", ")", ")", "{", "throw", "RestException", "::", "invalidQueryParam", "(", "self", "::", "PARAM_FIELDSETS", ",", "'The field parameter must be an array of entity type keys to fields.'", ")", ";", "}", "foreach", "(", "$", "fields", "as", "$", "entityType", "=>", "$", "string", ")", "{", "$", "this", "->", "fields", "[", "$", "entityType", "]", "=", "explode", "(", "','", ",", "$", "string", ")", ";", "}", "return", "$", "this", ";", "}" ]
Extracts fields to return from an array of query params. @param array $params @return self
[ "Extracts", "fields", "to", "return", "from", "an", "array", "of", "query", "params", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L728-L741
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.extractFilters
private function extractFilters(array $params) { if (false === $this->issetNotEmpty(self::PARAM_FILTERING, $params)) { return $this; } $filters = $params[self::PARAM_FILTERING]; if (!is_array($filters)) { throw RestException::invalidQueryParam(self::PARAM_FILTERING, 'The filter parameter must be an array keyed by filter name and value.'); } foreach ($filters as $key => $value) { $this->filters[$key] = $value; } return $this; }
php
private function extractFilters(array $params) { if (false === $this->issetNotEmpty(self::PARAM_FILTERING, $params)) { return $this; } $filters = $params[self::PARAM_FILTERING]; if (!is_array($filters)) { throw RestException::invalidQueryParam(self::PARAM_FILTERING, 'The filter parameter must be an array keyed by filter name and value.'); } foreach ($filters as $key => $value) { $this->filters[$key] = $value; } return $this; }
[ "private", "function", "extractFilters", "(", "array", "$", "params", ")", "{", "if", "(", "false", "===", "$", "this", "->", "issetNotEmpty", "(", "self", "::", "PARAM_FILTERING", ",", "$", "params", ")", ")", "{", "return", "$", "this", ";", "}", "$", "filters", "=", "$", "params", "[", "self", "::", "PARAM_FILTERING", "]", ";", "if", "(", "!", "is_array", "(", "$", "filters", ")", ")", "{", "throw", "RestException", "::", "invalidQueryParam", "(", "self", "::", "PARAM_FILTERING", ",", "'The filter parameter must be an array keyed by filter name and value.'", ")", ";", "}", "foreach", "(", "$", "filters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "filters", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Extracts filtering criteria from an array of query params. @param array $params @return self
[ "Extracts", "filtering", "criteria", "from", "an", "array", "of", "query", "params", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L771-L784
train
as3io/modlr
src/Rest/RestRequest.php
RestRequest.getSupportedParams
public function getSupportedParams() { return [ self::PARAM_INCLUSIONS => true, self::PARAM_FIELDSETS => true, self::PARAM_SORTING => true, self::PARAM_PAGINATION => true, self::PARAM_FILTERING => true, ]; }
php
public function getSupportedParams() { return [ self::PARAM_INCLUSIONS => true, self::PARAM_FIELDSETS => true, self::PARAM_SORTING => true, self::PARAM_PAGINATION => true, self::PARAM_FILTERING => true, ]; }
[ "public", "function", "getSupportedParams", "(", ")", "{", "return", "[", "self", "::", "PARAM_INCLUSIONS", "=>", "true", ",", "self", "::", "PARAM_FIELDSETS", "=>", "true", ",", "self", "::", "PARAM_SORTING", "=>", "true", ",", "self", "::", "PARAM_PAGINATION", "=>", "true", ",", "self", "::", "PARAM_FILTERING", "=>", "true", ",", "]", ";", "}" ]
Gets query string parameters that this request supports. @return array
[ "Gets", "query", "string", "parameters", "that", "this", "request", "supports", "." ]
7e684b88bb22a2e18397df9402075c6533084b16
https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Rest/RestRequest.php#L791-L800
train
soliantconsulting/SoliantEntityAudit
src/SoliantEntityAudit/Controller/IndexController.php
IndexController.userAction
public function userAction() { $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $userId = (int)$this->getEvent()->getRouteMatch()->getParam('userId'); $user = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository(\SoliantEntityAudit\Module::getModuleOptions()->getUserEntityClassName())->find($userId); return array( 'page' => $page, 'user' => $user, ); }
php
public function userAction() { $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $userId = (int)$this->getEvent()->getRouteMatch()->getParam('userId'); $user = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository(\SoliantEntityAudit\Module::getModuleOptions()->getUserEntityClassName())->find($userId); return array( 'page' => $page, 'user' => $user, ); }
[ "public", "function", "userAction", "(", ")", "{", "$", "page", "=", "(", "int", ")", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'page'", ")", ";", "$", "userId", "=", "(", "int", ")", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'userId'", ")", ";", "$", "user", "=", "\\", "SoliantEntityAudit", "\\", "Module", "::", "getModuleOptions", "(", ")", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "\\", "SoliantEntityAudit", "\\", "Module", "::", "getModuleOptions", "(", ")", "->", "getUserEntityClassName", "(", ")", ")", "->", "find", "(", "$", "userId", ")", ";", "return", "array", "(", "'page'", "=>", "$", "page", ",", "'user'", "=>", "$", "user", ",", ")", ";", "}" ]
Renders a paginated list of revisions for the given user @param int $page
[ "Renders", "a", "paginated", "list", "of", "revisions", "for", "the", "given", "user" ]
9e77a39ca8399d43c2113c532f3cf2df5349d4a5
https://github.com/soliantconsulting/SoliantEntityAudit/blob/9e77a39ca8399d43c2113c532f3cf2df5349d4a5/src/SoliantEntityAudit/Controller/IndexController.php#L31-L43
train
soliantconsulting/SoliantEntityAudit
src/SoliantEntityAudit/Controller/IndexController.php
IndexController.revisionEntityAction
public function revisionEntityAction() { $this->mapAllAuditedClasses(); $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $revisionEntityId = (int) $this->getEvent()->getRouteMatch()->getParam('revisionEntityId'); $revisionEntity = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository('SoliantEntityAudit\\Entity\\RevisionEntity')->find($revisionEntityId); if (!$revisionEntity) return $this->plugin('redirect')->toRoute('audit'); $repository = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository('SoliantEntityAudit\\Entity\\RevisionEntity'); return array( 'page' => $page, 'revisionEntity' => $revisionEntity, 'auditService' => $this->getServiceLocator()->get('auditService'), ); }
php
public function revisionEntityAction() { $this->mapAllAuditedClasses(); $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $revisionEntityId = (int) $this->getEvent()->getRouteMatch()->getParam('revisionEntityId'); $revisionEntity = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository('SoliantEntityAudit\\Entity\\RevisionEntity')->find($revisionEntityId); if (!$revisionEntity) return $this->plugin('redirect')->toRoute('audit'); $repository = \SoliantEntityAudit\Module::getModuleOptions()->getEntityManager() ->getRepository('SoliantEntityAudit\\Entity\\RevisionEntity'); return array( 'page' => $page, 'revisionEntity' => $revisionEntity, 'auditService' => $this->getServiceLocator()->get('auditService'), ); }
[ "public", "function", "revisionEntityAction", "(", ")", "{", "$", "this", "->", "mapAllAuditedClasses", "(", ")", ";", "$", "page", "=", "(", "int", ")", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'page'", ")", ";", "$", "revisionEntityId", "=", "(", "int", ")", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'revisionEntityId'", ")", ";", "$", "revisionEntity", "=", "\\", "SoliantEntityAudit", "\\", "Module", "::", "getModuleOptions", "(", ")", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "'SoliantEntityAudit\\\\Entity\\\\RevisionEntity'", ")", "->", "find", "(", "$", "revisionEntityId", ")", ";", "if", "(", "!", "$", "revisionEntity", ")", "return", "$", "this", "->", "plugin", "(", "'redirect'", ")", "->", "toRoute", "(", "'audit'", ")", ";", "$", "repository", "=", "\\", "SoliantEntityAudit", "\\", "Module", "::", "getModuleOptions", "(", ")", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "'SoliantEntityAudit\\\\Entity\\\\RevisionEntity'", ")", ";", "return", "array", "(", "'page'", "=>", "$", "page", ",", "'revisionEntity'", "=>", "$", "revisionEntity", ",", "'auditService'", "=>", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'auditService'", ")", ",", ")", ";", "}" ]
Show the detail for a specific revision entity
[ "Show", "the", "detail", "for", "a", "specific", "revision", "entity" ]
9e77a39ca8399d43c2113c532f3cf2df5349d4a5
https://github.com/soliantconsulting/SoliantEntityAudit/blob/9e77a39ca8399d43c2113c532f3cf2df5349d4a5/src/SoliantEntityAudit/Controller/IndexController.php#L70-L91
train
soliantconsulting/SoliantEntityAudit
src/SoliantEntityAudit/Controller/IndexController.php
IndexController.entityAction
public function entityAction() { $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $entityClass = $this->getEvent()->getRouteMatch()->getParam('entityClass'); return array( 'entityClass' => $entityClass, 'page' => $page, ); }
php
public function entityAction() { $page = (int)$this->getEvent()->getRouteMatch()->getParam('page'); $entityClass = $this->getEvent()->getRouteMatch()->getParam('entityClass'); return array( 'entityClass' => $entityClass, 'page' => $page, ); }
[ "public", "function", "entityAction", "(", ")", "{", "$", "page", "=", "(", "int", ")", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'page'", ")", ";", "$", "entityClass", "=", "$", "this", "->", "getEvent", "(", ")", "->", "getRouteMatch", "(", ")", "->", "getParam", "(", "'entityClass'", ")", ";", "return", "array", "(", "'entityClass'", "=>", "$", "entityClass", ",", "'page'", "=>", "$", "page", ",", ")", ";", "}" ]
Lists revisions for the supplied entity. Takes an audited entity class or audit class @param string $className @param string $id
[ "Lists", "revisions", "for", "the", "supplied", "entity", ".", "Takes", "an", "audited", "entity", "class", "or", "audit", "class" ]
9e77a39ca8399d43c2113c532f3cf2df5349d4a5
https://github.com/soliantconsulting/SoliantEntityAudit/blob/9e77a39ca8399d43c2113c532f3cf2df5349d4a5/src/SoliantEntityAudit/Controller/IndexController.php#L99-L108
train
edwardstock/forker
src/system/SharedMemoryManager.php
SharedMemoryManager.packHeader
private function packHeader(int $id, int $offset, int $size, int $flags = 0): string { return pack('SSQI', $id, $offset, $size, $flags); }
php
private function packHeader(int $id, int $offset, int $size, int $flags = 0): string { return pack('SSQI', $id, $offset, $size, $flags); }
[ "private", "function", "packHeader", "(", "int", "$", "id", ",", "int", "$", "offset", ",", "int", "$", "size", ",", "int", "$", "flags", "=", "0", ")", ":", "string", "{", "return", "pack", "(", "'SSQI'", ",", "$", "id", ",", "$", "offset", ",", "$", "size", ",", "$", "flags", ")", ";", "}" ]
Blocking method, writes process result state to state file @param int $id @param int $offset @param int $size @param int $flags @return string binary data sizes: 2 (ushort) + 2 (ushort) + 8(ulong long) + 4(uint) bytes, order - machine-dependent @see SharedMemoryManager::F_SERIALIZED and other flags
[ "Blocking", "method", "writes", "process", "result", "state", "to", "state", "file" ]
024a6d1d8a34a4fffb59717e066cad01a78141b5
https://github.com/edwardstock/forker/blob/024a6d1d8a34a4fffb59717e066cad01a78141b5/src/system/SharedMemoryManager.php#L323-L326
train
activecollab/databaseconnection
src/Connection/MysqliConnection.php
MysqliConnection.&
public function &setDatabaseName($database_name, $select_database = true) { if (empty($select_database) || $this->link->select_db($database_name)) { $this->database_name = $database_name; } else { throw new ConnectionException("Failed to select database '$database_name'"); } return $this; }
php
public function &setDatabaseName($database_name, $select_database = true) { if (empty($select_database) || $this->link->select_db($database_name)) { $this->database_name = $database_name; } else { throw new ConnectionException("Failed to select database '$database_name'"); } return $this; }
[ "public", "function", "&", "setDatabaseName", "(", "$", "database_name", ",", "$", "select_database", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "select_database", ")", "||", "$", "this", "->", "link", "->", "select_db", "(", "$", "database_name", ")", ")", "{", "$", "this", "->", "database_name", "=", "$", "database_name", ";", "}", "else", "{", "throw", "new", "ConnectionException", "(", "\"Failed to select database '$database_name'\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set database name and optionally select that database. @param string $database_name @param bool|true $select_database @return $this @throws ConnectionException
[ "Set", "database", "name", "and", "optionally", "select", "that", "database", "." ]
f38accc083863262325858a3d72a5afb6b4513f8
https://github.com/activecollab/databaseconnection/blob/f38accc083863262325858a3d72a5afb6b4513f8/src/Connection/MysqliConnection.php#L71-L80
train
activecollab/databaseconnection
src/Connection/MysqliConnection.php
MysqliConnection.tryToRecoverFromFailedQuery
private function tryToRecoverFromFailedQuery($sql, $arguments, $load_mode, $return_mode) { switch ($this->link->errno) { // Non-transactional tables not rolled back! case 1196: return null; // Server gone away case 2006: case 2013: return $this->handleMySqlGoneAway($sql, $arguments, $load_mode, $return_mode); // Deadlock detection and retry case 1213: return $this->handleDeadlock(); // Other error default: throw new QueryException($this->link->error, $this->link->errno); } }
php
private function tryToRecoverFromFailedQuery($sql, $arguments, $load_mode, $return_mode) { switch ($this->link->errno) { // Non-transactional tables not rolled back! case 1196: return null; // Server gone away case 2006: case 2013: return $this->handleMySqlGoneAway($sql, $arguments, $load_mode, $return_mode); // Deadlock detection and retry case 1213: return $this->handleDeadlock(); // Other error default: throw new QueryException($this->link->error, $this->link->errno); } }
[ "private", "function", "tryToRecoverFromFailedQuery", "(", "$", "sql", ",", "$", "arguments", ",", "$", "load_mode", ",", "$", "return_mode", ")", "{", "switch", "(", "$", "this", "->", "link", "->", "errno", ")", "{", "// Non-transactional tables not rolled back!", "case", "1196", ":", "return", "null", ";", "// Server gone away", "case", "2006", ":", "case", "2013", ":", "return", "$", "this", "->", "handleMySqlGoneAway", "(", "$", "sql", ",", "$", "arguments", ",", "$", "load_mode", ",", "$", "return_mode", ")", ";", "// Deadlock detection and retry", "case", "1213", ":", "return", "$", "this", "->", "handleDeadlock", "(", ")", ";", "// Other error", "default", ":", "throw", "new", "QueryException", "(", "$", "this", "->", "link", "->", "error", ",", "$", "this", "->", "link", "->", "errno", ")", ";", "}", "}" ]
Try to recover from failed query. @param string $sql @param array|null $arguments @param $load_mode @param $return_mode @return array|bool|DateTime|float|int|mixed|null|string|void @throws QueryException
[ "Try", "to", "recover", "from", "failed", "query", "." ]
f38accc083863262325858a3d72a5afb6b4513f8
https://github.com/activecollab/databaseconnection/blob/f38accc083863262325858a3d72a5afb6b4513f8/src/Connection/MysqliConnection.php#L778-L799
train
activecollab/databaseconnection
src/Connection/MysqliConnection.php
MysqliConnection.onLogQuery
public function onLogQuery(callable $callback = null) { if ($callback === null || is_callable($callback)) { $this->on_log_query = $callback; } else { throw new InvalidArgumentException('Callback needs to be NULL or callable'); } }
php
public function onLogQuery(callable $callback = null) { if ($callback === null || is_callable($callback)) { $this->on_log_query = $callback; } else { throw new InvalidArgumentException('Callback needs to be NULL or callable'); } }
[ "public", "function", "onLogQuery", "(", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", "||", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "this", "->", "on_log_query", "=", "$", "callback", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Callback needs to be NULL or callable'", ")", ";", "}", "}" ]
Set a callback that will receive every query after we run it. Callback should accept two parameters: first for SQL that was ran, and second for time that it took to run @param callable|null $callback
[ "Set", "a", "callback", "that", "will", "receive", "every", "query", "after", "we", "run", "it", "." ]
f38accc083863262325858a3d72a5afb6b4513f8
https://github.com/activecollab/databaseconnection/blob/f38accc083863262325858a3d72a5afb6b4513f8/src/Connection/MysqliConnection.php#L955-L962
train
QoboLtd/cakephp-translations
src/Model/Table/TranslationsTable.php
TranslationsTable.getLanguageId
public function getLanguageId(string $shortCode): string { $query = $this->Languages->find('all', [ 'conditions' => ['Languages.code' => $shortCode] ]); $language = $query->first(); if (empty($language->id)) { throw new InvalidArgumentException("Unsupported language code [$shortCode]"); } return $language->id; }
php
public function getLanguageId(string $shortCode): string { $query = $this->Languages->find('all', [ 'conditions' => ['Languages.code' => $shortCode] ]); $language = $query->first(); if (empty($language->id)) { throw new InvalidArgumentException("Unsupported language code [$shortCode]"); } return $language->id; }
[ "public", "function", "getLanguageId", "(", "string", "$", "shortCode", ")", ":", "string", "{", "$", "query", "=", "$", "this", "->", "Languages", "->", "find", "(", "'all'", ",", "[", "'conditions'", "=>", "[", "'Languages.code'", "=>", "$", "shortCode", "]", "]", ")", ";", "$", "language", "=", "$", "query", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "language", "->", "id", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported language code [$shortCode]\"", ")", ";", "}", "return", "$", "language", "->", "id", ";", "}" ]
Retrive language ID by code @throws \InvalidArgumentException for unknown short code @param string $shortCode language code i.e. ru, cn etc @return string language's uuid
[ "Retrive", "language", "ID", "by", "code" ]
b488eafce71a55d517b975342487812f0d2d375a
https://github.com/QoboLtd/cakephp-translations/blob/b488eafce71a55d517b975342487812f0d2d375a/src/Model/Table/TranslationsTable.php#L185-L197
train
andyburton/Sonic-Framework
src/Resource/Crypt.php
Crypt._genRijndael256IV
public static function _genRijndael256IV ($cypher = FALSE) { // If a module has not been passed if (!$cypher) { // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); } // Create the IV $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($cypher), MCRYPT_RAND); // Close Module mcrypt_module_close ($cypher); // Return IV return $iv; }
php
public static function _genRijndael256IV ($cypher = FALSE) { // If a module has not been passed if (!$cypher) { // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); } // Create the IV $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($cypher), MCRYPT_RAND); // Close Module mcrypt_module_close ($cypher); // Return IV return $iv; }
[ "public", "static", "function", "_genRijndael256IV", "(", "$", "cypher", "=", "FALSE", ")", "{", "// If a module has not been passed", "if", "(", "!", "$", "cypher", ")", "{", "// Open the cypher", "$", "cypher", "=", "mcrypt_module_open", "(", "'rijndael-256'", ",", "''", ",", "'ofb'", ",", "''", ")", ";", "}", "// Create the IV", "$", "iv", "=", "mcrypt_create_iv", "(", "mcrypt_enc_get_iv_size", "(", "$", "cypher", ")", ",", "MCRYPT_RAND", ")", ";", "// Close Module", "mcrypt_module_close", "(", "$", "cypher", ")", ";", "// Return IV", "return", "$", "iv", ";", "}" ]
Generate a rijndael 256 initialisation vector @param resource $cypher Encryption Resource @return string
[ "Generate", "a", "rijndael", "256", "initialisation", "vector" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Crypt.php#L70-L96
train
andyburton/Sonic-Framework
src/Resource/Crypt.php
Crypt._encryptRijndael256
public static function _encryptRijndael256 ($str, $key, $iv = FALSE) { // If the string is empty if (empty ($str)) { return ''; } // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); // Create the IV if there is none if ($iv === FALSE) { $iv = self::_genRijndael256IV ($cypher); } // Set Key $key = substr ($key, 0, mcrypt_enc_get_key_size ($cypher)); // Initialise encryption mcrypt_generic_init ($cypher, $key, $iv); // Encrypt String $encrypted = mcrypt_generic ($cypher, $strString); // Terminate encryption hander mcrypt_generic_deinit ($cypher); // Close Module mcrypt_module_close ($cypher); // Return encrypted string return $encrypted; }
php
public static function _encryptRijndael256 ($str, $key, $iv = FALSE) { // If the string is empty if (empty ($str)) { return ''; } // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); // Create the IV if there is none if ($iv === FALSE) { $iv = self::_genRijndael256IV ($cypher); } // Set Key $key = substr ($key, 0, mcrypt_enc_get_key_size ($cypher)); // Initialise encryption mcrypt_generic_init ($cypher, $key, $iv); // Encrypt String $encrypted = mcrypt_generic ($cypher, $strString); // Terminate encryption hander mcrypt_generic_deinit ($cypher); // Close Module mcrypt_module_close ($cypher); // Return encrypted string return $encrypted; }
[ "public", "static", "function", "_encryptRijndael256", "(", "$", "str", ",", "$", "key", ",", "$", "iv", "=", "FALSE", ")", "{", "// If the string is empty", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "return", "''", ";", "}", "// Open the cypher", "$", "cypher", "=", "mcrypt_module_open", "(", "'rijndael-256'", ",", "''", ",", "'ofb'", ",", "''", ")", ";", "// Create the IV if there is none", "if", "(", "$", "iv", "===", "FALSE", ")", "{", "$", "iv", "=", "self", "::", "_genRijndael256IV", "(", "$", "cypher", ")", ";", "}", "// Set Key", "$", "key", "=", "substr", "(", "$", "key", ",", "0", ",", "mcrypt_enc_get_key_size", "(", "$", "cypher", ")", ")", ";", "// Initialise encryption", "mcrypt_generic_init", "(", "$", "cypher", ",", "$", "key", ",", "$", "iv", ")", ";", "// Encrypt String", "$", "encrypted", "=", "mcrypt_generic", "(", "$", "cypher", ",", "$", "strString", ")", ";", "// Terminate encryption hander", "mcrypt_generic_deinit", "(", "$", "cypher", ")", ";", "// Close Module", "mcrypt_module_close", "(", "$", "cypher", ")", ";", "// Return encrypted string", "return", "$", "encrypted", ";", "}" ]
Encrypt and return a string using the Rijndael 256 cypher @param string $str String to encrypt @param string $key Key to encrypt the string @param string $iv Initialisation vector @return string
[ "Encrypt", "and", "return", "a", "string", "using", "the", "Rijndael", "256", "cypher" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Crypt.php#L107-L152
train
andyburton/Sonic-Framework
src/Resource/Crypt.php
Crypt._decryptRijndael256
public static function _decryptRijndael256 ($str, $key, $iv) { // If the string is empty if (empty ($str)) { return ''; } // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); // Set Key $key = substr ($key, 0, mcrypt_enc_get_key_size ($cypher)); // Initialise decryption mcrypt_generic_init ($cypher, $key, $iv); // Decrypt String $decrypted = mdecrypt_generic ($cypher, $str); // Terminate encryption hander mcrypt_generic_deinit ($cypher); // Close Module mcrypt_module_close ($cypher); // Return decrypted string return $decrypted; }
php
public static function _decryptRijndael256 ($str, $key, $iv) { // If the string is empty if (empty ($str)) { return ''; } // Open the cypher $cypher = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); // Set Key $key = substr ($key, 0, mcrypt_enc_get_key_size ($cypher)); // Initialise decryption mcrypt_generic_init ($cypher, $key, $iv); // Decrypt String $decrypted = mdecrypt_generic ($cypher, $str); // Terminate encryption hander mcrypt_generic_deinit ($cypher); // Close Module mcrypt_module_close ($cypher); // Return decrypted string return $decrypted; }
[ "public", "static", "function", "_decryptRijndael256", "(", "$", "str", ",", "$", "key", ",", "$", "iv", ")", "{", "// If the string is empty", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "return", "''", ";", "}", "// Open the cypher", "$", "cypher", "=", "mcrypt_module_open", "(", "'rijndael-256'", ",", "''", ",", "'ofb'", ",", "''", ")", ";", "// Set Key", "$", "key", "=", "substr", "(", "$", "key", ",", "0", ",", "mcrypt_enc_get_key_size", "(", "$", "cypher", ")", ")", ";", "// Initialise decryption", "mcrypt_generic_init", "(", "$", "cypher", ",", "$", "key", ",", "$", "iv", ")", ";", "// Decrypt String", "$", "decrypted", "=", "mdecrypt_generic", "(", "$", "cypher", ",", "$", "str", ")", ";", "// Terminate encryption hander", "mcrypt_generic_deinit", "(", "$", "cypher", ")", ";", "// Close Module", "mcrypt_module_close", "(", "$", "cypher", ")", ";", "// Return decrypted string", "return", "$", "decrypted", ";", "}" ]
Decrypt and return a string using the Rijndael 256 cypher @param string $str String to decrypt @param string $key Key to decrypt the string @param string $ic Initialisation vector @return string
[ "Decrypt", "and", "return", "a", "string", "using", "the", "Rijndael", "256", "cypher" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Resource/Crypt.php#L163-L201
train
canax/anax-ramverk1-me
src/StyleChooser/StyleChooserController.php
StyleChooserController.updateActionPost
public function updateActionPost() : object { $response = $this->di->get("response"); $request = $this->di->get("request"); $session = $this->di->get("session"); $key = $request->getPost("stylechooser"); if ($key === "none") { $session->set("flashmessage", "Unsetting the style and using deafult style."); $session->set(self::$key, null); } elseif (array_key_exists($key, $this->styles)) { $session->set("flashmessage", "Using the style '$key'."); $session->set(self::$key, $key); } return $response->redirect("style"); }
php
public function updateActionPost() : object { $response = $this->di->get("response"); $request = $this->di->get("request"); $session = $this->di->get("session"); $key = $request->getPost("stylechooser"); if ($key === "none") { $session->set("flashmessage", "Unsetting the style and using deafult style."); $session->set(self::$key, null); } elseif (array_key_exists($key, $this->styles)) { $session->set("flashmessage", "Using the style '$key'."); $session->set(self::$key, $key); } return $response->redirect("style"); }
[ "public", "function", "updateActionPost", "(", ")", ":", "object", "{", "$", "response", "=", "$", "this", "->", "di", "->", "get", "(", "\"response\"", ")", ";", "$", "request", "=", "$", "this", "->", "di", "->", "get", "(", "\"request\"", ")", ";", "$", "session", "=", "$", "this", "->", "di", "->", "get", "(", "\"session\"", ")", ";", "$", "key", "=", "$", "request", "->", "getPost", "(", "\"stylechooser\"", ")", ";", "if", "(", "$", "key", "===", "\"none\"", ")", "{", "$", "session", "->", "set", "(", "\"flashmessage\"", ",", "\"Unsetting the style and using deafult style.\"", ")", ";", "$", "session", "->", "set", "(", "self", "::", "$", "key", ",", "null", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "styles", ")", ")", "{", "$", "session", "->", "set", "(", "\"flashmessage\"", ",", "\"Using the style '$key'.\"", ")", ";", "$", "session", "->", "set", "(", "self", "::", "$", "key", ",", "$", "key", ")", ";", "}", "return", "$", "response", "->", "redirect", "(", "\"style\"", ")", ";", "}" ]
Update current selected style. @return object
[ "Update", "current", "selected", "style", "." ]
592d5e7891f20b68047009ae2c9efdff45763543
https://github.com/canax/anax-ramverk1-me/blob/592d5e7891f20b68047009ae2c9efdff45763543/src/StyleChooser/StyleChooserController.php#L111-L127
train
canax/anax-ramverk1-me
src/StyleChooser/StyleChooserController.php
StyleChooserController.updateActionGet
public function updateActionGet($style) : object { $response = $this->di->get("response"); $session = $this->di->get("session"); $key = $this->cssUrl . "/" . $style . ".css"; $keyMin = $this->cssUrl . "/" . $style . ".min.css"; if ($style === "none") { $session->set("flashmessage", "Unsetting the style and using the default style."); $session->set(self::$key, null); } elseif (array_key_exists($keyMin, $this->styles)) { $session->set("flashmessage", "Now using the style '$keyMin'."); $session->set(self::$key, $keyMin); } elseif (array_key_exists($key, $this->styles)) { $session->set("flashmessage", "Now using the style '$key'."); $session->set(self::$key, $key); } $url = $session->getOnce("redirect", "style"); return $response->redirect($url); }
php
public function updateActionGet($style) : object { $response = $this->di->get("response"); $session = $this->di->get("session"); $key = $this->cssUrl . "/" . $style . ".css"; $keyMin = $this->cssUrl . "/" . $style . ".min.css"; if ($style === "none") { $session->set("flashmessage", "Unsetting the style and using the default style."); $session->set(self::$key, null); } elseif (array_key_exists($keyMin, $this->styles)) { $session->set("flashmessage", "Now using the style '$keyMin'."); $session->set(self::$key, $keyMin); } elseif (array_key_exists($key, $this->styles)) { $session->set("flashmessage", "Now using the style '$key'."); $session->set(self::$key, $key); } $url = $session->getOnce("redirect", "style"); return $response->redirect($url); }
[ "public", "function", "updateActionGet", "(", "$", "style", ")", ":", "object", "{", "$", "response", "=", "$", "this", "->", "di", "->", "get", "(", "\"response\"", ")", ";", "$", "session", "=", "$", "this", "->", "di", "->", "get", "(", "\"session\"", ")", ";", "$", "key", "=", "$", "this", "->", "cssUrl", ".", "\"/\"", ".", "$", "style", ".", "\".css\"", ";", "$", "keyMin", "=", "$", "this", "->", "cssUrl", ".", "\"/\"", ".", "$", "style", ".", "\".min.css\"", ";", "if", "(", "$", "style", "===", "\"none\"", ")", "{", "$", "session", "->", "set", "(", "\"flashmessage\"", ",", "\"Unsetting the style and using the default style.\"", ")", ";", "$", "session", "->", "set", "(", "self", "::", "$", "key", ",", "null", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "keyMin", ",", "$", "this", "->", "styles", ")", ")", "{", "$", "session", "->", "set", "(", "\"flashmessage\"", ",", "\"Now using the style '$keyMin'.\"", ")", ";", "$", "session", "->", "set", "(", "self", "::", "$", "key", ",", "$", "keyMin", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "styles", ")", ")", "{", "$", "session", "->", "set", "(", "\"flashmessage\"", ",", "\"Now using the style '$key'.\"", ")", ";", "$", "session", "->", "set", "(", "self", "::", "$", "key", ",", "$", "key", ")", ";", "}", "$", "url", "=", "$", "session", "->", "getOnce", "(", "\"redirect\"", ",", "\"style\"", ")", ";", "return", "$", "response", "->", "redirect", "(", "$", "url", ")", ";", "}" ]
Update current selected style using a GET url and redirect to last page visited. @param string $style the key to the style to use. @return object
[ "Update", "current", "selected", "style", "using", "a", "GET", "url", "and", "redirect", "to", "last", "page", "visited", "." ]
592d5e7891f20b68047009ae2c9efdff45763543
https://github.com/canax/anax-ramverk1-me/blob/592d5e7891f20b68047009ae2c9efdff45763543/src/StyleChooser/StyleChooserController.php#L139-L160
train
schpill/thin
src/Reflection.php
Reflection.get
public function get($class = null) { $class = $this->getClass($class); if (Arrays::exists($class, $this->reflections)) { return $this->reflections[$class]; } throw new Exception("Class not found: $class"); }
php
public function get($class = null) { $class = $this->getClass($class); if (Arrays::exists($class, $this->reflections)) { return $this->reflections[$class]; } throw new Exception("Class not found: $class"); }
[ "public", "function", "get", "(", "$", "class", "=", "null", ")", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", "$", "class", ")", ";", "if", "(", "Arrays", "::", "exists", "(", "$", "class", ",", "$", "this", "->", "reflections", ")", ")", "{", "return", "$", "this", "->", "reflections", "[", "$", "class", "]", ";", "}", "throw", "new", "Exception", "(", "\"Class not found: $class\"", ")", ";", "}" ]
Get an Instantiated ReflectionClass. @param string $class Optional name of a class @return mixed null or a ReflectionClass instance @throws Exception if class was not found
[ "Get", "an", "Instantiated", "ReflectionClass", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Reflection.php#L58-L67
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.appendIgnorePattern
protected function appendIgnorePattern($config, $latestWrapper, $previousWrapper) { $latestWrapper->setFilter($config->filter()); $previousWrapper->setFilter($config->filter()); }
php
protected function appendIgnorePattern($config, $latestWrapper, $previousWrapper) { $latestWrapper->setFilter($config->filter()); $previousWrapper->setFilter($config->filter()); }
[ "protected", "function", "appendIgnorePattern", "(", "$", "config", ",", "$", "latestWrapper", ",", "$", "previousWrapper", ")", "{", "$", "latestWrapper", "->", "setFilter", "(", "$", "config", "->", "filter", "(", ")", ")", ";", "$", "previousWrapper", "->", "setFilter", "(", "$", "config", "->", "filter", "(", ")", ")", ";", "}" ]
Add pattern to exclude files. @param Config $config @param AbstractWrapper $latestWrapper @param AbstractWrapper $previousWrapper
[ "Add", "pattern", "to", "exclude", "files", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L54-L58
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.debug
public function debug($message) { if ( ! $this->getOutput()->isDebug()) { return null; } if (func_num_args() > 1) { $message = vsprintf($message, array_slice(func_get_args(), 1)); } $this->getOutput()->writeln($message); }
php
public function debug($message) { if ( ! $this->getOutput()->isDebug()) { return null; } if (func_num_args() > 1) { $message = vsprintf($message, array_slice(func_get_args(), 1)); } $this->getOutput()->writeln($message); }
[ "public", "function", "debug", "(", "$", "message", ")", "{", "if", "(", "!", "$", "this", "->", "getOutput", "(", ")", "->", "isDebug", "(", ")", ")", "{", "return", "null", ";", "}", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "$", "message", "=", "vsprintf", "(", "$", "message", ",", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ")", ";", "}", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "message", ")", ";", "}" ]
Print debug message. Prints debug message, if debug mode is enabled (via -vvv). @param $message @return null
[ "Print", "debug", "message", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L97-L108
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.getEnvironment
public function getEnvironment($config = null) { if ( ! $this->environment) { if (null == $config) { $config = $this->getConfig(); } $this->environment = new Environment($config); } return $this->environment; }
php
public function getEnvironment($config = null) { if ( ! $this->environment) { if (null == $config) { $config = $this->getConfig(); } $this->environment = new Environment($config); } return $this->environment; }
[ "public", "function", "getEnvironment", "(", "$", "config", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "environment", ")", "{", "if", "(", "null", "==", "$", "config", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "}", "$", "this", "->", "environment", "=", "new", "Environment", "(", "$", "config", ")", ";", "}", "return", "$", "this", "->", "environment", ";", "}" ]
Get environment object. @param Config $config Deprecated 4.0.0, command config will be used instead. @return Environment
[ "Get", "environment", "object", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L154-L165
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.getPreviousWrapper
protected function getPreviousWrapper() { if ($this->previousWrapper) { return $this->previousWrapper; } $input = $this->getInput(); $this->previousWrapper = $this->getWrapperInstance( $input->getArgument('previous'), $input->getOption('type') ); return $this->previousWrapper; }
php
protected function getPreviousWrapper() { if ($this->previousWrapper) { return $this->previousWrapper; } $input = $this->getInput(); $this->previousWrapper = $this->getWrapperInstance( $input->getArgument('previous'), $input->getOption('type') ); return $this->previousWrapper; }
[ "protected", "function", "getPreviousWrapper", "(", ")", "{", "if", "(", "$", "this", "->", "previousWrapper", ")", "{", "return", "$", "this", "->", "previousWrapper", ";", "}", "$", "input", "=", "$", "this", "->", "getInput", "(", ")", ";", "$", "this", "->", "previousWrapper", "=", "$", "this", "->", "getWrapperInstance", "(", "$", "input", "->", "getArgument", "(", "'previous'", ")", ",", "$", "input", "->", "getOption", "(", "'type'", ")", ")", ";", "return", "$", "this", "->", "previousWrapper", ";", "}" ]
Get the wrapper for the VCS. @return AbstractWrapper
[ "Get", "the", "wrapper", "for", "the", "VCS", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L213-L227
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.getWrapperInstance
protected function getWrapperInstance($base, $type = 'Directory') { $wrapper = $this->getWrapperClass($type); if ( ! $wrapper) { throw new \InvalidArgumentException( sprintf( '<error>Unknown wrapper-type "%s"</error>', $type ) ); } if (is_dir($base)) { $wrapper = $this->getWrapperClass('Directory'); } $this->debug('Using wrapper "' . $wrapper . '" for "' . $base . '"'); return new $wrapper($base); }
php
protected function getWrapperInstance($base, $type = 'Directory') { $wrapper = $this->getWrapperClass($type); if ( ! $wrapper) { throw new \InvalidArgumentException( sprintf( '<error>Unknown wrapper-type "%s"</error>', $type ) ); } if (is_dir($base)) { $wrapper = $this->getWrapperClass('Directory'); } $this->debug('Using wrapper "' . $wrapper . '" for "' . $base . '"'); return new $wrapper($base); }
[ "protected", "function", "getWrapperInstance", "(", "$", "base", ",", "$", "type", "=", "'Directory'", ")", "{", "$", "wrapper", "=", "$", "this", "->", "getWrapperClass", "(", "$", "type", ")", ";", "if", "(", "!", "$", "wrapper", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'<error>Unknown wrapper-type \"%s\"</error>'", ",", "$", "type", ")", ")", ";", "}", "if", "(", "is_dir", "(", "$", "base", ")", ")", "{", "$", "wrapper", "=", "$", "this", "->", "getWrapperClass", "(", "'Directory'", ")", ";", "}", "$", "this", "->", "debug", "(", "'Using wrapper \"'", ".", "$", "wrapper", ".", "'\" for \"'", ".", "$", "base", ".", "'\"'", ")", ";", "return", "new", "$", "wrapper", "(", "$", "base", ")", ";", "}" ]
Create a wrapper for the given target. When the target is a directory, then the type overridden with "Directory". @param string $base @param string $type @return AbstractWrapper
[ "Create", "a", "wrapper", "for", "the", "given", "target", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L251-L271
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.parseFiles
protected function parseFiles($wrapper, $prefix) { $this->verbose($prefix . 'Fetching files ...'); $time = microtime(true); $fileAmount = count($wrapper->getAllFileNames()); $this->verbose( sprintf( "\r" . $prefix . "Collected %d files in %0.2f seconds.", $fileAmount, microtime(true) - $time ) ); $this->verbose($prefix . 'Parsing ' . $fileAmount . ' files '); $this->debug(' in ' . $wrapper->getBasePath()); $time = microtime(true); $progress = new ProgressBar($this->getOutput(), $fileAmount); $progress->setFormat('%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s% RAM'); $dataTree = []; foreach ($wrapper->getDataTree() as $tree) { $dataTree = $wrapper->mergeTrees($dataTree, $tree); $progress->advance(); } $progress->clear(); $this->verbose( sprintf( $prefix . "Parsed %d files in %0.2f seconds.", $fileAmount, microtime(true) - $time ) ); return $dataTree; }
php
protected function parseFiles($wrapper, $prefix) { $this->verbose($prefix . 'Fetching files ...'); $time = microtime(true); $fileAmount = count($wrapper->getAllFileNames()); $this->verbose( sprintf( "\r" . $prefix . "Collected %d files in %0.2f seconds.", $fileAmount, microtime(true) - $time ) ); $this->verbose($prefix . 'Parsing ' . $fileAmount . ' files '); $this->debug(' in ' . $wrapper->getBasePath()); $time = microtime(true); $progress = new ProgressBar($this->getOutput(), $fileAmount); $progress->setFormat('%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s% RAM'); $dataTree = []; foreach ($wrapper->getDataTree() as $tree) { $dataTree = $wrapper->mergeTrees($dataTree, $tree); $progress->advance(); } $progress->clear(); $this->verbose( sprintf( $prefix . "Parsed %d files in %0.2f seconds.", $fileAmount, microtime(true) - $time ) ); return $dataTree; }
[ "protected", "function", "parseFiles", "(", "$", "wrapper", ",", "$", "prefix", ")", "{", "$", "this", "->", "verbose", "(", "$", "prefix", ".", "'Fetching files ...'", ")", ";", "$", "time", "=", "microtime", "(", "true", ")", ";", "$", "fileAmount", "=", "count", "(", "$", "wrapper", "->", "getAllFileNames", "(", ")", ")", ";", "$", "this", "->", "verbose", "(", "sprintf", "(", "\"\\r\"", ".", "$", "prefix", ".", "\"Collected %d files in %0.2f seconds.\"", ",", "$", "fileAmount", ",", "microtime", "(", "true", ")", "-", "$", "time", ")", ")", ";", "$", "this", "->", "verbose", "(", "$", "prefix", ".", "'Parsing '", ".", "$", "fileAmount", ".", "' files '", ")", ";", "$", "this", "->", "debug", "(", "' in '", ".", "$", "wrapper", "->", "getBasePath", "(", ")", ")", ";", "$", "time", "=", "microtime", "(", "true", ")", ";", "$", "progress", "=", "new", "ProgressBar", "(", "$", "this", "->", "getOutput", "(", ")", ",", "$", "fileAmount", ")", ";", "$", "progress", "->", "setFormat", "(", "'%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s% RAM'", ")", ";", "$", "dataTree", "=", "[", "]", ";", "foreach", "(", "$", "wrapper", "->", "getDataTree", "(", ")", "as", "$", "tree", ")", "{", "$", "dataTree", "=", "$", "wrapper", "->", "mergeTrees", "(", "$", "dataTree", ",", "$", "tree", ")", ";", "$", "progress", "->", "advance", "(", ")", ";", "}", "$", "progress", "->", "clear", "(", ")", ";", "$", "this", "->", "verbose", "(", "sprintf", "(", "$", "prefix", ".", "\"Parsed %d files in %0.2f seconds.\"", ",", "$", "fileAmount", ",", "microtime", "(", "true", ")", "-", "$", "time", ")", ")", ";", "return", "$", "dataTree", ";", "}" ]
Parse files within a wrapper. @param AbstractWrapper $wrapper @param string $prefix @return mixed
[ "Parse", "files", "within", "a", "wrapper", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L348-L386
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.printConfig
protected function printConfig() { $config = $this->getConfig(); $output = $this->getOutput(); foreach ($config->ruleSet()->getChildren() as $ruleSet) { $output->writeln('Using rule set ' . $ruleSet->getName()); if ( ! $output->isDebug()) { continue; } if ( ! $ruleSet->trigger()) { $output->writeln(' No triggers found.'); continue; } foreach ($ruleSet->trigger()->getAll() as $singleTrigger) { $output->writeln(' Contains trigger ' . $singleTrigger); } } }
php
protected function printConfig() { $config = $this->getConfig(); $output = $this->getOutput(); foreach ($config->ruleSet()->getChildren() as $ruleSet) { $output->writeln('Using rule set ' . $ruleSet->getName()); if ( ! $output->isDebug()) { continue; } if ( ! $ruleSet->trigger()) { $output->writeln(' No triggers found.'); continue; } foreach ($ruleSet->trigger()->getAll() as $singleTrigger) { $output->writeln(' Contains trigger ' . $singleTrigger); } } }
[ "protected", "function", "printConfig", "(", ")", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "output", "=", "$", "this", "->", "getOutput", "(", ")", ";", "foreach", "(", "$", "config", "->", "ruleSet", "(", ")", "->", "getChildren", "(", ")", "as", "$", "ruleSet", ")", "{", "$", "output", "->", "writeln", "(", "'Using rule set '", ".", "$", "ruleSet", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "$", "output", "->", "isDebug", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "ruleSet", "->", "trigger", "(", ")", ")", "{", "$", "output", "->", "writeln", "(", "' No triggers found.'", ")", ";", "continue", ";", "}", "foreach", "(", "$", "ruleSet", "->", "trigger", "(", ")", "->", "getAll", "(", ")", "as", "$", "singleTrigger", ")", "{", "$", "output", "->", "writeln", "(", "' Contains trigger '", ".", "$", "singleTrigger", ")", ";", "}", "}", "}" ]
Print debug information of the used config. @param Config $config @param OutputInterface $output
[ "Print", "debug", "information", "of", "the", "used", "config", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L394-L415
train
ScreamingDev/phpsemver
lib/PHPSemVer/Console/AbstractCommand.php
AbstractCommand.resolveConfigFile
protected function resolveConfigFile() { $ruleSet = $this->getInput()->getOption('ruleSet'); if (null === $ruleSet && file_exists('phpsemver.xml')) { return 'phpsemver.xml'; } if (null === $ruleSet) { $ruleSet = 'SemVer2'; } if (file_exists($ruleSet)) { return $ruleSet; } $defaultPath = PHPSEMVER_LIB_PATH . '/PHPSemVer/Rules/'; if (file_exists($defaultPath . $ruleSet . '.xml')) { return $defaultPath . $ruleSet . '.xml'; } throw new \InvalidArgumentException( 'Could not find rule set: ' . $ruleSet ); }
php
protected function resolveConfigFile() { $ruleSet = $this->getInput()->getOption('ruleSet'); if (null === $ruleSet && file_exists('phpsemver.xml')) { return 'phpsemver.xml'; } if (null === $ruleSet) { $ruleSet = 'SemVer2'; } if (file_exists($ruleSet)) { return $ruleSet; } $defaultPath = PHPSEMVER_LIB_PATH . '/PHPSemVer/Rules/'; if (file_exists($defaultPath . $ruleSet . '.xml')) { return $defaultPath . $ruleSet . '.xml'; } throw new \InvalidArgumentException( 'Could not find rule set: ' . $ruleSet ); }
[ "protected", "function", "resolveConfigFile", "(", ")", "{", "$", "ruleSet", "=", "$", "this", "->", "getInput", "(", ")", "->", "getOption", "(", "'ruleSet'", ")", ";", "if", "(", "null", "===", "$", "ruleSet", "&&", "file_exists", "(", "'phpsemver.xml'", ")", ")", "{", "return", "'phpsemver.xml'", ";", "}", "if", "(", "null", "===", "$", "ruleSet", ")", "{", "$", "ruleSet", "=", "'SemVer2'", ";", "}", "if", "(", "file_exists", "(", "$", "ruleSet", ")", ")", "{", "return", "$", "ruleSet", ";", "}", "$", "defaultPath", "=", "PHPSEMVER_LIB_PATH", ".", "'/PHPSemVer/Rules/'", ";", "if", "(", "file_exists", "(", "$", "defaultPath", ".", "$", "ruleSet", ".", "'.xml'", ")", ")", "{", "return", "$", "defaultPath", ".", "$", "ruleSet", ".", "'.xml'", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Could not find rule set: '", ".", "$", "ruleSet", ")", ";", "}" ]
Resolve path to rule set XML. @param string $ruleSet Path to XML config file. @return string
[ "Resolve", "path", "to", "rule", "set", "XML", "." ]
11a4bc508f71dee73d4f5fee2e9d39e7984d3e15
https://github.com/ScreamingDev/phpsemver/blob/11a4bc508f71dee73d4f5fee2e9d39e7984d3e15/lib/PHPSemVer/Console/AbstractCommand.php#L424-L448
train
infusephp/auth
src/Models/UserLink.php
UserLink.url
public function url() { if ($this->type === self::FORGOT_PASSWORD) { return $this->getApp()['base_url'].'users/forgot/'.$this->link; } else if ($this->type === self::TEMPORARY) { return $this->getApp()['base_url'].'users/signup/'.$this->link; } return false; }
php
public function url() { if ($this->type === self::FORGOT_PASSWORD) { return $this->getApp()['base_url'].'users/forgot/'.$this->link; } else if ($this->type === self::TEMPORARY) { return $this->getApp()['base_url'].'users/signup/'.$this->link; } return false; }
[ "public", "function", "url", "(", ")", "{", "if", "(", "$", "this", "->", "type", "===", "self", "::", "FORGOT_PASSWORD", ")", "{", "return", "$", "this", "->", "getApp", "(", ")", "[", "'base_url'", "]", ".", "'users/forgot/'", ".", "$", "this", "->", "link", ";", "}", "else", "if", "(", "$", "this", "->", "type", "===", "self", "::", "TEMPORARY", ")", "{", "return", "$", "this", "->", "getApp", "(", ")", "[", "'base_url'", "]", ".", "'users/signup/'", ".", "$", "this", "->", "link", ";", "}", "return", "false", ";", "}" ]
Gets the URL for this link. @return string|false
[ "Gets", "the", "URL", "for", "this", "link", "." ]
720280b4b2635572f331afe8d082e3e88cf54eb7
https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Models/UserLink.php#L84-L93
train
graze/csv-token
src/Tokeniser/StreamTokeniser.php
StreamTokeniser.getTokens
public function getTokens() { fseek($this->stream, 0); $this->buffer = new StreamBuffer($this->stream, static::BUFFER_SIZE, $this->minLength); $this->buffer->read(); /** @var Token $last */ $last = null; while (!$this->buffer->isEof()) { foreach ($this->state->match($this->buffer) as $token) { if ($token[0] == Token::T_BOM) { $this->changeEncoding($token[1]); } $this->state = $this->state->getNextState($token[0]); // merge tokens together to condense T_CONTENT tokens if ($token[0] == Token::T_CONTENT) { if (!is_null($last)) { $last[1] .= $token[1]; $last[3] = strlen($last[1]); } else { $last = $token; } } else { if (!is_null($last)) { yield $last; $last = null; } yield $token; } $this->buffer->move($token[3]); $this->buffer->read(); } } if (!is_null($last)) { yield $last; } fclose($this->stream); }
php
public function getTokens() { fseek($this->stream, 0); $this->buffer = new StreamBuffer($this->stream, static::BUFFER_SIZE, $this->minLength); $this->buffer->read(); /** @var Token $last */ $last = null; while (!$this->buffer->isEof()) { foreach ($this->state->match($this->buffer) as $token) { if ($token[0] == Token::T_BOM) { $this->changeEncoding($token[1]); } $this->state = $this->state->getNextState($token[0]); // merge tokens together to condense T_CONTENT tokens if ($token[0] == Token::T_CONTENT) { if (!is_null($last)) { $last[1] .= $token[1]; $last[3] = strlen($last[1]); } else { $last = $token; } } else { if (!is_null($last)) { yield $last; $last = null; } yield $token; } $this->buffer->move($token[3]); $this->buffer->read(); } } if (!is_null($last)) { yield $last; } fclose($this->stream); }
[ "public", "function", "getTokens", "(", ")", "{", "fseek", "(", "$", "this", "->", "stream", ",", "0", ")", ";", "$", "this", "->", "buffer", "=", "new", "StreamBuffer", "(", "$", "this", "->", "stream", ",", "static", "::", "BUFFER_SIZE", ",", "$", "this", "->", "minLength", ")", ";", "$", "this", "->", "buffer", "->", "read", "(", ")", ";", "/** @var Token $last */", "$", "last", "=", "null", ";", "while", "(", "!", "$", "this", "->", "buffer", "->", "isEof", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "state", "->", "match", "(", "$", "this", "->", "buffer", ")", "as", "$", "token", ")", "{", "if", "(", "$", "token", "[", "0", "]", "==", "Token", "::", "T_BOM", ")", "{", "$", "this", "->", "changeEncoding", "(", "$", "token", "[", "1", "]", ")", ";", "}", "$", "this", "->", "state", "=", "$", "this", "->", "state", "->", "getNextState", "(", "$", "token", "[", "0", "]", ")", ";", "// merge tokens together to condense T_CONTENT tokens", "if", "(", "$", "token", "[", "0", "]", "==", "Token", "::", "T_CONTENT", ")", "{", "if", "(", "!", "is_null", "(", "$", "last", ")", ")", "{", "$", "last", "[", "1", "]", ".=", "$", "token", "[", "1", "]", ";", "$", "last", "[", "3", "]", "=", "strlen", "(", "$", "last", "[", "1", "]", ")", ";", "}", "else", "{", "$", "last", "=", "$", "token", ";", "}", "}", "else", "{", "if", "(", "!", "is_null", "(", "$", "last", ")", ")", "{", "yield", "$", "last", ";", "$", "last", "=", "null", ";", "}", "yield", "$", "token", ";", "}", "$", "this", "->", "buffer", "->", "move", "(", "$", "token", "[", "3", "]", ")", ";", "$", "this", "->", "buffer", "->", "read", "(", ")", ";", "}", "}", "if", "(", "!", "is_null", "(", "$", "last", ")", ")", "{", "yield", "$", "last", ";", "}", "fclose", "(", "$", "this", "->", "stream", ")", ";", "}" ]
Loop through the stream, pulling maximum type length each time, find the largest type that matches and create a token, then move on length characters @return Iterator
[ "Loop", "through", "the", "stream", "pulling", "maximum", "type", "length", "each", "time", "find", "the", "largest", "type", "that", "matches", "and", "create", "a", "token", "then", "move", "on", "length", "characters" ]
ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8
https://github.com/graze/csv-token/blob/ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8/src/Tokeniser/StreamTokeniser.php#L61-L104
train
pmdevelopment/tool-bundle
Components/Traits/HasDoctrineTrait.php
HasDoctrineTrait.persistAndFlush
public function persistAndFlush() { if (0 === func_num_args()) { throw new \LogicException('Missing arguments'); } $persists = []; $entities = func_get_args(); foreach ($entities as $entity) { if (true === is_array($entity)) { $persists = array_merge($persists, $entity); } else { $persists[] = $entity; } } foreach ($persists as $persist) { $this->getDoctrine()->getManager()->persist($persist); } $this->getDoctrine()->getManager()->flush(); return $this; }
php
public function persistAndFlush() { if (0 === func_num_args()) { throw new \LogicException('Missing arguments'); } $persists = []; $entities = func_get_args(); foreach ($entities as $entity) { if (true === is_array($entity)) { $persists = array_merge($persists, $entity); } else { $persists[] = $entity; } } foreach ($persists as $persist) { $this->getDoctrine()->getManager()->persist($persist); } $this->getDoctrine()->getManager()->flush(); return $this; }
[ "public", "function", "persistAndFlush", "(", ")", "{", "if", "(", "0", "===", "func_num_args", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Missing arguments'", ")", ";", "}", "$", "persists", "=", "[", "]", ";", "$", "entities", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "if", "(", "true", "===", "is_array", "(", "$", "entity", ")", ")", "{", "$", "persists", "=", "array_merge", "(", "$", "persists", ",", "$", "entity", ")", ";", "}", "else", "{", "$", "persists", "[", "]", "=", "$", "entity", ";", "}", "}", "foreach", "(", "$", "persists", "as", "$", "persist", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "persist", "(", "$", "persist", ")", ";", "}", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", ";", "}" ]
Persist and Flush @return $this
[ "Persist", "and", "Flush" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Components/Traits/HasDoctrineTrait.php#L35-L59
train
pmdevelopment/tool-bundle
Components/Traits/HasDoctrineTrait.php
HasDoctrineTrait.removeAndFlush
public function removeAndFlush() { if (0 === func_num_args()) { throw new \LogicException('Missing arguments'); } foreach (func_get_args() as $remove) { $this->getDoctrine()->getManager()->remove($remove); } $this->getDoctrine()->getManager()->flush(); return $this; }
php
public function removeAndFlush() { if (0 === func_num_args()) { throw new \LogicException('Missing arguments'); } foreach (func_get_args() as $remove) { $this->getDoctrine()->getManager()->remove($remove); } $this->getDoctrine()->getManager()->flush(); return $this; }
[ "public", "function", "removeAndFlush", "(", ")", "{", "if", "(", "0", "===", "func_num_args", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Missing arguments'", ")", ";", "}", "foreach", "(", "func_get_args", "(", ")", "as", "$", "remove", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "remove", "(", "$", "remove", ")", ";", "}", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "flush", "(", ")", ";", "return", "$", "this", ";", "}" ]
Remove and Flush @return $this
[ "Remove", "and", "Flush" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Components/Traits/HasDoctrineTrait.php#L66-L79
train
amarcinkowski/hospitalplugin
src/WP/Menu.php
Menu.registerPages
public function registerPages() { foreach ($this->menus as $menu) { $this->registerPage($menu['title'], $menu['cap'], $menu['link'], $menu['class'], $menu['callback'], $menu['type']); } $this->hideMenu(); }
php
public function registerPages() { foreach ($this->menus as $menu) { $this->registerPage($menu['title'], $menu['cap'], $menu['link'], $menu['class'], $menu['callback'], $menu['type']); } $this->hideMenu(); }
[ "public", "function", "registerPages", "(", ")", "{", "foreach", "(", "$", "this", "->", "menus", "as", "$", "menu", ")", "{", "$", "this", "->", "registerPage", "(", "$", "menu", "[", "'title'", "]", ",", "$", "menu", "[", "'cap'", "]", ",", "$", "menu", "[", "'link'", "]", ",", "$", "menu", "[", "'class'", "]", ",", "$", "menu", "[", "'callback'", "]", ",", "$", "menu", "[", "'type'", "]", ")", ";", "}", "$", "this", "->", "hideMenu", "(", ")", ";", "}" ]
register menu pages
[ "register", "menu", "pages" ]
acdc2be5157abfbdcafb4dcf6c6ba505e291263f
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/WP/Menu.php#L65-L71
train
amarcinkowski/hospitalplugin
src/WP/Menu.php
Menu.registerPage
private function registerPage($title, $capabilities, $url_param, $class, $callback, $type) { if ($type == 'submenu') { add_submenu_page($this->url, $title, $title, $capabilities, $url_param, array( $class, $callback )); } else { add_menu_page($title, $title, $capabilities, $url_param, array( $class, $callback )); } }
php
private function registerPage($title, $capabilities, $url_param, $class, $callback, $type) { if ($type == 'submenu') { add_submenu_page($this->url, $title, $title, $capabilities, $url_param, array( $class, $callback )); } else { add_menu_page($title, $title, $capabilities, $url_param, array( $class, $callback )); } }
[ "private", "function", "registerPage", "(", "$", "title", ",", "$", "capabilities", ",", "$", "url_param", ",", "$", "class", ",", "$", "callback", ",", "$", "type", ")", "{", "if", "(", "$", "type", "==", "'submenu'", ")", "{", "add_submenu_page", "(", "$", "this", "->", "url", ",", "$", "title", ",", "$", "title", ",", "$", "capabilities", ",", "$", "url_param", ",", "array", "(", "$", "class", ",", "$", "callback", ")", ")", ";", "}", "else", "{", "add_menu_page", "(", "$", "title", ",", "$", "title", ",", "$", "capabilities", ",", "$", "url_param", ",", "array", "(", "$", "class", ",", "$", "callback", ")", ")", ";", "}", "}" ]
register using add_submenu_page
[ "register", "using", "add_submenu_page" ]
acdc2be5157abfbdcafb4dcf6c6ba505e291263f
https://github.com/amarcinkowski/hospitalplugin/blob/acdc2be5157abfbdcafb4dcf6c6ba505e291263f/src/WP/Menu.php#L86-L99
train
graze/csv-token
src/Tokeniser/Token/TokenStore.php
TokenStore.sort
private function sort() { // sort by reverse key length uksort($this->tokens, function ($first, $second) { return strlen($second) - strlen($first); }); }
php
private function sort() { // sort by reverse key length uksort($this->tokens, function ($first, $second) { return strlen($second) - strlen($first); }); }
[ "private", "function", "sort", "(", ")", "{", "// sort by reverse key length", "uksort", "(", "$", "this", "->", "tokens", ",", "function", "(", "$", "first", ",", "$", "second", ")", "{", "return", "strlen", "(", "$", "second", ")", "-", "strlen", "(", "$", "first", ")", ";", "}", ")", ";", "}" ]
Sort the tokens into reverse key length order
[ "Sort", "the", "tokens", "into", "reverse", "key", "length", "order" ]
ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8
https://github.com/graze/csv-token/blob/ad11cfc83e7f0cae56da6844f9216bbaf5c8dcb8/src/Tokeniser/Token/TokenStore.php#L123-L129
train
aledefreitas/zlx_security
src/Security/Security.php
Security.validHmac
private function validHmac($hmac, $compareHmac) { if(function_exists("hash_equals")) { return hash_equals($hmac, $compareHmac); } $hashLength = mb_strlen($hmac, '8bit'); $compareLength = mb_strlen($compareHmac, '8bit'); if ($hashLength !== $compareLength) { return false; } $result = 0; for ($i = 0; $i < $hashLength; $i++) { $result |= (ord($hmac[$i]) ^ ord($compareHmac[$i])); } return $result === 0; }
php
private function validHmac($hmac, $compareHmac) { if(function_exists("hash_equals")) { return hash_equals($hmac, $compareHmac); } $hashLength = mb_strlen($hmac, '8bit'); $compareLength = mb_strlen($compareHmac, '8bit'); if ($hashLength !== $compareLength) { return false; } $result = 0; for ($i = 0; $i < $hashLength; $i++) { $result |= (ord($hmac[$i]) ^ ord($compareHmac[$i])); } return $result === 0; }
[ "private", "function", "validHmac", "(", "$", "hmac", ",", "$", "compareHmac", ")", "{", "if", "(", "function_exists", "(", "\"hash_equals\"", ")", ")", "{", "return", "hash_equals", "(", "$", "hmac", ",", "$", "compareHmac", ")", ";", "}", "$", "hashLength", "=", "mb_strlen", "(", "$", "hmac", ",", "'8bit'", ")", ";", "$", "compareLength", "=", "mb_strlen", "(", "$", "compareHmac", ",", "'8bit'", ")", ";", "if", "(", "$", "hashLength", "!==", "$", "compareLength", ")", "{", "return", "false", ";", "}", "$", "result", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "hashLength", ";", "$", "i", "++", ")", "{", "$", "result", "|=", "(", "ord", "(", "$", "hmac", "[", "$", "i", "]", ")", "^", "ord", "(", "$", "compareHmac", "[", "$", "i", "]", ")", ")", ";", "}", "return", "$", "result", "===", "0", ";", "}" ]
Validates if the provided hmac is equal to the expected hmac @param string $hmac Provided hmac @param string $compareHmac Expected hmac @return boolean
[ "Validates", "if", "the", "provided", "hmac", "is", "equal", "to", "the", "expected", "hmac" ]
3281db6bacfff51695835e1e6fc5bbddcf1a028a
https://github.com/aledefreitas/zlx_security/blob/3281db6bacfff51695835e1e6fc5bbddcf1a028a/src/Security/Security.php#L66-L86
train
aledefreitas/zlx_security
src/Security/Security.php
Security.encrypt
public function encrypt($original_string, $cipher_key) { $cipher_key = $this->_genKey($cipher_key); $ivSize = openssl_cipher_iv_length('AES-256-CBC'); $iv = openssl_random_pseudo_bytes($ivSize); $cipher_text = $iv . openssl_encrypt($original_string, 'AES-256-CBC', $cipher_key, OPENSSL_RAW_DATA, $iv); return $this->_genHmac($cipher_text, $cipher_key) . $cipher_text; }
php
public function encrypt($original_string, $cipher_key) { $cipher_key = $this->_genKey($cipher_key); $ivSize = openssl_cipher_iv_length('AES-256-CBC'); $iv = openssl_random_pseudo_bytes($ivSize); $cipher_text = $iv . openssl_encrypt($original_string, 'AES-256-CBC', $cipher_key, OPENSSL_RAW_DATA, $iv); return $this->_genHmac($cipher_text, $cipher_key) . $cipher_text; }
[ "public", "function", "encrypt", "(", "$", "original_string", ",", "$", "cipher_key", ")", "{", "$", "cipher_key", "=", "$", "this", "->", "_genKey", "(", "$", "cipher_key", ")", ";", "$", "ivSize", "=", "openssl_cipher_iv_length", "(", "'AES-256-CBC'", ")", ";", "$", "iv", "=", "openssl_random_pseudo_bytes", "(", "$", "ivSize", ")", ";", "$", "cipher_text", "=", "$", "iv", ".", "openssl_encrypt", "(", "$", "original_string", ",", "'AES-256-CBC'", ",", "$", "cipher_key", ",", "OPENSSL_RAW_DATA", ",", "$", "iv", ")", ";", "return", "$", "this", "->", "_genHmac", "(", "$", "cipher_text", ",", "$", "cipher_key", ")", ".", "$", "cipher_text", ";", "}" ]
Encrypts a string using a secret @param string $original_string Original string @param string $cipher_key Secret used to encrypt @return string
[ "Encrypts", "a", "string", "using", "a", "secret" ]
3281db6bacfff51695835e1e6fc5bbddcf1a028a
https://github.com/aledefreitas/zlx_security/blob/3281db6bacfff51695835e1e6fc5bbddcf1a028a/src/Security/Security.php#L108-L118
train
aledefreitas/zlx_security
src/Security/Security.php
Security.decrypt
public function decrypt($cipher_string, $cipher_key) { $cipher_key = $this->_genKey($cipher_key); $hmacSize = 64; $hmacString = mb_substr($cipher_string, 0, $hmacSize, "8bit"); $cipher_text = mb_substr($cipher_string, $hmacSize, null, "8bit"); if(!$this->validHmac($hmacString, $this->_genHmac($cipher_text, $cipher_key))) return false; $ivSize = openssl_cipher_iv_length('AES-256-CBC'); $iv = mb_substr($cipher_text, 0, $ivSize, '8bit'); $cipher_text = mb_substr($cipher_text, $ivSize, null, '8bit'); return openssl_decrypt($cipher_text, 'AES-256-CBC', $cipher_key, OPENSSL_RAW_DATA, $iv); }
php
public function decrypt($cipher_string, $cipher_key) { $cipher_key = $this->_genKey($cipher_key); $hmacSize = 64; $hmacString = mb_substr($cipher_string, 0, $hmacSize, "8bit"); $cipher_text = mb_substr($cipher_string, $hmacSize, null, "8bit"); if(!$this->validHmac($hmacString, $this->_genHmac($cipher_text, $cipher_key))) return false; $ivSize = openssl_cipher_iv_length('AES-256-CBC'); $iv = mb_substr($cipher_text, 0, $ivSize, '8bit'); $cipher_text = mb_substr($cipher_text, $ivSize, null, '8bit'); return openssl_decrypt($cipher_text, 'AES-256-CBC', $cipher_key, OPENSSL_RAW_DATA, $iv); }
[ "public", "function", "decrypt", "(", "$", "cipher_string", ",", "$", "cipher_key", ")", "{", "$", "cipher_key", "=", "$", "this", "->", "_genKey", "(", "$", "cipher_key", ")", ";", "$", "hmacSize", "=", "64", ";", "$", "hmacString", "=", "mb_substr", "(", "$", "cipher_string", ",", "0", ",", "$", "hmacSize", ",", "\"8bit\"", ")", ";", "$", "cipher_text", "=", "mb_substr", "(", "$", "cipher_string", ",", "$", "hmacSize", ",", "null", ",", "\"8bit\"", ")", ";", "if", "(", "!", "$", "this", "->", "validHmac", "(", "$", "hmacString", ",", "$", "this", "->", "_genHmac", "(", "$", "cipher_text", ",", "$", "cipher_key", ")", ")", ")", "return", "false", ";", "$", "ivSize", "=", "openssl_cipher_iv_length", "(", "'AES-256-CBC'", ")", ";", "$", "iv", "=", "mb_substr", "(", "$", "cipher_text", ",", "0", ",", "$", "ivSize", ",", "'8bit'", ")", ";", "$", "cipher_text", "=", "mb_substr", "(", "$", "cipher_text", ",", "$", "ivSize", ",", "null", ",", "'8bit'", ")", ";", "return", "openssl_decrypt", "(", "$", "cipher_text", ",", "'AES-256-CBC'", ",", "$", "cipher_key", ",", "OPENSSL_RAW_DATA", ",", "$", "iv", ")", ";", "}" ]
Decrypts a string using a secret @param string $cipher_string Ciphered string @param string $cipher_key Secret used to encrypt @return string
[ "Decrypts", "a", "string", "using", "a", "secret" ]
3281db6bacfff51695835e1e6fc5bbddcf1a028a
https://github.com/aledefreitas/zlx_security/blob/3281db6bacfff51695835e1e6fc5bbddcf1a028a/src/Security/Security.php#L128-L144
train
bruno-barros/w.eloquent-framework
src/weloquent/Core/Http/Ajax.php
Ajax.listen
public function listen($action, $logged = 'no', $callable) { if (!is_string($action) || strlen($action) == 0) { throw new AjaxException("Invalid parameter for the action."); } // resolve callable if (is_callable($callable)) { $this->registerWithClosure($action, $logged, $callable); } else { if (strpos($callable, '@') !== false) { $parts = explode('@', $callable); $callable = $parts[0]; $method = $parts[1]; } else { $method = 'run';// default } try { $resolvedCallback = $this->app->make($callable); $this->registerWithClassInstance($action, $logged, $resolvedCallback, $method); } catch (\Exception $e) { throw new AjaxException($e->getMessage()); } } }
php
public function listen($action, $logged = 'no', $callable) { if (!is_string($action) || strlen($action) == 0) { throw new AjaxException("Invalid parameter for the action."); } // resolve callable if (is_callable($callable)) { $this->registerWithClosure($action, $logged, $callable); } else { if (strpos($callable, '@') !== false) { $parts = explode('@', $callable); $callable = $parts[0]; $method = $parts[1]; } else { $method = 'run';// default } try { $resolvedCallback = $this->app->make($callable); $this->registerWithClassInstance($action, $logged, $resolvedCallback, $method); } catch (\Exception $e) { throw new AjaxException($e->getMessage()); } } }
[ "public", "function", "listen", "(", "$", "action", ",", "$", "logged", "=", "'no'", ",", "$", "callable", ")", "{", "if", "(", "!", "is_string", "(", "$", "action", ")", "||", "strlen", "(", "$", "action", ")", "==", "0", ")", "{", "throw", "new", "AjaxException", "(", "\"Invalid parameter for the action.\"", ")", ";", "}", "// resolve callable", "if", "(", "is_callable", "(", "$", "callable", ")", ")", "{", "$", "this", "->", "registerWithClosure", "(", "$", "action", ",", "$", "logged", ",", "$", "callable", ")", ";", "}", "else", "{", "if", "(", "strpos", "(", "$", "callable", ",", "'@'", ")", "!==", "false", ")", "{", "$", "parts", "=", "explode", "(", "'@'", ",", "$", "callable", ")", ";", "$", "callable", "=", "$", "parts", "[", "0", "]", ";", "$", "method", "=", "$", "parts", "[", "1", "]", ";", "}", "else", "{", "$", "method", "=", "'run'", ";", "// default", "}", "try", "{", "$", "resolvedCallback", "=", "$", "this", "->", "app", "->", "make", "(", "$", "callable", ")", ";", "$", "this", "->", "registerWithClassInstance", "(", "$", "action", ",", "$", "logged", ",", "$", "resolvedCallback", ",", "$", "method", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "AjaxException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "}" ]
Handle the Ajax response. Run the appropriate action hooks used by WordPress in order to perform POST ajax request securely. Developers have the option to run ajax for the Front-end, Back-end either users are logged in or not or both. @param string $action Your ajax 'action' name @param string $logged Accepted values are 'no', 'yes', 'both' @param callable|string $callable The function to run when ajax action is called @throws AjaxException
[ "Handle", "the", "Ajax", "response", ".", "Run", "the", "appropriate", "action", "hooks", "used", "by", "WordPress", "in", "order", "to", "perform", "POST", "ajax", "request", "securely", ".", "Developers", "have", "the", "option", "to", "run", "ajax", "for", "the", "Front", "-", "end", "Back", "-", "end", "either", "users", "are", "logged", "in", "or", "not", "or", "both", "." ]
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Core/Http/Ajax.php#L43-L82
train
bruno-barros/w.eloquent-framework
src/weloquent/Core/Http/Ajax.php
Ajax.validate
public function validate($nonce = null, $value = null, $message = null, $data = null) { $nonce = ($nonce) ? $nonce : $this->app['request']->get('nonce'); $value = ($value) ? $value : $this->app['config']->get('app.key'); if (!wp_verify_nonce($nonce, $value)) { $default = ($msg = trans('ajax.invalid')) ? $msg : 'AJAX is invalid.'; $data = ($data) ? $data : $this->app['request']->except(['nonce', 'action']); wp_send_json([ 'error' => true, 'msg' => ($message) ? $message : $default, 'data' => $data ]); } }
php
public function validate($nonce = null, $value = null, $message = null, $data = null) { $nonce = ($nonce) ? $nonce : $this->app['request']->get('nonce'); $value = ($value) ? $value : $this->app['config']->get('app.key'); if (!wp_verify_nonce($nonce, $value)) { $default = ($msg = trans('ajax.invalid')) ? $msg : 'AJAX is invalid.'; $data = ($data) ? $data : $this->app['request']->except(['nonce', 'action']); wp_send_json([ 'error' => true, 'msg' => ($message) ? $message : $default, 'data' => $data ]); } }
[ "public", "function", "validate", "(", "$", "nonce", "=", "null", ",", "$", "value", "=", "null", ",", "$", "message", "=", "null", ",", "$", "data", "=", "null", ")", "{", "$", "nonce", "=", "(", "$", "nonce", ")", "?", "$", "nonce", ":", "$", "this", "->", "app", "[", "'request'", "]", "->", "get", "(", "'nonce'", ")", ";", "$", "value", "=", "(", "$", "value", ")", "?", "$", "value", ":", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'app.key'", ")", ";", "if", "(", "!", "wp_verify_nonce", "(", "$", "nonce", ",", "$", "value", ")", ")", "{", "$", "default", "=", "(", "$", "msg", "=", "trans", "(", "'ajax.invalid'", ")", ")", "?", "$", "msg", ":", "'AJAX is invalid.'", ";", "$", "data", "=", "(", "$", "data", ")", "?", "$", "data", ":", "$", "this", "->", "app", "[", "'request'", "]", "->", "except", "(", "[", "'nonce'", ",", "'action'", "]", ")", ";", "wp_send_json", "(", "[", "'error'", "=>", "true", ",", "'msg'", "=>", "(", "$", "message", ")", "?", "$", "message", ":", "$", "default", ",", "'data'", "=>", "$", "data", "]", ")", ";", "}", "}" ]
Check nonce against app.key @param null|string $nonce By default will use 'nonce' index @param null|string $value By default will get app.key @param null|string $message By default try to get translation on ajax.invalid @param null|mixed $data
[ "Check", "nonce", "against", "app", ".", "key" ]
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Core/Http/Ajax.php#L93-L111
train
kmfk/slowdb
src/File.php
File.insert
public function insert($key, $value) { $this->file->flock(LOCK_SH); $this->file->fseek(0, SEEK_END); $position = $this->file->ftell(); if (is_array($value) || is_object($value)) { $value = json_encode($value); } $this->file->flock(LOCK_EX); $this->file->fwrite( pack('N*', strlen($key)) . pack('N*', strlen($value)) . $key . $value ); $this->file->flock(LOCK_UN); return $position; }
php
public function insert($key, $value) { $this->file->flock(LOCK_SH); $this->file->fseek(0, SEEK_END); $position = $this->file->ftell(); if (is_array($value) || is_object($value)) { $value = json_encode($value); } $this->file->flock(LOCK_EX); $this->file->fwrite( pack('N*', strlen($key)) . pack('N*', strlen($value)) . $key . $value ); $this->file->flock(LOCK_UN); return $position; }
[ "public", "function", "insert", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "file", "->", "flock", "(", "LOCK_SH", ")", ";", "$", "this", "->", "file", "->", "fseek", "(", "0", ",", "SEEK_END", ")", ";", "$", "position", "=", "$", "this", "->", "file", "->", "ftell", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", "||", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "json_encode", "(", "$", "value", ")", ";", "}", "$", "this", "->", "file", "->", "flock", "(", "LOCK_EX", ")", ";", "$", "this", "->", "file", "->", "fwrite", "(", "pack", "(", "'N*'", ",", "strlen", "(", "$", "key", ")", ")", ".", "pack", "(", "'N*'", ",", "strlen", "(", "$", "value", ")", ")", ".", "$", "key", ".", "$", "value", ")", ";", "$", "this", "->", "file", "->", "flock", "(", "LOCK_UN", ")", ";", "return", "$", "position", ";", "}" ]
Write the new record to the database file We store metadata (lengths) in the first 8 bytes of each row allowing us to use binary searches and indexing key/value positions @param string $key The Key to be stored @param mixed $value The Value to be stored @return integer Returns the position of the data
[ "Write", "the", "new", "record", "to", "the", "database", "file" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/File.php#L75-L96
train
kmfk/slowdb
src/File.php
File.read
public function read($position) { $this->file->flock(LOCK_SH); $metadata = $this->getMetadata($position); $this->file->fseek($metadata->klen, SEEK_CUR); $value = $this->file->fread($metadata->vlen); $this->file->flock(LOCK_UN); $mixed = json_decode($value, true); if (json_last_error() !== JSON_ERROR_NONE) { return $value; } return $mixed; }
php
public function read($position) { $this->file->flock(LOCK_SH); $metadata = $this->getMetadata($position); $this->file->fseek($metadata->klen, SEEK_CUR); $value = $this->file->fread($metadata->vlen); $this->file->flock(LOCK_UN); $mixed = json_decode($value, true); if (json_last_error() !== JSON_ERROR_NONE) { return $value; } return $mixed; }
[ "public", "function", "read", "(", "$", "position", ")", "{", "$", "this", "->", "file", "->", "flock", "(", "LOCK_SH", ")", ";", "$", "metadata", "=", "$", "this", "->", "getMetadata", "(", "$", "position", ")", ";", "$", "this", "->", "file", "->", "fseek", "(", "$", "metadata", "->", "klen", ",", "SEEK_CUR", ")", ";", "$", "value", "=", "$", "this", "->", "file", "->", "fread", "(", "$", "metadata", "->", "vlen", ")", ";", "$", "this", "->", "file", "->", "flock", "(", "LOCK_UN", ")", ";", "$", "mixed", "=", "json_decode", "(", "$", "value", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "return", "$", "value", ";", "}", "return", "$", "mixed", ";", "}" ]
Retrieves the data from the database for a Key based on position @param integer $position The offset in the file where the data is stored @return array
[ "Retrieves", "the", "data", "from", "the", "database", "for", "a", "Key", "based", "on", "position" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/File.php#L105-L120
train
kmfk/slowdb
src/File.php
File.update
public function update($position, $key, $value) { $this->remove($position); return $this->insert($key, $value); }
php
public function update($position, $key, $value) { $this->remove($position); return $this->insert($key, $value); }
[ "public", "function", "update", "(", "$", "position", ",", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "remove", "(", "$", "position", ")", ";", "return", "$", "this", "->", "insert", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Updates an existing key by removing it from the existing file and appending the new value to the end of the file. @param string $key The Key to be stored @param mixed $value The Value to be stored @return integer
[ "Updates", "an", "existing", "key", "by", "removing", "it", "from", "the", "existing", "file", "and", "appending", "the", "new", "value", "to", "the", "end", "of", "the", "file", "." ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/File.php#L131-L136
train
kmfk/slowdb
src/File.php
File.truncate
public function truncate() { $this->file->flock(LOCK_EX); $result = $this->file->ftruncate(0); $this->file->flock(LOCK_UN); return $result; }
php
public function truncate() { $this->file->flock(LOCK_EX); $result = $this->file->ftruncate(0); $this->file->flock(LOCK_UN); return $result; }
[ "public", "function", "truncate", "(", ")", "{", "$", "this", "->", "file", "->", "flock", "(", "LOCK_EX", ")", ";", "$", "result", "=", "$", "this", "->", "file", "->", "ftruncate", "(", "0", ")", ";", "$", "this", "->", "file", "->", "flock", "(", "LOCK_UN", ")", ";", "return", "$", "result", ";", "}" ]
Truncates the collection, removing all the data from the file @return bool
[ "Truncates", "the", "collection", "removing", "all", "the", "data", "from", "the", "file" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/File.php#L174-L181
train
alphacomm/alpharpc
src/AlphaRPC/Common/Socket/Socket.php
Socket.create
public static function create($context, $type, LoggerInterface $logger = null, $persistentId = null, $onNewSocket = null) { if (!is_callable($onNewSocket)) { $onNewSocket = null; } $newSocket = false; $callback = function() use ($onNewSocket, &$newSocket) { $newSocket = true; if ($onNewSocket !== null) { $onNewSocket(); } }; $instance = new self($context, $type, $persistentId, $callback); $instance->setId(self::$nextId); $instance->setNewSocket($newSocket); $instance->setSockOpt(ZMQ::SOCKOPT_LINGER, 0); self::$nextId++; if (null !== $logger) { $instance->setLogger($logger); } return $instance; }
php
public static function create($context, $type, LoggerInterface $logger = null, $persistentId = null, $onNewSocket = null) { if (!is_callable($onNewSocket)) { $onNewSocket = null; } $newSocket = false; $callback = function() use ($onNewSocket, &$newSocket) { $newSocket = true; if ($onNewSocket !== null) { $onNewSocket(); } }; $instance = new self($context, $type, $persistentId, $callback); $instance->setId(self::$nextId); $instance->setNewSocket($newSocket); $instance->setSockOpt(ZMQ::SOCKOPT_LINGER, 0); self::$nextId++; if (null !== $logger) { $instance->setLogger($logger); } return $instance; }
[ "public", "static", "function", "create", "(", "$", "context", ",", "$", "type", ",", "LoggerInterface", "$", "logger", "=", "null", ",", "$", "persistentId", "=", "null", ",", "$", "onNewSocket", "=", "null", ")", "{", "if", "(", "!", "is_callable", "(", "$", "onNewSocket", ")", ")", "{", "$", "onNewSocket", "=", "null", ";", "}", "$", "newSocket", "=", "false", ";", "$", "callback", "=", "function", "(", ")", "use", "(", "$", "onNewSocket", ",", "&", "$", "newSocket", ")", "{", "$", "newSocket", "=", "true", ";", "if", "(", "$", "onNewSocket", "!==", "null", ")", "{", "$", "onNewSocket", "(", ")", ";", "}", "}", ";", "$", "instance", "=", "new", "self", "(", "$", "context", ",", "$", "type", ",", "$", "persistentId", ",", "$", "callback", ")", ";", "$", "instance", "->", "setId", "(", "self", "::", "$", "nextId", ")", ";", "$", "instance", "->", "setNewSocket", "(", "$", "newSocket", ")", ";", "$", "instance", "->", "setSockOpt", "(", "ZMQ", "::", "SOCKOPT_LINGER", ",", "0", ")", ";", "self", "::", "$", "nextId", "++", ";", "if", "(", "null", "!==", "$", "logger", ")", "{", "$", "instance", "->", "setLogger", "(", "$", "logger", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Create a new Socket. @param \ZMQContext $context The Context to create this Socket with @param integer $type One of the ZMQ::SOCKET_{PUB,SUB,PUSH,PULL,REQ,REP,ROUTER,DEALER} contants. @param LoggerInterface $logger A Logger @param string $persistentId When using a persistent socket: the persistence ID @param callable|null $onNewSocket Callback to use when a new socket is created @return \AlphaRPC\Common\Socket\Socket
[ "Create", "a", "new", "Socket", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Common/Socket/Socket.php#L54-L79
train
alphacomm/alpharpc
src/AlphaRPC/Common/Socket/Socket.php
Socket.hasEvents
public function hasEvents($timeout = 0) { $poll = new ZMQPoll(); $poll->add($this, ZMQ::POLL_IN); $read = $write = array(); $events = $poll->poll($read, $write, $timeout); if ($events > 0) { return true; } return false; }
php
public function hasEvents($timeout = 0) { $poll = new ZMQPoll(); $poll->add($this, ZMQ::POLL_IN); $read = $write = array(); $events = $poll->poll($read, $write, $timeout); if ($events > 0) { return true; } return false; }
[ "public", "function", "hasEvents", "(", "$", "timeout", "=", "0", ")", "{", "$", "poll", "=", "new", "ZMQPoll", "(", ")", ";", "$", "poll", "->", "add", "(", "$", "this", ",", "ZMQ", "::", "POLL_IN", ")", ";", "$", "read", "=", "$", "write", "=", "array", "(", ")", ";", "$", "events", "=", "$", "poll", "->", "poll", "(", "$", "read", ",", "$", "write", ",", "$", "timeout", ")", ";", "if", "(", "$", "events", ">", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Poll for new Events on this Socket. @param integer $timeout Timeout in milliseconds. Defaults to 0 (return immediately). @return boolean
[ "Poll", "for", "new", "Events", "on", "this", "Socket", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Common/Socket/Socket.php#L88-L99
train
alphacomm/alpharpc
src/AlphaRPC/Common/Socket/Socket.php
Socket.mrecv
public function mrecv($mode = 0) { if ($this->verbose) { $this->getLogger()->debug('PRE RECV: '.$this->id); } $data = array(); while (true) { $data[] = $this->recv($mode); if (!$this->getSockOpt(ZMQ::SOCKOPT_RCVMORE)) { break; } } $message = new Message($data); if ($this->verbose) { $this->getLogger()->debug('RECV: '.$this->id); $this->getLogger()->debug($message); } if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) { $message->stripRoutingInformation(); } return $message; }
php
public function mrecv($mode = 0) { if ($this->verbose) { $this->getLogger()->debug('PRE RECV: '.$this->id); } $data = array(); while (true) { $data[] = $this->recv($mode); if (!$this->getSockOpt(ZMQ::SOCKOPT_RCVMORE)) { break; } } $message = new Message($data); if ($this->verbose) { $this->getLogger()->debug('RECV: '.$this->id); $this->getLogger()->debug($message); } if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) { $message->stripRoutingInformation(); } return $message; }
[ "public", "function", "mrecv", "(", "$", "mode", "=", "0", ")", "{", "if", "(", "$", "this", "->", "verbose", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'PRE RECV: '", ".", "$", "this", "->", "id", ")", ";", "}", "$", "data", "=", "array", "(", ")", ";", "while", "(", "true", ")", "{", "$", "data", "[", "]", "=", "$", "this", "->", "recv", "(", "$", "mode", ")", ";", "if", "(", "!", "$", "this", "->", "getSockOpt", "(", "ZMQ", "::", "SOCKOPT_RCVMORE", ")", ")", "{", "break", ";", "}", "}", "$", "message", "=", "new", "Message", "(", "$", "data", ")", ";", "if", "(", "$", "this", "->", "verbose", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'RECV: '", ".", "$", "this", "->", "id", ")", ";", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "$", "message", ")", ";", "}", "if", "(", "ZMQ", "::", "SOCKET_ROUTER", "===", "$", "this", "->", "getSocketType", "(", ")", ")", "{", "$", "message", "->", "stripRoutingInformation", "(", ")", ";", "}", "return", "$", "message", ";", "}" ]
Receive a Message. Use this instead of {@see ::recv}. @param int $mode @return \AlphaRPC\Common\Socket\Message
[ "Receive", "a", "Message", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Common/Socket/Socket.php#L166-L190
train
alphacomm/alpharpc
src/AlphaRPC/Common/Socket/Socket.php
Socket.msend
public function msend(Message $msg) { if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) { $msg->prepend($msg->getRoutingInformation()); } if ($this->verbose) { $this->getLogger()->debug('SEND: '.$this->id); $this->getLogger()->debug($msg); } $parts = $msg->toArray(); $iMax = count($parts)-1; if ($iMax < 0) { throw new RuntimeException('No parts to send.'); } for ($i = 0; $i < $iMax; $i++) { $this->send($parts[$i], ZMQ::MODE_SNDMORE); } $this->send($parts[$iMax]); if ($this->verbose) { $this->getLogger()->debug('Message sent.'); } return $this; }
php
public function msend(Message $msg) { if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) { $msg->prepend($msg->getRoutingInformation()); } if ($this->verbose) { $this->getLogger()->debug('SEND: '.$this->id); $this->getLogger()->debug($msg); } $parts = $msg->toArray(); $iMax = count($parts)-1; if ($iMax < 0) { throw new RuntimeException('No parts to send.'); } for ($i = 0; $i < $iMax; $i++) { $this->send($parts[$i], ZMQ::MODE_SNDMORE); } $this->send($parts[$iMax]); if ($this->verbose) { $this->getLogger()->debug('Message sent.'); } return $this; }
[ "public", "function", "msend", "(", "Message", "$", "msg", ")", "{", "if", "(", "ZMQ", "::", "SOCKET_ROUTER", "===", "$", "this", "->", "getSocketType", "(", ")", ")", "{", "$", "msg", "->", "prepend", "(", "$", "msg", "->", "getRoutingInformation", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "verbose", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'SEND: '", ".", "$", "this", "->", "id", ")", ";", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "$", "msg", ")", ";", "}", "$", "parts", "=", "$", "msg", "->", "toArray", "(", ")", ";", "$", "iMax", "=", "count", "(", "$", "parts", ")", "-", "1", ";", "if", "(", "$", "iMax", "<", "0", ")", "{", "throw", "new", "RuntimeException", "(", "'No parts to send.'", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "iMax", ";", "$", "i", "++", ")", "{", "$", "this", "->", "send", "(", "$", "parts", "[", "$", "i", "]", ",", "ZMQ", "::", "MODE_SNDMORE", ")", ";", "}", "$", "this", "->", "send", "(", "$", "parts", "[", "$", "iMax", "]", ")", ";", "if", "(", "$", "this", "->", "verbose", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Message sent.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Send a Messsage. @param Message $msg @return Socket
[ "Send", "a", "Messsage", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Common/Socket/Socket.php#L199-L223
train
K-Phoen/gaufrette-extras-bundle
DependencyInjection/KPhoenGaufretteExtrasExtension.php
KPhoenGaufretteExtrasExtension.createResolverFactories
private function createResolverFactories($config, ContainerBuilder $container) { if (null !== $this->factories) { return $this->factories; } // load bundled adapter factories $tempContainer = new ContainerBuilder(); $parameterBag = $container->getParameterBag(); $loader = new XmlFileLoader($tempContainer, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('resolver_factories.xml'); // load user-created adapter factories foreach ($config['factories'] as $factory) { $loader->load($parameterBag->resolveValue($factory)); } $services = $tempContainer->findTaggedServiceIds('gaufrette.resolver.factory'); $factories = array(); foreach (array_keys($services) as $id) { $factory = $tempContainer->get($id); $factories[str_replace('-', '_', $factory->getKey())] = $factory; } return $this->factories = $factories; }
php
private function createResolverFactories($config, ContainerBuilder $container) { if (null !== $this->factories) { return $this->factories; } // load bundled adapter factories $tempContainer = new ContainerBuilder(); $parameterBag = $container->getParameterBag(); $loader = new XmlFileLoader($tempContainer, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('resolver_factories.xml'); // load user-created adapter factories foreach ($config['factories'] as $factory) { $loader->load($parameterBag->resolveValue($factory)); } $services = $tempContainer->findTaggedServiceIds('gaufrette.resolver.factory'); $factories = array(); foreach (array_keys($services) as $id) { $factory = $tempContainer->get($id); $factories[str_replace('-', '_', $factory->getKey())] = $factory; } return $this->factories = $factories; }
[ "private", "function", "createResolverFactories", "(", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "factories", ")", "{", "return", "$", "this", "->", "factories", ";", "}", "// load bundled adapter factories", "$", "tempContainer", "=", "new", "ContainerBuilder", "(", ")", ";", "$", "parameterBag", "=", "$", "container", "->", "getParameterBag", "(", ")", ";", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "tempContainer", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'resolver_factories.xml'", ")", ";", "// load user-created adapter factories", "foreach", "(", "$", "config", "[", "'factories'", "]", "as", "$", "factory", ")", "{", "$", "loader", "->", "load", "(", "$", "parameterBag", "->", "resolveValue", "(", "$", "factory", ")", ")", ";", "}", "$", "services", "=", "$", "tempContainer", "->", "findTaggedServiceIds", "(", "'gaufrette.resolver.factory'", ")", ";", "$", "factories", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "services", ")", "as", "$", "id", ")", "{", "$", "factory", "=", "$", "tempContainer", "->", "get", "(", "$", "id", ")", ";", "$", "factories", "[", "str_replace", "(", "'-'", ",", "'_'", ",", "$", "factory", "->", "getKey", "(", ")", ")", "]", "=", "$", "factory", ";", "}", "return", "$", "this", "->", "factories", "=", "$", "factories", ";", "}" ]
Creates the resolver factories @param array $config @param ContainerBuilder $container
[ "Creates", "the", "resolver", "factories" ]
3f05779179117d5649184164544e1f22de28d706
https://github.com/K-Phoen/gaufrette-extras-bundle/blob/3f05779179117d5649184164544e1f22de28d706/DependencyInjection/KPhoenGaufretteExtrasExtension.php#L66-L92
train
hal-platform/hal-core
src/Repository/AuditEventRepository.php
AuditEventRepository.getPagedResults
public function getPagedResults($limit = 50, $page = 0) { $dql = sprintf(self::DQL_GET_PAGED, AuditEvent::class); return $this->getPaginator($dql, $limit, $page); }
php
public function getPagedResults($limit = 50, $page = 0) { $dql = sprintf(self::DQL_GET_PAGED, AuditEvent::class); return $this->getPaginator($dql, $limit, $page); }
[ "public", "function", "getPagedResults", "(", "$", "limit", "=", "50", ",", "$", "page", "=", "0", ")", "{", "$", "dql", "=", "sprintf", "(", "self", "::", "DQL_GET_PAGED", ",", "AuditEvent", "::", "class", ")", ";", "return", "$", "this", "->", "getPaginator", "(", "$", "dql", ",", "$", "limit", ",", "$", "page", ")", ";", "}" ]
Get all audit events, paged. @param int $limit @param int $page @return Paginator
[ "Get", "all", "audit", "events", "paged", "." ]
30d456f8392fc873301ad4217d2ae90436c67090
https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Repository/AuditEventRepository.php#L33-L37
train
zikula/FileSystem
Ftp.php
Ftp.connect
public function connect() { $this->errorHandler->start(); //create the connection if ($this->configuration->getSSL()) { $this->resource = $this->driver->sslConnect($this->configuration->getHost(), $this->configuration->getPort(), $this->configuration->getTimeout()); } else { $this->resource = $this->driver->connect($this->configuration->getHost(), $this->configuration->getPort(), $this->configuration->getTimeout()); } if ($this->resource !== false) { //log in if ($this->driver->login($this->resource, $this->configuration->getUser(), $this->configuration->getPass())) { //change directory if ($this->driver->pasv($this->resource, $this->configuration->getPasv())) { if ($this->driver->chdir($this->resource, $this->configuration->getDir())) { $this->dir = ftp_pwd($this->resource); $this->errorHandler->stop(); return true; } } } } $this->errorHandler->stop(); return false; }
php
public function connect() { $this->errorHandler->start(); //create the connection if ($this->configuration->getSSL()) { $this->resource = $this->driver->sslConnect($this->configuration->getHost(), $this->configuration->getPort(), $this->configuration->getTimeout()); } else { $this->resource = $this->driver->connect($this->configuration->getHost(), $this->configuration->getPort(), $this->configuration->getTimeout()); } if ($this->resource !== false) { //log in if ($this->driver->login($this->resource, $this->configuration->getUser(), $this->configuration->getPass())) { //change directory if ($this->driver->pasv($this->resource, $this->configuration->getPasv())) { if ($this->driver->chdir($this->resource, $this->configuration->getDir())) { $this->dir = ftp_pwd($this->resource); $this->errorHandler->stop(); return true; } } } } $this->errorHandler->stop(); return false; }
[ "public", "function", "connect", "(", ")", "{", "$", "this", "->", "errorHandler", "->", "start", "(", ")", ";", "//create the connection", "if", "(", "$", "this", "->", "configuration", "->", "getSSL", "(", ")", ")", "{", "$", "this", "->", "resource", "=", "$", "this", "->", "driver", "->", "sslConnect", "(", "$", "this", "->", "configuration", "->", "getHost", "(", ")", ",", "$", "this", "->", "configuration", "->", "getPort", "(", ")", ",", "$", "this", "->", "configuration", "->", "getTimeout", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "resource", "=", "$", "this", "->", "driver", "->", "connect", "(", "$", "this", "->", "configuration", "->", "getHost", "(", ")", ",", "$", "this", "->", "configuration", "->", "getPort", "(", ")", ",", "$", "this", "->", "configuration", "->", "getTimeout", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "resource", "!==", "false", ")", "{", "//log in", "if", "(", "$", "this", "->", "driver", "->", "login", "(", "$", "this", "->", "resource", ",", "$", "this", "->", "configuration", "->", "getUser", "(", ")", ",", "$", "this", "->", "configuration", "->", "getPass", "(", ")", ")", ")", "{", "//change directory", "if", "(", "$", "this", "->", "driver", "->", "pasv", "(", "$", "this", "->", "resource", ",", "$", "this", "->", "configuration", "->", "getPasv", "(", ")", ")", ")", "{", "if", "(", "$", "this", "->", "driver", "->", "chdir", "(", "$", "this", "->", "resource", ",", "$", "this", "->", "configuration", "->", "getDir", "(", ")", ")", ")", "{", "$", "this", "->", "dir", "=", "ftp_pwd", "(", "$", "this", "->", "resource", ")", ";", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "true", ";", "}", "}", "}", "}", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "false", ";", "}" ]
Standard function for creating a FTP connection and logging in. This must be called before any of the other functions in the Interface. However the construct itself calles this function upon completion, which alleviates the need to ever call this function manualy. @return boolean
[ "Standard", "function", "for", "creating", "a", "FTP", "connection", "and", "logging", "in", "." ]
8e12d6839aa50a7590f5ad22cc2d33c8f88ff726
https://github.com/zikula/FileSystem/blob/8e12d6839aa50a7590f5ad22cc2d33c8f88ff726/Ftp.php#L47-L75
train
zikula/FileSystem
Ftp.php
Ftp.fput
public function fput($stream, $remote) { $this->isAlive(true); $this->errorHandler->start(); if ($this->driver->fput($this->resource, $remote, $stream, FTP_BINARY)) { $this->errorHandler->stop(); return true; } $this->errorHandler->stop(); return false; }
php
public function fput($stream, $remote) { $this->isAlive(true); $this->errorHandler->start(); if ($this->driver->fput($this->resource, $remote, $stream, FTP_BINARY)) { $this->errorHandler->stop(); return true; } $this->errorHandler->stop(); return false; }
[ "public", "function", "fput", "(", "$", "stream", ",", "$", "remote", ")", "{", "$", "this", "->", "isAlive", "(", "true", ")", ";", "$", "this", "->", "errorHandler", "->", "start", "(", ")", ";", "if", "(", "$", "this", "->", "driver", "->", "fput", "(", "$", "this", "->", "resource", ",", "$", "remote", ",", "$", "stream", ",", "FTP_BINARY", ")", ")", "{", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "true", ";", "}", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "false", ";", "}" ]
Similar to put but does not get the file localy. This should be used instead of put in most cases. @param stream|resource $stream The resource to put remotely, probably the resource returned from a fget. @param string $remote The pathname to the desired remote pathname. @return integer|boolean number of bytes written on success, false on failure.
[ "Similar", "to", "put", "but", "does", "not", "get", "the", "file", "localy", "." ]
8e12d6839aa50a7590f5ad22cc2d33c8f88ff726
https://github.com/zikula/FileSystem/blob/8e12d6839aa50a7590f5ad22cc2d33c8f88ff726/Ftp.php#L113-L125
train
zikula/FileSystem
Ftp.php
Ftp.putContents
public function putContents($contents, $remote) { $stream = fopen('data://text/plain,' . $contents, 'r'); return $this->fput($stream, $remote); }
php
public function putContents($contents, $remote) { $stream = fopen('data://text/plain,' . $contents, 'r'); return $this->fput($stream, $remote); }
[ "public", "function", "putContents", "(", "$", "contents", ",", "$", "remote", ")", "{", "$", "stream", "=", "fopen", "(", "'data://text/plain,'", ".", "$", "contents", ",", "'r'", ")", ";", "return", "$", "this", "->", "fput", "(", "$", "stream", ",", "$", "remote", ")", ";", "}" ]
Write the contents of a string to the remote. @param string $contents The contents to put remotely. @param string $remote The pathname to the desired remote pathname. @return boolean|integer Number of bytes written on success, false on failure.
[ "Write", "the", "contents", "of", "a", "string", "to", "the", "remote", "." ]
8e12d6839aa50a7590f5ad22cc2d33c8f88ff726
https://github.com/zikula/FileSystem/blob/8e12d6839aa50a7590f5ad22cc2d33c8f88ff726/Ftp.php#L135-L140
train
zikula/FileSystem
Ftp.php
Ftp.fget
public function fget($remote) { $this->isAlive(true); $this->errorHandler->start(); $handle = fopen('php://temp', 'r+'); if ($this->driver->fget($this->resource, $handle, $remote, FTP_BINARY)) { rewind($handle); $this->errorHandler->stop(); return $handle; } $this->errorHandler->stop(); return false; }
php
public function fget($remote) { $this->isAlive(true); $this->errorHandler->start(); $handle = fopen('php://temp', 'r+'); if ($this->driver->fget($this->resource, $handle, $remote, FTP_BINARY)) { rewind($handle); $this->errorHandler->stop(); return $handle; } $this->errorHandler->stop(); return false; }
[ "public", "function", "fget", "(", "$", "remote", ")", "{", "$", "this", "->", "isAlive", "(", "true", ")", ";", "$", "this", "->", "errorHandler", "->", "start", "(", ")", ";", "$", "handle", "=", "fopen", "(", "'php://temp'", ",", "'r+'", ")", ";", "if", "(", "$", "this", "->", "driver", "->", "fget", "(", "$", "this", "->", "resource", ",", "$", "handle", ",", "$", "remote", ",", "FTP_BINARY", ")", ")", "{", "rewind", "(", "$", "handle", ")", ";", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "$", "handle", ";", "}", "$", "this", "->", "errorHandler", "->", "stop", "(", ")", ";", "return", "false", ";", "}" ]
Similar to get but does not save file localy. This should usually be used instead of get in most cases. @param string $remote The path to the remote file. @return resource|boolean The resource on success false on fail.
[ "Similar", "to", "get", "but", "does", "not", "save", "file", "localy", "." ]
8e12d6839aa50a7590f5ad22cc2d33c8f88ff726
https://github.com/zikula/FileSystem/blob/8e12d6839aa50a7590f5ad22cc2d33c8f88ff726/Ftp.php#L189-L203
train
villermen/runescape-lookup-commons
src/Activity.php
Activity.getActivity
public static function getActivity(int $id): Activity { self::initializeActivities(); if (!isset(self::$activities[$id])) { throw new RuneScapeException(sprintf("Activity with id %d does not exist.", $id)); } return self::$activities[$id]; }
php
public static function getActivity(int $id): Activity { self::initializeActivities(); if (!isset(self::$activities[$id])) { throw new RuneScapeException(sprintf("Activity with id %d does not exist.", $id)); } return self::$activities[$id]; }
[ "public", "static", "function", "getActivity", "(", "int", "$", "id", ")", ":", "Activity", "{", "self", "::", "initializeActivities", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "activities", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "RuneScapeException", "(", "sprintf", "(", "\"Activity with id %d does not exist.\"", ",", "$", "id", ")", ")", ";", "}", "return", "self", "::", "$", "activities", "[", "$", "id", "]", ";", "}" ]
Retrieve an activity by ID. You can use the ACTIVITY_ constants in this class for IDs. @param int $id @return Activity @throws RuneScapeException When the requested activity does not exist.
[ "Retrieve", "an", "activity", "by", "ID", ".", "You", "can", "use", "the", "ACTIVITY_", "constants", "in", "this", "class", "for", "IDs", "." ]
3e24dadbdc5e20b755280e5110f4ca0a1758b04c
https://github.com/villermen/runescape-lookup-commons/blob/3e24dadbdc5e20b755280e5110f4ca0a1758b04c/src/Activity.php#L112-L121
train
chilimatic/chilimatic-framework
lib/database/sql/mysql/Command.php
Command.kill_process
public function kill_process($pid) { if (!is_numeric($pid)) return false; $pid = (int)$pid; $sql = "KILL $pid"; return $this->db->query($sql); }
php
public function kill_process($pid) { if (!is_numeric($pid)) return false; $pid = (int)$pid; $sql = "KILL $pid"; return $this->db->query($sql); }
[ "public", "function", "kill_process", "(", "$", "pid", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "pid", ")", ")", "return", "false", ";", "$", "pid", "=", "(", "int", ")", "$", "pid", ";", "$", "sql", "=", "\"KILL $pid\"", ";", "return", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ")", ";", "}" ]
kill a specific process @param int $pid @return boolean
[ "kill", "a", "specific", "process" ]
8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Command.php#L44-L52
train
timostamm/url-builder
src/UrlQuery.php
UrlQuery.setArray
public function setArray($key, array $values) { $this->validateKey($key); if (empty($values)) { throw new \InvalidArgumentException("Missing value."); } foreach ($values as $v) { $this->validateValue($v); } $this->params[$key] = []; foreach ($values as $v) { $this->params[$key][] = $v; } return $this; }
php
public function setArray($key, array $values) { $this->validateKey($key); if (empty($values)) { throw new \InvalidArgumentException("Missing value."); } foreach ($values as $v) { $this->validateValue($v); } $this->params[$key] = []; foreach ($values as $v) { $this->params[$key][] = $v; } return $this; }
[ "public", "function", "setArray", "(", "$", "key", ",", "array", "$", "values", ")", "{", "$", "this", "->", "validateKey", "(", "$", "key", ")", ";", "if", "(", "empty", "(", "$", "values", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Missing value.\"", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "v", ")", "{", "$", "this", "->", "validateValue", "(", "$", "v", ")", ";", "}", "$", "this", "->", "params", "[", "$", "key", "]", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "v", ")", "{", "$", "this", "->", "params", "[", "$", "key", "]", "[", "]", "=", "$", "v", ";", "}", "return", "$", "this", ";", "}" ]
Sets several values for the given parameter key. @param string $key @param array $values @throws \InvalidArgumentException If the key is empty, the key is not a string, no values are given or a value is not a string. @return self
[ "Sets", "several", "values", "for", "the", "given", "parameter", "key", "." ]
9dec80635017415d83b7e6ef155e9324f4b27a00
https://github.com/timostamm/url-builder/blob/9dec80635017415d83b7e6ef155e9324f4b27a00/src/UrlQuery.php#L59-L73
train