id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
25,800
LpFactory/NestedSetRoutingBundle
Configuration/AbstractPageRouteConfiguration.php
AbstractPageRouteConfiguration.extractId
public function extractId($routeName) { if (!$this->supports($routeName)) { return null; } return (int) str_replace($this->getPrefix(), '', $routeName); }
php
public function extractId($routeName) { if (!$this->supports($routeName)) { return null; } return (int) str_replace($this->getPrefix(), '', $routeName); }
[ "public", "function", "extractId", "(", "$", "routeName", ")", "{", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "routeName", ")", ")", "{", "return", "null", ";", "}", "return", "(", "int", ")", "str_replace", "(", "$", "this", "->", "getPrefix", "(", ")", ",", "''", ",", "$", "routeName", ")", ";", "}" ]
Extract a page id from the route name @param string $routeName @return int|null
[ "Extract", "a", "page", "id", "from", "the", "route", "name" ]
dc07227a6764e657b7b321827a18127ec18ba214
https://github.com/LpFactory/NestedSetRoutingBundle/blob/dc07227a6764e657b7b321827a18127ec18ba214/Configuration/AbstractPageRouteConfiguration.php#L85-L92
25,801
LpFactory/NestedSetRoutingBundle
Configuration/AbstractPageRouteConfiguration.php
AbstractPageRouteConfiguration.buildPath
public function buildPath($pathInfo) { if (null === $this->getPath()) { return $pathInfo; } return sprintf($this->getPath(), rtrim($pathInfo, '/')); }
php
public function buildPath($pathInfo) { if (null === $this->getPath()) { return $pathInfo; } return sprintf($this->getPath(), rtrim($pathInfo, '/')); }
[ "public", "function", "buildPath", "(", "$", "pathInfo", ")", "{", "if", "(", "null", "===", "$", "this", "->", "getPath", "(", ")", ")", "{", "return", "$", "pathInfo", ";", "}", "return", "sprintf", "(", "$", "this", "->", "getPath", "(", ")", ",", "rtrim", "(", "$", "pathInfo", ",", "'/'", ")", ")", ";", "}" ]
Build a path @param string $pathInfo @return string
[ "Build", "a", "path" ]
dc07227a6764e657b7b321827a18127ec18ba214
https://github.com/LpFactory/NestedSetRoutingBundle/blob/dc07227a6764e657b7b321827a18127ec18ba214/Configuration/AbstractPageRouteConfiguration.php#L101-L108
25,802
openWorkers/RedObject
src/RedObject/HashSet.php
HashSet.toArray
public function toArray() { $keys = $this->redis->hKeys($this->key); $result = array(); foreach ($keys as $key) { $result[$key] = $this->offsetGet($key); } return $result; }
php
public function toArray() { $keys = $this->redis->hKeys($this->key); $result = array(); foreach ($keys as $key) { $result[$key] = $this->offsetGet($key); } return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "keys", "=", "$", "this", "->", "redis", "->", "hKeys", "(", "$", "this", "->", "key", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "offsetGet", "(", "$", "key", ")", ";", "}", "return", "$", "result", ";", "}" ]
Converts the hashset to an php-array @return array
[ "Converts", "the", "hashset", "to", "an", "php", "-", "array" ]
ce60d782352f97154294d7d200e7c87df80aa41a
https://github.com/openWorkers/RedObject/blob/ce60d782352f97154294d7d200e7c87df80aa41a/src/RedObject/HashSet.php#L114-L122
25,803
Vectrex/vxPHP
src/Http/Response.php
Response.getMaxAge
public function getMaxAge() { if ($this->headers->hasCacheControlDirective('s-maxage')) { return (int) $this->headers->getCacheControlDirective('s-maxage'); } if ($this->headers->hasCacheControlDirective('max-age')) { return (int) $this->headers->getCacheControlDirective('max-age'); } if (NULL !== $this->getExpires()) { return $this->getExpires()->format('U') - $this->getDate()->format('U'); } return NULL; }
php
public function getMaxAge() { if ($this->headers->hasCacheControlDirective('s-maxage')) { return (int) $this->headers->getCacheControlDirective('s-maxage'); } if ($this->headers->hasCacheControlDirective('max-age')) { return (int) $this->headers->getCacheControlDirective('max-age'); } if (NULL !== $this->getExpires()) { return $this->getExpires()->format('U') - $this->getDate()->format('U'); } return NULL; }
[ "public", "function", "getMaxAge", "(", ")", "{", "if", "(", "$", "this", "->", "headers", "->", "hasCacheControlDirective", "(", "'s-maxage'", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "headers", "->", "getCacheControlDirective", "(", "'s-maxage'", ")", ";", "}", "if", "(", "$", "this", "->", "headers", "->", "hasCacheControlDirective", "(", "'max-age'", ")", ")", "{", "return", "(", "int", ")", "$", "this", "->", "headers", "->", "getCacheControlDirective", "(", "'max-age'", ")", ";", "}", "if", "(", "NULL", "!==", "$", "this", "->", "getExpires", "(", ")", ")", "{", "return", "$", "this", "->", "getExpires", "(", ")", "->", "format", "(", "'U'", ")", "-", "$", "this", "->", "getDate", "(", ")", "->", "format", "(", "'U'", ")", ";", "}", "return", "NULL", ";", "}" ]
Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh. First, it checks for a s-maxage directive, then a max-age directive, and then it falls back on an expires header. It returns null when no maximum age can be established. @return integer|null Number of seconds
[ "Returns", "the", "number", "of", "seconds", "after", "the", "time", "specified", "in", "the", "response", "s", "Date", "header", "when", "the", "response", "should", "no", "longer", "be", "considered", "fresh", ".", "First", "it", "checks", "for", "a", "s", "-", "maxage", "directive", "then", "a", "max", "-", "age", "directive", "and", "then", "it", "falls", "back", "on", "an", "expires", "header", ".", "It", "returns", "null", "when", "no", "maximum", "age", "can", "be", "established", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/Response.php#L758-L774
25,804
Vectrex/vxPHP
src/Http/Response.php
Response.setNotModified
public function setNotModified() { $this->setStatusCode(self::HTTP_NOT_MODIFIED); $this->setContent(NULL); // remove headers that MUST NOT be included with 304 Not Modified responses foreach (['Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) { $this->headers->remove($header); } return $this; }
php
public function setNotModified() { $this->setStatusCode(self::HTTP_NOT_MODIFIED); $this->setContent(NULL); // remove headers that MUST NOT be included with 304 Not Modified responses foreach (['Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) { $this->headers->remove($header); } return $this; }
[ "public", "function", "setNotModified", "(", ")", "{", "$", "this", "->", "setStatusCode", "(", "self", "::", "HTTP_NOT_MODIFIED", ")", ";", "$", "this", "->", "setContent", "(", "NULL", ")", ";", "// remove headers that MUST NOT be included with 304 Not Modified responses", "foreach", "(", "[", "'Allow'", ",", "'Content-Encoding'", ",", "'Content-Language'", ",", "'Content-Length'", ",", "'Content-MD5'", ",", "'Content-Type'", ",", "'Last-Modified'", "]", "as", "$", "header", ")", "{", "$", "this", "->", "headers", "->", "remove", "(", "$", "header", ")", ";", "}", "return", "$", "this", ";", "}" ]
Modifies the response so that it conforms to the rules defined for a 304 status code. This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses. @return Response @see http://tools.ietf.org/html/rfc2616#section-10.3.5
[ "Modifies", "the", "response", "so", "that", "it", "conforms", "to", "the", "rules", "defined", "for", "a", "304", "status", "code", ".", "This", "sets", "the", "status", "removes", "the", "body", "and", "discards", "any", "headers", "that", "MUST", "NOT", "be", "included", "in", "304", "responses", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/Response.php#L977-L990
25,805
Vectrex/vxPHP
src/Http/Response.php
Response.ensureIEOverSSLCompatibility
protected function ensureIEOverSSLCompatibility(Request $request) { if ( FALSE !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && TRUE === $request->isSecure() ) { if (intval(preg_replace('/(MSIE )(.*?);/', '$2', $match[0])) < 9) { $this->headers->remove('Cache-Control'); } } }
php
protected function ensureIEOverSSLCompatibility(Request $request) { if ( FALSE !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && TRUE === $request->isSecure() ) { if (intval(preg_replace('/(MSIE )(.*?);/', '$2', $match[0])) < 9) { $this->headers->remove('Cache-Control'); } } }
[ "protected", "function", "ensureIEOverSSLCompatibility", "(", "Request", "$", "request", ")", "{", "if", "(", "FALSE", "!==", "stripos", "(", "$", "this", "->", "headers", "->", "get", "(", "'Content-Disposition'", ")", ",", "'attachment'", ")", "&&", "preg_match", "(", "'/MSIE (.*?);/i'", ",", "$", "request", "->", "server", "->", "get", "(", "'HTTP_USER_AGENT'", ")", ",", "$", "match", ")", "==", "1", "&&", "TRUE", "===", "$", "request", "->", "isSecure", "(", ")", ")", "{", "if", "(", "intval", "(", "preg_replace", "(", "'/(MSIE )(.*?);/'", ",", "'$2'", ",", "$", "match", "[", "0", "]", ")", ")", "<", "9", ")", "{", "$", "this", "->", "headers", "->", "remove", "(", "'Cache-Control'", ")", ";", "}", "}", "}" ]
Check if we need to remove Cache-Control for ssl encrypted downloads when using IE < 9 @link http://support.microsoft.com/kb/323308
[ "Check", "if", "we", "need", "to", "remove", "Cache", "-", "Control", "for", "ssl", "encrypted", "downloads", "when", "using", "IE", "<", "9" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/Response.php#L1235-L1247
25,806
netbull/CoreBundle
Utils/PDFLabelFormat.php
PDFLabelFormat.getValue
public function getValue( $field, $default = null ) { if ( array_key_exists($field, $this->defaults) ){ switch ($this->defaults[$field]['type']) { case self::TYPE_INT: return (int) $this->values[$field]; case self::TYPE_FLOAT: // Round float values to three decimal places and trim trailing zeros. // Add a leading zero to values less than 1. $f = sprintf('%05.3f', $this->values[$field]); $f = rtrim($f, '0'); $f = rtrim($f, '.'); return (float) (empty($f) ? '0' : $f); } return $this->values[$field]; } return $default; }
php
public function getValue( $field, $default = null ) { if ( array_key_exists($field, $this->defaults) ){ switch ($this->defaults[$field]['type']) { case self::TYPE_INT: return (int) $this->values[$field]; case self::TYPE_FLOAT: // Round float values to three decimal places and trim trailing zeros. // Add a leading zero to values less than 1. $f = sprintf('%05.3f', $this->values[$field]); $f = rtrim($f, '0'); $f = rtrim($f, '.'); return (float) (empty($f) ? '0' : $f); } return $this->values[$field]; } return $default; }
[ "public", "function", "getValue", "(", "$", "field", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "defaults", ")", ")", "{", "switch", "(", "$", "this", "->", "defaults", "[", "$", "field", "]", "[", "'type'", "]", ")", "{", "case", "self", "::", "TYPE_INT", ":", "return", "(", "int", ")", "$", "this", "->", "values", "[", "$", "field", "]", ";", "case", "self", "::", "TYPE_FLOAT", ":", "// Round float values to three decimal places and trim trailing zeros.", "// Add a leading zero to values less than 1.", "$", "f", "=", "sprintf", "(", "'%05.3f'", ",", "$", "this", "->", "values", "[", "$", "field", "]", ")", ";", "$", "f", "=", "rtrim", "(", "$", "f", ",", "'0'", ")", ";", "$", "f", "=", "rtrim", "(", "$", "f", ",", "'.'", ")", ";", "return", "(", "float", ")", "(", "empty", "(", "$", "f", ")", "?", "'0'", ":", "$", "f", ")", ";", "}", "return", "$", "this", "->", "values", "[", "$", "field", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get Label Format field from associative array. @param string $field Name of a label format field. @param null|string $default @return float|int|mixed|null
[ "Get", "Label", "Format", "field", "from", "associative", "array", "." ]
0bacc1d9e4733b6da613027400c48421e5a14645
https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Utils/PDFLabelFormat.php#L159-L176
25,807
netbull/CoreBundle
Utils/PDFLabelFormat.php
PDFLabelFormat.isMetric
public function isMetric( $field ) { if ( array_key_exists($field, $this->defaults) ){ return ( isset($this->defaults[$field]['metric']) ) ? $this->defaults[$field]['metric'] : false; } return false; }
php
public function isMetric( $field ) { if ( array_key_exists($field, $this->defaults) ){ return ( isset($this->defaults[$field]['metric']) ) ? $this->defaults[$field]['metric'] : false; } return false; }
[ "public", "function", "isMetric", "(", "$", "field", ")", "{", "if", "(", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "defaults", ")", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "defaults", "[", "$", "field", "]", "[", "'metric'", "]", ")", ")", "?", "$", "this", "->", "defaults", "[", "$", "field", "]", "[", "'metric'", "]", ":", "false", ";", "}", "return", "false", ";", "}" ]
Check if field is metric @param $field @return bool
[ "Check", "if", "field", "is", "metric" ]
0bacc1d9e4733b6da613027400c48421e5a14645
https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Utils/PDFLabelFormat.php#L183-L189
25,808
geega/php-simple-orm
src/Config.php
Config.init
public function init() { $host =getenv('PDO_HOST'); if($host) { $this->setHost(trim($host)); } $database = getenv('PDO_DATABASE'); if($database) { $this->setDatabase(trim($database)); } $user = getenv('PDO_USER'); if($user) { $this->setUser($user); } $password = getenv('PDO_PASSWORD'); if($password) { $this->setPassword($password); } }
php
public function init() { $host =getenv('PDO_HOST'); if($host) { $this->setHost(trim($host)); } $database = getenv('PDO_DATABASE'); if($database) { $this->setDatabase(trim($database)); } $user = getenv('PDO_USER'); if($user) { $this->setUser($user); } $password = getenv('PDO_PASSWORD'); if($password) { $this->setPassword($password); } }
[ "public", "function", "init", "(", ")", "{", "$", "host", "=", "getenv", "(", "'PDO_HOST'", ")", ";", "if", "(", "$", "host", ")", "{", "$", "this", "->", "setHost", "(", "trim", "(", "$", "host", ")", ")", ";", "}", "$", "database", "=", "getenv", "(", "'PDO_DATABASE'", ")", ";", "if", "(", "$", "database", ")", "{", "$", "this", "->", "setDatabase", "(", "trim", "(", "$", "database", ")", ")", ";", "}", "$", "user", "=", "getenv", "(", "'PDO_USER'", ")", ";", "if", "(", "$", "user", ")", "{", "$", "this", "->", "setUser", "(", "$", "user", ")", ";", "}", "$", "password", "=", "getenv", "(", "'PDO_PASSWORD'", ")", ";", "if", "(", "$", "password", ")", "{", "$", "this", "->", "setPassword", "(", "$", "password", ")", ";", "}", "}" ]
Main init method
[ "Main", "init", "method" ]
8ef636fd181c16ee3936d630d99e232c53883447
https://github.com/geega/php-simple-orm/blob/8ef636fd181c16ee3936d630d99e232c53883447/src/Config.php#L47-L67
25,809
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getInject
public static function getInject($type = null) { if ($type === null) return static::$inject; elseif (isset(static::$inject[$type])) return static::$inject[$type]; return array(); }
php
public static function getInject($type = null) { if ($type === null) return static::$inject; elseif (isset(static::$inject[$type])) return static::$inject[$type]; return array(); }
[ "public", "static", "function", "getInject", "(", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "===", "null", ")", "return", "static", "::", "$", "inject", ";", "elseif", "(", "isset", "(", "static", "::", "$", "inject", "[", "$", "type", "]", ")", ")", "return", "static", "::", "$", "inject", "[", "$", "type", "]", ";", "return", "array", "(", ")", ";", "}" ]
Fetches classes to inject from the config @param string $type all|controllers|services|views @return array
[ "Fetches", "classes", "to", "inject", "from", "the", "config" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L84-L91
25,810
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.initDB
protected static function initDB() { $dbConfig = static::getConfig('db', static::getServer()); static::$db = new Connection($dbConfig['dsn'], $dbConfig['user'], $dbConfig['password'], $dbConfig['options']); static::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!empty($dbConfig['tablePrefix'])) static::$db->setTablePrefix($dbConfig['tablePrefix']); }
php
protected static function initDB() { $dbConfig = static::getConfig('db', static::getServer()); static::$db = new Connection($dbConfig['dsn'], $dbConfig['user'], $dbConfig['password'], $dbConfig['options']); static::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!empty($dbConfig['tablePrefix'])) static::$db->setTablePrefix($dbConfig['tablePrefix']); }
[ "protected", "static", "function", "initDB", "(", ")", "{", "$", "dbConfig", "=", "static", "::", "getConfig", "(", "'db'", ",", "static", "::", "getServer", "(", ")", ")", ";", "static", "::", "$", "db", "=", "new", "Connection", "(", "$", "dbConfig", "[", "'dsn'", "]", ",", "$", "dbConfig", "[", "'user'", "]", ",", "$", "dbConfig", "[", "'password'", "]", ",", "$", "dbConfig", "[", "'options'", "]", ")", ";", "static", "::", "$", "db", "->", "setAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ",", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "if", "(", "!", "empty", "(", "$", "dbConfig", "[", "'tablePrefix'", "]", ")", ")", "static", "::", "$", "db", "->", "setTablePrefix", "(", "$", "dbConfig", "[", "'tablePrefix'", "]", ")", ";", "}" ]
Creates a database connection using \DBScribe\Connection
[ "Creates", "a", "database", "connection", "using", "\\", "DBScribe", "\\", "Connection" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L108-L115
25,811
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getUrls
public static function getUrls() { if (static::$urls !== null) return static::$urls; $uri = $_SERVER['REQUEST_URI']; static::$isVirtual = true; if (substr($uri, 0, strlen($_SERVER['SCRIPT_NAME'])) === $_SERVER['SCRIPT_NAME']) { $uri = str_replace('/index.php', '', $uri); } else if (stristr($_SERVER['SCRIPT_NAME'], '/index.php', true)) { static::$serverPath = stristr($_SERVER['SCRIPT_NAME'], '/index.php', true); $uri = str_replace(array(static::$serverPath, '/index.php'), '', $uri); static::$isVirtual = false; } parse_str($_SERVER['QUERY_STRING'], $_GET); static::$urls = static::updateArrayKeys(explode('/', str_replace('?' . $_SERVER['QUERY_STRING'], '', $uri)), true); return static::$urls; }
php
public static function getUrls() { if (static::$urls !== null) return static::$urls; $uri = $_SERVER['REQUEST_URI']; static::$isVirtual = true; if (substr($uri, 0, strlen($_SERVER['SCRIPT_NAME'])) === $_SERVER['SCRIPT_NAME']) { $uri = str_replace('/index.php', '', $uri); } else if (stristr($_SERVER['SCRIPT_NAME'], '/index.php', true)) { static::$serverPath = stristr($_SERVER['SCRIPT_NAME'], '/index.php', true); $uri = str_replace(array(static::$serverPath, '/index.php'), '', $uri); static::$isVirtual = false; } parse_str($_SERVER['QUERY_STRING'], $_GET); static::$urls = static::updateArrayKeys(explode('/', str_replace('?' . $_SERVER['QUERY_STRING'], '', $uri)), true); return static::$urls; }
[ "public", "static", "function", "getUrls", "(", ")", "{", "if", "(", "static", "::", "$", "urls", "!==", "null", ")", "return", "static", "::", "$", "urls", ";", "$", "uri", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "static", "::", "$", "isVirtual", "=", "true", ";", "if", "(", "substr", "(", "$", "uri", ",", "0", ",", "strlen", "(", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ")", ")", "===", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ")", "{", "$", "uri", "=", "str_replace", "(", "'/index.php'", ",", "''", ",", "$", "uri", ")", ";", "}", "else", "if", "(", "stristr", "(", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ",", "'/index.php'", ",", "true", ")", ")", "{", "static", "::", "$", "serverPath", "=", "stristr", "(", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ",", "'/index.php'", ",", "true", ")", ";", "$", "uri", "=", "str_replace", "(", "array", "(", "static", "::", "$", "serverPath", ",", "'/index.php'", ")", ",", "''", ",", "$", "uri", ")", ";", "static", "::", "$", "isVirtual", "=", "false", ";", "}", "parse_str", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ",", "$", "_GET", ")", ";", "static", "::", "$", "urls", "=", "static", "::", "updateArrayKeys", "(", "explode", "(", "'/'", ",", "str_replace", "(", "'?'", ".", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ",", "''", ",", "$", "uri", ")", ")", ",", "true", ")", ";", "return", "static", "::", "$", "urls", ";", "}" ]
Fetches the urls from the server request uri @return array
[ "Fetches", "the", "urls", "from", "the", "server", "request", "uri" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L132-L152
25,812
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.checkAlias
protected static function checkAlias($module) { // $module alias not called if (array_key_exists($module, static::getConfig('modules'))) return $module; // check module alias foreach (static::getConfig('modules') as $cModule => $moduleOptions) { if (!array_key_exists('alias', $moduleOptions)) continue; if ($moduleOptions['alias'] === Util::camelToHyphen($module)) return $cModule; } // module nor alias found return $module; }
php
protected static function checkAlias($module) { // $module alias not called if (array_key_exists($module, static::getConfig('modules'))) return $module; // check module alias foreach (static::getConfig('modules') as $cModule => $moduleOptions) { if (!array_key_exists('alias', $moduleOptions)) continue; if ($moduleOptions['alias'] === Util::camelToHyphen($module)) return $cModule; } // module nor alias found return $module; }
[ "protected", "static", "function", "checkAlias", "(", "$", "module", ")", "{", "// $module alias not called", "if", "(", "array_key_exists", "(", "$", "module", ",", "static", "::", "getConfig", "(", "'modules'", ")", ")", ")", "return", "$", "module", ";", "// check module alias", "foreach", "(", "static", "::", "getConfig", "(", "'modules'", ")", "as", "$", "cModule", "=>", "$", "moduleOptions", ")", "{", "if", "(", "!", "array_key_exists", "(", "'alias'", ",", "$", "moduleOptions", ")", ")", "continue", ";", "if", "(", "$", "moduleOptions", "[", "'alias'", "]", "===", "Util", "::", "camelToHyphen", "(", "$", "module", ")", ")", "return", "$", "cModule", ";", "}", "// module nor alias found", "return", "$", "module", ";", "}" ]
Checks if the module is an alias and returns the ModuleName @param string $module @return string
[ "Checks", "if", "the", "module", "is", "an", "alias", "and", "returns", "the", "ModuleName" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L177-L193
25,813
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getModuleAlias
public static function getModuleAlias($module) { if (NULL !== $alias = static::getConfig('modules', $module, 'alias', false)) { return $alias; } return Util::camelToHyphen($module); }
php
public static function getModuleAlias($module) { if (NULL !== $alias = static::getConfig('modules', $module, 'alias', false)) { return $alias; } return Util::camelToHyphen($module); }
[ "public", "static", "function", "getModuleAlias", "(", "$", "module", ")", "{", "if", "(", "NULL", "!==", "$", "alias", "=", "static", "::", "getConfig", "(", "'modules'", ",", "$", "module", ",", "'alias'", ",", "false", ")", ")", "{", "return", "$", "alias", ";", "}", "return", "Util", "::", "camelToHyphen", "(", "$", "module", ")", ";", "}" ]
Fetches the alias for the given module @param string $module @return string
[ "Fetches", "the", "alias", "for", "the", "given", "module" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L200-L206
25,814
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getDefaultModule
public static function getDefaultModule($getAlias = false) { if (!$module = static::getConfig('defaults', 'module', false)) { $modules = static::getConfig('modules'); $moduleNames = array_keys($modules); $module = $moduleNames[0]; } return $getAlias ? static::getModuleAlias($module) : $module; }
php
public static function getDefaultModule($getAlias = false) { if (!$module = static::getConfig('defaults', 'module', false)) { $modules = static::getConfig('modules'); $moduleNames = array_keys($modules); $module = $moduleNames[0]; } return $getAlias ? static::getModuleAlias($module) : $module; }
[ "public", "static", "function", "getDefaultModule", "(", "$", "getAlias", "=", "false", ")", "{", "if", "(", "!", "$", "module", "=", "static", "::", "getConfig", "(", "'defaults'", ",", "'module'", ",", "false", ")", ")", "{", "$", "modules", "=", "static", "::", "getConfig", "(", "'modules'", ")", ";", "$", "moduleNames", "=", "array_keys", "(", "$", "modules", ")", ";", "$", "module", "=", "$", "moduleNames", "[", "0", "]", ";", "}", "return", "$", "getAlias", "?", "static", "::", "getModuleAlias", "(", "$", "module", ")", ":", "$", "module", ";", "}" ]
Fetches the default module from the config @param boolean $getAlias Indicates whether to return the alias if available or not @return string
[ "Fetches", "the", "default", "module", "from", "the", "config" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L229-L237
25,815
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getDefaultController
public static function getDefaultController($module = null, $exception = false) { $module = ($module === null) ? static::getDefaultModule() : $module; return static::getConfig('modules', $module, 'defaults', 'controller', $exception); }
php
public static function getDefaultController($module = null, $exception = false) { $module = ($module === null) ? static::getDefaultModule() : $module; return static::getConfig('modules', $module, 'defaults', 'controller', $exception); }
[ "public", "static", "function", "getDefaultController", "(", "$", "module", "=", "null", ",", "$", "exception", "=", "false", ")", "{", "$", "module", "=", "(", "$", "module", "===", "null", ")", "?", "static", "::", "getDefaultModule", "(", ")", ":", "$", "module", ";", "return", "static", "::", "getConfig", "(", "'modules'", ",", "$", "module", ",", "'defaults'", ",", "'controller'", ",", "$", "exception", ")", ";", "}" ]
Fetches the default controller from the config @param string $module @param boolean $exception Indicates whether to throw an exception if not found @return string
[ "Fetches", "the", "default", "controller", "from", "the", "config" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L268-L272
25,816
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getDefaultAction
public static function getDefaultAction($module = null, $exception = false) { $module = ($module === null) ? static::getDefaultModule() : $module; return static::getConfig('modules', $module, 'defaults', 'action', $exception); }
php
public static function getDefaultAction($module = null, $exception = false) { $module = ($module === null) ? static::getDefaultModule() : $module; return static::getConfig('modules', $module, 'defaults', 'action', $exception); }
[ "public", "static", "function", "getDefaultAction", "(", "$", "module", "=", "null", ",", "$", "exception", "=", "false", ")", "{", "$", "module", "=", "(", "$", "module", "===", "null", ")", "?", "static", "::", "getDefaultModule", "(", ")", ":", "$", "module", ";", "return", "static", "::", "getConfig", "(", "'modules'", ",", "$", "module", ",", "'defaults'", ",", "'action'", ",", "$", "exception", ")", ";", "}" ]
Fetches the default action from the config @param string $module @param boolean $exception Indicates whether to throw an exception if not found @return string
[ "Fetches", "the", "default", "action", "from", "the", "config" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L301-L305
25,817
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.getControllerClass
protected static function getControllerClass($live = true) { $class = static::getModule() . '\Controllers\\' . static::getController() . 'Controller'; if (!class_exists($class)) ControllerException::notFound($class); if (!in_array('DScribe\Core\AController', class_parents($class))) throw new \Exception('Controller Exception: Controller "' . $class . '" does not extend "DScribe\Core\AController"'); return ($live) ? new $class() : $class; }
php
protected static function getControllerClass($live = true) { $class = static::getModule() . '\Controllers\\' . static::getController() . 'Controller'; if (!class_exists($class)) ControllerException::notFound($class); if (!in_array('DScribe\Core\AController', class_parents($class))) throw new \Exception('Controller Exception: Controller "' . $class . '" does not extend "DScribe\Core\AController"'); return ($live) ? new $class() : $class; }
[ "protected", "static", "function", "getControllerClass", "(", "$", "live", "=", "true", ")", "{", "$", "class", "=", "static", "::", "getModule", "(", ")", ".", "'\\Controllers\\\\'", ".", "static", "::", "getController", "(", ")", ".", "'Controller'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "ControllerException", "::", "notFound", "(", "$", "class", ")", ";", "if", "(", "!", "in_array", "(", "'DScribe\\Core\\AController'", ",", "class_parents", "(", "$", "class", ")", ")", ")", "throw", "new", "\\", "Exception", "(", "'Controller Exception: Controller \"'", ".", "$", "class", ".", "'\" does not extend \"DScribe\\Core\\AController\"'", ")", ";", "return", "(", "$", "live", ")", "?", "new", "$", "class", "(", ")", ":", "$", "class", ";", "}" ]
Creates an instance of the current controller class @return AController @throws Exception
[ "Creates", "an", "instance", "of", "the", "current", "controller", "class" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L340-L351
25,818
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.authenticate
protected static function authenticate($controller, $action, $params) { $auth = new Authenticate(static::$userId, $controller, $action); if (!$auth->execute()) { $controller->accessDenied($action, $params); exit; } }
php
protected static function authenticate($controller, $action, $params) { $auth = new Authenticate(static::$userId, $controller, $action); if (!$auth->execute()) { $controller->accessDenied($action, $params); exit; } }
[ "protected", "static", "function", "authenticate", "(", "$", "controller", ",", "$", "action", ",", "$", "params", ")", "{", "$", "auth", "=", "new", "Authenticate", "(", "static", "::", "$", "userId", ",", "$", "controller", ",", "$", "action", ")", ";", "if", "(", "!", "$", "auth", "->", "execute", "(", ")", ")", "{", "$", "controller", "->", "accessDenied", "(", "$", "action", ",", "$", "params", ")", ";", "exit", ";", "}", "}" ]
Authenticates the current user against the controller and action @param string $controller @param string $action
[ "Authenticates", "the", "current", "user", "against", "the", "controller", "and", "action" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L358-L364
25,819
ezra-obiwale/dSCore
src/Core/Engine.php
Engine.resetUserIdentity
public static function resetUserIdentity(AUser $user = NULL, $duration = null) { static::$userId = new UserIdentity($user, $duration); if (!$user) Session::reset(); static::saveSession(); }
php
public static function resetUserIdentity(AUser $user = NULL, $duration = null) { static::$userId = new UserIdentity($user, $duration); if (!$user) Session::reset(); static::saveSession(); }
[ "public", "static", "function", "resetUserIdentity", "(", "AUser", "$", "user", "=", "NULL", ",", "$", "duration", "=", "null", ")", "{", "static", "::", "$", "userId", "=", "new", "UserIdentity", "(", "$", "user", ",", "$", "duration", ")", ";", "if", "(", "!", "$", "user", ")", "Session", "::", "reset", "(", ")", ";", "static", "::", "saveSession", "(", ")", ";", "}" ]
Resets the user to guest @param AUser $user @param int $duration Duration for which the identity should be valid
[ "Resets", "the", "user", "to", "guest" ]
dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Core/Engine.php#L371-L376
25,820
Linkvalue-Interne/MajoraOAuthServerBundle
src/Majora/Component/OAuth/Server/Server.php
Server.createLoginAttempt
protected function createLoginAttempt(array $data, array $headers, array $query) { // validate grant_type manually (needed to guess specialized option resolver) if (empty($data['grant_type'])) { throw new \InvalidArgumentException('Any grant_type given.'); } $grantType = $data['grant_type']; if (!$this->grantExtensions->containsKey($grantType)) { throw new \InvalidArgumentException('Given grant_type is invalid.'); } // create option resolver $requestResolver = new OptionsResolver(); $requestResolver->setRequired(array( 'client_secret', 'client_api_key', 'grant_type', )); $this->grantExtensions->get($grantType) ->configureRequestParameters($requestResolver) ; return new LoginAttempt( $query, $requestResolver->resolve($data), $headers ); }
php
protected function createLoginAttempt(array $data, array $headers, array $query) { // validate grant_type manually (needed to guess specialized option resolver) if (empty($data['grant_type'])) { throw new \InvalidArgumentException('Any grant_type given.'); } $grantType = $data['grant_type']; if (!$this->grantExtensions->containsKey($grantType)) { throw new \InvalidArgumentException('Given grant_type is invalid.'); } // create option resolver $requestResolver = new OptionsResolver(); $requestResolver->setRequired(array( 'client_secret', 'client_api_key', 'grant_type', )); $this->grantExtensions->get($grantType) ->configureRequestParameters($requestResolver) ; return new LoginAttempt( $query, $requestResolver->resolve($data), $headers ); }
[ "protected", "function", "createLoginAttempt", "(", "array", "$", "data", ",", "array", "$", "headers", ",", "array", "$", "query", ")", "{", "// validate grant_type manually (needed to guess specialized option resolver)", "if", "(", "empty", "(", "$", "data", "[", "'grant_type'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Any grant_type given.'", ")", ";", "}", "$", "grantType", "=", "$", "data", "[", "'grant_type'", "]", ";", "if", "(", "!", "$", "this", "->", "grantExtensions", "->", "containsKey", "(", "$", "grantType", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Given grant_type is invalid.'", ")", ";", "}", "// create option resolver", "$", "requestResolver", "=", "new", "OptionsResolver", "(", ")", ";", "$", "requestResolver", "->", "setRequired", "(", "array", "(", "'client_secret'", ",", "'client_api_key'", ",", "'grant_type'", ",", ")", ")", ";", "$", "this", "->", "grantExtensions", "->", "get", "(", "$", "grantType", ")", "->", "configureRequestParameters", "(", "$", "requestResolver", ")", ";", "return", "new", "LoginAttempt", "(", "$", "query", ",", "$", "requestResolver", "->", "resolve", "(", "$", "data", ")", ",", "$", "headers", ")", ";", "}" ]
Validate given request parameters and build a LoginAttempt object with it. @param array $data @param array $headers @param array $query @return LoginAttempt
[ "Validate", "given", "request", "parameters", "and", "build", "a", "LoginAttempt", "object", "with", "it", "." ]
3e84e2494c947d1bd5d5c16221a3b9e343ebff92
https://github.com/Linkvalue-Interne/MajoraOAuthServerBundle/blob/3e84e2494c947d1bd5d5c16221a3b9e343ebff92/src/Majora/Component/OAuth/Server/Server.php#L119-L146
25,821
Linkvalue-Interne/MajoraOAuthServerBundle
src/Majora/Component/OAuth/Server/Server.php
Server.loadApplication
protected function loadApplication(LoginAttempt $loginAttempt) { // retrieve Application if (!$application = $this->applicationLoader->retrieveByApiKeyAndSecret( $loginAttempt->getData('client_api_key'), $loginAttempt->getData('client_secret') )) { throw new InvalidGrantException( $loginAttempt, 'Any application found for given api_key / secret.' ); } return $application; }
php
protected function loadApplication(LoginAttempt $loginAttempt) { // retrieve Application if (!$application = $this->applicationLoader->retrieveByApiKeyAndSecret( $loginAttempt->getData('client_api_key'), $loginAttempt->getData('client_secret') )) { throw new InvalidGrantException( $loginAttempt, 'Any application found for given api_key / secret.' ); } return $application; }
[ "protected", "function", "loadApplication", "(", "LoginAttempt", "$", "loginAttempt", ")", "{", "// retrieve Application", "if", "(", "!", "$", "application", "=", "$", "this", "->", "applicationLoader", "->", "retrieveByApiKeyAndSecret", "(", "$", "loginAttempt", "->", "getData", "(", "'client_api_key'", ")", ",", "$", "loginAttempt", "->", "getData", "(", "'client_secret'", ")", ")", ")", "{", "throw", "new", "InvalidGrantException", "(", "$", "loginAttempt", ",", "'Any application found for given api_key / secret.'", ")", ";", "}", "return", "$", "application", ";", "}" ]
Loads application for given login attempt. @param LoginAttempt $loginAttempt @return ApplicationInterface @throws InvalidGrantException
[ "Loads", "application", "for", "given", "login", "attempt", "." ]
3e84e2494c947d1bd5d5c16221a3b9e343ebff92
https://github.com/Linkvalue-Interne/MajoraOAuthServerBundle/blob/3e84e2494c947d1bd5d5c16221a3b9e343ebff92/src/Majora/Component/OAuth/Server/Server.php#L157-L171
25,822
Linkvalue-Interne/MajoraOAuthServerBundle
src/Majora/Component/OAuth/Server/Server.php
Server.loadAccount
protected function loadAccount( ApplicationInterface $application, LoginAttempt $loginAttempt ) { // run grant extension result return $this->grantExtensions ->get($loginAttempt->getData('grant_type')) ->grant($application, $loginAttempt) ; }
php
protected function loadAccount( ApplicationInterface $application, LoginAttempt $loginAttempt ) { // run grant extension result return $this->grantExtensions ->get($loginAttempt->getData('grant_type')) ->grant($application, $loginAttempt) ; }
[ "protected", "function", "loadAccount", "(", "ApplicationInterface", "$", "application", ",", "LoginAttempt", "$", "loginAttempt", ")", "{", "// run grant extension result", "return", "$", "this", "->", "grantExtensions", "->", "get", "(", "$", "loginAttempt", "->", "getData", "(", "'grant_type'", ")", ")", "->", "grant", "(", "$", "application", ",", "$", "loginAttempt", ")", ";", "}" ]
Runs grant extension to load accounts. @param ApplicationInterface $application @param LoginAttempt $loginAttempt @return AccountInterface @throws \InvalidArgumentException @throws UnknownGrantTypeException
[ "Runs", "grant", "extension", "to", "load", "accounts", "." ]
3e84e2494c947d1bd5d5c16221a3b9e343ebff92
https://github.com/Linkvalue-Interne/MajoraOAuthServerBundle/blob/3e84e2494c947d1bd5d5c16221a3b9e343ebff92/src/Majora/Component/OAuth/Server/Server.php#L184-L193
25,823
Linkvalue-Interne/MajoraOAuthServerBundle
src/Majora/Component/OAuth/Server/Server.php
Server.grant
public function grant(array $data, array $headers = array(), array $query = array()) { // create and validate login attempt from given data $loginAttempt = $this->createLoginAttempt( $data, $headers, $query ); // load application / account $account = $this->loadAccount( $application = $this->loadApplication($loginAttempt), $loginAttempt ); // event call $this->eventDispatcher->dispatch( AccessTokenEvents::MAJORA_ACCESS_TOKEN_CREATED, new AccessTokenEvent( // access token generation $accessToken = new $this->tokenOptions['access_token_class']( $application, $account, $this->tokenOptions['access_token_ttl'], null, // for now, we let the expiration date calculate itself $this->randomTokenGenerator->generate('access_token'), // refresh token generation only if necessary in_array('refresh_token', $application->getAllowedGrantTypes()) && $this->grantExtensions->containsKey('refresh_token') ? new $this->tokenOptions['refresh_token_class']( $application, $account, $this->tokenOptions['refresh_token_ttl'], null, // same $this->randomTokenGenerator->generate('refresh_token') ) : null ) ) ); return $accessToken; }
php
public function grant(array $data, array $headers = array(), array $query = array()) { // create and validate login attempt from given data $loginAttempt = $this->createLoginAttempt( $data, $headers, $query ); // load application / account $account = $this->loadAccount( $application = $this->loadApplication($loginAttempt), $loginAttempt ); // event call $this->eventDispatcher->dispatch( AccessTokenEvents::MAJORA_ACCESS_TOKEN_CREATED, new AccessTokenEvent( // access token generation $accessToken = new $this->tokenOptions['access_token_class']( $application, $account, $this->tokenOptions['access_token_ttl'], null, // for now, we let the expiration date calculate itself $this->randomTokenGenerator->generate('access_token'), // refresh token generation only if necessary in_array('refresh_token', $application->getAllowedGrantTypes()) && $this->grantExtensions->containsKey('refresh_token') ? new $this->tokenOptions['refresh_token_class']( $application, $account, $this->tokenOptions['refresh_token_ttl'], null, // same $this->randomTokenGenerator->generate('refresh_token') ) : null ) ) ); return $accessToken; }
[ "public", "function", "grant", "(", "array", "$", "data", ",", "array", "$", "headers", "=", "array", "(", ")", ",", "array", "$", "query", "=", "array", "(", ")", ")", "{", "// create and validate login attempt from given data", "$", "loginAttempt", "=", "$", "this", "->", "createLoginAttempt", "(", "$", "data", ",", "$", "headers", ",", "$", "query", ")", ";", "// load application / account", "$", "account", "=", "$", "this", "->", "loadAccount", "(", "$", "application", "=", "$", "this", "->", "loadApplication", "(", "$", "loginAttempt", ")", ",", "$", "loginAttempt", ")", ";", "// event call", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "AccessTokenEvents", "::", "MAJORA_ACCESS_TOKEN_CREATED", ",", "new", "AccessTokenEvent", "(", "// access token generation", "$", "accessToken", "=", "new", "$", "this", "->", "tokenOptions", "[", "'access_token_class'", "]", "(", "$", "application", ",", "$", "account", ",", "$", "this", "->", "tokenOptions", "[", "'access_token_ttl'", "]", ",", "null", ",", "// for now, we let the expiration date calculate itself", "$", "this", "->", "randomTokenGenerator", "->", "generate", "(", "'access_token'", ")", ",", "// refresh token generation only if necessary", "in_array", "(", "'refresh_token'", ",", "$", "application", "->", "getAllowedGrantTypes", "(", ")", ")", "&&", "$", "this", "->", "grantExtensions", "->", "containsKey", "(", "'refresh_token'", ")", "?", "new", "$", "this", "->", "tokenOptions", "[", "'refresh_token_class'", "]", "(", "$", "application", ",", "$", "account", ",", "$", "this", "->", "tokenOptions", "[", "'refresh_token_ttl'", "]", ",", "null", ",", "// same", "$", "this", "->", "randomTokenGenerator", "->", "generate", "(", "'refresh_token'", ")", ")", ":", "null", ")", ")", ")", ";", "return", "$", "accessToken", ";", "}" ]
Grant given credentials, or throws an exception if invalid credentials for application or account. @param array $data login request data @param array $headers optionnal login request headers @param array $query optionnal login request query @return AccessTokenInterface
[ "Grant", "given", "credentials", "or", "throws", "an", "exception", "if", "invalid", "credentials", "for", "application", "or", "account", "." ]
3e84e2494c947d1bd5d5c16221a3b9e343ebff92
https://github.com/Linkvalue-Interne/MajoraOAuthServerBundle/blob/3e84e2494c947d1bd5d5c16221a3b9e343ebff92/src/Majora/Component/OAuth/Server/Server.php#L205-L247
25,824
goncalomb/asbestos
src/classes/Page.php
Page.start
public static function start() { if (self::$_page) { return null; } self::$_page = new Html\Document(); self::$_zones['head'] = self::$_page->head(); self::$_zones['body'] = self::$_page->body(); ob_start(); return self::$_page; }
php
public static function start() { if (self::$_page) { return null; } self::$_page = new Html\Document(); self::$_zones['head'] = self::$_page->head(); self::$_zones['body'] = self::$_page->body(); ob_start(); return self::$_page; }
[ "public", "static", "function", "start", "(", ")", "{", "if", "(", "self", "::", "$", "_page", ")", "{", "return", "null", ";", "}", "self", "::", "$", "_page", "=", "new", "Html", "\\", "Document", "(", ")", ";", "self", "::", "$", "_zones", "[", "'head'", "]", "=", "self", "::", "$", "_page", "->", "head", "(", ")", ";", "self", "::", "$", "_zones", "[", "'body'", "]", "=", "self", "::", "$", "_page", "->", "body", "(", ")", ";", "ob_start", "(", ")", ";", "return", "self", "::", "$", "_page", ";", "}" ]
Initialize page. @return \Asbestos\Html\Document
[ "Initialize", "page", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L56-L66
25,825
goncalomb/asbestos
src/classes/Page.php
Page.createZone
public static function createZone($zoneName, $tag='div') { if (self::$_page && !isset(self::$_zones[$zoneName])) { $element = new Html\Element($tag); self::$_zones[$zoneName] = $element; self::append(self::$_outputZone, $element); return $element; } return null; }
php
public static function createZone($zoneName, $tag='div') { if (self::$_page && !isset(self::$_zones[$zoneName])) { $element = new Html\Element($tag); self::$_zones[$zoneName] = $element; self::append(self::$_outputZone, $element); return $element; } return null; }
[ "public", "static", "function", "createZone", "(", "$", "zoneName", ",", "$", "tag", "=", "'div'", ")", "{", "if", "(", "self", "::", "$", "_page", "&&", "!", "isset", "(", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", ")", ")", "{", "$", "element", "=", "new", "Html", "\\", "Element", "(", "$", "tag", ")", ";", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", "=", "$", "element", ";", "self", "::", "append", "(", "self", "::", "$", "_outputZone", ",", "$", "element", ")", ";", "return", "$", "element", ";", "}", "return", "null", ";", "}" ]
Create a new page zone. @param string $zoneName Zone name. @param string $tag Tag name (defaults to div). @return \Asbestos\Html\Element
[ "Create", "a", "new", "page", "zone", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L75-L84
25,826
goncalomb/asbestos
src/classes/Page.php
Page.getZone
public static function getZone($zoneName=null) { if ($zoneName === null) { $zoneName = self::$_outputZone; } return (isset(self::$_zones[$zoneName]) ? self::$_zones[$zoneName] : null); }
php
public static function getZone($zoneName=null) { if ($zoneName === null) { $zoneName = self::$_outputZone; } return (isset(self::$_zones[$zoneName]) ? self::$_zones[$zoneName] : null); }
[ "public", "static", "function", "getZone", "(", "$", "zoneName", "=", "null", ")", "{", "if", "(", "$", "zoneName", "===", "null", ")", "{", "$", "zoneName", "=", "self", "::", "$", "_outputZone", ";", "}", "return", "(", "isset", "(", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", ")", "?", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", ":", "null", ")", ";", "}" ]
Get zone element. @param string $zoneName Zone name (defaults to current zone). @return \Asbestos\Html\Element
[ "Get", "zone", "element", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L92-L98
25,827
goncalomb/asbestos
src/classes/Page.php
Page.append
public static function append($zoneName, ...$data) { if (isset(self::$_zones[$zoneName])) { self::flushBuffer(); call_user_func_array(array(self::$_zones[$zoneName], 'append'), $data); return true; } return false; }
php
public static function append($zoneName, ...$data) { if (isset(self::$_zones[$zoneName])) { self::flushBuffer(); call_user_func_array(array(self::$_zones[$zoneName], 'append'), $data); return true; } return false; }
[ "public", "static", "function", "append", "(", "$", "zoneName", ",", "...", "$", "data", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", ")", ")", "{", "self", "::", "flushBuffer", "(", ")", ";", "call_user_func_array", "(", "array", "(", "self", "::", "$", "_zones", "[", "$", "zoneName", "]", ",", "'append'", ")", ",", "$", "data", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Append data to to zone. @param string $zoneName Zone name. @param mixed $data Data to be appended. @return boolean
[ "Append", "data", "to", "to", "zone", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L151-L159
25,828
goncalomb/asbestos
src/classes/Page.php
Page.flushBuffer
public static function flushBuffer() { if (self::$_page && ob_get_length()) { self::$_zones[self::$_outputZone]->append(ob_get_clean()); ob_start(); return true; } return false; }
php
public static function flushBuffer() { if (self::$_page && ob_get_length()) { self::$_zones[self::$_outputZone]->append(ob_get_clean()); ob_start(); return true; } return false; }
[ "public", "static", "function", "flushBuffer", "(", ")", "{", "if", "(", "self", "::", "$", "_page", "&&", "ob_get_length", "(", ")", ")", "{", "self", "::", "$", "_zones", "[", "self", "::", "$", "_outputZone", "]", "->", "append", "(", "ob_get_clean", "(", ")", ")", ";", "ob_start", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Flushes the output buffer to the current zone element. @return boolean
[ "Flushes", "the", "output", "buffer", "to", "the", "current", "zone", "element", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L166-L174
25,829
goncalomb/asbestos
src/classes/Page.php
Page.metaTag
public static function metaTag($name, $content) { if (self::$_page) { self::$_page->metaTag($name, $content); } }
php
public static function metaTag($name, $content) { if (self::$_page) { self::$_page->metaTag($name, $content); } }
[ "public", "static", "function", "metaTag", "(", "$", "name", ",", "$", "content", ")", "{", "if", "(", "self", "::", "$", "_page", ")", "{", "self", "::", "$", "_page", "->", "metaTag", "(", "$", "name", ",", "$", "content", ")", ";", "}", "}" ]
Set meta tag. @param string $name Meta tag name. @param string $content Meta tag content.
[ "Set", "meta", "tag", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L194-L199
25,830
goncalomb/asbestos
src/classes/Page.php
Page.end
public static function end() { if (!self::$_page || ErrorHandling::lastError()) { return; } self::$_zones[self::$_outputZone]->append(ob_get_clean()); self::$_page->output(); // reset class self::$_page = null; self::$_zones = array(); self::$_zoneStack = array(); self::$_outputZone = 'body'; echo '<!-- '; echo '~', Asbestos::executionTime(); echo " -->\n"; }
php
public static function end() { if (!self::$_page || ErrorHandling::lastError()) { return; } self::$_zones[self::$_outputZone]->append(ob_get_clean()); self::$_page->output(); // reset class self::$_page = null; self::$_zones = array(); self::$_zoneStack = array(); self::$_outputZone = 'body'; echo '<!-- '; echo '~', Asbestos::executionTime(); echo " -->\n"; }
[ "public", "static", "function", "end", "(", ")", "{", "if", "(", "!", "self", "::", "$", "_page", "||", "ErrorHandling", "::", "lastError", "(", ")", ")", "{", "return", ";", "}", "self", "::", "$", "_zones", "[", "self", "::", "$", "_outputZone", "]", "->", "append", "(", "ob_get_clean", "(", ")", ")", ";", "self", "::", "$", "_page", "->", "output", "(", ")", ";", "// reset class", "self", "::", "$", "_page", "=", "null", ";", "self", "::", "$", "_zones", "=", "array", "(", ")", ";", "self", "::", "$", "_zoneStack", "=", "array", "(", ")", ";", "self", "::", "$", "_outputZone", "=", "'body'", ";", "echo", "'<!-- '", ";", "echo", "'~'", ",", "Asbestos", "::", "executionTime", "(", ")", ";", "echo", "\" -->\\n\"", ";", "}" ]
Finalize and output page.
[ "Finalize", "and", "output", "page", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Page.php#L326-L343
25,831
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Type/TypeFactory.php
TypeFactory.getType
public static function getType($type) { if (!isset(self::$typesMap[$type])) { throw new \InvalidArgumentException(sprintf('Invalid type specified "%s".', $type)); } if (!isset(self::$typeObjects[$type])) { $className = self::$typesMap[$type]; self::$typeObjects[$type] = new $className; } return self::$typeObjects[$type]; }
php
public static function getType($type) { if (!isset(self::$typesMap[$type])) { throw new \InvalidArgumentException(sprintf('Invalid type specified "%s".', $type)); } if (!isset(self::$typeObjects[$type])) { $className = self::$typesMap[$type]; self::$typeObjects[$type] = new $className; } return self::$typeObjects[$type]; }
[ "public", "static", "function", "getType", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "typesMap", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid type specified \"%s\".'", ",", "$", "type", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "typeObjects", "[", "$", "type", "]", ")", ")", "{", "$", "className", "=", "self", "::", "$", "typesMap", "[", "$", "type", "]", ";", "self", "::", "$", "typeObjects", "[", "$", "type", "]", "=", "new", "$", "className", ";", "}", "return", "self", "::", "$", "typeObjects", "[", "$", "type", "]", ";", "}" ]
Get a Type instance. @param string $type The type name. @return Type $type @throws \InvalidArgumentException
[ "Get", "a", "Type", "instance", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Type/TypeFactory.php#L78-L89
25,832
pluf/discount
src/Discount/Service.php
Discount_Service.discountIsValid
public static function discountIsValid($code) { $discount = Discount_Shortcuts_GetDiscountByCodeOrNull($code); if ($discount == null) return false; $engine = Discount_Shortcuts_GetEngineOrNull($discount->get_type()); if ($engine == null) return false; return $engine->isValid($discount); }
php
public static function discountIsValid($code) { $discount = Discount_Shortcuts_GetDiscountByCodeOrNull($code); if ($discount == null) return false; $engine = Discount_Shortcuts_GetEngineOrNull($discount->get_type()); if ($engine == null) return false; return $engine->isValid($discount); }
[ "public", "static", "function", "discountIsValid", "(", "$", "code", ")", "{", "$", "discount", "=", "Discount_Shortcuts_GetDiscountByCodeOrNull", "(", "$", "code", ")", ";", "if", "(", "$", "discount", "==", "null", ")", "return", "false", ";", "$", "engine", "=", "Discount_Shortcuts_GetEngineOrNull", "(", "$", "discount", "->", "get_type", "(", ")", ")", ";", "if", "(", "$", "engine", "==", "null", ")", "return", "false", ";", "return", "$", "engine", "->", "isValid", "(", "$", "discount", ")", ";", "}" ]
Checks if discount with given code is valid. @param string $code @return boolean
[ "Checks", "if", "discount", "with", "given", "code", "is", "valid", "." ]
b0006d6b25dd61241f51b5b098d7d546b470de26
https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Service.php#L49-L58
25,833
pluf/discount
src/Discount/Service.php
Discount_Service.getPrice
public static function getPrice($originPrice, $discountCode, $request) { $discount = Discount_Shortcuts_GetDiscountByCodeOr404($discountCode); $engine = $discount->get_engine(); return $engine->getPrice($originPrice, $discount, $request); }
php
public static function getPrice($originPrice, $discountCode, $request) { $discount = Discount_Shortcuts_GetDiscountByCodeOr404($discountCode); $engine = $discount->get_engine(); return $engine->getPrice($originPrice, $discount, $request); }
[ "public", "static", "function", "getPrice", "(", "$", "originPrice", ",", "$", "discountCode", ",", "$", "request", ")", "{", "$", "discount", "=", "Discount_Shortcuts_GetDiscountByCodeOr404", "(", "$", "discountCode", ")", ";", "$", "engine", "=", "$", "discount", "->", "get_engine", "(", ")", ";", "return", "$", "engine", "->", "getPrice", "(", "$", "originPrice", ",", "$", "discount", ",", "$", "request", ")", ";", "}" ]
Computes and returns new price after using given discount @param integer $originPrice @param string $discountCode @param Pluf_HTTP_Request $request @return integer
[ "Computes", "and", "returns", "new", "price", "after", "using", "given", "discount" ]
b0006d6b25dd61241f51b5b098d7d546b470de26
https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Service.php#L68-L73
25,834
pluf/discount
src/Discount/Service.php
Discount_Service.consumeDiscount
public static function consumeDiscount($discountCode) { $discount = Discount_Shortcuts_GetDiscountByCodeOr404($discountCode); $engine = $discount->get_engine(); $engine->consumeDiscount($discount); return $discount; }
php
public static function consumeDiscount($discountCode) { $discount = Discount_Shortcuts_GetDiscountByCodeOr404($discountCode); $engine = $discount->get_engine(); $engine->consumeDiscount($discount); return $discount; }
[ "public", "static", "function", "consumeDiscount", "(", "$", "discountCode", ")", "{", "$", "discount", "=", "Discount_Shortcuts_GetDiscountByCodeOr404", "(", "$", "discountCode", ")", ";", "$", "engine", "=", "$", "discount", "->", "get_engine", "(", ")", ";", "$", "engine", "->", "consumeDiscount", "(", "$", "discount", ")", ";", "return", "$", "discount", ";", "}" ]
Decrease one unit of given discount. If discount is one-time-use it will be invalid after this function. @param string $discountCode @return Discount_Discount
[ "Decrease", "one", "unit", "of", "given", "discount", ".", "If", "discount", "is", "one", "-", "time", "-", "use", "it", "will", "be", "invalid", "after", "this", "function", "." ]
b0006d6b25dd61241f51b5b098d7d546b470de26
https://github.com/pluf/discount/blob/b0006d6b25dd61241f51b5b098d7d546b470de26/src/Discount/Service.php#L82-L88
25,835
nhlm/pipechain
src/InvokerProcessors/Traits/StackProcessingTrait.php
StackProcessingTrait.processStack
public function processStack($payload, PipeChainCollectionInterface $pipeChainCollection) { foreach ( $pipeChainCollection as $stage => $fallback ) { $payload = $this->process($payload, $stage, $fallback); } return $payload; }
php
public function processStack($payload, PipeChainCollectionInterface $pipeChainCollection) { foreach ( $pipeChainCollection as $stage => $fallback ) { $payload = $this->process($payload, $stage, $fallback); } return $payload; }
[ "public", "function", "processStack", "(", "$", "payload", ",", "PipeChainCollectionInterface", "$", "pipeChainCollection", ")", "{", "foreach", "(", "$", "pipeChainCollection", "as", "$", "stage", "=>", "$", "fallback", ")", "{", "$", "payload", "=", "$", "this", "->", "process", "(", "$", "payload", ",", "$", "stage", ",", "$", "fallback", ")", ";", "}", "return", "$", "payload", ";", "}" ]
processes a PipeChainCollection with the provided payload. @param mixed $payload @param PipeChainCollectionInterface $pipeChainCollection @return mixed payload
[ "processes", "a", "PipeChainCollection", "with", "the", "provided", "payload", "." ]
7f67b54372415a66c42ce074bc359c55fda218a5
https://github.com/nhlm/pipechain/blob/7f67b54372415a66c42ce074bc359c55fda218a5/src/InvokerProcessors/Traits/StackProcessingTrait.php#L25-L32
25,836
wb-crowdfusion/crowdfusion
system/core/classes/libraries/http/HttpRequest.php
HttpRequest.fetchJSON
public function fetchJSON($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { $contents = $this->fetchURL($url, $followRedirects, $username, $password, $headers); return JSONUtils::decode($contents,true); }
php
public function fetchJSON($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { $contents = $this->fetchURL($url, $followRedirects, $username, $password, $headers); return JSONUtils::decode($contents,true); }
[ "public", "function", "fetchJSON", "(", "$", "url", ",", "$", "followRedirects", "=", "true", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "contents", "=", "$", "this", "->", "fetchURL", "(", "$", "url", ",", "$", "followRedirects", ",", "$", "username", ",", "$", "password", ",", "$", "headers", ")", ";", "return", "JSONUtils", "::", "decode", "(", "$", "contents", ",", "true", ")", ";", "}" ]
Fetch the contents of a URL as a JSON array @param string $url Fully-qualified URL to request @param bool $followRedirects If true, follow redirects to default max of 5 @param string $username Username to use in http authentication header @param string $password Password to use in http authentication header @param array $headers Array of http headers to append to the existing headers list @return array PHP array version of JSON contents @throws HttpRequestException If contents cannot be fetched
[ "Fetch", "the", "contents", "of", "a", "URL", "as", "a", "JSON", "array" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/http/HttpRequest.php#L63-L67
25,837
wb-crowdfusion/crowdfusion
system/core/classes/libraries/http/HttpRequest.php
HttpRequest.headURL
public function headURL($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { if (function_exists('curl_init')) { $contents = $this->curlRequest($url, true, $followRedirects, $username, $password, $headers); return $contents; } else { throw new HttpRequestException('headURL not supported without curl'); } }
php
public function headURL($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { if (function_exists('curl_init')) { $contents = $this->curlRequest($url, true, $followRedirects, $username, $password, $headers); return $contents; } else { throw new HttpRequestException('headURL not supported without curl'); } }
[ "public", "function", "headURL", "(", "$", "url", ",", "$", "followRedirects", "=", "true", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "if", "(", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "contents", "=", "$", "this", "->", "curlRequest", "(", "$", "url", ",", "true", ",", "$", "followRedirects", ",", "$", "username", ",", "$", "password", ",", "$", "headers", ")", ";", "return", "$", "contents", ";", "}", "else", "{", "throw", "new", "HttpRequestException", "(", "'headURL not supported without curl'", ")", ";", "}", "}" ]
Fetch the headers of a URL @param string $url Fully-qualified URL to request @param bool $followRedirects If true, follow redirects to default max of 5 @param string $username Username to use in http authentication header @param string $password Password to use in http authentication header @param array $headers Array of http headers to append to the existing headers list @return string Contents of the HTTP headers @throws HttpRequestException If contents cannot be fetched
[ "Fetch", "the", "headers", "of", "a", "URL" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/http/HttpRequest.php#L81-L94
25,838
wb-crowdfusion/crowdfusion
system/core/classes/libraries/http/HttpRequest.php
HttpRequest.fetchURL
public function fetchURL($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { if (function_exists('curl_init')) { $contents = $this->curlRequest($url, false, $followRedirects, $username, $password, $headers); return $contents; } else { if ($this->userAgent != null) { $opts = array( 'http'=> array( 'user_agent'=> $this->userAgent, 'max_redirects' => $this->redirects, // stop after 10 redirects ) ); } if ($username && $password) { $opts = ($opts) ? $opts : array('http' => array()); $opts['http']['header'] = array('Authorization: Basic ' . base64_encode("$username:$password")); } if ($headers) { $opts['http']['header'] =$headers; } $context = ($opts) ? stream_context_create($opts) : null; unset($opts); $contents = @file_get_contents($url, false, $context); if ($contents === false) throw new HttpRequestException("Unknown error fetching URL '".$url."'"); unset($context); unset($url); return $contents; } }
php
public function fetchURL($url, $followRedirects = true, $username = null, $password = null, $headers = array()) { if (function_exists('curl_init')) { $contents = $this->curlRequest($url, false, $followRedirects, $username, $password, $headers); return $contents; } else { if ($this->userAgent != null) { $opts = array( 'http'=> array( 'user_agent'=> $this->userAgent, 'max_redirects' => $this->redirects, // stop after 10 redirects ) ); } if ($username && $password) { $opts = ($opts) ? $opts : array('http' => array()); $opts['http']['header'] = array('Authorization: Basic ' . base64_encode("$username:$password")); } if ($headers) { $opts['http']['header'] =$headers; } $context = ($opts) ? stream_context_create($opts) : null; unset($opts); $contents = @file_get_contents($url, false, $context); if ($contents === false) throw new HttpRequestException("Unknown error fetching URL '".$url."'"); unset($context); unset($url); return $contents; } }
[ "public", "function", "fetchURL", "(", "$", "url", ",", "$", "followRedirects", "=", "true", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "if", "(", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "contents", "=", "$", "this", "->", "curlRequest", "(", "$", "url", ",", "false", ",", "$", "followRedirects", ",", "$", "username", ",", "$", "password", ",", "$", "headers", ")", ";", "return", "$", "contents", ";", "}", "else", "{", "if", "(", "$", "this", "->", "userAgent", "!=", "null", ")", "{", "$", "opts", "=", "array", "(", "'http'", "=>", "array", "(", "'user_agent'", "=>", "$", "this", "->", "userAgent", ",", "'max_redirects'", "=>", "$", "this", "->", "redirects", ",", "// stop after 10 redirects", ")", ")", ";", "}", "if", "(", "$", "username", "&&", "$", "password", ")", "{", "$", "opts", "=", "(", "$", "opts", ")", "?", "$", "opts", ":", "array", "(", "'http'", "=>", "array", "(", ")", ")", ";", "$", "opts", "[", "'http'", "]", "[", "'header'", "]", "=", "array", "(", "'Authorization: Basic '", ".", "base64_encode", "(", "\"$username:$password\"", ")", ")", ";", "}", "if", "(", "$", "headers", ")", "{", "$", "opts", "[", "'http'", "]", "[", "'header'", "]", "=", "$", "headers", ";", "}", "$", "context", "=", "(", "$", "opts", ")", "?", "stream_context_create", "(", "$", "opts", ")", ":", "null", ";", "unset", "(", "$", "opts", ")", ";", "$", "contents", "=", "@", "file_get_contents", "(", "$", "url", ",", "false", ",", "$", "context", ")", ";", "if", "(", "$", "contents", "===", "false", ")", "throw", "new", "HttpRequestException", "(", "\"Unknown error fetching URL '\"", ".", "$", "url", ".", "\"'\"", ")", ";", "unset", "(", "$", "context", ")", ";", "unset", "(", "$", "url", ")", ";", "return", "$", "contents", ";", "}", "}" ]
Fetch the contents of a URL @param string $url Fully-qualified URL to request @param bool $followRedirects If true, follow redirects to default max of 5 @param string $username Username to use in http authentication header @param string $password Password to use in http authentication header @param array $headers Array of http headers to append to the existing headers list @return string Contents of the HTTP response body @throws HttpRequestException If contents cannot be fetched
[ "Fetch", "the", "contents", "of", "a", "URL" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/http/HttpRequest.php#L274-L320
25,839
kambalabs/KmbBase
src/KmbBase/Widget/AbstractWidgetAction.php
AbstractWidgetAction.setPluginManager
public function setPluginManager(PluginManager $plugins) { $this->plugins = $plugins; $this->plugins->setController($this->controller); return $this; }
php
public function setPluginManager(PluginManager $plugins) { $this->plugins = $plugins; $this->plugins->setController($this->controller); return $this; }
[ "public", "function", "setPluginManager", "(", "PluginManager", "$", "plugins", ")", "{", "$", "this", "->", "plugins", "=", "$", "plugins", ";", "$", "this", "->", "plugins", "->", "setController", "(", "$", "this", "->", "controller", ")", ";", "return", "$", "this", ";", "}" ]
Set plugin manager @param PluginManager $plugins @return AbstractWidgetAction
[ "Set", "plugin", "manager" ]
ca420f247e9e4063266005e30afc4c8af492a33b
https://github.com/kambalabs/KmbBase/blob/ca420f247e9e4063266005e30afc4c8af492a33b/src/KmbBase/Widget/AbstractWidgetAction.php#L80-L86
25,840
OxfordInfoLabs/kinikit-core
src/Util/Annotation/Annotation.php
Annotation.getValues
public function getValues() { $exploded = explode(",", $this->getValue()); $values = array(); foreach ($exploded as $entry){ $values[] = trim($entry); } return $values; }
php
public function getValues() { $exploded = explode(",", $this->getValue()); $values = array(); foreach ($exploded as $entry){ $values[] = trim($entry); } return $values; }
[ "public", "function", "getValues", "(", ")", "{", "$", "exploded", "=", "explode", "(", "\",\"", ",", "$", "this", "->", "getValue", "(", ")", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "exploded", "as", "$", "entry", ")", "{", "$", "values", "[", "]", "=", "trim", "(", "$", "entry", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return value as an array split by ","
[ "Return", "value", "as", "an", "array", "split", "by" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Annotation/Annotation.php#L62-L70
25,841
goncalomb/asbestos
src/classes/Http/Request.php
Request.fromGlobals
public static function fromGlobals() { $request = new self(); foreach ([ 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language', 'Connection', 'Host', 'Referer', 'User-Agent' ] as $name) { $key = 'HTTP_' . str_replace('-', '_', strtoupper($name)); if (isset($_SERVER[$key])) { $request->setHeader($name, $_SERVER[$key], false); } } $request->_isSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'); $request->_method = $_SERVER['REQUEST_METHOD']; $request->_uri = $_SERVER['REQUEST_URI']; $request->_path = strstr($_SERVER['REQUEST_URI'], '?', true); if ($request->_path == false) { $request->_path = $_SERVER['REQUEST_URI']; } $request->_query = strstr($_SERVER['REQUEST_URI'], '?'); if ($request->_query == false) { $request->_query = ''; } return $request; }
php
public static function fromGlobals() { $request = new self(); foreach ([ 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language', 'Connection', 'Host', 'Referer', 'User-Agent' ] as $name) { $key = 'HTTP_' . str_replace('-', '_', strtoupper($name)); if (isset($_SERVER[$key])) { $request->setHeader($name, $_SERVER[$key], false); } } $request->_isSecure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'); $request->_method = $_SERVER['REQUEST_METHOD']; $request->_uri = $_SERVER['REQUEST_URI']; $request->_path = strstr($_SERVER['REQUEST_URI'], '?', true); if ($request->_path == false) { $request->_path = $_SERVER['REQUEST_URI']; } $request->_query = strstr($_SERVER['REQUEST_URI'], '?'); if ($request->_query == false) { $request->_query = ''; } return $request; }
[ "public", "static", "function", "fromGlobals", "(", ")", "{", "$", "request", "=", "new", "self", "(", ")", ";", "foreach", "(", "[", "'Accept'", ",", "'Accept-Charset'", ",", "'Accept-Encoding'", ",", "'Accept-Language'", ",", "'Connection'", ",", "'Host'", ",", "'Referer'", ",", "'User-Agent'", "]", "as", "$", "name", ")", "{", "$", "key", "=", "'HTTP_'", ".", "str_replace", "(", "'-'", ",", "'_'", ",", "strtoupper", "(", "$", "name", ")", ")", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "$", "key", "]", ")", ")", "{", "$", "request", "->", "setHeader", "(", "$", "name", ",", "$", "_SERVER", "[", "$", "key", "]", ",", "false", ")", ";", "}", "}", "$", "request", "->", "_isSecure", "=", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "&&", "$", "_SERVER", "[", "'HTTPS'", "]", "!=", "'off'", ")", ";", "$", "request", "->", "_method", "=", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ";", "$", "request", "->", "_uri", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "$", "request", "->", "_path", "=", "strstr", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "'?'", ",", "true", ")", ";", "if", "(", "$", "request", "->", "_path", "==", "false", ")", "{", "$", "request", "->", "_path", "=", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "}", "$", "request", "->", "_query", "=", "strstr", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "'?'", ")", ";", "if", "(", "$", "request", "->", "_query", "==", "false", ")", "{", "$", "request", "->", "_query", "=", "''", ";", "}", "return", "$", "request", ";", "}" ]
Create request from PHP globals.
[ "Create", "request", "from", "PHP", "globals", "." ]
14a875b6c125cfeefe4eb1c3c524500eb8a51d04
https://github.com/goncalomb/asbestos/blob/14a875b6c125cfeefe4eb1c3c524500eb8a51d04/src/classes/Http/Request.php#L61-L90
25,842
offworks/laraquent
src/Support/Exedra/Wizard.php
Wizard.executeMigrate
public function executeMigrate() { $this->app->eloquent->getConnection()->useDefaultSchemaGrammar(); $file = $this->app->path['app']->file($this->app->config->get('db.schema_path', 'database/schema.php')); if(!$file->isExists()) throw new \Exception('['.$file.'] does not exists.'); $file->load(array( 'schema' => new \Laraquent\Schema($this->app->eloquent->getConnection()) )); }
php
public function executeMigrate() { $this->app->eloquent->getConnection()->useDefaultSchemaGrammar(); $file = $this->app->path['app']->file($this->app->config->get('db.schema_path', 'database/schema.php')); if(!$file->isExists()) throw new \Exception('['.$file.'] does not exists.'); $file->load(array( 'schema' => new \Laraquent\Schema($this->app->eloquent->getConnection()) )); }
[ "public", "function", "executeMigrate", "(", ")", "{", "$", "this", "->", "app", "->", "eloquent", "->", "getConnection", "(", ")", "->", "useDefaultSchemaGrammar", "(", ")", ";", "$", "file", "=", "$", "this", "->", "app", "->", "path", "[", "'app'", "]", "->", "file", "(", "$", "this", "->", "app", "->", "config", "->", "get", "(", "'db.schema_path'", ",", "'database/schema.php'", ")", ")", ";", "if", "(", "!", "$", "file", "->", "isExists", "(", ")", ")", "throw", "new", "\\", "Exception", "(", "'['", ".", "$", "file", ".", "'] does not exists.'", ")", ";", "$", "file", "->", "load", "(", "array", "(", "'schema'", "=>", "new", "\\", "Laraquent", "\\", "Schema", "(", "$", "this", "->", "app", "->", "eloquent", "->", "getConnection", "(", ")", ")", ")", ")", ";", "}" ]
Migrate eloquent schema Use db.schema_path config if configured @description Migrate eloquent schema
[ "Migrate", "eloquent", "schema", "Use", "db", ".", "schema_path", "config", "if", "configured" ]
74cbc6258acfda8f7213c701887a7b223aff954f
https://github.com/offworks/laraquent/blob/74cbc6258acfda8f7213c701887a7b223aff954f/src/Support/Exedra/Wizard.php#L13-L25
25,843
staticka/staticka
src/Filter/InlineMinifier.php
InlineMinifier.elements
protected function elements($code) { libxml_use_internal_errors(true); $doc = new \DOMDocument; $doc->loadHTML((string) $code); $tag = (string) $this->tagname; $items = $doc->getElementsByTagName($tag); $items = iterator_to_array($items); return count($items) > 0 ? $items : array(); }
php
protected function elements($code) { libxml_use_internal_errors(true); $doc = new \DOMDocument; $doc->loadHTML((string) $code); $tag = (string) $this->tagname; $items = $doc->getElementsByTagName($tag); $items = iterator_to_array($items); return count($items) > 0 ? $items : array(); }
[ "protected", "function", "elements", "(", "$", "code", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "doc", "=", "new", "\\", "DOMDocument", ";", "$", "doc", "->", "loadHTML", "(", "(", "string", ")", "$", "code", ")", ";", "$", "tag", "=", "(", "string", ")", "$", "this", "->", "tagname", ";", "$", "items", "=", "$", "doc", "->", "getElementsByTagName", "(", "$", "tag", ")", ";", "$", "items", "=", "iterator_to_array", "(", "$", "items", ")", ";", "return", "count", "(", "$", "items", ")", ">", "0", "?", "$", "items", ":", "array", "(", ")", ";", "}" ]
Returns elements by a tag name. @param string $code @return \DOMNodeList
[ "Returns", "elements", "by", "a", "tag", "name", "." ]
6e3b814c391ed03b0bd409803e11579bae677ce4
https://github.com/staticka/staticka/blob/6e3b814c391ed03b0bd409803e11579bae677ce4/src/Filter/InlineMinifier.php#L60-L75
25,844
ZFrapid/zfrapid-library
src/View/Helper/H1.php
H1.toString
public function toString($indent = null) { $output = parent::toString($indent); $output = str_replace( ['<title>', '</title>'], ['<h1>', '</h1>'], $output ); return $output; }
php
public function toString($indent = null) { $output = parent::toString($indent); $output = str_replace( ['<title>', '</title>'], ['<h1>', '</h1>'], $output ); return $output; }
[ "public", "function", "toString", "(", "$", "indent", "=", "null", ")", "{", "$", "output", "=", "parent", "::", "toString", "(", "$", "indent", ")", ";", "$", "output", "=", "str_replace", "(", "[", "'<title>'", ",", "'</title>'", "]", ",", "[", "'<h1>'", ",", "'</h1>'", "]", ",", "$", "output", ")", ";", "return", "$", "output", ";", "}" ]
Turn helper into string @param string|null $indent @return string
[ "Turn", "helper", "into", "string" ]
3eca4f465dd1f2dee889532892c5052e830bc03c
https://github.com/ZFrapid/zfrapid-library/blob/3eca4f465dd1f2dee889532892c5052e830bc03c/src/View/Helper/H1.php#L51-L59
25,845
Vectrex/vxPHP
src/Application/Config.php
Config.dumpXmlErrors
private function dumpXmlErrors($xmlFile) { $severity = [LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal']; $errors = []; foreach(libxml_get_errors() as $error) { $errors[] = sprintf("Row %d, column %d: %s (%d) %s", $error->line, $error->column, $severity[$error->level], $error->code, $error->message); } throw new ConfigException(sprintf("Could not parse XML configuration in '%s'.\n\n%s", $xmlFile, implode("\n", $errors))); }
php
private function dumpXmlErrors($xmlFile) { $severity = [LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal']; $errors = []; foreach(libxml_get_errors() as $error) { $errors[] = sprintf("Row %d, column %d: %s (%d) %s", $error->line, $error->column, $severity[$error->level], $error->code, $error->message); } throw new ConfigException(sprintf("Could not parse XML configuration in '%s'.\n\n%s", $xmlFile, implode("\n", $errors))); }
[ "private", "function", "dumpXmlErrors", "(", "$", "xmlFile", ")", "{", "$", "severity", "=", "[", "LIBXML_ERR_WARNING", "=>", "'Warning'", ",", "LIBXML_ERR_ERROR", "=>", "'Error'", ",", "LIBXML_ERR_FATAL", "=>", "'Fatal'", "]", ";", "$", "errors", "=", "[", "]", ";", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "{", "$", "errors", "[", "]", "=", "sprintf", "(", "\"Row %d, column %d: %s (%d) %s\"", ",", "$", "error", "->", "line", ",", "$", "error", "->", "column", ",", "$", "severity", "[", "$", "error", "->", "level", "]", ",", "$", "error", "->", "code", ",", "$", "error", "->", "message", ")", ";", "}", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"Could not parse XML configuration in '%s'.\\n\\n%s\"", ",", "$", "xmlFile", ",", "implode", "(", "\"\\n\"", ",", "$", "errors", ")", ")", ")", ";", "}" ]
Create formatted output of XML errors @param string $xmlFile @throws ConfigException
[ "Create", "formatted", "output", "of", "XML", "errors" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L173-L184
25,846
Vectrex/vxPHP
src/Application/Config.php
Config.parseDbSettings
private function parseDbSettings(\DOMNode $db) { $context = $this->isLocalhost ? 'local' : 'remote'; $xpath = new \DOMXPath($db->ownerDocument); $d = $xpath->query("db_connection[@context='$context']", $db); if(!$d->length) { $d = $db->getElementsByTagName('db_connection'); } if($d->length) { $this->db = new \stdClass(); foreach($d->item(0)->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } $v = trim($node->nodeValue); $k = $node->nodeName; $this->db->$k = $v; } } }
php
private function parseDbSettings(\DOMNode $db) { $context = $this->isLocalhost ? 'local' : 'remote'; $xpath = new \DOMXPath($db->ownerDocument); $d = $xpath->query("db_connection[@context='$context']", $db); if(!$d->length) { $d = $db->getElementsByTagName('db_connection'); } if($d->length) { $this->db = new \stdClass(); foreach($d->item(0)->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } $v = trim($node->nodeValue); $k = $node->nodeName; $this->db->$k = $v; } } }
[ "private", "function", "parseDbSettings", "(", "\\", "DOMNode", "$", "db", ")", "{", "$", "context", "=", "$", "this", "->", "isLocalhost", "?", "'local'", ":", "'remote'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "db", "->", "ownerDocument", ")", ";", "$", "d", "=", "$", "xpath", "->", "query", "(", "\"db_connection[@context='$context']\"", ",", "$", "db", ")", ";", "if", "(", "!", "$", "d", "->", "length", ")", "{", "$", "d", "=", "$", "db", "->", "getElementsByTagName", "(", "'db_connection'", ")", ";", "}", "if", "(", "$", "d", "->", "length", ")", "{", "$", "this", "->", "db", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "$", "d", "->", "item", "(", "0", ")", "->", "childNodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "nodeType", "!==", "XML_ELEMENT_NODE", ")", "{", "continue", ";", "}", "$", "v", "=", "trim", "(", "$", "node", "->", "nodeValue", ")", ";", "$", "k", "=", "$", "node", "->", "nodeName", ";", "$", "this", "->", "db", "->", "$", "k", "=", "$", "v", ";", "}", "}", "}" ]
parse db settings @deprecated will be replaced by datasource settings @param DOMNode $db
[ "parse", "db", "settings" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L335-L363
25,847
Vectrex/vxPHP
src/Application/Config.php
Config.parseVxpdoSettings
private function parseVxpdoSettings(\DOMNode $vxpdo) { if(is_null($this->vxpdo)) { $this->vxpdo = []; } foreach($vxpdo->getElementsByTagName('datasource') as $datasource) { $name = $datasource->getAttribute('name') ?: 'default'; if(array_key_exists($name, $this->vxpdo)) { throw new ConfigException(sprintf("Datasource '%s' declared twice.", $name)); } $config = [ 'driver' => null, 'dsn' => null, 'host' => null, 'port' => null, 'user' => null, 'password' => null, 'dbname' => null, ]; foreach($datasource->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } if(array_key_exists($node->nodeName, $config)) { $config[$node->nodeName] = trim($node->nodeValue); } } $this->vxpdo[$name] = (object) $config; } }
php
private function parseVxpdoSettings(\DOMNode $vxpdo) { if(is_null($this->vxpdo)) { $this->vxpdo = []; } foreach($vxpdo->getElementsByTagName('datasource') as $datasource) { $name = $datasource->getAttribute('name') ?: 'default'; if(array_key_exists($name, $this->vxpdo)) { throw new ConfigException(sprintf("Datasource '%s' declared twice.", $name)); } $config = [ 'driver' => null, 'dsn' => null, 'host' => null, 'port' => null, 'user' => null, 'password' => null, 'dbname' => null, ]; foreach($datasource->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } if(array_key_exists($node->nodeName, $config)) { $config[$node->nodeName] = trim($node->nodeValue); } } $this->vxpdo[$name] = (object) $config; } }
[ "private", "function", "parseVxpdoSettings", "(", "\\", "DOMNode", "$", "vxpdo", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "vxpdo", ")", ")", "{", "$", "this", "->", "vxpdo", "=", "[", "]", ";", "}", "foreach", "(", "$", "vxpdo", "->", "getElementsByTagName", "(", "'datasource'", ")", "as", "$", "datasource", ")", "{", "$", "name", "=", "$", "datasource", "->", "getAttribute", "(", "'name'", ")", "?", ":", "'default'", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "vxpdo", ")", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"Datasource '%s' declared twice.\"", ",", "$", "name", ")", ")", ";", "}", "$", "config", "=", "[", "'driver'", "=>", "null", ",", "'dsn'", "=>", "null", ",", "'host'", "=>", "null", ",", "'port'", "=>", "null", ",", "'user'", "=>", "null", ",", "'password'", "=>", "null", ",", "'dbname'", "=>", "null", ",", "]", ";", "foreach", "(", "$", "datasource", "->", "childNodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "nodeType", "!==", "XML_ELEMENT_NODE", ")", "{", "continue", ";", "}", "if", "(", "array_key_exists", "(", "$", "node", "->", "nodeName", ",", "$", "config", ")", ")", "{", "$", "config", "[", "$", "node", "->", "nodeName", "]", "=", "trim", "(", "$", "node", "->", "nodeValue", ")", ";", "}", "}", "$", "this", "->", "vxpdo", "[", "$", "name", "]", "=", "(", "object", ")", "$", "config", ";", "}", "}" ]
parse datasource settings @param \DOMNode $datasources @throws ConfigException
[ "parse", "datasource", "settings" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L371-L410
25,848
Vectrex/vxPHP
src/Application/Config.php
Config.parseSiteSettings
private function parseSiteSettings(\DOMNode $site) { if(is_null($this->site)) { $this->site = new \stdClass; $this->site->use_nice_uris = FALSE; } foreach($site->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } $v = trim($node->nodeValue); $k = $node->nodeName; switch ($k) { case 'locales': if(!isset($this->site->locales)) { $this->site->locales = []; } foreach($node->getElementsByTagName('locale') as $locale) { $loc = $locale->getAttribute('value'); if($loc && !in_array($loc, $this->site->locales)) { $this->site->locales[] = $loc; } if($loc && $locale->getAttribute('default') === '1') { $this->site->default_locale = $loc; } } break; case 'site->use_nice_uris': if($v === '1') { $this->site->use_nice_uris = TRUE; } break; default: $this->site->$k = $v; } } }
php
private function parseSiteSettings(\DOMNode $site) { if(is_null($this->site)) { $this->site = new \stdClass; $this->site->use_nice_uris = FALSE; } foreach($site->childNodes as $node) { if($node->nodeType !== XML_ELEMENT_NODE) { continue; } $v = trim($node->nodeValue); $k = $node->nodeName; switch ($k) { case 'locales': if(!isset($this->site->locales)) { $this->site->locales = []; } foreach($node->getElementsByTagName('locale') as $locale) { $loc = $locale->getAttribute('value'); if($loc && !in_array($loc, $this->site->locales)) { $this->site->locales[] = $loc; } if($loc && $locale->getAttribute('default') === '1') { $this->site->default_locale = $loc; } } break; case 'site->use_nice_uris': if($v === '1') { $this->site->use_nice_uris = TRUE; } break; default: $this->site->$k = $v; } } }
[ "private", "function", "parseSiteSettings", "(", "\\", "DOMNode", "$", "site", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "site", ")", ")", "{", "$", "this", "->", "site", "=", "new", "\\", "stdClass", ";", "$", "this", "->", "site", "->", "use_nice_uris", "=", "FALSE", ";", "}", "foreach", "(", "$", "site", "->", "childNodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "nodeType", "!==", "XML_ELEMENT_NODE", ")", "{", "continue", ";", "}", "$", "v", "=", "trim", "(", "$", "node", "->", "nodeValue", ")", ";", "$", "k", "=", "$", "node", "->", "nodeName", ";", "switch", "(", "$", "k", ")", "{", "case", "'locales'", ":", "if", "(", "!", "isset", "(", "$", "this", "->", "site", "->", "locales", ")", ")", "{", "$", "this", "->", "site", "->", "locales", "=", "[", "]", ";", "}", "foreach", "(", "$", "node", "->", "getElementsByTagName", "(", "'locale'", ")", "as", "$", "locale", ")", "{", "$", "loc", "=", "$", "locale", "->", "getAttribute", "(", "'value'", ")", ";", "if", "(", "$", "loc", "&&", "!", "in_array", "(", "$", "loc", ",", "$", "this", "->", "site", "->", "locales", ")", ")", "{", "$", "this", "->", "site", "->", "locales", "[", "]", "=", "$", "loc", ";", "}", "if", "(", "$", "loc", "&&", "$", "locale", "->", "getAttribute", "(", "'default'", ")", "===", "'1'", ")", "{", "$", "this", "->", "site", "->", "default_locale", "=", "$", "loc", ";", "}", "}", "break", ";", "case", "'site->use_nice_uris'", ":", "if", "(", "$", "v", "===", "'1'", ")", "{", "$", "this", "->", "site", "->", "use_nice_uris", "=", "TRUE", ";", "}", "break", ";", "default", ":", "$", "this", "->", "site", "->", "$", "k", "=", "$", "v", ";", "}", "}", "}" ]
parse general website settings @param \DOMNode $site
[ "parse", "general", "website", "settings" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L511-L560
25,849
Vectrex/vxPHP
src/Application/Config.php
Config.parseTemplatingSettings
private function parseTemplatingSettings(\DOMNode $templating) { if(is_null($this->templating)) { $this->templating = new \stdClass; $this->templating->filters = []; } $xpath = new \DOMXPath($templating->ownerDocument); foreach($xpath->query("filters/filter", $templating) as $filter) { $id = $filter->getAttribute('id'); $class = $filter->getAttribute('class'); if(!$id) { throw new ConfigException('Templating filter without id found.'); } if(!$class) { throw new ConfigException(sprintf("No class for templating filter '%s' configured.", $id)); } if(isset($this->templating->filters[$id])) { throw new ConfigException(sprintf("Templating filter '%s' has already been defined.", $id)); } // clean path delimiters, prepend leading backslash, and replace slashes with backslashes $class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\'); // store parsed information $this->templating->filters[$id] = [ 'class' => $class, 'parameters' => $filter->getAttribute('parameters') ]; } }
php
private function parseTemplatingSettings(\DOMNode $templating) { if(is_null($this->templating)) { $this->templating = new \stdClass; $this->templating->filters = []; } $xpath = new \DOMXPath($templating->ownerDocument); foreach($xpath->query("filters/filter", $templating) as $filter) { $id = $filter->getAttribute('id'); $class = $filter->getAttribute('class'); if(!$id) { throw new ConfigException('Templating filter without id found.'); } if(!$class) { throw new ConfigException(sprintf("No class for templating filter '%s' configured.", $id)); } if(isset($this->templating->filters[$id])) { throw new ConfigException(sprintf("Templating filter '%s' has already been defined.", $id)); } // clean path delimiters, prepend leading backslash, and replace slashes with backslashes $class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\'); // store parsed information $this->templating->filters[$id] = [ 'class' => $class, 'parameters' => $filter->getAttribute('parameters') ]; } }
[ "private", "function", "parseTemplatingSettings", "(", "\\", "DOMNode", "$", "templating", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "templating", ")", ")", "{", "$", "this", "->", "templating", "=", "new", "\\", "stdClass", ";", "$", "this", "->", "templating", "->", "filters", "=", "[", "]", ";", "}", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "templating", "->", "ownerDocument", ")", ";", "foreach", "(", "$", "xpath", "->", "query", "(", "\"filters/filter\"", ",", "$", "templating", ")", "as", "$", "filter", ")", "{", "$", "id", "=", "$", "filter", "->", "getAttribute", "(", "'id'", ")", ";", "$", "class", "=", "$", "filter", "->", "getAttribute", "(", "'class'", ")", ";", "if", "(", "!", "$", "id", ")", "{", "throw", "new", "ConfigException", "(", "'Templating filter without id found.'", ")", ";", "}", "if", "(", "!", "$", "class", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"No class for templating filter '%s' configured.\"", ",", "$", "id", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "templating", "->", "filters", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"Templating filter '%s' has already been defined.\"", ",", "$", "id", ")", ")", ";", "}", "// clean path delimiters, prepend leading backslash, and replace slashes with backslashes", "$", "class", "=", "'\\\\'", ".", "ltrim", "(", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "class", ")", ",", "'/\\\\'", ")", ";", "// store parsed information", "$", "this", "->", "templating", "->", "filters", "[", "$", "id", "]", "=", "[", "'class'", "=>", "$", "class", ",", "'parameters'", "=>", "$", "filter", "->", "getAttribute", "(", "'parameters'", ")", "]", ";", "}", "}" ]
parse templating configuration currently only filters for SimpleTemplate templates and their configuration are parsed @param \DOMNode $templating
[ "parse", "templating", "configuration", "currently", "only", "filters", "for", "SimpleTemplate", "templates", "and", "their", "configuration", "are", "parsed" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L568-L607
25,850
Vectrex/vxPHP
src/Application/Config.php
Config.parsePathsSettings
private function parsePathsSettings(\DOMNode $paths) { if(is_null($this->paths)) { $this->paths = []; } foreach($paths->getElementsByTagName('path') as $path) { $id = $path->getAttribute('id'); $subdir = $path->getAttribute('subdir') ?: ''; if(!$id || !$subdir) { continue; } $subdir = '/' . trim($subdir, '/') . '/'; // additional attributes are currently ignored $this->paths[$id] = ['subdir' => $subdir]; } }
php
private function parsePathsSettings(\DOMNode $paths) { if(is_null($this->paths)) { $this->paths = []; } foreach($paths->getElementsByTagName('path') as $path) { $id = $path->getAttribute('id'); $subdir = $path->getAttribute('subdir') ?: ''; if(!$id || !$subdir) { continue; } $subdir = '/' . trim($subdir, '/') . '/'; // additional attributes are currently ignored $this->paths[$id] = ['subdir' => $subdir]; } }
[ "private", "function", "parsePathsSettings", "(", "\\", "DOMNode", "$", "paths", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "paths", ")", ")", "{", "$", "this", "->", "paths", "=", "[", "]", ";", "}", "foreach", "(", "$", "paths", "->", "getElementsByTagName", "(", "'path'", ")", "as", "$", "path", ")", "{", "$", "id", "=", "$", "path", "->", "getAttribute", "(", "'id'", ")", ";", "$", "subdir", "=", "$", "path", "->", "getAttribute", "(", "'subdir'", ")", "?", ":", "''", ";", "if", "(", "!", "$", "id", "||", "!", "$", "subdir", ")", "{", "continue", ";", "}", "$", "subdir", "=", "'/'", ".", "trim", "(", "$", "subdir", ",", "'/'", ")", ".", "'/'", ";", "// additional attributes are currently ignored", "$", "this", "->", "paths", "[", "$", "id", "]", "=", "[", "'subdir'", "=>", "$", "subdir", "]", ";", "}", "}" ]
parse various path setting @param \DOMNode $paths
[ "parse", "various", "path", "setting" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L614-L637
25,851
Vectrex/vxPHP
src/Application/Config.php
Config.parseMenusSettings
private function parseMenusSettings(\DOMNode $menus) { foreach ((new \DOMXPath($menus->ownerDocument))->query('menu', $menus) as $menu) { $id = $menu->getAttribute('id') ?: Menu::DEFAULT_ID; if(isset($this->menus[$id])) { $this->appendMenuEntries($menu->childNodes, $this->menus[$id]); } else { $this->menus[$id] = $this->parseMenu($menu); } } }
php
private function parseMenusSettings(\DOMNode $menus) { foreach ((new \DOMXPath($menus->ownerDocument))->query('menu', $menus) as $menu) { $id = $menu->getAttribute('id') ?: Menu::DEFAULT_ID; if(isset($this->menus[$id])) { $this->appendMenuEntries($menu->childNodes, $this->menus[$id]); } else { $this->menus[$id] = $this->parseMenu($menu); } } }
[ "private", "function", "parseMenusSettings", "(", "\\", "DOMNode", "$", "menus", ")", "{", "foreach", "(", "(", "new", "\\", "DOMXPath", "(", "$", "menus", "->", "ownerDocument", ")", ")", "->", "query", "(", "'menu'", ",", "$", "menus", ")", "as", "$", "menu", ")", "{", "$", "id", "=", "$", "menu", "->", "getAttribute", "(", "'id'", ")", "?", ":", "Menu", "::", "DEFAULT_ID", ";", "if", "(", "isset", "(", "$", "this", "->", "menus", "[", "$", "id", "]", ")", ")", "{", "$", "this", "->", "appendMenuEntries", "(", "$", "menu", "->", "childNodes", ",", "$", "this", "->", "menus", "[", "$", "id", "]", ")", ";", "}", "else", "{", "$", "this", "->", "menus", "[", "$", "id", "]", "=", "$", "this", "->", "parseMenu", "(", "$", "menu", ")", ";", "}", "}", "}" ]
parse menu tree if menus share the same id entries of later menus are appended to the first; other menu attributes are left unchanged @param \DOMNode $menus @throws ConfigException
[ "parse", "menu", "tree", "if", "menus", "share", "the", "same", "id", "entries", "of", "later", "menus", "are", "appended", "to", "the", "first", ";", "other", "menu", "attributes", "are", "left", "unchanged" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L814-L829
25,852
Vectrex/vxPHP
src/Application/Config.php
Config.parseServicesSettings
private function parseServicesSettings(\DOMNode $services) { if(is_null($this->services)) { $this->services = []; } foreach($services->getElementsByTagName('service') as $service) { if(!($id = $service->getAttribute('id'))) { throw new ConfigException('Service without id found.'); } if(isset($this->services[$id])) { throw new ConfigException(sprintf("Service '%s' has already been defined.", $id)); } if(!($class = $service->getAttribute('class'))) { throw new ConfigException(sprintf("No class for service '%s' configured.", $id)); } // clean path delimiters, prepend leading backslash, and replace slashes with backslashes $class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\'); // store parsed information $this->services[$id] = [ 'class' => $class, 'parameters' => [] ]; foreach($service->getElementsByTagName('parameter') as $parameter) { $name = $parameter->getAttribute('name'); $value = $parameter->getAttribute('value'); if(!$name) { throw new ConfigException(sprintf("A parameter for service '%s' has no name.", $id)); } $this->services[$id]['parameters'][$name] = $value; } } }
php
private function parseServicesSettings(\DOMNode $services) { if(is_null($this->services)) { $this->services = []; } foreach($services->getElementsByTagName('service') as $service) { if(!($id = $service->getAttribute('id'))) { throw new ConfigException('Service without id found.'); } if(isset($this->services[$id])) { throw new ConfigException(sprintf("Service '%s' has already been defined.", $id)); } if(!($class = $service->getAttribute('class'))) { throw new ConfigException(sprintf("No class for service '%s' configured.", $id)); } // clean path delimiters, prepend leading backslash, and replace slashes with backslashes $class = '\\' . ltrim(str_replace('/', '\\', $class), '/\\'); // store parsed information $this->services[$id] = [ 'class' => $class, 'parameters' => [] ]; foreach($service->getElementsByTagName('parameter') as $parameter) { $name = $parameter->getAttribute('name'); $value = $parameter->getAttribute('value'); if(!$name) { throw new ConfigException(sprintf("A parameter for service '%s' has no name.", $id)); } $this->services[$id]['parameters'][$name] = $value; } } }
[ "private", "function", "parseServicesSettings", "(", "\\", "DOMNode", "$", "services", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "services", ")", ")", "{", "$", "this", "->", "services", "=", "[", "]", ";", "}", "foreach", "(", "$", "services", "->", "getElementsByTagName", "(", "'service'", ")", "as", "$", "service", ")", "{", "if", "(", "!", "(", "$", "id", "=", "$", "service", "->", "getAttribute", "(", "'id'", ")", ")", ")", "{", "throw", "new", "ConfigException", "(", "'Service without id found.'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "services", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"Service '%s' has already been defined.\"", ",", "$", "id", ")", ")", ";", "}", "if", "(", "!", "(", "$", "class", "=", "$", "service", "->", "getAttribute", "(", "'class'", ")", ")", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"No class for service '%s' configured.\"", ",", "$", "id", ")", ")", ";", "}", "// clean path delimiters, prepend leading backslash, and replace slashes with backslashes", "$", "class", "=", "'\\\\'", ".", "ltrim", "(", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "class", ")", ",", "'/\\\\'", ")", ";", "// store parsed information", "$", "this", "->", "services", "[", "$", "id", "]", "=", "[", "'class'", "=>", "$", "class", ",", "'parameters'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "service", "->", "getElementsByTagName", "(", "'parameter'", ")", "as", "$", "parameter", ")", "{", "$", "name", "=", "$", "parameter", "->", "getAttribute", "(", "'name'", ")", ";", "$", "value", "=", "$", "parameter", "->", "getAttribute", "(", "'value'", ")", ";", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "ConfigException", "(", "sprintf", "(", "\"A parameter for service '%s' has no name.\"", ",", "$", "id", ")", ")", ";", "}", "$", "this", "->", "services", "[", "$", "id", "]", "[", "'parameters'", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}" ]
parse settings for services only service id, class and parameters are parsed lazy initialization is handled by Application instance @param \DOMNode $services @throws ConfigException
[ "parse", "settings", "for", "services", "only", "service", "id", "class", "and", "parameters", "are", "parsed", "lazy", "initialization", "is", "handled", "by", "Application", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L839-L885
25,853
Vectrex/vxPHP
src/Application/Config.php
Config.parseMenu
private function parseMenu(\DOMNode $menu) { $root = $menu->getAttribute('script'); if(!$root) { if($this->site) { $root= $this->site->root_document ?: 'index.php'; } else { $root= 'index.php'; } } $type = $menu->getAttribute('type') === 'dynamic' ? 'dynamic' : 'static'; $service = $menu->getAttribute('service') ?: NULL; $id = $menu->getAttribute('id') ?: NULL; if($type === 'dynamic' && !$service) { throw new ConfigException("A dynamic menu requires a configured service."); } $m = new Menu( $root, $id, $type, $service ); if(($menuAuth = strtolower(trim($menu->getAttribute('auth'))))) { $m->setAuth($menuAuth); // if an auth level is defined, additional authentication parameters can be set if(($authParameters = $menu->getAttribute('auth_parameters'))) { $m->setAuthParameters($authParameters); } } $this->appendMenuEntries($menu->childNodes, $m); return $m; }
php
private function parseMenu(\DOMNode $menu) { $root = $menu->getAttribute('script'); if(!$root) { if($this->site) { $root= $this->site->root_document ?: 'index.php'; } else { $root= 'index.php'; } } $type = $menu->getAttribute('type') === 'dynamic' ? 'dynamic' : 'static'; $service = $menu->getAttribute('service') ?: NULL; $id = $menu->getAttribute('id') ?: NULL; if($type === 'dynamic' && !$service) { throw new ConfigException("A dynamic menu requires a configured service."); } $m = new Menu( $root, $id, $type, $service ); if(($menuAuth = strtolower(trim($menu->getAttribute('auth'))))) { $m->setAuth($menuAuth); // if an auth level is defined, additional authentication parameters can be set if(($authParameters = $menu->getAttribute('auth_parameters'))) { $m->setAuthParameters($authParameters); } } $this->appendMenuEntries($menu->childNodes, $m); return $m; }
[ "private", "function", "parseMenu", "(", "\\", "DOMNode", "$", "menu", ")", "{", "$", "root", "=", "$", "menu", "->", "getAttribute", "(", "'script'", ")", ";", "if", "(", "!", "$", "root", ")", "{", "if", "(", "$", "this", "->", "site", ")", "{", "$", "root", "=", "$", "this", "->", "site", "->", "root_document", "?", ":", "'index.php'", ";", "}", "else", "{", "$", "root", "=", "'index.php'", ";", "}", "}", "$", "type", "=", "$", "menu", "->", "getAttribute", "(", "'type'", ")", "===", "'dynamic'", "?", "'dynamic'", ":", "'static'", ";", "$", "service", "=", "$", "menu", "->", "getAttribute", "(", "'service'", ")", "?", ":", "NULL", ";", "$", "id", "=", "$", "menu", "->", "getAttribute", "(", "'id'", ")", "?", ":", "NULL", ";", "if", "(", "$", "type", "===", "'dynamic'", "&&", "!", "$", "service", ")", "{", "throw", "new", "ConfigException", "(", "\"A dynamic menu requires a configured service.\"", ")", ";", "}", "$", "m", "=", "new", "Menu", "(", "$", "root", ",", "$", "id", ",", "$", "type", ",", "$", "service", ")", ";", "if", "(", "(", "$", "menuAuth", "=", "strtolower", "(", "trim", "(", "$", "menu", "->", "getAttribute", "(", "'auth'", ")", ")", ")", ")", ")", "{", "$", "m", "->", "setAuth", "(", "$", "menuAuth", ")", ";", "// if an auth level is defined, additional authentication parameters can be set", "if", "(", "(", "$", "authParameters", "=", "$", "menu", "->", "getAttribute", "(", "'auth_parameters'", ")", ")", ")", "{", "$", "m", "->", "setAuthParameters", "(", "$", "authParameters", ")", ";", "}", "}", "$", "this", "->", "appendMenuEntries", "(", "$", "menu", "->", "childNodes", ",", "$", "m", ")", ";", "return", "$", "m", ";", "}" ]
Parse XML menu entries and creates menu instance @param \DOMNode $menu @return Menu @throws ConfigException
[ "Parse", "XML", "menu", "entries", "and", "creates", "menu", "instance" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L950-L994
25,854
Vectrex/vxPHP
src/Application/Config.php
Config.createConst
public function createConst() { $properties = get_object_vars($this); if(isset($properties['db'])) { foreach($properties['db'] as $k => $v) { if(is_scalar($v)) { $k = strtoupper($k); if(!defined("DB$k")) { define("DB$k", $v); } } } } if(isset($properties['site'])) { foreach($properties['site'] as $k => $v) { if(is_scalar($v)) { $k = strtoupper($k); if(!defined($k)) { define($k, $v); } } } } if(isset($properties['paths'])) { foreach($properties['paths'] as $k => $v) { $k = strtoupper($k); if(!defined($k)) { define($k, $v['subdir']); } } } $locale = localeconv(); foreach($locale as $k => $v) { $k = strtoupper($k); if(!defined($k) && !is_array($v)) { define($k, $v); } } }
php
public function createConst() { $properties = get_object_vars($this); if(isset($properties['db'])) { foreach($properties['db'] as $k => $v) { if(is_scalar($v)) { $k = strtoupper($k); if(!defined("DB$k")) { define("DB$k", $v); } } } } if(isset($properties['site'])) { foreach($properties['site'] as $k => $v) { if(is_scalar($v)) { $k = strtoupper($k); if(!defined($k)) { define($k, $v); } } } } if(isset($properties['paths'])) { foreach($properties['paths'] as $k => $v) { $k = strtoupper($k); if(!defined($k)) { define($k, $v['subdir']); } } } $locale = localeconv(); foreach($locale as $k => $v) { $k = strtoupper($k); if(!defined($k) && !is_array($v)) { define($k, $v); } } }
[ "public", "function", "createConst", "(", ")", "{", "$", "properties", "=", "get_object_vars", "(", "$", "this", ")", ";", "if", "(", "isset", "(", "$", "properties", "[", "'db'", "]", ")", ")", "{", "foreach", "(", "$", "properties", "[", "'db'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_scalar", "(", "$", "v", ")", ")", "{", "$", "k", "=", "strtoupper", "(", "$", "k", ")", ";", "if", "(", "!", "defined", "(", "\"DB$k\"", ")", ")", "{", "define", "(", "\"DB$k\"", ",", "$", "v", ")", ";", "}", "}", "}", "}", "if", "(", "isset", "(", "$", "properties", "[", "'site'", "]", ")", ")", "{", "foreach", "(", "$", "properties", "[", "'site'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_scalar", "(", "$", "v", ")", ")", "{", "$", "k", "=", "strtoupper", "(", "$", "k", ")", ";", "if", "(", "!", "defined", "(", "$", "k", ")", ")", "{", "define", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "}", "}", "if", "(", "isset", "(", "$", "properties", "[", "'paths'", "]", ")", ")", "{", "foreach", "(", "$", "properties", "[", "'paths'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "k", "=", "strtoupper", "(", "$", "k", ")", ";", "if", "(", "!", "defined", "(", "$", "k", ")", ")", "{", "define", "(", "$", "k", ",", "$", "v", "[", "'subdir'", "]", ")", ";", "}", "}", "}", "$", "locale", "=", "localeconv", "(", ")", ";", "foreach", "(", "$", "locale", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "k", "=", "strtoupper", "(", "$", "k", ")", ";", "if", "(", "!", "defined", "(", "$", "k", ")", "&&", "!", "is_array", "(", "$", "v", ")", ")", "{", "define", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "}" ]
create constants for simple access to certain configuration settings
[ "create", "constants", "for", "simple", "access", "to", "certain", "configuration", "settings" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L1105-L1140
25,855
Vectrex/vxPHP
src/Application/Config.php
Config.getPaths
public function getPaths($access = 'rw') { $paths = []; foreach($this->paths as $p) { if($p['access'] === $access) { array_push($paths, $p); } } return $paths; }
php
public function getPaths($access = 'rw') { $paths = []; foreach($this->paths as $p) { if($p['access'] === $access) { array_push($paths, $p); } } return $paths; }
[ "public", "function", "getPaths", "(", "$", "access", "=", "'rw'", ")", "{", "$", "paths", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "paths", "as", "$", "p", ")", "{", "if", "(", "$", "p", "[", "'access'", "]", "===", "$", "access", ")", "{", "array_push", "(", "$", "paths", ",", "$", "p", ")", ";", "}", "}", "return", "$", "paths", ";", "}" ]
returns all paths matching access criteria @param string $access @return paths
[ "returns", "all", "paths", "matching", "access", "criteria" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L1148-L1156
25,856
Vectrex/vxPHP
src/Application/Config.php
Config.getServerConfig
private function getServerConfig() { $this->server['apc_on'] = extension_loaded('apc') && function_exists('apc_add') && ini_get('apc.enabled') && ini_get('apc.rfc1867'); $fs = ini_get('upload_max_filesize'); $suffix = strtoupper(substr($fs, -1)); switch($suffix) { case 'K': $mult = 1024; break; case 'M': $mult = 1024*1024; break; case 'G': $mult = 1024*1024*1024; break; default: $mult = 0; } $this->server['max_upload_filesize'] = $mult ? (float) (substr($fs, 0, -1)) * $mult : (int) $fs; }
php
private function getServerConfig() { $this->server['apc_on'] = extension_loaded('apc') && function_exists('apc_add') && ini_get('apc.enabled') && ini_get('apc.rfc1867'); $fs = ini_get('upload_max_filesize'); $suffix = strtoupper(substr($fs, -1)); switch($suffix) { case 'K': $mult = 1024; break; case 'M': $mult = 1024*1024; break; case 'G': $mult = 1024*1024*1024; break; default: $mult = 0; } $this->server['max_upload_filesize'] = $mult ? (float) (substr($fs, 0, -1)) * $mult : (int) $fs; }
[ "private", "function", "getServerConfig", "(", ")", "{", "$", "this", "->", "server", "[", "'apc_on'", "]", "=", "extension_loaded", "(", "'apc'", ")", "&&", "function_exists", "(", "'apc_add'", ")", "&&", "ini_get", "(", "'apc.enabled'", ")", "&&", "ini_get", "(", "'apc.rfc1867'", ")", ";", "$", "fs", "=", "ini_get", "(", "'upload_max_filesize'", ")", ";", "$", "suffix", "=", "strtoupper", "(", "substr", "(", "$", "fs", ",", "-", "1", ")", ")", ";", "switch", "(", "$", "suffix", ")", "{", "case", "'K'", ":", "$", "mult", "=", "1024", ";", "break", ";", "case", "'M'", ":", "$", "mult", "=", "1024", "*", "1024", ";", "break", ";", "case", "'G'", ":", "$", "mult", "=", "1024", "*", "1024", "*", "1024", ";", "break", ";", "default", ":", "$", "mult", "=", "0", ";", "}", "$", "this", "->", "server", "[", "'max_upload_filesize'", "]", "=", "$", "mult", "?", "(", "float", ")", "(", "substr", "(", "$", "fs", ",", "0", ",", "-", "1", ")", ")", "*", "$", "mult", ":", "(", "int", ")", "$", "fs", ";", "}" ]
add particular information regarding server configuration, like PHP extensions
[ "add", "particular", "information", "regarding", "server", "configuration", "like", "PHP", "extensions" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Application/Config.php#L1161-L1180
25,857
Raphhh/puppy-application
src/Application.php
Application.run
public function run() { $request = $this->getService('requestStack')->getMasterRequest(); $this->getPreProcesses()->execute($request); $response = $this->getFrontController()->call($request); $this->getPostProcesses()->execute($response); $response->send(); }
php
public function run() { $request = $this->getService('requestStack')->getMasterRequest(); $this->getPreProcesses()->execute($request); $response = $this->getFrontController()->call($request); $this->getPostProcesses()->execute($response); $response->send(); }
[ "public", "function", "run", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getService", "(", "'requestStack'", ")", "->", "getMasterRequest", "(", ")", ";", "$", "this", "->", "getPreProcesses", "(", ")", "->", "execute", "(", "$", "request", ")", ";", "$", "response", "=", "$", "this", "->", "getFrontController", "(", ")", "->", "call", "(", "$", "request", ")", ";", "$", "this", "->", "getPostProcesses", "(", ")", "->", "execute", "(", "$", "response", ")", ";", "$", "response", "->", "send", "(", ")", ";", "}" ]
Sends the http response
[ "Sends", "the", "http", "response" ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L62-L69
25,858
Raphhh/puppy-application
src/Application.php
Application.initModules
public function initModules(IModulesLoader $modulesLoader) { foreach ($modulesLoader->getModules() as $module) { $this->addModule($module); } }
php
public function initModules(IModulesLoader $modulesLoader) { foreach ($modulesLoader->getModules() as $module) { $this->addModule($module); } }
[ "public", "function", "initModules", "(", "IModulesLoader", "$", "modulesLoader", ")", "{", "foreach", "(", "$", "modulesLoader", "->", "getModules", "(", ")", "as", "$", "module", ")", "{", "$", "this", "->", "addModule", "(", "$", "module", ")", ";", "}", "}" ]
Init the modules of the current project. @param IModulesLoader $modulesLoader
[ "Init", "the", "modules", "of", "the", "current", "project", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L76-L81
25,859
Raphhh/puppy-application
src/Application.php
Application.get
public function get($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, 'get')->getPattern() ); }
php
public function get($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, 'get')->getPattern() ); }
[ "public", "function", "get", "(", "$", "uriPattern", ",", "callable", "$", "controller", ")", "{", "return", "new", "IRoutePatternSetterAdapter", "(", "$", "this", "->", "getFrontController", "(", ")", "->", "addController", "(", "$", "uriPattern", ",", "$", "controller", ",", "'get'", ")", "->", "getPattern", "(", ")", ")", ";", "}" ]
Adds a controller called by http GET method. @param string $uriPattern @param callable $controller @return IRoutePatternSetter
[ "Adds", "a", "controller", "called", "by", "http", "GET", "method", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L101-L106
25,860
Raphhh/puppy-application
src/Application.php
Application.post
public function post($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, 'post')->getPattern() ); }
php
public function post($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, 'post')->getPattern() ); }
[ "public", "function", "post", "(", "$", "uriPattern", ",", "callable", "$", "controller", ")", "{", "return", "new", "IRoutePatternSetterAdapter", "(", "$", "this", "->", "getFrontController", "(", ")", "->", "addController", "(", "$", "uriPattern", ",", "$", "controller", ",", "'post'", ")", "->", "getPattern", "(", ")", ")", ";", "}" ]
Adds a controller called by http POST method. @param string $uriPattern @param callable $controller @return IRoutePatternSetter
[ "Adds", "a", "controller", "called", "by", "http", "POST", "method", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L115-L120
25,861
Raphhh/puppy-application
src/Application.php
Application.json
public function json($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, '', 'application/json')->getPattern() ); }
php
public function json($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller, '', 'application/json')->getPattern() ); }
[ "public", "function", "json", "(", "$", "uriPattern", ",", "callable", "$", "controller", ")", "{", "return", "new", "IRoutePatternSetterAdapter", "(", "$", "this", "->", "getFrontController", "(", ")", "->", "addController", "(", "$", "uriPattern", ",", "$", "controller", ",", "''", ",", "'application/json'", ")", "->", "getPattern", "(", ")", ")", ";", "}" ]
Adds a controller with a json format. @param string $uriPattern @param callable $controller @return IRoutePatternSetter
[ "Adds", "a", "controller", "with", "a", "json", "format", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L129-L134
25,862
Raphhh/puppy-application
src/Application.php
Application.any
public function any($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller)->getPattern() ); }
php
public function any($uriPattern, callable $controller) { return new IRoutePatternSetterAdapter( $this->getFrontController()->addController($uriPattern, $controller)->getPattern() ); }
[ "public", "function", "any", "(", "$", "uriPattern", ",", "callable", "$", "controller", ")", "{", "return", "new", "IRoutePatternSetterAdapter", "(", "$", "this", "->", "getFrontController", "(", ")", "->", "addController", "(", "$", "uriPattern", ",", "$", "controller", ")", "->", "getPattern", "(", ")", ")", ";", "}" ]
Adds a controller called by any http method or format. @param string $uriPattern @param callable $controller @return IRoutePatternSetter
[ "Adds", "a", "controller", "called", "by", "any", "http", "method", "or", "format", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L143-L148
25,863
Raphhh/puppy-application
src/Application.php
Application.filter
public function filter(callable $filter, callable $controller) { $pattern = $this->getFrontController()->addController(':all', $controller)->getPattern(); $pattern->addFilter($filter); return new IRoutePatternSetterAdapter($pattern); }
php
public function filter(callable $filter, callable $controller) { $pattern = $this->getFrontController()->addController(':all', $controller)->getPattern(); $pattern->addFilter($filter); return new IRoutePatternSetterAdapter($pattern); }
[ "public", "function", "filter", "(", "callable", "$", "filter", ",", "callable", "$", "controller", ")", "{", "$", "pattern", "=", "$", "this", "->", "getFrontController", "(", ")", "->", "addController", "(", "':all'", ",", "$", "controller", ")", "->", "getPattern", "(", ")", ";", "$", "pattern", "->", "addFilter", "(", "$", "filter", ")", ";", "return", "new", "IRoutePatternSetterAdapter", "(", "$", "pattern", ")", ";", "}" ]
Adds a controller with a special filter. This filter receive the current Request as first param. @param callable $filter @param callable $controller @return IRoutePatternSetter
[ "Adds", "a", "controller", "with", "a", "special", "filter", ".", "This", "filter", "receive", "the", "current", "Request", "as", "first", "param", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L158-L163
25,864
Raphhh/puppy-application
src/Application.php
Application.mirror
public function mirror($uriPattern, $mirror) { return $this->any( $uriPattern, function (AppController $appController, array $args) use ($mirror) { return $appController->call($mirror, $args); } ); }
php
public function mirror($uriPattern, $mirror) { return $this->any( $uriPattern, function (AppController $appController, array $args) use ($mirror) { return $appController->call($mirror, $args); } ); }
[ "public", "function", "mirror", "(", "$", "uriPattern", ",", "$", "mirror", ")", "{", "return", "$", "this", "->", "any", "(", "$", "uriPattern", ",", "function", "(", "AppController", "$", "appController", ",", "array", "$", "args", ")", "use", "(", "$", "mirror", ")", "{", "return", "$", "appController", "->", "call", "(", "$", "mirror", ",", "$", "args", ")", ";", "}", ")", ";", "}" ]
Adds a mirror of a route. @param string $uriPattern @param string $mirror @return IRoutePatternSetterAdapter
[ "Adds", "a", "mirror", "of", "a", "route", "." ]
9291543cd28e19a2986abd7fb146898ca5f5f5da
https://github.com/Raphhh/puppy-application/blob/9291543cd28e19a2986abd7fb146898ca5f5f5da/src/Application.php#L183-L191
25,865
AnonymPHP/Anonym-Database
Mode/ModeManager.php
ModeManager.pagination
public function pagination($perPage = 15) { $currentPageFinder = Paginator::getCurrentPageFinder(); $pathFinder = Paginator::getRequestPathFinder(); $pagination = new Paginator($perPage, call_user_func($currentPageFinder), [ 'pageName' => 'page', 'path' => call_user_func($pathFinder), ]); $pagination->setMode(Paginator::MODE_STANDART); $count = $this->build()->rowCount(); $pagination->count($count); return $pagination; }
php
public function pagination($perPage = 15) { $currentPageFinder = Paginator::getCurrentPageFinder(); $pathFinder = Paginator::getRequestPathFinder(); $pagination = new Paginator($perPage, call_user_func($currentPageFinder), [ 'pageName' => 'page', 'path' => call_user_func($pathFinder), ]); $pagination->setMode(Paginator::MODE_STANDART); $count = $this->build()->rowCount(); $pagination->count($count); return $pagination; }
[ "public", "function", "pagination", "(", "$", "perPage", "=", "15", ")", "{", "$", "currentPageFinder", "=", "Paginator", "::", "getCurrentPageFinder", "(", ")", ";", "$", "pathFinder", "=", "Paginator", "::", "getRequestPathFinder", "(", ")", ";", "$", "pagination", "=", "new", "Paginator", "(", "$", "perPage", ",", "call_user_func", "(", "$", "currentPageFinder", ")", ",", "[", "'pageName'", "=>", "'page'", ",", "'path'", "=>", "call_user_func", "(", "$", "pathFinder", ")", ",", "]", ")", ";", "$", "pagination", "->", "setMode", "(", "Paginator", "::", "MODE_STANDART", ")", ";", "$", "count", "=", "$", "this", "->", "build", "(", ")", "->", "rowCount", "(", ")", ";", "$", "pagination", "->", "count", "(", "$", "count", ")", ";", "return", "$", "pagination", ";", "}" ]
create a instance for standart pagination @param int $perPage @return Paginator
[ "create", "a", "instance", "for", "standart", "pagination" ]
4d034219e0e3eb2833fa53204e9f52a74a9a7e4b
https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Mode/ModeManager.php#L305-L323
25,866
AnonymPHP/Anonym-Database
Mode/ModeManager.php
ModeManager.simplePagination
public function simplePagination($perPage = 15){ $pegination = $this->pagination($perPage); $pegination->setMode(Paginator::MODE_SIMPLE); return $pegination; }
php
public function simplePagination($perPage = 15){ $pegination = $this->pagination($perPage); $pegination->setMode(Paginator::MODE_SIMPLE); return $pegination; }
[ "public", "function", "simplePagination", "(", "$", "perPage", "=", "15", ")", "{", "$", "pegination", "=", "$", "this", "->", "pagination", "(", "$", "perPage", ")", ";", "$", "pegination", "->", "setMode", "(", "Paginator", "::", "MODE_SIMPLE", ")", ";", "return", "$", "pegination", ";", "}" ]
create a paginaton instance and return it @param int $perPage @return Paginator
[ "create", "a", "paginaton", "instance", "and", "return", "it" ]
4d034219e0e3eb2833fa53204e9f52a74a9a7e4b
https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Mode/ModeManager.php#L332-L337
25,867
zineinc/floppy-client
src/Floppy/Client/FileTypeGuesser.php
FileTypeGuesser.guessFileType
public function guessFileType(FileId $fileId) { $extension = strtolower(\pathinfo($fileId->id(), PATHINFO_EXTENSION)); foreach($this->fileTypeExtensions as $fileType => $extensions) { if(in_array($extension, $extensions)) { return $fileType; } } return 'file'; }
php
public function guessFileType(FileId $fileId) { $extension = strtolower(\pathinfo($fileId->id(), PATHINFO_EXTENSION)); foreach($this->fileTypeExtensions as $fileType => $extensions) { if(in_array($extension, $extensions)) { return $fileType; } } return 'file'; }
[ "public", "function", "guessFileType", "(", "FileId", "$", "fileId", ")", "{", "$", "extension", "=", "strtolower", "(", "\\", "pathinfo", "(", "$", "fileId", "->", "id", "(", ")", ",", "PATHINFO_EXTENSION", ")", ")", ";", "foreach", "(", "$", "this", "->", "fileTypeExtensions", "as", "$", "fileType", "=>", "$", "extensions", ")", "{", "if", "(", "in_array", "(", "$", "extension", ",", "$", "extensions", ")", ")", "{", "return", "$", "fileType", ";", "}", "}", "return", "'file'", ";", "}" ]
Guess file type code @param FileId $fileId @return string
[ "Guess", "file", "type", "code" ]
24a4e72756ef88de561d08d71090bcf4c00be845
https://github.com/zineinc/floppy-client/blob/24a4e72756ef88de561d08d71090bcf4c00be845/src/Floppy/Client/FileTypeGuesser.php#L23-L34
25,868
danielgp/network-components
source/NetworkComponentsByDanielGP.php
NetworkComponentsByDanielGP.checkIpIsInRange
public function checkIpIsInRange($ipGiven, $ipStart, $ipEnd) { $sReturn = 'out'; $startNo = $this->convertIpToNumber($ipStart); $endNo = $this->convertIpToNumber($ipEnd); $evaluatedNo = $this->convertIpToNumber($ipGiven); if ($sReturn == 'out') { if (($evaluatedNo >= $startNo) && ($evaluatedNo <= $endNo)) { $sReturn = 'in'; } } return $sReturn; }
php
public function checkIpIsInRange($ipGiven, $ipStart, $ipEnd) { $sReturn = 'out'; $startNo = $this->convertIpToNumber($ipStart); $endNo = $this->convertIpToNumber($ipEnd); $evaluatedNo = $this->convertIpToNumber($ipGiven); if ($sReturn == 'out') { if (($evaluatedNo >= $startNo) && ($evaluatedNo <= $endNo)) { $sReturn = 'in'; } } return $sReturn; }
[ "public", "function", "checkIpIsInRange", "(", "$", "ipGiven", ",", "$", "ipStart", ",", "$", "ipEnd", ")", "{", "$", "sReturn", "=", "'out'", ";", "$", "startNo", "=", "$", "this", "->", "convertIpToNumber", "(", "$", "ipStart", ")", ";", "$", "endNo", "=", "$", "this", "->", "convertIpToNumber", "(", "$", "ipEnd", ")", ";", "$", "evaluatedNo", "=", "$", "this", "->", "convertIpToNumber", "(", "$", "ipGiven", ")", ";", "if", "(", "$", "sReturn", "==", "'out'", ")", "{", "if", "(", "(", "$", "evaluatedNo", ">=", "$", "startNo", ")", "&&", "(", "$", "evaluatedNo", "<=", "$", "endNo", ")", ")", "{", "$", "sReturn", "=", "'in'", ";", "}", "}", "return", "$", "sReturn", ";", "}" ]
Determines if a given IP is with a defined range @param ipv4 $ipGiven @param ipv4 $ipStart @param ipv4 $ipEnd @return string
[ "Determines", "if", "a", "given", "IP", "is", "with", "a", "defined", "range" ]
96d3f8247b2aac6db951ec9d76626e7ab8b824e4
https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L42-L54
25,869
danielgp/network-components
source/NetworkComponentsByDanielGP.php
NetworkComponentsByDanielGP.checkIpIsPrivate
public function checkIpIsPrivate($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (!filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE)) { return 'private'; } return 'public'; } return 'invalid IP'; }
php
public function checkIpIsPrivate($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (!filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE)) { return 'private'; } return 'public'; } return 'invalid IP'; }
[ "public", "function", "checkIpIsPrivate", "(", "$", "ipGiven", ")", "{", "if", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "if", "(", "!", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_NO_RES_RANGE", "|", "FILTER_FLAG_NO_PRIV_RANGE", ")", ")", "{", "return", "'private'", ";", "}", "return", "'public'", ";", "}", "return", "'invalid IP'", ";", "}" ]
Checks if given IP is a private or public one @param ipv4 $ipGiven @return string
[ "Checks", "if", "given", "IP", "is", "a", "private", "or", "public", "one" ]
96d3f8247b2aac6db951ec9d76626e7ab8b824e4
https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L62-L71
25,870
danielgp/network-components
source/NetworkComponentsByDanielGP.php
NetworkComponentsByDanielGP.checkIpIsV4OrV6
public function checkIpIsV4OrV6($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return 'V4'; } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return 'V6'; } } return 'invalid IP'; }
php
public function checkIpIsV4OrV6($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { return 'V4'; } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return 'V6'; } } return 'invalid IP'; }
[ "public", "function", "checkIpIsV4OrV6", "(", "$", "ipGiven", ")", "{", "if", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "if", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", ")", ")", "{", "return", "'V4'", ";", "}", "elseif", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV6", ")", ")", "{", "return", "'V6'", ";", "}", "}", "return", "'invalid IP'", ";", "}" ]
Checks if given IP is a V4 or V6 @param ipv4 $ipGiven @return string
[ "Checks", "if", "given", "IP", "is", "a", "V4", "or", "V6" ]
96d3f8247b2aac6db951ec9d76626e7ab8b824e4
https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L79-L89
25,871
danielgp/network-components
source/NetworkComponentsByDanielGP.php
NetworkComponentsByDanielGP.convertIpToNumber
public function convertIpToNumber($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $ips = explode('.', $ipGiven); return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216; } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $this->convertIpV6ToNumber($ipGiven); } } return 'invalid IP'; }
php
public function convertIpToNumber($ipGiven) { if (filter_var($ipGiven, FILTER_VALIDATE_IP)) { if (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $ips = explode('.', $ipGiven); return $ips[3] + $ips[2] * 256 + $ips[1] * 65536 + $ips[0] * 16777216; } elseif (filter_var($ipGiven, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $this->convertIpV6ToNumber($ipGiven); } } return 'invalid IP'; }
[ "public", "function", "convertIpToNumber", "(", "$", "ipGiven", ")", "{", "if", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "if", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", ")", ")", "{", "$", "ips", "=", "explode", "(", "'.'", ",", "$", "ipGiven", ")", ";", "return", "$", "ips", "[", "3", "]", "+", "$", "ips", "[", "2", "]", "*", "256", "+", "$", "ips", "[", "1", "]", "*", "65536", "+", "$", "ips", "[", "0", "]", "*", "16777216", ";", "}", "elseif", "(", "filter_var", "(", "$", "ipGiven", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV6", ")", ")", "{", "return", "$", "this", "->", "convertIpV6ToNumber", "(", "$", "ipGiven", ")", ";", "}", "}", "return", "'invalid IP'", ";", "}" ]
Converts IP to a number @param type $ipGiven @return string|int
[ "Converts", "IP", "to", "a", "number" ]
96d3f8247b2aac6db951ec9d76626e7ab8b824e4
https://github.com/danielgp/network-components/blob/96d3f8247b2aac6db951ec9d76626e7ab8b824e4/source/NetworkComponentsByDanielGP.php#L97-L108
25,872
joalcapa/Fundamentary
src/Http/Request.php
Request.bodyRequest
public function bodyRequest($forApi = false) { $json = file_get_contents('php://input'); $data = json_decode($json); $forApi ? $requestWithBodyRequest = $this->getInteractionsRequestForApi() : $requestWithBodyRequest = $this->getInteractionsRequest(); foreach ($data as $key => $value) $requestWithBodyRequest->$key = $value; return $requestWithBodyRequest; }
php
public function bodyRequest($forApi = false) { $json = file_get_contents('php://input'); $data = json_decode($json); $forApi ? $requestWithBodyRequest = $this->getInteractionsRequestForApi() : $requestWithBodyRequest = $this->getInteractionsRequest(); foreach ($data as $key => $value) $requestWithBodyRequest->$key = $value; return $requestWithBodyRequest; }
[ "public", "function", "bodyRequest", "(", "$", "forApi", "=", "false", ")", "{", "$", "json", "=", "file_get_contents", "(", "'php://input'", ")", ";", "$", "data", "=", "json_decode", "(", "$", "json", ")", ";", "$", "forApi", "?", "$", "requestWithBodyRequest", "=", "$", "this", "->", "getInteractionsRequestForApi", "(", ")", ":", "$", "requestWithBodyRequest", "=", "$", "this", "->", "getInteractionsRequest", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "$", "requestWithBodyRequest", "->", "$", "key", "=", "$", "value", ";", "return", "$", "requestWithBodyRequest", ";", "}" ]
Retorno del cuerpo de Request. @return array
[ "Retorno", "del", "cuerpo", "de", "Request", "." ]
fd83dea5f90a92a38b42e3f5516f31137349601f
https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L160-L169
25,873
joalcapa/Fundamentary
src/Http/Request.php
Request.input
public function input($input) { if(isset($this->inputs->$input)) return $this->inputs->$input; return null; }
php
public function input($input) { if(isset($this->inputs->$input)) return $this->inputs->$input; return null; }
[ "public", "function", "input", "(", "$", "input", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "inputs", "->", "$", "input", ")", ")", "return", "$", "this", "->", "inputs", "->", "$", "input", ";", "return", "null", ";", "}" ]
Retorno de la variable enviada por el cliente. @return string
[ "Retorno", "de", "la", "variable", "enviada", "por", "el", "cliente", "." ]
fd83dea5f90a92a38b42e3f5516f31137349601f
https://github.com/joalcapa/Fundamentary/blob/fd83dea5f90a92a38b42e3f5516f31137349601f/src/Http/Request.php#L176-L180
25,874
zapheus/zapheus
src/Http/Message/Message.php
Message.header
public function header($name) { $exists = isset($this->headers[$name]); return $exists ? $this->headers[$name] : array(); // getHeader }
php
public function header($name) { $exists = isset($this->headers[$name]); return $exists ? $this->headers[$name] : array(); // getHeader }
[ "public", "function", "header", "(", "$", "name", ")", "{", "$", "exists", "=", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ";", "return", "$", "exists", "?", "$", "this", "->", "headers", "[", "$", "name", "]", ":", "array", "(", ")", ";", "// getHeader", "}" ]
Returns a message header value by the given case-insensitive name. @param string $name @return array
[ "Returns", "a", "message", "header", "value", "by", "the", "given", "case", "-", "insensitive", "name", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/Message.php#L59-L66
25,875
bytic/MediaLibrary
src/Media/Media.php
Media.getUrl
public function getUrl(string $conversionName = ''): string { if ($this->hasFile()) { return $this->getFile()->getUrl(); } return $this->getCollection()->getDefaultMediaUrl(); // $urlGenerator = UrlGeneratorFactory::createForMedia($this); // if ($conversionName !== '') { //// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName); //// $urlGenerator->setConversion($conversion); // } // return $urlGenerator->getUrl(); }
php
public function getUrl(string $conversionName = ''): string { if ($this->hasFile()) { return $this->getFile()->getUrl(); } return $this->getCollection()->getDefaultMediaUrl(); // $urlGenerator = UrlGeneratorFactory::createForMedia($this); // if ($conversionName !== '') { //// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName); //// $urlGenerator->setConversion($conversion); // } // return $urlGenerator->getUrl(); }
[ "public", "function", "getUrl", "(", "string", "$", "conversionName", "=", "''", ")", ":", "string", "{", "if", "(", "$", "this", "->", "hasFile", "(", ")", ")", "{", "return", "$", "this", "->", "getFile", "(", ")", "->", "getUrl", "(", ")", ";", "}", "return", "$", "this", "->", "getCollection", "(", ")", "->", "getDefaultMediaUrl", "(", ")", ";", "// $urlGenerator = UrlGeneratorFactory::createForMedia($this);", "// if ($conversionName !== '') {", "//// $conversion = ConversionCollection::createForMedia($this)->getByName($conversionName);", "//// $urlGenerator->setConversion($conversion);", "// }", "// return $urlGenerator->getUrl();", "}" ]
Get the url to a original media file. @param string $conversionName @return string
[ "Get", "the", "url", "to", "a", "original", "media", "file", "." ]
c52783e726b512184bd72e04d829d6f93242a61d
https://github.com/bytic/MediaLibrary/blob/c52783e726b512184bd72e04d829d6f93242a61d/src/Media/Media.php#L92-L104
25,876
pipaslot/forms
src/Forms/FormFactory.php
FormFactory.createBootstrap
public function createBootstrap($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3Renderer()); return $form; }
php
public function createBootstrap($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3Renderer()); return $form; }
[ "public", "function", "createBootstrap", "(", "$", "secured", "=", "true", ")", "{", "$", "form", "=", "$", "this", "->", "create", "(", "$", "secured", ")", ";", "$", "form", "->", "setRenderer", "(", "new", "Bootstrap3Renderer", "(", ")", ")", ";", "return", "$", "form", ";", "}" ]
Create Form with Bootstrap styling @param bool|true $secured @return Form|IForm
[ "Create", "Form", "with", "Bootstrap", "styling" ]
9e1d48db512f843270fd4079ed3ff1b1729c951b
https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L50-L55
25,877
pipaslot/forms
src/Forms/FormFactory.php
FormFactory.createBootstrapInline
public function createBootstrapInline($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3InlineRenderer()); return $form; }
php
public function createBootstrapInline($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3InlineRenderer()); return $form; }
[ "public", "function", "createBootstrapInline", "(", "$", "secured", "=", "true", ")", "{", "$", "form", "=", "$", "this", "->", "create", "(", "$", "secured", ")", ";", "$", "form", "->", "setRenderer", "(", "new", "Bootstrap3InlineRenderer", "(", ")", ")", ";", "return", "$", "form", ";", "}" ]
Create Form with inline Bootstrap styling @param bool|true $secured @return Form|IForm
[ "Create", "Form", "with", "inline", "Bootstrap", "styling" ]
9e1d48db512f843270fd4079ed3ff1b1729c951b
https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L62-L67
25,878
pipaslot/forms
src/Forms/FormFactory.php
FormFactory.createBootstrapStacked
public function createBootstrapStacked($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3StackRenderer()); return $form; }
php
public function createBootstrapStacked($secured = true) { $form = $this->create($secured); $form->setRenderer(new Bootstrap3StackRenderer()); return $form; }
[ "public", "function", "createBootstrapStacked", "(", "$", "secured", "=", "true", ")", "{", "$", "form", "=", "$", "this", "->", "create", "(", "$", "secured", ")", ";", "$", "form", "->", "setRenderer", "(", "new", "Bootstrap3StackRenderer", "(", ")", ")", ";", "return", "$", "form", ";", "}" ]
One column form where labels are placed to controls @param bool|true $secured @return Form|IForm
[ "One", "column", "form", "where", "labels", "are", "placed", "to", "controls" ]
9e1d48db512f843270fd4079ed3ff1b1729c951b
https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/FormFactory.php#L74-L79
25,879
DeimosProject/Helper
src/Helper/Helpers/Arr/KeyTrait.php
KeyTrait.oddKey
public function oddKey(array $storage) { return $this->filter($storage, function ($value, $key) { return $this->helper->math()->isOdd($key); }); }
php
public function oddKey(array $storage) { return $this->filter($storage, function ($value, $key) { return $this->helper->math()->isOdd($key); }); }
[ "public", "function", "oddKey", "(", "array", "$", "storage", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "storage", ",", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "$", "this", "->", "helper", "->", "math", "(", ")", "->", "isOdd", "(", "$", "key", ")", ";", "}", ")", ";", "}" ]
0=>'', 2=> ''... @param array $storage @return array
[ "0", "=", ">", "2", "=", ">", "..." ]
39c67de21a87c7c6391b2f98416063f41c94e26f
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/KeyTrait.php#L50-L56
25,880
DeimosProject/Helper
src/Helper/Helpers/Arr/KeyTrait.php
KeyTrait.evenKey
public function evenKey(array $storage) { return $this->filter($storage, function ($value, $key) { return $this->helper->math()->isEven($key); }); }
php
public function evenKey(array $storage) { return $this->filter($storage, function ($value, $key) { return $this->helper->math()->isEven($key); }); }
[ "public", "function", "evenKey", "(", "array", "$", "storage", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "storage", ",", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "$", "this", "->", "helper", "->", "math", "(", ")", "->", "isEven", "(", "$", "key", ")", ";", "}", ")", ";", "}" ]
1=>'', 3=>''... @param array $storage @return array
[ "1", "=", ">", "3", "=", ">", "..." ]
39c67de21a87c7c6391b2f98416063f41c94e26f
https://github.com/DeimosProject/Helper/blob/39c67de21a87c7c6391b2f98416063f41c94e26f/src/Helper/Helpers/Arr/KeyTrait.php#L65-L71
25,881
prolic/HumusMvc
src/HumusMvc/Translate/Service/TranslatorFactory.php
TranslatorFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); if (!isset($config['translator'])) { throw new Exception\RuntimeException( 'No translator config found.' ); } $allOptions = $config['translator']; foreach ($allOptions as $module => $options) { if (!isset($options['content']) && !isset($options['data'])) { throw new Exception\RuntimeException('No translation source data provided.'); } else if (array_key_exists('content', $options) && array_key_exists('data', $options)) { throw new Exception\RuntimeException( 'Conflict on translation source data: choose only one key between content and data.' ); } if (empty($options['adapter'])) { $options['adapter'] = Zend_Translate::AN_ARRAY; } if (!empty($options['data'])) { $options['content'] = $options['data']; unset($options['data']); } if (isset($options['options'])) { foreach($options['options'] as $key => $value) { $options[$key] = $value; } } if (!empty($options['cache']) && is_string($options['cache'])) { $cacheManager = $serviceLocator->get('CacheManager'); if ($cacheManager->hasCache($options['cache'])) { $options['cache'] = $cacheManager->getCache($options['cache']); } } if ($this->translator instanceof Zend_Translate_Adapter) { $this->translator->addTranslation($options); } else { $translate = new Zend_Translate($options); $this->translator = $translate->getAdapter(); } } return $this->translator; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); if (!isset($config['translator'])) { throw new Exception\RuntimeException( 'No translator config found.' ); } $allOptions = $config['translator']; foreach ($allOptions as $module => $options) { if (!isset($options['content']) && !isset($options['data'])) { throw new Exception\RuntimeException('No translation source data provided.'); } else if (array_key_exists('content', $options) && array_key_exists('data', $options)) { throw new Exception\RuntimeException( 'Conflict on translation source data: choose only one key between content and data.' ); } if (empty($options['adapter'])) { $options['adapter'] = Zend_Translate::AN_ARRAY; } if (!empty($options['data'])) { $options['content'] = $options['data']; unset($options['data']); } if (isset($options['options'])) { foreach($options['options'] as $key => $value) { $options[$key] = $value; } } if (!empty($options['cache']) && is_string($options['cache'])) { $cacheManager = $serviceLocator->get('CacheManager'); if ($cacheManager->hasCache($options['cache'])) { $options['cache'] = $cacheManager->getCache($options['cache']); } } if ($this->translator instanceof Zend_Translate_Adapter) { $this->translator->addTranslation($options); } else { $translate = new Zend_Translate($options); $this->translator = $translate->getAdapter(); } } return $this->translator; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'Config'", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'translator'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "'No translator config found.'", ")", ";", "}", "$", "allOptions", "=", "$", "config", "[", "'translator'", "]", ";", "foreach", "(", "$", "allOptions", "as", "$", "module", "=>", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'content'", "]", ")", "&&", "!", "isset", "(", "$", "options", "[", "'data'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "'No translation source data provided.'", ")", ";", "}", "else", "if", "(", "array_key_exists", "(", "'content'", ",", "$", "options", ")", "&&", "array_key_exists", "(", "'data'", ",", "$", "options", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "'Conflict on translation source data: choose only one key between content and data.'", ")", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'adapter'", "]", ")", ")", "{", "$", "options", "[", "'adapter'", "]", "=", "Zend_Translate", "::", "AN_ARRAY", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'data'", "]", ")", ")", "{", "$", "options", "[", "'content'", "]", "=", "$", "options", "[", "'data'", "]", ";", "unset", "(", "$", "options", "[", "'data'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'options'", "]", ")", ")", "{", "foreach", "(", "$", "options", "[", "'options'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "options", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'cache'", "]", ")", "&&", "is_string", "(", "$", "options", "[", "'cache'", "]", ")", ")", "{", "$", "cacheManager", "=", "$", "serviceLocator", "->", "get", "(", "'CacheManager'", ")", ";", "if", "(", "$", "cacheManager", "->", "hasCache", "(", "$", "options", "[", "'cache'", "]", ")", ")", "{", "$", "options", "[", "'cache'", "]", "=", "$", "cacheManager", "->", "getCache", "(", "$", "options", "[", "'cache'", "]", ")", ";", "}", "}", "if", "(", "$", "this", "->", "translator", "instanceof", "Zend_Translate_Adapter", ")", "{", "$", "this", "->", "translator", "->", "addTranslation", "(", "$", "options", ")", ";", "}", "else", "{", "$", "translate", "=", "new", "Zend_Translate", "(", "$", "options", ")", ";", "$", "this", "->", "translator", "=", "$", "translate", "->", "getAdapter", "(", ")", ";", "}", "}", "return", "$", "this", "->", "translator", ";", "}" ]
Create translator adapter @param ServiceLocatorInterface $serviceLocator @return Zend_Translate_Adapter @throws Exception\RuntimeException
[ "Create", "translator", "adapter" ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Translate/Service/TranslatorFactory.php#L41-L89
25,882
zenodorus-tools/filesystem
src/Filesystem/Directories.php
Directories.isBeneathReal
public static function isBeneathReal( string $child, string $parent, string $childDir = null, string $parentDir = null ) { $realChildPath = Filesystem::resolveReal($child, $childDir); $realParentPath = Filesystem::resolveReal($parent, $parentDir); if ($realChildPath && $realParentPath) { return Directories::isBeneath($realChildPath, $realParentPath); } return false; }
php
public static function isBeneathReal( string $child, string $parent, string $childDir = null, string $parentDir = null ) { $realChildPath = Filesystem::resolveReal($child, $childDir); $realParentPath = Filesystem::resolveReal($parent, $parentDir); if ($realChildPath && $realParentPath) { return Directories::isBeneath($realChildPath, $realParentPath); } return false; }
[ "public", "static", "function", "isBeneathReal", "(", "string", "$", "child", ",", "string", "$", "parent", ",", "string", "$", "childDir", "=", "null", ",", "string", "$", "parentDir", "=", "null", ")", "{", "$", "realChildPath", "=", "Filesystem", "::", "resolveReal", "(", "$", "child", ",", "$", "childDir", ")", ";", "$", "realParentPath", "=", "Filesystem", "::", "resolveReal", "(", "$", "parent", ",", "$", "parentDir", ")", ";", "if", "(", "$", "realChildPath", "&&", "$", "realParentPath", ")", "{", "return", "Directories", "::", "isBeneath", "(", "$", "realChildPath", ",", "$", "realParentPath", ")", ";", "}", "return", "false", ";", "}" ]
Determine if a real path is beneath another path. The files/directories passed to this method are checked to make sure they exists, so the results returned by this method can be trusted. @see Filesystem::resolveReal() @see Filesystem\Directories::isBeneath() @param string $child @param string $parent @param string $childDir @param string $parentDir @return boolean
[ "Determine", "if", "a", "real", "path", "is", "beneath", "another", "path", "." ]
210d098fa9cc7f261d68402667763497cba1fba0
https://github.com/zenodorus-tools/filesystem/blob/210d098fa9cc7f261d68402667763497cba1fba0/src/Filesystem/Directories.php#L70-L84
25,883
mtils/cmsable
src/Cmsable/Resource/Distributor.php
Distributor.makeForm
protected function makeForm($resource, $class, $model) { $form = $this->container->make($class); if (!$this->formRules($form) && $rules = $this->rules($resource)) { $form->getValidator()->setRules($rules); } if ($model) { $form->setModel($model); } $this->publish($resource, 'form.created', [$form]); return $form; }
php
protected function makeForm($resource, $class, $model) { $form = $this->container->make($class); if (!$this->formRules($form) && $rules = $this->rules($resource)) { $form->getValidator()->setRules($rules); } if ($model) { $form->setModel($model); } $this->publish($resource, 'form.created', [$form]); return $form; }
[ "protected", "function", "makeForm", "(", "$", "resource", ",", "$", "class", ",", "$", "model", ")", "{", "$", "form", "=", "$", "this", "->", "container", "->", "make", "(", "$", "class", ")", ";", "if", "(", "!", "$", "this", "->", "formRules", "(", "$", "form", ")", "&&", "$", "rules", "=", "$", "this", "->", "rules", "(", "$", "resource", ")", ")", "{", "$", "form", "->", "getValidator", "(", ")", "->", "setRules", "(", "$", "rules", ")", ";", "}", "if", "(", "$", "model", ")", "{", "$", "form", "->", "setModel", "(", "$", "model", ")", ";", "}", "$", "this", "->", "publish", "(", "$", "resource", ",", "'form.created'", ",", "[", "$", "form", "]", ")", ";", "return", "$", "form", ";", "}" ]
Creates the form and fires an event @param string $resource @param string $class @param mixed $model @return \FormObject\Form
[ "Creates", "the", "form", "and", "fires", "an", "event" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L289-L304
25,884
mtils/cmsable
src/Cmsable/Resource/Distributor.php
Distributor.makeSearchForm
protected function makeSearchForm($resource, $class) { $form = $this->container->make($class); $this->publish($resource, 'search-form.created', [$form]); $form->addCssClass('search-form'); return $form; }
php
protected function makeSearchForm($resource, $class) { $form = $this->container->make($class); $this->publish($resource, 'search-form.created', [$form]); $form->addCssClass('search-form'); return $form; }
[ "protected", "function", "makeSearchForm", "(", "$", "resource", ",", "$", "class", ")", "{", "$", "form", "=", "$", "this", "->", "container", "->", "make", "(", "$", "class", ")", ";", "$", "this", "->", "publish", "(", "$", "resource", ",", "'search-form.created'", ",", "[", "$", "form", "]", ")", ";", "$", "form", "->", "addCssClass", "(", "'search-form'", ")", ";", "return", "$", "form", ";", "}" ]
Creates the search form and fires an event @param string $resource @param string $class @return \FormObject\Form
[ "Creates", "the", "search", "form", "and", "fires", "an", "event" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L313-L319
25,885
mtils/cmsable
src/Cmsable/Resource/Distributor.php
Distributor.makeValidator
protected function makeValidator($resource, $class) { $validator = $this->container->make($class); if (method_exists($validator, 'setResourceName')) { $validator->setResourceName($resource); } $this->publish($resource, 'validator.created', [$validator]); return $validator; }
php
protected function makeValidator($resource, $class) { $validator = $this->container->make($class); if (method_exists($validator, 'setResourceName')) { $validator->setResourceName($resource); } $this->publish($resource, 'validator.created', [$validator]); return $validator; }
[ "protected", "function", "makeValidator", "(", "$", "resource", ",", "$", "class", ")", "{", "$", "validator", "=", "$", "this", "->", "container", "->", "make", "(", "$", "class", ")", ";", "if", "(", "method_exists", "(", "$", "validator", ",", "'setResourceName'", ")", ")", "{", "$", "validator", "->", "setResourceName", "(", "$", "resource", ")", ";", "}", "$", "this", "->", "publish", "(", "$", "resource", ",", "'validator.created'", ",", "[", "$", "validator", "]", ")", ";", "return", "$", "validator", ";", "}" ]
Creates the validator and fires an event @param string $resource @param string $class @return \Cmsable\Resource\Contracts\Validator
[ "Creates", "the", "validator", "and", "fires", "an", "event" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L328-L337
25,886
mtils/cmsable
src/Cmsable/Resource/Distributor.php
Distributor.publish
protected function publish($resource, $event, array $params=[]) { $eventName = $this->eventName("$resource.$event"); $this->callOnListeners($eventName, $params); }
php
protected function publish($resource, $event, array $params=[]) { $eventName = $this->eventName("$resource.$event"); $this->callOnListeners($eventName, $params); }
[ "protected", "function", "publish", "(", "$", "resource", ",", "$", "event", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "eventName", "=", "$", "this", "->", "eventName", "(", "\"$resource.$event\"", ")", ";", "$", "this", "->", "callOnListeners", "(", "$", "eventName", ",", "$", "params", ")", ";", "}" ]
Publishes an event on the event bus @param string $resource @param string $event @param array $params
[ "Publishes", "an", "event", "on", "the", "event", "bus" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Resource/Distributor.php#L360-L365
25,887
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.add
public function add($identifier, array $configuration) { $presets = $this->loadPresets(); if (!empty($presets[$identifier])) { throw new Exception('Preset exists already', 1410552459); } if (empty($configuration)) { throw new Exception('Empty configuration is not allowed', 1410595656); } $presets[$identifier] = $configuration; ksort($presets); $this->savePresets($presets, 'Adds preset with identifier "' . $identifier . '"'); }
php
public function add($identifier, array $configuration) { $presets = $this->loadPresets(); if (!empty($presets[$identifier])) { throw new Exception('Preset exists already', 1410552459); } if (empty($configuration)) { throw new Exception('Empty configuration is not allowed', 1410595656); } $presets[$identifier] = $configuration; ksort($presets); $this->savePresets($presets, 'Adds preset with identifier "' . $identifier . '"'); }
[ "public", "function", "add", "(", "$", "identifier", ",", "array", "$", "configuration", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "presets", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Preset exists already'", ",", "1410552459", ")", ";", "}", "if", "(", "empty", "(", "$", "configuration", ")", ")", "{", "throw", "new", "Exception", "(", "'Empty configuration is not allowed'", ",", "1410595656", ")", ";", "}", "$", "presets", "[", "$", "identifier", "]", "=", "$", "configuration", ";", "ksort", "(", "$", "presets", ")", ";", "$", "this", "->", "savePresets", "(", "$", "presets", ",", "'Adds preset with identifier \"'", ".", "$", "identifier", ".", "'\"'", ")", ";", "}" ]
Adds a preset to this repository. @param string $identifier @param array $configuration @return void @throws Exception
[ "Adds", "a", "preset", "to", "this", "repository", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L31-L43
25,888
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.update
public function update($identifier, array $configuration) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410552339); } if (empty($configuration)) { throw new Exception('Empty configuration is not allowed', 1410595612); } $presets[$identifier] = $configuration; $this->savePresets($presets, 'Updates preset with identifier "' . $identifier . '"'); }
php
public function update($identifier, array $configuration) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410552339); } if (empty($configuration)) { throw new Exception('Empty configuration is not allowed', 1410595612); } $presets[$identifier] = $configuration; $this->savePresets($presets, 'Updates preset with identifier "' . $identifier . '"'); }
[ "public", "function", "update", "(", "$", "identifier", ",", "array", "$", "configuration", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "if", "(", "empty", "(", "$", "presets", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not find preset'", ",", "1410552339", ")", ";", "}", "if", "(", "empty", "(", "$", "configuration", ")", ")", "{", "throw", "new", "Exception", "(", "'Empty configuration is not allowed'", ",", "1410595612", ")", ";", "}", "$", "presets", "[", "$", "identifier", "]", "=", "$", "configuration", ";", "$", "this", "->", "savePresets", "(", "$", "presets", ",", "'Updates preset with identifier \"'", ".", "$", "identifier", ".", "'\"'", ")", ";", "}" ]
Updates a given preset. @param string $identifier @param array $configuration @return void @throws Exception
[ "Updates", "a", "given", "preset", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L69-L80
25,889
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.remove
public function remove($identifier) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410549993); } unset($presets[$identifier]); $this->savePresets($presets, 'Removes preset with identifier "' . $identifier . '"'); }
php
public function remove($identifier) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410549993); } unset($presets[$identifier]); $this->savePresets($presets, 'Removes preset with identifier "' . $identifier . '"'); }
[ "public", "function", "remove", "(", "$", "identifier", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "if", "(", "empty", "(", "$", "presets", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not find preset'", ",", "1410549993", ")", ";", "}", "unset", "(", "$", "presets", "[", "$", "identifier", "]", ")", ";", "$", "this", "->", "savePresets", "(", "$", "presets", ",", "'Removes preset with identifier \"'", ".", "$", "identifier", ".", "'\"'", ")", ";", "}" ]
Removes a preset from this repository. @param string $identifier @return void @throws Exception
[ "Removes", "a", "preset", "from", "this", "repository", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L89-L97
25,890
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.findByIdentifier
public function findByIdentifier($identifier) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410549868); } return $presets[$identifier]; }
php
public function findByIdentifier($identifier) { $presets = $this->loadPresets(); if (empty($presets[$identifier])) { throw new Exception('Could not find preset', 1410549868); } return $presets[$identifier]; }
[ "public", "function", "findByIdentifier", "(", "$", "identifier", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "if", "(", "empty", "(", "$", "presets", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Could not find preset'", ",", "1410549868", ")", ";", "}", "return", "$", "presets", "[", "$", "identifier", "]", ";", "}" ]
Finds a preset matching the given identifier. @param string $identifier @return array $configuration @throws Exception
[ "Finds", "a", "preset", "matching", "the", "given", "identifier", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L116-L123
25,891
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.findByRepositoryUrl
public function findByRepositoryUrl($repositoryUrl) { $presets = $this->loadPresets(); $repositoryPresets = []; foreach ($presets as $key => $preset) { foreach ($preset['applications'] as $application) { if (!empty($application['options']['repositoryUrl']) && $repositoryUrl === $application['options']['repositoryUrl']) { $repositoryPresets[$key] = $preset; } } } return $repositoryPresets; }
php
public function findByRepositoryUrl($repositoryUrl) { $presets = $this->loadPresets(); $repositoryPresets = []; foreach ($presets as $key => $preset) { foreach ($preset['applications'] as $application) { if (!empty($application['options']['repositoryUrl']) && $repositoryUrl === $application['options']['repositoryUrl']) { $repositoryPresets[$key] = $preset; } } } return $repositoryPresets; }
[ "public", "function", "findByRepositoryUrl", "(", "$", "repositoryUrl", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "$", "repositoryPresets", "=", "[", "]", ";", "foreach", "(", "$", "presets", "as", "$", "key", "=>", "$", "preset", ")", "{", "foreach", "(", "$", "preset", "[", "'applications'", "]", "as", "$", "application", ")", "{", "if", "(", "!", "empty", "(", "$", "application", "[", "'options'", "]", "[", "'repositoryUrl'", "]", ")", "&&", "$", "repositoryUrl", "===", "$", "application", "[", "'options'", "]", "[", "'repositoryUrl'", "]", ")", "{", "$", "repositoryPresets", "[", "$", "key", "]", "=", "$", "preset", ";", "}", "}", "}", "return", "$", "repositoryPresets", ";", "}" ]
Find presets matching the given repositoryUrl. @param string $repositoryUrl @return array $presets
[ "Find", "presets", "matching", "the", "given", "repositoryUrl", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L131-L143
25,892
lightwerk/SurfCaptain
Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php
AbstractRepository.findGlobals
public function findGlobals() { $presets = $this->loadPresets(); $globalPresets = []; foreach ($presets as $key => $preset) { foreach ($preset['applications'] as $application) { if (empty($application['options']['repositoryUrl'])) { $globalPresets[$key] = $preset; } } } return $globalPresets; }
php
public function findGlobals() { $presets = $this->loadPresets(); $globalPresets = []; foreach ($presets as $key => $preset) { foreach ($preset['applications'] as $application) { if (empty($application['options']['repositoryUrl'])) { $globalPresets[$key] = $preset; } } } return $globalPresets; }
[ "public", "function", "findGlobals", "(", ")", "{", "$", "presets", "=", "$", "this", "->", "loadPresets", "(", ")", ";", "$", "globalPresets", "=", "[", "]", ";", "foreach", "(", "$", "presets", "as", "$", "key", "=>", "$", "preset", ")", "{", "foreach", "(", "$", "preset", "[", "'applications'", "]", "as", "$", "application", ")", "{", "if", "(", "empty", "(", "$", "application", "[", "'options'", "]", "[", "'repositoryUrl'", "]", ")", ")", "{", "$", "globalPresets", "[", "$", "key", "]", "=", "$", "preset", ";", "}", "}", "}", "return", "$", "globalPresets", ";", "}" ]
Finds all presets without a repositoryUrl. @return array $presets
[ "Finds", "all", "presets", "without", "a", "repositoryUrl", "." ]
2865e963fd634504d8923902cf422873749a0940
https://github.com/lightwerk/SurfCaptain/blob/2865e963fd634504d8923902cf422873749a0940/Classes/Lightwerk/SurfCaptain/Domain/Repository/Preset/AbstractRepository.php#L150-L162
25,893
kambalabs/KmbZendDbInfrastructure
src/KmbZendDbInfrastructure/Proxy/GroupClassProxy.php
GroupClassProxy.getGroup
public function getGroup() { if ($this->group === null) { $this->setGroup($this->groupRepository->getByClass($this)); } return $this->group; }
php
public function getGroup() { if ($this->group === null) { $this->setGroup($this->groupRepository->getByClass($this)); } return $this->group; }
[ "public", "function", "getGroup", "(", ")", "{", "if", "(", "$", "this", "->", "group", "===", "null", ")", "{", "$", "this", "->", "setGroup", "(", "$", "this", "->", "groupRepository", "->", "getByClass", "(", "$", "this", ")", ")", ";", "}", "return", "$", "this", "->", "group", ";", "}" ]
Get Group. @return \KmbDomain\Model\GroupInterface
[ "Get", "Group", "." ]
9bf4df4272d2064965202d0e689f944d56a4c6bb
https://github.com/kambalabs/KmbZendDbInfrastructure/blob/9bf4df4272d2064965202d0e689f944d56a4c6bb/src/KmbZendDbInfrastructure/Proxy/GroupClassProxy.php#L119-L125
25,894
Palmabit-IT/library
src/Palmabit/Library/Views/Helper.php
Helper.get_active_route_name
public static function get_active_route_name($match, $active = 'active') { $route_name = Route::currentRouteName(); return (strcasecmp(static::get_base_route_name($route_name), $match) == 0) ? $active : ''; }
php
public static function get_active_route_name($match, $active = 'active') { $route_name = Route::currentRouteName(); return (strcasecmp(static::get_base_route_name($route_name), $match) == 0) ? $active : ''; }
[ "public", "static", "function", "get_active_route_name", "(", "$", "match", ",", "$", "active", "=", "'active'", ")", "{", "$", "route_name", "=", "Route", "::", "currentRouteName", "(", ")", ";", "return", "(", "strcasecmp", "(", "static", "::", "get_base_route_name", "(", "$", "route_name", ")", ",", "$", "match", ")", "==", "0", ")", "?", "$", "active", ":", "''", ";", "}" ]
Check if route name is the same as the current url and returns active state @param $match @param $active
[ "Check", "if", "route", "name", "is", "the", "same", "as", "the", "current", "url", "and", "returns", "active", "state" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Views/Helper.php#L28-L32
25,895
Hnto/nuki
src/Handlers/Security/Crypter.php
Crypter.encrypt
public function encrypt($data, $key) { $this->validateData($data); $this->validateKey($key); $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD)); $encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv); $encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv); return new Encrypted($encoded); }
php
public function encrypt($data, $key) { $this->validateData($data); $this->validateKey($key); $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(self::CIPHER_METHOD)); $encrypted = openssl_encrypt($data, self::CIPHER_METHOD, $key, 0, $iv); $encoded = base64_encode($encrypted . self::ENCRYPTED_IV_SEPERATOR . $iv); return new Encrypted($encoded); }
[ "public", "function", "encrypt", "(", "$", "data", ",", "$", "key", ")", "{", "$", "this", "->", "validateData", "(", "$", "data", ")", ";", "$", "this", "->", "validateKey", "(", "$", "key", ")", ";", "$", "iv", "=", "openssl_random_pseudo_bytes", "(", "openssl_cipher_iv_length", "(", "self", "::", "CIPHER_METHOD", ")", ")", ";", "$", "encrypted", "=", "openssl_encrypt", "(", "$", "data", ",", "self", "::", "CIPHER_METHOD", ",", "$", "key", ",", "0", ",", "$", "iv", ")", ";", "$", "encoded", "=", "base64_encode", "(", "$", "encrypted", ".", "self", "::", "ENCRYPTED_IV_SEPERATOR", ".", "$", "iv", ")", ";", "return", "new", "Encrypted", "(", "$", "encoded", ")", ";", "}" ]
Encrypt data by key @param string $data @param string $key @return Encrypted
[ "Encrypt", "data", "by", "key" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L39-L49
25,896
Hnto/nuki
src/Handlers/Security/Crypter.php
Crypter.decrypt
public function decrypt($data, $key) : string { $this->validateData($data); $this->validateKey($key); if (empty($data)) { return ''; } list($encrypted, $iv) = explode(self::ENCRYPTED_IV_SEPERATOR, base64_decode($data), 2); return openssl_decrypt($encrypted, self::CIPHER_METHOD, $key, 0, $iv); }
php
public function decrypt($data, $key) : string { $this->validateData($data); $this->validateKey($key); if (empty($data)) { return ''; } list($encrypted, $iv) = explode(self::ENCRYPTED_IV_SEPERATOR, base64_decode($data), 2); return openssl_decrypt($encrypted, self::CIPHER_METHOD, $key, 0, $iv); }
[ "public", "function", "decrypt", "(", "$", "data", ",", "$", "key", ")", ":", "string", "{", "$", "this", "->", "validateData", "(", "$", "data", ")", ";", "$", "this", "->", "validateKey", "(", "$", "key", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "''", ";", "}", "list", "(", "$", "encrypted", ",", "$", "iv", ")", "=", "explode", "(", "self", "::", "ENCRYPTED_IV_SEPERATOR", ",", "base64_decode", "(", "$", "data", ")", ",", "2", ")", ";", "return", "openssl_decrypt", "(", "$", "encrypted", ",", "self", "::", "CIPHER_METHOD", ",", "$", "key", ",", "0", ",", "$", "iv", ")", ";", "}" ]
Decrypt data by key @param mixed $data @param string $key @return string
[ "Decrypt", "data", "by", "key" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L58-L69
25,897
Hnto/nuki
src/Handlers/Security/Crypter.php
Crypter.validateKey
private function validateKey($key) : bool { if (!hash_equals($this->appKey, $key)) { throw new \Nuki\Exceptions\Base('Used key does not equal the known application key'); } return true; }
php
private function validateKey($key) : bool { if (!hash_equals($this->appKey, $key)) { throw new \Nuki\Exceptions\Base('Used key does not equal the known application key'); } return true; }
[ "private", "function", "validateKey", "(", "$", "key", ")", ":", "bool", "{", "if", "(", "!", "hash_equals", "(", "$", "this", "->", "appKey", ",", "$", "key", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "'Used key does not equal the known application key'", ")", ";", "}", "return", "true", ";", "}" ]
Validate the crypter application key against the used key @param string $key @return boolean @throws \Nuki\Exceptions\Base
[ "Validate", "the", "crypter", "application", "key", "against", "the", "used", "key" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Security/Crypter.php#L78-L84
25,898
craig-mcmahon/google-helper
src/GoogleHelper/Apps/EmailHelper.php
EmailHelper.getSignature
public function getSignature($domain, $user) { $url = self::BASE_URL . "{$domain}/{$user}/signature"; $request = new \Google_Http_Request($url, 'GET', null, null); $httpRequest = $this->helper->getClient() ->getAuth() ->authenticatedRequest($request); if ($httpRequest->getResponseHttpCode() == 200) { $xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true); return (string)$xmlResponse->children('apps', true) ->attributes()->value; } else { // An error occurred. return null; } }
php
public function getSignature($domain, $user) { $url = self::BASE_URL . "{$domain}/{$user}/signature"; $request = new \Google_Http_Request($url, 'GET', null, null); $httpRequest = $this->helper->getClient() ->getAuth() ->authenticatedRequest($request); if ($httpRequest->getResponseHttpCode() == 200) { $xmlResponse = new \SimpleXMLElement($httpRequest->getResponseBody(), 0, false, 'apps', true); return (string)$xmlResponse->children('apps', true) ->attributes()->value; } else { // An error occurred. return null; } }
[ "public", "function", "getSignature", "(", "$", "domain", ",", "$", "user", ")", "{", "$", "url", "=", "self", "::", "BASE_URL", ".", "\"{$domain}/{$user}/signature\"", ";", "$", "request", "=", "new", "\\", "Google_Http_Request", "(", "$", "url", ",", "'GET'", ",", "null", ",", "null", ")", ";", "$", "httpRequest", "=", "$", "this", "->", "helper", "->", "getClient", "(", ")", "->", "getAuth", "(", ")", "->", "authenticatedRequest", "(", "$", "request", ")", ";", "if", "(", "$", "httpRequest", "->", "getResponseHttpCode", "(", ")", "==", "200", ")", "{", "$", "xmlResponse", "=", "new", "\\", "SimpleXMLElement", "(", "$", "httpRequest", "->", "getResponseBody", "(", ")", ",", "0", ",", "false", ",", "'apps'", ",", "true", ")", ";", "return", "(", "string", ")", "$", "xmlResponse", "->", "children", "(", "'apps'", ",", "true", ")", "->", "attributes", "(", ")", "->", "value", ";", "}", "else", "{", "// An error occurred.", "return", "null", ";", "}", "}" ]
Get a Users email signature @param string $domain @param string $user @return string|null Signature or null on error
[ "Get", "a", "Users", "email", "signature" ]
6b877efd7c9827555ecac65ee01e337849db6611
https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/Apps/EmailHelper.php#L17-L34
25,899
craig-mcmahon/google-helper
src/GoogleHelper/Apps/EmailHelper.php
EmailHelper.setSignature
public function setSignature($domain, $user, $signature) { $url = self::BASE_URL . "{$domain}/{$user}/signature"; $request = <<<XML <?xml version="1.0" encoding="utf-8"?> <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006"> <apps:property name="signature" value="{$signature}" /> </atom:entry> XML; $request = new \Google_Http_Request($url, 'PUT', array('Content-Type' => 'application/atom+xml'), $request); $httpRequest = $this->helper->getClient() ->getAuth() ->authenticatedRequest($request); return ($httpRequest->getResponseHttpCode() == 200); }
php
public function setSignature($domain, $user, $signature) { $url = self::BASE_URL . "{$domain}/{$user}/signature"; $request = <<<XML <?xml version="1.0" encoding="utf-8"?> <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006"> <apps:property name="signature" value="{$signature}" /> </atom:entry> XML; $request = new \Google_Http_Request($url, 'PUT', array('Content-Type' => 'application/atom+xml'), $request); $httpRequest = $this->helper->getClient() ->getAuth() ->authenticatedRequest($request); return ($httpRequest->getResponseHttpCode() == 200); }
[ "public", "function", "setSignature", "(", "$", "domain", ",", "$", "user", ",", "$", "signature", ")", "{", "$", "url", "=", "self", "::", "BASE_URL", ".", "\"{$domain}/{$user}/signature\"", ";", "$", "request", "=", " <<<XML\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:apps=\"http://schemas.google.com/apps/2006\">\n <apps:property name=\"signature\" value=\"{$signature}\" />\n</atom:entry>\nXML", ";", "$", "request", "=", "new", "\\", "Google_Http_Request", "(", "$", "url", ",", "'PUT'", ",", "array", "(", "'Content-Type'", "=>", "'application/atom+xml'", ")", ",", "$", "request", ")", ";", "$", "httpRequest", "=", "$", "this", "->", "helper", "->", "getClient", "(", ")", "->", "getAuth", "(", ")", "->", "authenticatedRequest", "(", "$", "request", ")", ";", "return", "(", "$", "httpRequest", "->", "getResponseHttpCode", "(", ")", "==", "200", ")", ";", "}" ]
Set a Users email signature @param string $domain @param string $user @param string $signature @return bool success
[ "Set", "a", "Users", "email", "signature" ]
6b877efd7c9827555ecac65ee01e337849db6611
https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/Apps/EmailHelper.php#L43-L59