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
24,800
jenskooij/cloudcontrol
src/storage/storage/BricksStorage.php
BricksStorage.deleteBrickBySlug
public function deleteBrickBySlug($slug) { $bricks = $this->repository->bricks; foreach ($bricks as $key => $brickObject) { if ($brickObject->slug == $slug) { unset($bricks[$key]); } } $bricks = array_values($bricks); $this->repository->bricks = $bricks; $this->save(); }
php
public function deleteBrickBySlug($slug) { $bricks = $this->repository->bricks; foreach ($bricks as $key => $brickObject) { if ($brickObject->slug == $slug) { unset($bricks[$key]); } } $bricks = array_values($bricks); $this->repository->bricks = $bricks; $this->save(); }
[ "public", "function", "deleteBrickBySlug", "(", "$", "slug", ")", "{", "$", "bricks", "=", "$", "this", "->", "repository", "->", "bricks", ";", "foreach", "(", "$", "bricks", "as", "$", "key", "=>", "$", "brickObject", ")", "{", "if", "(", "$", "brickObject", "->", "slug", "==", "$", "slug", ")", "{", "unset", "(", "$", "bricks", "[", "$", "key", "]", ")", ";", "}", "}", "$", "bricks", "=", "array_values", "(", "$", "bricks", ")", ";", "$", "this", "->", "repository", "->", "bricks", "=", "$", "bricks", ";", "$", "this", "->", "save", "(", ")", ";", "}" ]
Delete a brick by its slug @param $slug @throws \Exception
[ "Delete", "a", "brick", "by", "its", "slug" ]
76e5d9ac8f9c50d06d39a995d13cc03742536548
https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/BricksStorage.php#L87-L99
24,801
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Collection/Collections.php
Collections.toMap
public static function toMap(array $array) { $map = new SimpleMap(); foreach ($array as $k => $v) $map->put($k, $v); return $map; }
php
public static function toMap(array $array) { $map = new SimpleMap(); foreach ($array as $k => $v) $map->put($k, $v); return $map; }
[ "public", "static", "function", "toMap", "(", "array", "$", "array", ")", "{", "$", "map", "=", "new", "SimpleMap", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "k", "=>", "$", "v", ")", "$", "map", "->", "put", "(", "$", "k", ",", "$", "v", ")", ";", "return", "$", "map", ";", "}" ]
Converts a PHP array into a Map. @see SimpleMap @param array $array the array to convert @return Map the map built from the PHP array
[ "Converts", "a", "PHP", "array", "into", "a", "Map", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/Collections.php#L17-L24
24,802
nathan818fr/phpuc-io-streams
src/InputStream.php
InputStream.skip
public function skip(int $n) : int { if ($n <= 0) { return 0; } $skipped = 0; $skipLimit = min(self::MAX_SKIP_BUFFER_SIZE, $n); while ($skipped < $n) { $buf = $this->read(min($skipLimit, $n - $skipped)); if ($buf === null) { break; } $skipped += strlen($buf); } return $skipped; }
php
public function skip(int $n) : int { if ($n <= 0) { return 0; } $skipped = 0; $skipLimit = min(self::MAX_SKIP_BUFFER_SIZE, $n); while ($skipped < $n) { $buf = $this->read(min($skipLimit, $n - $skipped)); if ($buf === null) { break; } $skipped += strlen($buf); } return $skipped; }
[ "public", "function", "skip", "(", "int", "$", "n", ")", ":", "int", "{", "if", "(", "$", "n", "<=", "0", ")", "{", "return", "0", ";", "}", "$", "skipped", "=", "0", ";", "$", "skipLimit", "=", "min", "(", "self", "::", "MAX_SKIP_BUFFER_SIZE", ",", "$", "n", ")", ";", "while", "(", "$", "skipped", "<", "$", "n", ")", "{", "$", "buf", "=", "$", "this", "->", "read", "(", "min", "(", "$", "skipLimit", ",", "$", "n", "-", "$", "skipped", ")", ")", ";", "if", "(", "$", "buf", "===", "null", ")", "{", "break", ";", "}", "$", "skipped", "+=", "strlen", "(", "$", "buf", ")", ";", "}", "return", "$", "skipped", ";", "}" ]
Skips over and discards n bytes of data from this input stream. @param int $n the number of bytes to be skipped @return int the actual number of bytes skipped @throws IOException
[ "Skips", "over", "and", "discards", "n", "bytes", "of", "data", "from", "this", "input", "stream", "." ]
8f748c1b3338b50e7c6e25a2f2ee73699cadb0ba
https://github.com/nathan818fr/phpuc-io-streams/blob/8f748c1b3338b50e7c6e25a2f2ee73699cadb0ba/src/InputStream.php#L50-L66
24,803
Topolis/FunctionLibrary
src/Token.php
Token.uuid
public static function uuid($version = self::UUID_V4){ switch($version){ case self::UUID_V4: $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); default: throw new Exception("Invalid or unknown uuid version specified"); } }
php
public static function uuid($version = self::UUID_V4){ switch($version){ case self::UUID_V4: $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); default: throw new Exception("Invalid or unknown uuid version specified"); } }
[ "public", "static", "function", "uuid", "(", "$", "version", "=", "self", "::", "UUID_V4", ")", "{", "switch", "(", "$", "version", ")", "{", "case", "self", "::", "UUID_V4", ":", "$", "data", "=", "openssl_random_pseudo_bytes", "(", "16", ")", ";", "$", "data", "[", "6", "]", "=", "chr", "(", "ord", "(", "$", "data", "[", "6", "]", ")", "&", "0x0f", "|", "0x40", ")", ";", "// set version to 0010", "$", "data", "[", "8", "]", "=", "chr", "(", "ord", "(", "$", "data", "[", "8", "]", ")", "&", "0x3f", "|", "0x80", ")", ";", "// set bits 6-7 to 10", "return", "vsprintf", "(", "'%s%s-%s-%s-%s-%s%s%s'", ",", "str_split", "(", "bin2hex", "(", "$", "data", ")", ",", "4", ")", ")", ";", "default", ":", "throw", "new", "Exception", "(", "\"Invalid or unknown uuid version specified\"", ")", ";", "}", "}" ]
Generate a uuid according to a specific UUID definition @param integer $version format/version of UUID to generate @throws \Exception @return string
[ "Generate", "a", "uuid", "according", "to", "a", "specific", "UUID", "definition" ]
bc57f465932fbf297927c2a32765255131b907eb
https://github.com/Topolis/FunctionLibrary/blob/bc57f465932fbf297927c2a32765255131b907eb/src/Token.php#L17-L31
24,804
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.toUser
public function toUser($token = false) { $payload = $this->getPayload($token); if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) { return false; } return $user; }
php
public function toUser($token = false) { $payload = $this->getPayload($token); if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) { return false; } return $user; }
[ "public", "function", "toUser", "(", "$", "token", "=", "false", ")", "{", "$", "payload", "=", "$", "this", "->", "getPayload", "(", "$", "token", ")", ";", "if", "(", "!", "$", "user", "=", "$", "this", "->", "user", "->", "getBy", "(", "$", "this", "->", "identifier", ",", "$", "payload", "[", "'sub'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "user", ";", "}" ]
Find a user using the user identifier in the subject claim. @param bool|string $token @return mixed
[ "Find", "a", "user", "using", "the", "user", "identifier", "in", "the", "subject", "claim", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L63-L72
24,805
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.fromUser
public function fromUser($user, array $customClaims = []) { $payload = $this->makePayload($user->{$this->identifier}, $customClaims); return $this->manager->encode($payload)->get(); }
php
public function fromUser($user, array $customClaims = []) { $payload = $this->makePayload($user->{$this->identifier}, $customClaims); return $this->manager->encode($payload)->get(); }
[ "public", "function", "fromUser", "(", "$", "user", ",", "array", "$", "customClaims", "=", "[", "]", ")", "{", "$", "payload", "=", "$", "this", "->", "makePayload", "(", "$", "user", "->", "{", "$", "this", "->", "identifier", "}", ",", "$", "customClaims", ")", ";", "return", "$", "this", "->", "manager", "->", "encode", "(", "$", "payload", ")", "->", "get", "(", ")", ";", "}" ]
Generate a token using the user identifier as the subject claim. @param mixed $user @param array $customClaims @return string
[ "Generate", "a", "token", "using", "the", "user", "identifier", "as", "the", "subject", "claim", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L82-L87
24,806
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.authenticate
public function authenticate($token = false) { $id = $this->getPayload($token)->get('sub'); if (! $this->auth->byId($id)) { return false; } return $this->auth->user(); }
php
public function authenticate($token = false) { $id = $this->getPayload($token)->get('sub'); if (! $this->auth->byId($id)) { return false; } return $this->auth->user(); }
[ "public", "function", "authenticate", "(", "$", "token", "=", "false", ")", "{", "$", "id", "=", "$", "this", "->", "getPayload", "(", "$", "token", ")", "->", "get", "(", "'sub'", ")", ";", "if", "(", "!", "$", "this", "->", "auth", "->", "byId", "(", "$", "id", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "auth", "->", "user", "(", ")", ";", "}" ]
Authenticate a user via a token. @param mixed $token @return mixed
[ "Authenticate", "a", "user", "via", "a", "token", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L113-L121
24,807
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.getPayload
public function getPayload($token = false) { $this->requireToken($token); return $this->manager->decode($this->token); }
php
public function getPayload($token = false) { $this->requireToken($token); return $this->manager->decode($this->token); }
[ "public", "function", "getPayload", "(", "$", "token", "=", "false", ")", "{", "$", "this", "->", "requireToken", "(", "$", "token", ")", ";", "return", "$", "this", "->", "manager", "->", "decode", "(", "$", "this", "->", "token", ")", ";", "}" ]
Get the raw Payload instance. @param mixed $token @return \Lia\Addons\JWTAuth\Payload
[ "Get", "the", "raw", "Payload", "instance", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L176-L181
24,808
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.parseToken
public function parseToken($method = 'bearer', $header = 'authorization', $query = 'token') { if (! $token = $this->parseAuthHeader($header, $method)) { if (! $token = $this->request->{$query}) { if (! $token = $this->request->header('Token')) { throw new JWTException('The token could not be parsed from the request', 400); } } } return $this->setToken($token); }
php
public function parseToken($method = 'bearer', $header = 'authorization', $query = 'token') { if (! $token = $this->parseAuthHeader($header, $method)) { if (! $token = $this->request->{$query}) { if (! $token = $this->request->header('Token')) { throw new JWTException('The token could not be parsed from the request', 400); } } } return $this->setToken($token); }
[ "public", "function", "parseToken", "(", "$", "method", "=", "'bearer'", ",", "$", "header", "=", "'authorization'", ",", "$", "query", "=", "'token'", ")", "{", "if", "(", "!", "$", "token", "=", "$", "this", "->", "parseAuthHeader", "(", "$", "header", ",", "$", "method", ")", ")", "{", "if", "(", "!", "$", "token", "=", "$", "this", "->", "request", "->", "{", "$", "query", "}", ")", "{", "if", "(", "!", "$", "token", "=", "$", "this", "->", "request", "->", "header", "(", "'Token'", ")", ")", "{", "throw", "new", "JWTException", "(", "'The token could not be parsed from the request'", ",", "400", ")", ";", "}", "}", "}", "return", "$", "this", "->", "setToken", "(", "$", "token", ")", ";", "}" ]
Parse the token from the request. @param string $query @return JWTAuth
[ "Parse", "the", "token", "from", "the", "request", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L190-L201
24,809
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.parseAuthHeader
protected function parseAuthHeader($header = 'authorization', $method = 'bearer') { $header = $this->request->headers->get($header); if (! starts_with(strtolower($header), $method)) { return false; } return trim(str_ireplace($method, '', $header)); }
php
protected function parseAuthHeader($header = 'authorization', $method = 'bearer') { $header = $this->request->headers->get($header); if (! starts_with(strtolower($header), $method)) { return false; } return trim(str_ireplace($method, '', $header)); }
[ "protected", "function", "parseAuthHeader", "(", "$", "header", "=", "'authorization'", ",", "$", "method", "=", "'bearer'", ")", "{", "$", "header", "=", "$", "this", "->", "request", "->", "headers", "->", "get", "(", "$", "header", ")", ";", "if", "(", "!", "starts_with", "(", "strtolower", "(", "$", "header", ")", ",", "$", "method", ")", ")", "{", "return", "false", ";", "}", "return", "trim", "(", "str_ireplace", "(", "$", "method", ",", "''", ",", "$", "header", ")", ")", ";", "}" ]
Parse token from the authorization header. @param string $header @param string $method @return false|string
[ "Parse", "token", "from", "the", "authorization", "header", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L211-L220
24,810
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/JWTAuth.php
JWTAuth.requireToken
protected function requireToken($token) { if ($token) { return $this->setToken($token); } elseif ($this->token) { return $this; } else { throw new JWTException('A token is required', 400); } }
php
protected function requireToken($token) { if ($token) { return $this->setToken($token); } elseif ($this->token) { return $this; } else { throw new JWTException('A token is required', 400); } }
[ "protected", "function", "requireToken", "(", "$", "token", ")", "{", "if", "(", "$", "token", ")", "{", "return", "$", "this", "->", "setToken", "(", "$", "token", ")", ";", "}", "elseif", "(", "$", "this", "->", "token", ")", "{", "return", "$", "this", ";", "}", "else", "{", "throw", "new", "JWTException", "(", "'A token is required'", ",", "400", ")", ";", "}", "}" ]
Ensure that a token is available. @param mixed $token @return JWTAuth @throws \Lia\Addons\JWTAuth\Exceptions\JWTException
[ "Ensure", "that", "a", "token", "is", "available", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L284-L293
24,811
zapheus/zapheus
src/Application.php
Application.add
public function add(ProviderInterface $provider) { $container = $this->container; $this->container = $provider->register($container); $this->providers[] = (string) get_class($provider); return $this; }
php
public function add(ProviderInterface $provider) { $container = $this->container; $this->container = $provider->register($container); $this->providers[] = (string) get_class($provider); return $this; }
[ "public", "function", "add", "(", "ProviderInterface", "$", "provider", ")", "{", "$", "container", "=", "$", "this", "->", "container", ";", "$", "this", "->", "container", "=", "$", "provider", "->", "register", "(", "$", "container", ")", ";", "$", "this", "->", "providers", "[", "]", "=", "(", "string", ")", "get_class", "(", "$", "provider", ")", ";", "return", "$", "this", ";", "}" ]
Adds a new provider to be registered. @param \Zapheus\Provider\ProviderInterface $provider @return self
[ "Adds", "a", "new", "provider", "to", "be", "registered", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Application.php#L74-L83
24,812
zapheus/zapheus
src/Application.php
Application.config
public function config($data) { $items = is_array($data) ? $data : array(); $config = new Provider\Configuration($items); if (is_string($data)) { $config->load($data); } $interface = ProviderInterface::CONFIG; return $this->set($interface, $config); }
php
public function config($data) { $items = is_array($data) ? $data : array(); $config = new Provider\Configuration($items); if (is_string($data)) { $config->load($data); } $interface = ProviderInterface::CONFIG; return $this->set($interface, $config); }
[ "public", "function", "config", "(", "$", "data", ")", "{", "$", "items", "=", "is_array", "(", "$", "data", ")", "?", "$", "data", ":", "array", "(", ")", ";", "$", "config", "=", "new", "Provider", "\\", "Configuration", "(", "$", "items", ")", ";", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "config", "->", "load", "(", "$", "data", ")", ";", "}", "$", "interface", "=", "ProviderInterface", "::", "CONFIG", ";", "return", "$", "this", "->", "set", "(", "$", "interface", ",", "$", "config", ")", ";", "}" ]
Creates a new configuration based on given data. @param array|string $data @return self
[ "Creates", "a", "new", "configuration", "based", "on", "given", "data", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Application.php#L91-L105
24,813
zapheus/zapheus
src/Application.php
Application.emit
public function emit(ResponseInterface $response) { $code = $response->code() . ' ' . $response->reason(); $headers = $response->headers(); $version = $response->version(); foreach ($headers as $name => $values) { header($name . ': ' . implode(',', $values)); } header(sprintf('HTTP/%s %s', $version, $code)); return $response; }
php
public function emit(ResponseInterface $response) { $code = $response->code() . ' ' . $response->reason(); $headers = $response->headers(); $version = $response->version(); foreach ($headers as $name => $values) { header($name . ': ' . implode(',', $values)); } header(sprintf('HTTP/%s %s', $version, $code)); return $response; }
[ "public", "function", "emit", "(", "ResponseInterface", "$", "response", ")", "{", "$", "code", "=", "$", "response", "->", "code", "(", ")", ".", "' '", ".", "$", "response", "->", "reason", "(", ")", ";", "$", "headers", "=", "$", "response", "->", "headers", "(", ")", ";", "$", "version", "=", "$", "response", "->", "version", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "values", ")", "{", "header", "(", "$", "name", ".", "': '", ".", "implode", "(", "','", ",", "$", "values", ")", ")", ";", "}", "header", "(", "sprintf", "(", "'HTTP/%s %s'", ",", "$", "version", ",", "$", "code", ")", ")", ";", "return", "$", "response", ";", "}" ]
Emits the headers from the response instance. @param \Zapheus\Http\Message\ResponseInterface $response @return \Zapheus\Http\Message\ResponseInterface
[ "Emits", "the", "headers", "from", "the", "response", "instance", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Application.php#L113-L129
24,814
zapheus/zapheus
src/Application.php
Application.handle
public function handle(RequestInterface $request) { $handler = new RoutingHandler($this->container); if (! $this->has(Application::MIDDLEWARE)) { return $handler->handle($request); } $dispatcher = $this->get(Application::MIDDLEWARE); return $dispatcher->process($request, $handler); }
php
public function handle(RequestInterface $request) { $handler = new RoutingHandler($this->container); if (! $this->has(Application::MIDDLEWARE)) { return $handler->handle($request); } $dispatcher = $this->get(Application::MIDDLEWARE); return $dispatcher->process($request, $handler); }
[ "public", "function", "handle", "(", "RequestInterface", "$", "request", ")", "{", "$", "handler", "=", "new", "RoutingHandler", "(", "$", "this", "->", "container", ")", ";", "if", "(", "!", "$", "this", "->", "has", "(", "Application", "::", "MIDDLEWARE", ")", ")", "{", "return", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "}", "$", "dispatcher", "=", "$", "this", "->", "get", "(", "Application", "::", "MIDDLEWARE", ")", ";", "return", "$", "dispatcher", "->", "process", "(", "$", "request", ",", "$", "handler", ")", ";", "}" ]
Dispatches the request and returns into a response. @param \Zapheus\Http\Message\RequestInterface $request @return \Zapheus\Http\Message\ResponseInterface
[ "Dispatches", "the", "request", "and", "returns", "into", "a", "response", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Application.php#L150-L162
24,815
ARCANESOFT/SEO
src/ViewComposers/ViewComposer.php
ViewComposer.cacheResults
protected function cacheResults($name, Closure $callback) { return Cache::remember('cache::' . $name, $this->minutes, $callback); }
php
protected function cacheResults($name, Closure $callback) { return Cache::remember('cache::' . $name, $this->minutes, $callback); }
[ "protected", "function", "cacheResults", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "return", "Cache", "::", "remember", "(", "'cache::'", ".", "$", "name", ",", "$", "this", "->", "minutes", ",", "$", "callback", ")", ";", "}" ]
Cache the results. @param string $name @param \Closure $callback @return mixed
[ "Cache", "the", "results", "." ]
ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2
https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/ViewComposers/ViewComposer.php#L39-L42
24,816
squareproton/Bond
src/Bond/RecordManager.php
RecordManager.getTransaction
public function getTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true ) { if( $transaction === self::TRANSACTIONS_ALL ) { return array_keys( $this->queue ); } if( $transaction === self::TRANSACTION_LAST_CREATED ) { if( !$this->queue) { $this->newTransaction(); } $queue = array_keys( $this->queue ); return array_pop( $queue ); } if( $transaction === self::TRANSACTION_LAST_USED ) { if( !$this->queue) { $this->newTransaction(); } return $this->lastTransaction; } if( $transaction === self::TRANSACTION_NEW ) { return $this->newTransaction(); } if( !array_key_exists( $transaction, $this->queue ) ) { if( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ); } return null; } return $transaction; }
php
public function getTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true ) { if( $transaction === self::TRANSACTIONS_ALL ) { return array_keys( $this->queue ); } if( $transaction === self::TRANSACTION_LAST_CREATED ) { if( !$this->queue) { $this->newTransaction(); } $queue = array_keys( $this->queue ); return array_pop( $queue ); } if( $transaction === self::TRANSACTION_LAST_USED ) { if( !$this->queue) { $this->newTransaction(); } return $this->lastTransaction; } if( $transaction === self::TRANSACTION_NEW ) { return $this->newTransaction(); } if( !array_key_exists( $transaction, $this->queue ) ) { if( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ); } return null; } return $transaction; }
[ "public", "function", "getTransaction", "(", "$", "transaction", "=", "self", "::", "TRANSACTION_LAST_USED", ",", "$", "throwExceptionIfNotFound", "=", "true", ")", "{", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTIONS_ALL", ")", "{", "return", "array_keys", "(", "$", "this", "->", "queue", ")", ";", "}", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTION_LAST_CREATED", ")", "{", "if", "(", "!", "$", "this", "->", "queue", ")", "{", "$", "this", "->", "newTransaction", "(", ")", ";", "}", "$", "queue", "=", "array_keys", "(", "$", "this", "->", "queue", ")", ";", "return", "array_pop", "(", "$", "queue", ")", ";", "}", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTION_LAST_USED", ")", "{", "if", "(", "!", "$", "this", "->", "queue", ")", "{", "$", "this", "->", "newTransaction", "(", ")", ";", "}", "return", "$", "this", "->", "lastTransaction", ";", "}", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTION_NEW", ")", "{", "return", "$", "this", "->", "newTransaction", "(", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "transaction", ",", "$", "this", "->", "queue", ")", ")", "{", "if", "(", "$", "throwExceptionIfNotFound", ")", "{", "throw", "new", "TransactionDoesNotExistException", "(", "\"Transaction with this name `{$transaction}` doesn't exist. Sorry.\"", ")", ";", "}", "return", "null", ";", "}", "return", "$", "transaction", ";", "}" ]
Get a transaction name @param scalar The name of a transaction; @param bool Throw exception if we can't find. @return scalar|false in the event of not found
[ "Get", "a", "transaction", "name" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager.php#L409-L446
24,817
squareproton/Bond
src/Bond/RecordManager.php
RecordManager.removeTransaction
public function removeTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true ) { // remove all transactions if( $transaction === self::TRANSACTIONS_ALL ) { $numTransactions = count( $this->queue ); $this->queue = array(); $this->lastTransaction = null; return $numTransactions; } // last created transaction if( $transaction === self::TRANSACTION_LAST_CREATED ) { $keys = array_keys( $this->queue ); if( $transaction = array_pop( $keys ) ) { if( $this->lastTransaction === $transaction ) { $this->lastTransaction = null; } unset( $this->queue[$transaction] ); return 1; } return 0; } // last used if( $transaction === self::TRANSACTION_LAST_USED ) { if( $this->lastTransaction ) { unset( $this->queue[$this->lastTransaction] ); $this->lastTransaction = null; return 0; } return 0; } // array of transactions if( is_array( $transaction ) ) { $output = 0; foreach( $transaction as $name ) { if( array_key_exists( $name, $this->queue ) ) { if( $this->lastTransaction === $name ) { $this->lastTransaction = null; } unset( $this->queue[$name] ); $output++; } elseif ( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$name}` doesn't exist. Sorry." ); } } return $output; } if( is_scalar($transaction) ) { if( array_key_exists( $transaction, $this->queue ) ) { if( $this->lastTransaction === $transaction ) { $this->lastTransaction = null; } unset( $this->queue[$name] ); return 1; } elseif ( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ); } return 0; } throw new \InvalidArgumentException( sprintf( "Not sure how to remove transaction `%s`", print_r( $transaction, true ) ) ); }
php
public function removeTransaction( $transaction = self::TRANSACTION_LAST_USED, $throwExceptionIfNotFound = true ) { // remove all transactions if( $transaction === self::TRANSACTIONS_ALL ) { $numTransactions = count( $this->queue ); $this->queue = array(); $this->lastTransaction = null; return $numTransactions; } // last created transaction if( $transaction === self::TRANSACTION_LAST_CREATED ) { $keys = array_keys( $this->queue ); if( $transaction = array_pop( $keys ) ) { if( $this->lastTransaction === $transaction ) { $this->lastTransaction = null; } unset( $this->queue[$transaction] ); return 1; } return 0; } // last used if( $transaction === self::TRANSACTION_LAST_USED ) { if( $this->lastTransaction ) { unset( $this->queue[$this->lastTransaction] ); $this->lastTransaction = null; return 0; } return 0; } // array of transactions if( is_array( $transaction ) ) { $output = 0; foreach( $transaction as $name ) { if( array_key_exists( $name, $this->queue ) ) { if( $this->lastTransaction === $name ) { $this->lastTransaction = null; } unset( $this->queue[$name] ); $output++; } elseif ( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$name}` doesn't exist. Sorry." ); } } return $output; } if( is_scalar($transaction) ) { if( array_key_exists( $transaction, $this->queue ) ) { if( $this->lastTransaction === $transaction ) { $this->lastTransaction = null; } unset( $this->queue[$name] ); return 1; } elseif ( $throwExceptionIfNotFound ) { throw new TransactionDoesNotExistException( "Transaction with this name `{$transaction}` doesn't exist. Sorry." ); } return 0; } throw new \InvalidArgumentException( sprintf( "Not sure how to remove transaction `%s`", print_r( $transaction, true ) ) ); }
[ "public", "function", "removeTransaction", "(", "$", "transaction", "=", "self", "::", "TRANSACTION_LAST_USED", ",", "$", "throwExceptionIfNotFound", "=", "true", ")", "{", "// remove all transactions", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTIONS_ALL", ")", "{", "$", "numTransactions", "=", "count", "(", "$", "this", "->", "queue", ")", ";", "$", "this", "->", "queue", "=", "array", "(", ")", ";", "$", "this", "->", "lastTransaction", "=", "null", ";", "return", "$", "numTransactions", ";", "}", "// last created transaction", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTION_LAST_CREATED", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "queue", ")", ";", "if", "(", "$", "transaction", "=", "array_pop", "(", "$", "keys", ")", ")", "{", "if", "(", "$", "this", "->", "lastTransaction", "===", "$", "transaction", ")", "{", "$", "this", "->", "lastTransaction", "=", "null", ";", "}", "unset", "(", "$", "this", "->", "queue", "[", "$", "transaction", "]", ")", ";", "return", "1", ";", "}", "return", "0", ";", "}", "// last used", "if", "(", "$", "transaction", "===", "self", "::", "TRANSACTION_LAST_USED", ")", "{", "if", "(", "$", "this", "->", "lastTransaction", ")", "{", "unset", "(", "$", "this", "->", "queue", "[", "$", "this", "->", "lastTransaction", "]", ")", ";", "$", "this", "->", "lastTransaction", "=", "null", ";", "return", "0", ";", "}", "return", "0", ";", "}", "// array of transactions", "if", "(", "is_array", "(", "$", "transaction", ")", ")", "{", "$", "output", "=", "0", ";", "foreach", "(", "$", "transaction", "as", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "queue", ")", ")", "{", "if", "(", "$", "this", "->", "lastTransaction", "===", "$", "name", ")", "{", "$", "this", "->", "lastTransaction", "=", "null", ";", "}", "unset", "(", "$", "this", "->", "queue", "[", "$", "name", "]", ")", ";", "$", "output", "++", ";", "}", "elseif", "(", "$", "throwExceptionIfNotFound", ")", "{", "throw", "new", "TransactionDoesNotExistException", "(", "\"Transaction with this name `{$name}` doesn't exist. Sorry.\"", ")", ";", "}", "}", "return", "$", "output", ";", "}", "if", "(", "is_scalar", "(", "$", "transaction", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "transaction", ",", "$", "this", "->", "queue", ")", ")", "{", "if", "(", "$", "this", "->", "lastTransaction", "===", "$", "transaction", ")", "{", "$", "this", "->", "lastTransaction", "=", "null", ";", "}", "unset", "(", "$", "this", "->", "queue", "[", "$", "name", "]", ")", ";", "return", "1", ";", "}", "elseif", "(", "$", "throwExceptionIfNotFound", ")", "{", "throw", "new", "TransactionDoesNotExistException", "(", "\"Transaction with this name `{$transaction}` doesn't exist. Sorry.\"", ")", ";", "}", "return", "0", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Not sure how to remove transaction `%s`\"", ",", "print_r", "(", "$", "transaction", ",", "true", ")", ")", ")", ";", "}" ]
Remove a transaction @param scalar|array The name of the transaction @param bool Throw a exception if the transaction we want to remove can't be found @return int The number of transactions removed
[ "Remove", "a", "transaction" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/RecordManager.php#L456-L531
24,818
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.send
public function send($closure = null) { if(gettype($closure) == 'object') { call_user_func($closure, $this); } //Renders the optional viewmodels and assign the mail variables to them foreach($this -> viewmodels as $type => $view) { if(null !== $view) { $viewmodel = new ViewModel($view, false); $viewmodel -> assign($this -> variables); $this -> message[$type] = $viewmodel -> render(); } } $to = $this -> formatTo(); $headers = $this -> formatHeaders(); $message = $this -> formatMessage(); @mail($to, $this -> subject, $message, $headers); if(null === error_get_last()) { $this -> send = true; } return $this; }
php
public function send($closure = null) { if(gettype($closure) == 'object') { call_user_func($closure, $this); } //Renders the optional viewmodels and assign the mail variables to them foreach($this -> viewmodels as $type => $view) { if(null !== $view) { $viewmodel = new ViewModel($view, false); $viewmodel -> assign($this -> variables); $this -> message[$type] = $viewmodel -> render(); } } $to = $this -> formatTo(); $headers = $this -> formatHeaders(); $message = $this -> formatMessage(); @mail($to, $this -> subject, $message, $headers); if(null === error_get_last()) { $this -> send = true; } return $this; }
[ "public", "function", "send", "(", "$", "closure", "=", "null", ")", "{", "if", "(", "gettype", "(", "$", "closure", ")", "==", "'object'", ")", "{", "call_user_func", "(", "$", "closure", ",", "$", "this", ")", ";", "}", "//Renders the optional viewmodels and assign the mail variables to them\r", "foreach", "(", "$", "this", "->", "viewmodels", "as", "$", "type", "=>", "$", "view", ")", "{", "if", "(", "null", "!==", "$", "view", ")", "{", "$", "viewmodel", "=", "new", "ViewModel", "(", "$", "view", ",", "false", ")", ";", "$", "viewmodel", "->", "assign", "(", "$", "this", "->", "variables", ")", ";", "$", "this", "->", "message", "[", "$", "type", "]", "=", "$", "viewmodel", "->", "render", "(", ")", ";", "}", "}", "$", "to", "=", "$", "this", "->", "formatTo", "(", ")", ";", "$", "headers", "=", "$", "this", "->", "formatHeaders", "(", ")", ";", "$", "message", "=", "$", "this", "->", "formatMessage", "(", ")", ";", "@", "mail", "(", "$", "to", ",", "$", "this", "->", "subject", ",", "$", "message", ",", "$", "headers", ")", ";", "if", "(", "null", "===", "error_get_last", "(", ")", ")", "{", "$", "this", "->", "send", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Try to send the mail with optional callback. @param object $closure @return sFire\Mail\Mail
[ "Try", "to", "send", "the", "mail", "with", "optional", "callback", "." ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L69-L98
24,819
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.addHeader
public function addHeader($key, $value) { if(false === is_string($key)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR); } if(false === is_string($value)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR); } if(false === isset($this -> headers['custom'])) { $this -> headers['custom'] = []; } $this -> headers['custom'][$key] = $value; }
php
public function addHeader($key, $value) { if(false === is_string($key)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR); } if(false === is_string($value)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR); } if(false === isset($this -> headers['custom'])) { $this -> headers['custom'] = []; } $this -> headers['custom'][$key] = $value; }
[ "public", "function", "addHeader", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "key", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "key", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "===", "is_string", "(", "$", "value", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "value", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "headers", "[", "'custom'", "]", ")", ")", "{", "$", "this", "->", "headers", "[", "'custom'", "]", "=", "[", "]", ";", "}", "$", "this", "->", "headers", "[", "'custom'", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Adds a custom header to the mail @param string $key @param string $value @return sFire\Mail\Mail
[ "Adds", "a", "custom", "header", "to", "the", "mail" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L125-L140
24,820
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.removeHeader
public function removeHeader($key) { if(false === is_string($key)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR); } if(true === isset($this -> headers['custom'][$key])) { unset($this -> headers['custom'][$key]); } }
php
public function removeHeader($key) { if(false === is_string($key)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR); } if(true === isset($this -> headers['custom'][$key])) { unset($this -> headers['custom'][$key]); } }
[ "public", "function", "removeHeader", "(", "$", "key", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "key", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "key", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'custom'", "]", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "headers", "[", "'custom'", "]", "[", "$", "key", "]", ")", ";", "}", "}" ]
Removes a custom header by key @param string $key @return sFire\Mail\Mail
[ "Removes", "a", "custom", "header", "by", "key" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L180-L189
24,821
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.render
public function render($htmlview = null, $textview = null) { if(null !== $htmlview && false === is_string($htmlview)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($htmlview)), E_USER_ERROR); } if(null !== $textview && false === is_string($textview)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($textview)), E_USER_ERROR); } $this -> viewmodels = ['html' => $htmlview, 'text' => $textview]; return $this; }
php
public function render($htmlview = null, $textview = null) { if(null !== $htmlview && false === is_string($htmlview)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($htmlview)), E_USER_ERROR); } if(null !== $textview && false === is_string($textview)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($textview)), E_USER_ERROR); } $this -> viewmodels = ['html' => $htmlview, 'text' => $textview]; return $this; }
[ "public", "function", "render", "(", "$", "htmlview", "=", "null", ",", "$", "textview", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "htmlview", "&&", "false", "===", "is_string", "(", "$", "htmlview", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "htmlview", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "textview", "&&", "false", "===", "is_string", "(", "$", "textview", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "textview", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "viewmodels", "=", "[", "'html'", "=>", "$", "htmlview", ",", "'text'", "=>", "$", "textview", "]", ";", "return", "$", "this", ";", "}" ]
Parses the message by given an optional HTML view and an optional plain text view @param string $htmlview @param string $textview @return sFire\Mail\Mail
[ "Parses", "the", "message", "by", "given", "an", "optional", "HTML", "view", "and", "an", "optional", "plain", "text", "view" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L257-L270
24,822
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.priority
public function priority($level = 1) { if(false === ('-' . intval($level) == '-' . $level)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($level)), E_USER_ERROR); } if($level < 1 || $level > 5) { return trigger_error(sprintf('Argument 1 passed to %s() should be between 1 and 5, "%s" given', __METHOD__, $level), E_USER_ERROR); } $priorities = [ 1 => ['1 (Highest)', 'High', 'High'], 2 => ['2 (High)', 'High', 'High'], 3 => ['3 (Normal)', 'Normal', 'Normal'], 4 => ['4 (Low)', 'Low', 'Low'], 5 => ['5 (Lowest)', 'Low', 'Low'], ]; $this -> headers['priority'] = $priorities[$level]; return $this; }
php
public function priority($level = 1) { if(false === ('-' . intval($level) == '-' . $level)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($level)), E_USER_ERROR); } if($level < 1 || $level > 5) { return trigger_error(sprintf('Argument 1 passed to %s() should be between 1 and 5, "%s" given', __METHOD__, $level), E_USER_ERROR); } $priorities = [ 1 => ['1 (Highest)', 'High', 'High'], 2 => ['2 (High)', 'High', 'High'], 3 => ['3 (Normal)', 'Normal', 'Normal'], 4 => ['4 (Low)', 'Low', 'Low'], 5 => ['5 (Lowest)', 'Low', 'Low'], ]; $this -> headers['priority'] = $priorities[$level]; return $this; }
[ "public", "function", "priority", "(", "$", "level", "=", "1", ")", "{", "if", "(", "false", "===", "(", "'-'", ".", "intval", "(", "$", "level", ")", "==", "'-'", ".", "$", "level", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type integer, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "level", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "$", "level", "<", "1", "||", "$", "level", ">", "5", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() should be between 1 and 5, \"%s\" given'", ",", "__METHOD__", ",", "$", "level", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "priorities", "=", "[", "1", "=>", "[", "'1 (Highest)'", ",", "'High'", ",", "'High'", "]", ",", "2", "=>", "[", "'2 (High)'", ",", "'High'", ",", "'High'", "]", ",", "3", "=>", "[", "'3 (Normal)'", ",", "'Normal'", ",", "'Normal'", "]", ",", "4", "=>", "[", "'4 (Low)'", ",", "'Low'", ",", "'Low'", "]", ",", "5", "=>", "[", "'5 (Lowest)'", ",", "'Low'", ",", "'Low'", "]", ",", "]", ";", "$", "this", "->", "headers", "[", "'priority'", "]", "=", "$", "priorities", "[", "$", "level", "]", ";", "return", "$", "this", ";", "}" ]
Sets the priority Level between 1 and 5 @param int $level @return sFire\Mail\Mail
[ "Sets", "the", "priority", "Level", "between", "1", "and", "5" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L296-L318
24,823
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.to
public function to($email, $name = null) { if(false === $this -> validateEmail($email)) { return trigger_error(sprintf('Argument 1 passed to %s() must be a valid email', __METHOD__), E_USER_ERROR); } if(null !== $name && false === is_string($name)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR); } if(false === isset($this -> headers['to'])) { $this -> headers['to'] = []; } $this -> headers['to'][] = (object) ['email' => $email, 'name' => $name]; return $this; }
php
public function to($email, $name = null) { if(false === $this -> validateEmail($email)) { return trigger_error(sprintf('Argument 1 passed to %s() must be a valid email', __METHOD__), E_USER_ERROR); } if(null !== $name && false === is_string($name)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR); } if(false === isset($this -> headers['to'])) { $this -> headers['to'] = []; } $this -> headers['to'][] = (object) ['email' => $email, 'name' => $name]; return $this; }
[ "public", "function", "to", "(", "$", "email", ",", "$", "name", "=", "null", ")", "{", "if", "(", "false", "===", "$", "this", "->", "validateEmail", "(", "$", "email", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be a valid email'", ",", "__METHOD__", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "name", "&&", "false", "===", "is_string", "(", "$", "name", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "name", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "headers", "[", "'to'", "]", ")", ")", "{", "$", "this", "->", "headers", "[", "'to'", "]", "=", "[", "]", ";", "}", "$", "this", "->", "headers", "[", "'to'", "]", "[", "]", "=", "(", "object", ")", "[", "'email'", "=>", "$", "email", ",", "'name'", "=>", "$", "name", "]", ";", "return", "$", "this", ";", "}" ]
Adds to email @param string $email @param string $name @return sFire\Mail\Mail
[ "Adds", "to", "email" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L327-L344
24,824
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.validateEmail
private function validateEmail($email) { if(true === is_string($email)) { return false !== filter_var(trim($email), \FILTER_VALIDATE_EMAIL); } return false; }
php
private function validateEmail($email) { if(true === is_string($email)) { return false !== filter_var(trim($email), \FILTER_VALIDATE_EMAIL); } return false; }
[ "private", "function", "validateEmail", "(", "$", "email", ")", "{", "if", "(", "true", "===", "is_string", "(", "$", "email", ")", ")", "{", "return", "false", "!==", "filter_var", "(", "trim", "(", "$", "email", ")", ",", "\\", "FILTER_VALIDATE_EMAIL", ")", ";", "}", "return", "false", ";", "}" ]
Returns if a email is valid or not @param string email @return boolean
[ "Returns", "if", "a", "email", "is", "valid", "or", "not" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L473-L480
24,825
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.emailsToString
private function emailsToString($emails) { $format = []; foreach($emails as $email) { if(true === isset($email -> name) && trim($email -> name) !== '') { $format[] = sprintf('"%s" <%s>', $email -> name, filter_var($email -> email, FILTER_SANITIZE_EMAIL)); } else { $format[] = filter_var($email -> email, FILTER_SANITIZE_EMAIL); } } $emails = implode($format, ','); return ('' !== trim($emails)) ? $emails : null; }
php
private function emailsToString($emails) { $format = []; foreach($emails as $email) { if(true === isset($email -> name) && trim($email -> name) !== '') { $format[] = sprintf('"%s" <%s>', $email -> name, filter_var($email -> email, FILTER_SANITIZE_EMAIL)); } else { $format[] = filter_var($email -> email, FILTER_SANITIZE_EMAIL); } } $emails = implode($format, ','); return ('' !== trim($emails)) ? $emails : null; }
[ "private", "function", "emailsToString", "(", "$", "emails", ")", "{", "$", "format", "=", "[", "]", ";", "foreach", "(", "$", "emails", "as", "$", "email", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "email", "->", "name", ")", "&&", "trim", "(", "$", "email", "->", "name", ")", "!==", "''", ")", "{", "$", "format", "[", "]", "=", "sprintf", "(", "'\"%s\" <%s>'", ",", "$", "email", "->", "name", ",", "filter_var", "(", "$", "email", "->", "email", ",", "FILTER_SANITIZE_EMAIL", ")", ")", ";", "}", "else", "{", "$", "format", "[", "]", "=", "filter_var", "(", "$", "email", "->", "email", ",", "FILTER_SANITIZE_EMAIL", ")", ";", "}", "}", "$", "emails", "=", "implode", "(", "$", "format", ",", "','", ")", ";", "return", "(", "''", "!==", "trim", "(", "$", "emails", ")", ")", "?", "$", "emails", ":", "null", ";", "}" ]
Formats an array with emails to string @param array $emails @return null|string
[ "Formats", "an", "array", "with", "emails", "to", "string" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L488-L505
24,826
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.formatTo
private function formatTo() { $to = null; if(true === isset($this -> headers['to'])) { $to = $this -> emailsToString($this -> headers['to']); } return $to; }
php
private function formatTo() { $to = null; if(true === isset($this -> headers['to'])) { $to = $this -> emailsToString($this -> headers['to']); } return $to; }
[ "private", "function", "formatTo", "(", ")", "{", "$", "to", "=", "null", ";", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'to'", "]", ")", ")", "{", "$", "to", "=", "$", "this", "->", "emailsToString", "(", "$", "this", "->", "headers", "[", "'to'", "]", ")", ";", "}", "return", "$", "to", ";", "}" ]
Formats the "to" email and returns it @return string
[ "Formats", "the", "to", "email", "and", "returns", "it" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L512-L521
24,827
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.formatHeaders
private function formatHeaders() { $headers = []; $files = true === isset($this -> headers['files']) ? $this -> headers['files'] : []; //Prepair emailaddresses foreach(['BCC', 'CC', 'Reply-To', 'From'] as $type) { if(true === isset($this -> headers[strtolower($type)])) { $headers[] = sprintf("%s: %s\r\n", $type, $this -> emailsToString($this -> headers[strtolower($type)])); } } //Notify if($notify = $this -> formatNotify()) { $headers[] = sprintf("Disposition-Notification-To: %s\r\n", $notify); $headers[] = sprintf("X-Confirm-Reading-To: %s\r\n", $notify); } //Priority if(true === isset($this -> headers['priority'])) { $headers[] = sprintf("X-Priority: %s\r\n", $this -> headers['priority'][0]); $headers[] = sprintf("X-MSMail-Priority: %s\r\n", $this -> headers['priority'][1]); $headers[] = sprintf("Importance: %s\r\n", $this -> headers['priority'][2]); } //Custom headers if(true === isset($this -> headers['custom'])) { foreach($this -> headers['custom'] as $key => $value) { $headers[] = sprintf("%s: %s\r\n", $key, $value); } } //Files if(count($files) > 0) { $headers[] = sprintf("Content-Type: multipart/mixed; boundary=\"Boundary-mixed-%s\"\r\n", $this -> getBoundary()); } else { $headers[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary()); } return implode('', $headers); }
php
private function formatHeaders() { $headers = []; $files = true === isset($this -> headers['files']) ? $this -> headers['files'] : []; //Prepair emailaddresses foreach(['BCC', 'CC', 'Reply-To', 'From'] as $type) { if(true === isset($this -> headers[strtolower($type)])) { $headers[] = sprintf("%s: %s\r\n", $type, $this -> emailsToString($this -> headers[strtolower($type)])); } } //Notify if($notify = $this -> formatNotify()) { $headers[] = sprintf("Disposition-Notification-To: %s\r\n", $notify); $headers[] = sprintf("X-Confirm-Reading-To: %s\r\n", $notify); } //Priority if(true === isset($this -> headers['priority'])) { $headers[] = sprintf("X-Priority: %s\r\n", $this -> headers['priority'][0]); $headers[] = sprintf("X-MSMail-Priority: %s\r\n", $this -> headers['priority'][1]); $headers[] = sprintf("Importance: %s\r\n", $this -> headers['priority'][2]); } //Custom headers if(true === isset($this -> headers['custom'])) { foreach($this -> headers['custom'] as $key => $value) { $headers[] = sprintf("%s: %s\r\n", $key, $value); } } //Files if(count($files) > 0) { $headers[] = sprintf("Content-Type: multipart/mixed; boundary=\"Boundary-mixed-%s\"\r\n", $this -> getBoundary()); } else { $headers[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary()); } return implode('', $headers); }
[ "private", "function", "formatHeaders", "(", ")", "{", "$", "headers", "=", "[", "]", ";", "$", "files", "=", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'files'", "]", ")", "?", "$", "this", "->", "headers", "[", "'files'", "]", ":", "[", "]", ";", "//Prepair emailaddresses\r", "foreach", "(", "[", "'BCC'", ",", "'CC'", ",", "'Reply-To'", ",", "'From'", "]", "as", "$", "type", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "strtolower", "(", "$", "type", ")", "]", ")", ")", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"%s: %s\\r\\n\"", ",", "$", "type", ",", "$", "this", "->", "emailsToString", "(", "$", "this", "->", "headers", "[", "strtolower", "(", "$", "type", ")", "]", ")", ")", ";", "}", "}", "//Notify\r", "if", "(", "$", "notify", "=", "$", "this", "->", "formatNotify", "(", ")", ")", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"Disposition-Notification-To: %s\\r\\n\"", ",", "$", "notify", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "\"X-Confirm-Reading-To: %s\\r\\n\"", ",", "$", "notify", ")", ";", "}", "//Priority\r", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'priority'", "]", ")", ")", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"X-Priority: %s\\r\\n\"", ",", "$", "this", "->", "headers", "[", "'priority'", "]", "[", "0", "]", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "\"X-MSMail-Priority: %s\\r\\n\"", ",", "$", "this", "->", "headers", "[", "'priority'", "]", "[", "1", "]", ")", ";", "$", "headers", "[", "]", "=", "sprintf", "(", "\"Importance: %s\\r\\n\"", ",", "$", "this", "->", "headers", "[", "'priority'", "]", "[", "2", "]", ")", ";", "}", "//Custom headers\r", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'custom'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "headers", "[", "'custom'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"%s: %s\\r\\n\"", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "//Files\r", "if", "(", "count", "(", "$", "files", ")", ">", "0", ")", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"Content-Type: multipart/mixed; boundary=\\\"Boundary-mixed-%s\\\"\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "}", "else", "{", "$", "headers", "[", "]", "=", "sprintf", "(", "\"Content-Type: multipart/alternative; boundary=\\\"Boundary-alt-%s\\\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "}", "return", "implode", "(", "''", ",", "$", "headers", ")", ";", "}" ]
Formats the headers and returns it as a string @return string
[ "Formats", "the", "headers", "and", "returns", "it", "as", "a", "string" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L528-L573
24,828
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.formatMessage
private function formatMessage() { $message = []; $files = true === isset($this -> headers['files']) ? $this -> headers['files'] : []; if(count($files) > 0) { $message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary()); $message[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary()); } if(true === isset($this -> message['text'])) { $message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary()); $message[] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n"; $message[] = sprintf("%s\r\n\r\n", $this -> message['text']); } if(true === isset($this -> message['html'])) { $message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary()); $message[] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n"; $message[] = sprintf("%s\r\n\r\n", $this -> message['html']); } $message[] = sprintf("--Boundary-alt-%s--\r\n\r\n", $this -> getBoundary()); if(count($files) > 0) { foreach($files as $attachment) { $stream = fopen($attachment -> file -> entity() -> getBasepath(), 'rb'); $data = fread($stream, $attachment -> file -> getFilesize()); $data = chunk_split(base64_encode($data)); $message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary()); $message[] = sprintf("Content-Type: %s; name=\"%s\"\r\n", $attachment -> mime, $attachment -> name); $message[] = "Content-Transfer-Encoding: base64\r\n"; $message[] = "Content-Disposition: attachment \r\n\r\n"; $message[] = sprintf("%s\r\n", $data); } $message[] = sprintf("--Boundary-mixed-%s--\r\n", $this -> getBoundary()); } return implode('', $message); }
php
private function formatMessage() { $message = []; $files = true === isset($this -> headers['files']) ? $this -> headers['files'] : []; if(count($files) > 0) { $message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary()); $message[] = sprintf("Content-Type: multipart/alternative; boundary=\"Boundary-alt-%s\"\r\n\r\n", $this -> getBoundary()); } if(true === isset($this -> message['text'])) { $message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary()); $message[] = "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n"; $message[] = sprintf("%s\r\n\r\n", $this -> message['text']); } if(true === isset($this -> message['html'])) { $message[] = sprintf("--Boundary-alt-%s\r\n", $this -> getBoundary()); $message[] = "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $message[] = "Content-Transfer-Encoding: 7bit\r\n\r\n"; $message[] = sprintf("%s\r\n\r\n", $this -> message['html']); } $message[] = sprintf("--Boundary-alt-%s--\r\n\r\n", $this -> getBoundary()); if(count($files) > 0) { foreach($files as $attachment) { $stream = fopen($attachment -> file -> entity() -> getBasepath(), 'rb'); $data = fread($stream, $attachment -> file -> getFilesize()); $data = chunk_split(base64_encode($data)); $message[] = sprintf("--Boundary-mixed-%s\r\n", $this -> getBoundary()); $message[] = sprintf("Content-Type: %s; name=\"%s\"\r\n", $attachment -> mime, $attachment -> name); $message[] = "Content-Transfer-Encoding: base64\r\n"; $message[] = "Content-Disposition: attachment \r\n\r\n"; $message[] = sprintf("%s\r\n", $data); } $message[] = sprintf("--Boundary-mixed-%s--\r\n", $this -> getBoundary()); } return implode('', $message); }
[ "private", "function", "formatMessage", "(", ")", "{", "$", "message", "=", "[", "]", ";", "$", "files", "=", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'files'", "]", ")", "?", "$", "this", "->", "headers", "[", "'files'", "]", ":", "[", "]", ";", "if", "(", "count", "(", "$", "files", ")", ">", "0", ")", "{", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-mixed-%s\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"Content-Type: multipart/alternative; boundary=\\\"Boundary-alt-%s\\\"\\r\\n\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "}", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "message", "[", "'text'", "]", ")", ")", "{", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-alt-%s\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "$", "message", "[", "]", "=", "\"Content-Type: text/plain; charset=\\\"iso-8859-1\\\"\\r\\n\"", ";", "$", "message", "[", "]", "=", "\"Content-Transfer-Encoding: 7bit\\r\\n\\r\\n\"", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\\r\\n\"", ",", "$", "this", "->", "message", "[", "'text'", "]", ")", ";", "}", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "message", "[", "'html'", "]", ")", ")", "{", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-alt-%s\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "$", "message", "[", "]", "=", "\"Content-Type: text/html; charset=\\\"iso-8859-1\\\"\\r\\n\"", ";", "$", "message", "[", "]", "=", "\"Content-Transfer-Encoding: 7bit\\r\\n\\r\\n\"", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\\r\\n\"", ",", "$", "this", "->", "message", "[", "'html'", "]", ")", ";", "}", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-alt-%s--\\r\\n\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "if", "(", "count", "(", "$", "files", ")", ">", "0", ")", "{", "foreach", "(", "$", "files", "as", "$", "attachment", ")", "{", "$", "stream", "=", "fopen", "(", "$", "attachment", "->", "file", "->", "entity", "(", ")", "->", "getBasepath", "(", ")", ",", "'rb'", ")", ";", "$", "data", "=", "fread", "(", "$", "stream", ",", "$", "attachment", "->", "file", "->", "getFilesize", "(", ")", ")", ";", "$", "data", "=", "chunk_split", "(", "base64_encode", "(", "$", "data", ")", ")", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-mixed-%s\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"Content-Type: %s; name=\\\"%s\\\"\\r\\n\"", ",", "$", "attachment", "->", "mime", ",", "$", "attachment", "->", "name", ")", ";", "$", "message", "[", "]", "=", "\"Content-Transfer-Encoding: base64\\r\\n\"", ";", "$", "message", "[", "]", "=", "\"Content-Disposition: attachment \\r\\n\\r\\n\"", ";", "$", "message", "[", "]", "=", "sprintf", "(", "\"%s\\r\\n\"", ",", "$", "data", ")", ";", "}", "$", "message", "[", "]", "=", "sprintf", "(", "\"--Boundary-mixed-%s--\\r\\n\"", ",", "$", "this", "->", "getBoundary", "(", ")", ")", ";", "}", "return", "implode", "(", "''", ",", "$", "message", ")", ";", "}" ]
Formats the messages and returns it as a string @return string
[ "Formats", "the", "messages", "and", "returns", "it", "as", "a", "string" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L580-L628
24,829
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.formatNotify
private function formatNotify() { $notify = null; if(true === isset($this -> headers['notify'])) { $notify = $this -> emailsToString($this -> headers['notify']); if(null === $notify) { if(true === isset($this -> headers['from'])) { $notify = $this -> emailsToString($this -> headers['from']); } else { $notify = ini_get('sendmail_from'); } } } return $notify; }
php
private function formatNotify() { $notify = null; if(true === isset($this -> headers['notify'])) { $notify = $this -> emailsToString($this -> headers['notify']); if(null === $notify) { if(true === isset($this -> headers['from'])) { $notify = $this -> emailsToString($this -> headers['from']); } else { $notify = ini_get('sendmail_from'); } } } return $notify; }
[ "private", "function", "formatNotify", "(", ")", "{", "$", "notify", "=", "null", ";", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'notify'", "]", ")", ")", "{", "$", "notify", "=", "$", "this", "->", "emailsToString", "(", "$", "this", "->", "headers", "[", "'notify'", "]", ")", ";", "if", "(", "null", "===", "$", "notify", ")", "{", "if", "(", "true", "===", "isset", "(", "$", "this", "->", "headers", "[", "'from'", "]", ")", ")", "{", "$", "notify", "=", "$", "this", "->", "emailsToString", "(", "$", "this", "->", "headers", "[", "'from'", "]", ")", ";", "}", "else", "{", "$", "notify", "=", "ini_get", "(", "'sendmail_from'", ")", ";", "}", "}", "}", "return", "$", "notify", ";", "}" ]
Formats the notify email and returns it @return null|string
[ "Formats", "the", "notify", "email", "and", "returns", "it" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L635-L655
24,830
Kris-Kuiper/sFire-Framework
src/Mail/Mail.php
Mail.getBoundary
private function getBoundary() { if(null === $this -> boundary) { $this -> boundary = md5(date('r', time())); } return $this -> boundary; }
php
private function getBoundary() { if(null === $this -> boundary) { $this -> boundary = md5(date('r', time())); } return $this -> boundary; }
[ "private", "function", "getBoundary", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "boundary", ")", "{", "$", "this", "->", "boundary", "=", "md5", "(", "date", "(", "'r'", ",", "time", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "boundary", ";", "}" ]
Generates if needed and returns the boundary @return string
[ "Generates", "if", "needed", "and", "returns", "the", "boundary" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Mail/Mail.php#L662-L669
24,831
jstewmc/path
src/Path.php
Path.format
public function format() { $string = ''; if ( ! empty($this->segments)) { $string = implode($this->separator, $this->segments); } return $string; }
php
public function format() { $string = ''; if ( ! empty($this->segments)) { $string = implode($this->separator, $this->segments); } return $string; }
[ "public", "function", "format", "(", ")", "{", "$", "string", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "segments", ")", ")", "{", "$", "string", "=", "implode", "(", "$", "this", "->", "separator", ",", "$", "this", "->", "segments", ")", ";", "}", "return", "$", "string", ";", "}" ]
Returns the path as a string @return string @since 0.1.0
[ "Returns", "the", "path", "as", "a", "string" ]
d9813721cc10407710113865bd8baae7419b2f84
https://github.com/jstewmc/path/blob/d9813721cc10407710113865bd8baae7419b2f84/src/Path.php#L137-L146
24,832
jstewmc/path
src/Path.php
Path.parse
public function parse($path) { if (is_string($path)) { if (substr($path, 0, 1) === $this->separator) { $path = substr($path, 1); } $this->segments = explode($this->separator, $path); } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, path, to be a string" ); } return; }
php
public function parse($path) { if (is_string($path)) { if (substr($path, 0, 1) === $this->separator) { $path = substr($path, 1); } $this->segments = explode($this->separator, $path); } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, path, to be a string" ); } return; }
[ "public", "function", "parse", "(", "$", "path", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "===", "$", "this", "->", "separator", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "$", "this", "->", "segments", "=", "explode", "(", "$", "this", "->", "separator", ",", "$", "path", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\"() expects parameter one, path, to be a string\"", ")", ";", "}", "return", ";", "}" ]
Parses the string path into this Path object Keep in mind, if $path does not use the default separator, you should set the path's separator first, before calling parse(). @param string $path the path to parse (with or without leading separator) @return self @throws InvalidArgumentException if $path is not a string @since 0.1.0
[ "Parses", "the", "string", "path", "into", "this", "Path", "object" ]
d9813721cc10407710113865bd8baae7419b2f84
https://github.com/jstewmc/path/blob/d9813721cc10407710113865bd8baae7419b2f84/src/Path.php#L488-L502
24,833
jstewmc/path
src/Path.php
Path.slice
public function slice($offset, $length = null) { if (is_numeric($offset) && is_int(+$offset)) { if ($length === null || (is_numeric($length) && is_int(+$length))) { $this->segments = array_slice($this->segments, $offset, $length); } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter two, length, to be null or an integer" ); } } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, offset, to be an integer" ); } return $this; }
php
public function slice($offset, $length = null) { if (is_numeric($offset) && is_int(+$offset)) { if ($length === null || (is_numeric($length) && is_int(+$length))) { $this->segments = array_slice($this->segments, $offset, $length); } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter two, length, to be null or an integer" ); } } else { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, offset, to be an integer" ); } return $this; }
[ "public", "function", "slice", "(", "$", "offset", ",", "$", "length", "=", "null", ")", "{", "if", "(", "is_numeric", "(", "$", "offset", ")", "&&", "is_int", "(", "+", "$", "offset", ")", ")", "{", "if", "(", "$", "length", "===", "null", "||", "(", "is_numeric", "(", "$", "length", ")", "&&", "is_int", "(", "+", "$", "length", ")", ")", ")", "{", "$", "this", "->", "segments", "=", "array_slice", "(", "$", "this", "->", "segments", ",", "$", "offset", ",", "$", "length", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\"() expects parameter two, length, to be null or an integer\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\"() expects parameter one, offset, to be an integer\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Slices the path Keep in mind, I will change this path. To keep this path the same and return a new, sliced Path, use the getSlice() method instead. For example: $path = new Path('foo/bar/baz'); $path->slice(1); echo $path; // prints "bar/baz" @param int $offset if offset is non-negative, the slice will start at that offset from the beginning of the path; if offset is negative, the slice will start that far from the end of the path @param int $length if length is given and positive, the slice will have up to that many segments in it; if the path is shorter than length, then only the available segments will be present; if length is given and negative, the slice will stop that many segments from the end of the path; finally, if length is omitted, the slice will have everything from the offset to the end of the path (optional; if omitted, defaults to null) @return self @throws InvalidArgumentException if $offset is not an integer @throws InvalidArgumentException if $length is not null or an integer @since 0.1.0
[ "Slices", "the", "path" ]
d9813721cc10407710113865bd8baae7419b2f84
https://github.com/jstewmc/path/blob/d9813721cc10407710113865bd8baae7419b2f84/src/Path.php#L649-L666
24,834
alkemann/h.l
src/debug/util/Debug.php
Debug.array_out
public function array_out($key = null) { if (count($this->output) < 2 || ($key && !isset($this->output[$key]))) { return array(); } if ($key) { return $this->output[$key]; } array_shift($this->output); return $this->output; }
php
public function array_out($key = null) { if (count($this->output) < 2 || ($key && !isset($this->output[$key]))) { return array(); } if ($key) { return $this->output[$key]; } array_shift($this->output); return $this->output; }
[ "public", "function", "array_out", "(", "$", "key", "=", "null", ")", "{", "if", "(", "count", "(", "$", "this", "->", "output", ")", "<", "2", "||", "(", "$", "key", "&&", "!", "isset", "(", "$", "this", "->", "output", "[", "$", "key", "]", ")", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "key", ")", "{", "return", "$", "this", "->", "output", "[", "$", "key", "]", ";", "}", "array_shift", "(", "$", "this", "->", "output", ")", ";", "return", "$", "this", "->", "output", ";", "}" ]
Return output dump as array @param string $key @return array
[ "Return", "output", "dump", "as", "array" ]
0ba9a9738e317b32c4d6f800c618524fccfdbc9a
https://github.com/alkemann/h.l/blob/0ba9a9738e317b32c4d6f800c618524fccfdbc9a/src/debug/util/Debug.php#L115-L124
24,835
alkemann/h.l
src/debug/util/Debug.php
Debug.out
public function out($key = null) { if ($this->options['mode'] == 'Html') { \alkemann\hl\debug\util\adapters\Html::top($this->output, $key); return; } $this->__out($key); }
php
public function out($key = null) { if ($this->options['mode'] == 'Html') { \alkemann\hl\debug\util\adapters\Html::top($this->output, $key); return; } $this->__out($key); }
[ "public", "function", "out", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "this", "->", "options", "[", "'mode'", "]", "==", "'Html'", ")", "{", "\\", "alkemann", "\\", "hl", "\\", "debug", "\\", "util", "\\", "adapters", "\\", "Html", "::", "top", "(", "$", "this", "->", "output", ",", "$", "key", ")", ";", "return", ";", "}", "$", "this", "->", "__out", "(", "$", "key", ")", ";", "}" ]
Echo out stored debugging @param int $key
[ "Echo", "out", "stored", "debugging" ]
0ba9a9738e317b32c4d6f800c618524fccfdbc9a
https://github.com/alkemann/h.l/blob/0ba9a9738e317b32c4d6f800c618524fccfdbc9a/src/debug/util/Debug.php#L131-L137
24,836
alkemann/h.l
src/debug/util/Debug.php
Debug.defines
public function defines() { $defines = get_defined_constants(); $ret = array(); $offset = -1; while ($def = array_slice($defines, $offset--, 1)) { $key = key($def); $value = current($def); if ($key == 'FIRST_APP_CONSTANT') break; $ret[$key ] = $value; } return $ret; }
php
public function defines() { $defines = get_defined_constants(); $ret = array(); $offset = -1; while ($def = array_slice($defines, $offset--, 1)) { $key = key($def); $value = current($def); if ($key == 'FIRST_APP_CONSTANT') break; $ret[$key ] = $value; } return $ret; }
[ "public", "function", "defines", "(", ")", "{", "$", "defines", "=", "get_defined_constants", "(", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "$", "offset", "=", "-", "1", ";", "while", "(", "$", "def", "=", "array_slice", "(", "$", "defines", ",", "$", "offset", "--", ",", "1", ")", ")", "{", "$", "key", "=", "key", "(", "$", "def", ")", ";", "$", "value", "=", "current", "(", "$", "def", ")", ";", "if", "(", "$", "key", "==", "'FIRST_APP_CONSTANT'", ")", "break", ";", "$", "ret", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "ret", ";", "}" ]
Grab global defines, will start at 'FIRST_APP_CONSTANT', if defined @return type
[ "Grab", "global", "defines", "will", "start", "at", "FIRST_APP_CONSTANT", "if", "defined" ]
0ba9a9738e317b32c4d6f800c618524fccfdbc9a
https://github.com/alkemann/h.l/blob/0ba9a9738e317b32c4d6f800c618524fccfdbc9a/src/debug/util/Debug.php#L158-L168
24,837
alkemann/h.l
src/debug/util/Debug.php
Debug.dump_it
public function dump_it($var) { $adapter = '\alkemann\hl\debug\util\adapters\\'. $this->options['mode']; if (is_array($var)) return $adapter::dump_array($var, $this); elseif (is_object($var)) return $adapter::dump_object($var, $this); else return $adapter::dump_other($var); }
php
public function dump_it($var) { $adapter = '\alkemann\hl\debug\util\adapters\\'. $this->options['mode']; if (is_array($var)) return $adapter::dump_array($var, $this); elseif (is_object($var)) return $adapter::dump_object($var, $this); else return $adapter::dump_other($var); }
[ "public", "function", "dump_it", "(", "$", "var", ")", "{", "$", "adapter", "=", "'\\alkemann\\hl\\debug\\util\\adapters\\\\'", ".", "$", "this", "->", "options", "[", "'mode'", "]", ";", "if", "(", "is_array", "(", "$", "var", ")", ")", "return", "$", "adapter", "::", "dump_array", "(", "$", "var", ",", "$", "this", ")", ";", "elseif", "(", "is_object", "(", "$", "var", ")", ")", "return", "$", "adapter", "::", "dump_object", "(", "$", "var", ",", "$", "this", ")", ";", "else", "return", "$", "adapter", "::", "dump_other", "(", "$", "var", ")", ";", "}" ]
Send a variable to the adapter and return it's formated output @param mixed $var @return string
[ "Send", "a", "variable", "to", "the", "adapter", "and", "return", "it", "s", "formated", "output" ]
0ba9a9738e317b32c4d6f800c618524fccfdbc9a
https://github.com/alkemann/h.l/blob/0ba9a9738e317b32c4d6f800c618524fccfdbc9a/src/debug/util/Debug.php#L176-L184
24,838
alkemann/h.l
src/debug/util/Debug.php
Debug.location
public function location($trace) { $root = substr($_SERVER['DOCUMENT_ROOT'], 0 , strlen(static::$defaults['docroot']) * -1); $file = implode('/', array_diff(explode('/', $trace[0]['file']), explode('/', $root))); $ret = array( 'file' => $file, 'line' => $trace[0]['line'] ); if (isset($trace[1]['function'])) $ret['function'] = $trace[1]['function']; if (isset($trace[1]['class'])) $ret['class'] = $trace[1]['class']; return $ret; }
php
public function location($trace) { $root = substr($_SERVER['DOCUMENT_ROOT'], 0 , strlen(static::$defaults['docroot']) * -1); $file = implode('/', array_diff(explode('/', $trace[0]['file']), explode('/', $root))); $ret = array( 'file' => $file, 'line' => $trace[0]['line'] ); if (isset($trace[1]['function'])) $ret['function'] = $trace[1]['function']; if (isset($trace[1]['class'])) $ret['class'] = $trace[1]['class']; return $ret; }
[ "public", "function", "location", "(", "$", "trace", ")", "{", "$", "root", "=", "substr", "(", "$", "_SERVER", "[", "'DOCUMENT_ROOT'", "]", ",", "0", ",", "strlen", "(", "static", "::", "$", "defaults", "[", "'docroot'", "]", ")", "*", "-", "1", ")", ";", "$", "file", "=", "implode", "(", "'/'", ",", "array_diff", "(", "explode", "(", "'/'", ",", "$", "trace", "[", "0", "]", "[", "'file'", "]", ")", ",", "explode", "(", "'/'", ",", "$", "root", ")", ")", ")", ";", "$", "ret", "=", "array", "(", "'file'", "=>", "$", "file", ",", "'line'", "=>", "$", "trace", "[", "0", "]", "[", "'line'", "]", ")", ";", "if", "(", "isset", "(", "$", "trace", "[", "1", "]", "[", "'function'", "]", ")", ")", "$", "ret", "[", "'function'", "]", "=", "$", "trace", "[", "1", "]", "[", "'function'", "]", ";", "if", "(", "isset", "(", "$", "trace", "[", "1", "]", "[", "'class'", "]", ")", ")", "$", "ret", "[", "'class'", "]", "=", "$", "trace", "[", "1", "]", "[", "'class'", "]", ";", "return", "$", "ret", ";", "}" ]
Create an array that describes the location of the debug call @param string $trace @return array
[ "Create", "an", "array", "that", "describes", "the", "location", "of", "the", "debug", "call" ]
0ba9a9738e317b32c4d6f800c618524fccfdbc9a
https://github.com/alkemann/h.l/blob/0ba9a9738e317b32c4d6f800c618524fccfdbc9a/src/debug/util/Debug.php#L192-L202
24,839
RhubarbPHP/Scaffold.AuthenticationWithRoles
src/User.php
User.hasRole
public function hasRole($name) { if ($this->RoleID) { $role = new Role($this->RoleID); if ($role->RoleName == $name) { return true; } } foreach ($this->Roles as $role) { if ($role->RoleName == $name) { return true; } } return false; }
php
public function hasRole($name) { if ($this->RoleID) { $role = new Role($this->RoleID); if ($role->RoleName == $name) { return true; } } foreach ($this->Roles as $role) { if ($role->RoleName == $name) { return true; } } return false; }
[ "public", "function", "hasRole", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "RoleID", ")", "{", "$", "role", "=", "new", "Role", "(", "$", "this", "->", "RoleID", ")", ";", "if", "(", "$", "role", "->", "RoleName", "==", "$", "name", ")", "{", "return", "true", ";", "}", "}", "foreach", "(", "$", "this", "->", "Roles", "as", "$", "role", ")", "{", "if", "(", "$", "role", "->", "RoleName", "==", "$", "name", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if user has a specific role @param $name string @return bool
[ "Checks", "if", "user", "has", "a", "specific", "role" ]
7402e741b67f1936dfbb3d3ae6e1f6193c226f9b
https://github.com/RhubarbPHP/Scaffold.AuthenticationWithRoles/blob/7402e741b67f1936dfbb3d3ae6e1f6193c226f9b/src/User.php#L96-L111
24,840
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.getAttributeValue
public function getAttributeValue($document, $attribute) { if ($document instanceof Proxy && !in_array($attribute, $this->getIdentifierAttributeNames()) && !$document->__isInitialized()) { $document->__load(); } return $this->getPropertyMetadata($attribute)->getValue($document); }
php
public function getAttributeValue($document, $attribute) { if ($document instanceof Proxy && !in_array($attribute, $this->getIdentifierAttributeNames()) && !$document->__isInitialized()) { $document->__load(); } return $this->getPropertyMetadata($attribute)->getValue($document); }
[ "public", "function", "getAttributeValue", "(", "$", "document", ",", "$", "attribute", ")", "{", "if", "(", "$", "document", "instanceof", "Proxy", "&&", "!", "in_array", "(", "$", "attribute", ",", "$", "this", "->", "getIdentifierAttributeNames", "(", ")", ")", "&&", "!", "$", "document", "->", "__isInitialized", "(", ")", ")", "{", "$", "document", "->", "__load", "(", ")", ";", "}", "return", "$", "this", "->", "getPropertyMetadata", "(", "$", "attribute", ")", "->", "getValue", "(", "$", "document", ")", ";", "}" ]
Gets the specified attribute's value off the given document. @param object $document @param string $attribute @return mixed
[ "Gets", "the", "specified", "attribute", "s", "value", "off", "the", "given", "document", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L560-L567
24,841
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.getDefinitionTable
public function getDefinitionTable() { $definition = array_merge( $this->getIndex()->getDefinition(), $this->getDefinitionSecondaryIndexes() ); $definition['TableName'] = $this->getTableName(); $definition['AttributeDefinitions'] = $this->getDefinitionIndexAttributes(); return $definition; }
php
public function getDefinitionTable() { $definition = array_merge( $this->getIndex()->getDefinition(), $this->getDefinitionSecondaryIndexes() ); $definition['TableName'] = $this->getTableName(); $definition['AttributeDefinitions'] = $this->getDefinitionIndexAttributes(); return $definition; }
[ "public", "function", "getDefinitionTable", "(", ")", "{", "$", "definition", "=", "array_merge", "(", "$", "this", "->", "getIndex", "(", ")", "->", "getDefinition", "(", ")", ",", "$", "this", "->", "getDefinitionSecondaryIndexes", "(", ")", ")", ";", "$", "definition", "[", "'TableName'", "]", "=", "$", "this", "->", "getTableName", "(", ")", ";", "$", "definition", "[", "'AttributeDefinitions'", "]", "=", "$", "this", "->", "getDefinitionIndexAttributes", "(", ")", ";", "return", "$", "definition", ";", "}" ]
Return the table definition for this class, formatted for AWS SDK. @return array
[ "Return", "the", "table", "definition", "for", "this", "class", "formatted", "for", "AWS", "SDK", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L605-L616
24,842
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.getPropertyMetadata
public function getPropertyMetadata($propertyName) { if (!isset($this->propertyMetadata[$propertyName])) { throw MappingException::mappingNotFound($this->name, $propertyName); } return $this->propertyMetadata[$propertyName]; }
php
public function getPropertyMetadata($propertyName) { if (!isset($this->propertyMetadata[$propertyName])) { throw MappingException::mappingNotFound($this->name, $propertyName); } return $this->propertyMetadata[$propertyName]; }
[ "public", "function", "getPropertyMetadata", "(", "$", "propertyName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "propertyMetadata", "[", "$", "propertyName", "]", ")", ")", "{", "throw", "MappingException", "::", "mappingNotFound", "(", "$", "this", "->", "name", ",", "$", "propertyName", ")", ";", "}", "return", "$", "this", "->", "propertyMetadata", "[", "$", "propertyName", "]", ";", "}" ]
Gets the mapping metadata of a property. @param string $propertyName The property name. @return PropertyMetadata The property mapping. @throws MappingException
[ "Gets", "the", "mapping", "metadata", "of", "a", "property", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L788-L795
24,843
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.getTypeOfAttribute
public function getTypeOfAttribute($attributeName) { return isset($this->propertyMetadata[$attributeName]) ? $this->propertyMetadata[$attributeName]->type : null; }
php
public function getTypeOfAttribute($attributeName) { return isset($this->propertyMetadata[$attributeName]) ? $this->propertyMetadata[$attributeName]->type : null; }
[ "public", "function", "getTypeOfAttribute", "(", "$", "attributeName", ")", "{", "return", "isset", "(", "$", "this", "->", "propertyMetadata", "[", "$", "attributeName", "]", ")", "?", "$", "this", "->", "propertyMetadata", "[", "$", "attributeName", "]", "->", "type", ":", "null", ";", "}" ]
Returns a type name of this attribute. This type names can be implementation specific but should at least include the php types: integer, string, boolean, float/double, datetime. @param string $attributeName @return string
[ "Returns", "a", "type", "name", "of", "this", "attribute", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L847-L851
24,844
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.registerAlsoLoadMethod
public function registerAlsoLoadMethod($method, $attributes) { $this->alsoLoadMethods[$method] = is_array($attributes) ? $attributes : [$attributes]; }
php
public function registerAlsoLoadMethod($method, $attributes) { $this->alsoLoadMethods[$method] = is_array($attributes) ? $attributes : [$attributes]; }
[ "public", "function", "registerAlsoLoadMethod", "(", "$", "method", ",", "$", "attributes", ")", "{", "$", "this", "->", "alsoLoadMethods", "[", "$", "method", "]", "=", "is_array", "(", "$", "attributes", ")", "?", "$", "attributes", ":", "[", "$", "attributes", "]", ";", "}" ]
Registers a method for loading document data before attribute hydration. Note: A method may be registered multiple times for different attributes. it will be invoked only once for the first attribute found. @param string $method Method name @param array|string $attributes Database attribute name(s)
[ "Registers", "a", "method", "for", "loading", "document", "data", "before", "attribute", "hydration", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L1181-L1184
24,845
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.setDiscriminatorAttribute
public function setDiscriminatorAttribute($discriminatorAttribute) { if ($discriminatorAttribute === null) { $this->discriminatorAttribute = null; return; } foreach ($this->propertyMetadata as $attributeMapping) { if ($discriminatorAttribute === $attributeMapping->attributeName) { throw MappingException::discriminatorAttributeConflict($this->name, $discriminatorAttribute); } } $this->discriminatorAttribute = $discriminatorAttribute; }
php
public function setDiscriminatorAttribute($discriminatorAttribute) { if ($discriminatorAttribute === null) { $this->discriminatorAttribute = null; return; } foreach ($this->propertyMetadata as $attributeMapping) { if ($discriminatorAttribute === $attributeMapping->attributeName) { throw MappingException::discriminatorAttributeConflict($this->name, $discriminatorAttribute); } } $this->discriminatorAttribute = $discriminatorAttribute; }
[ "public", "function", "setDiscriminatorAttribute", "(", "$", "discriminatorAttribute", ")", "{", "if", "(", "$", "discriminatorAttribute", "===", "null", ")", "{", "$", "this", "->", "discriminatorAttribute", "=", "null", ";", "return", ";", "}", "foreach", "(", "$", "this", "->", "propertyMetadata", "as", "$", "attributeMapping", ")", "{", "if", "(", "$", "discriminatorAttribute", "===", "$", "attributeMapping", "->", "attributeName", ")", "{", "throw", "MappingException", "::", "discriminatorAttributeConflict", "(", "$", "this", "->", "name", ",", "$", "discriminatorAttribute", ")", ";", "}", "}", "$", "this", "->", "discriminatorAttribute", "=", "$", "discriminatorAttribute", ";", "}" ]
Sets the discriminator attribute. The attribute name is the the unmapped database attribute. Discriminator values are only used to discern the hydration class and are not mapped to class properties. @param string $discriminatorAttribute @throws MappingException If the discriminator attribute conflicts with the name of a mapped attribute.
[ "Sets", "the", "discriminator", "attribute", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L1239-L1254
24,846
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.setDiscriminatorDefaultValue
public function setDiscriminatorDefaultValue($discriminatorDefaultValue) { if ($discriminatorDefaultValue !== null && !array_key_exists($discriminatorDefaultValue, $this->discriminatorMap)) { throw MappingException::invalidDiscriminatorValue($discriminatorDefaultValue, $this->name); } $this->discriminatorDefaultValue = $discriminatorDefaultValue; }
php
public function setDiscriminatorDefaultValue($discriminatorDefaultValue) { if ($discriminatorDefaultValue !== null && !array_key_exists($discriminatorDefaultValue, $this->discriminatorMap)) { throw MappingException::invalidDiscriminatorValue($discriminatorDefaultValue, $this->name); } $this->discriminatorDefaultValue = $discriminatorDefaultValue; }
[ "public", "function", "setDiscriminatorDefaultValue", "(", "$", "discriminatorDefaultValue", ")", "{", "if", "(", "$", "discriminatorDefaultValue", "!==", "null", "&&", "!", "array_key_exists", "(", "$", "discriminatorDefaultValue", ",", "$", "this", "->", "discriminatorMap", ")", ")", "{", "throw", "MappingException", "::", "invalidDiscriminatorValue", "(", "$", "discriminatorDefaultValue", ",", "$", "this", "->", "name", ")", ";", "}", "$", "this", "->", "discriminatorDefaultValue", "=", "$", "discriminatorDefaultValue", ";", "}" ]
Sets the default discriminator value to be used for this class Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value @param string $discriminatorDefaultValue @throws MappingException
[ "Sets", "the", "default", "discriminator", "value", "to", "be", "used", "for", "this", "class", "Used", "for", "JOINED", "and", "SINGLE_TABLE", "inheritance", "mapping", "strategies", "if", "the", "document", "has", "no", "discriminator", "value" ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L1265-L1272
24,847
cloudtek/dynamodm
lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php
ClassMetadata.setTable
public function setTable($table) { if (is_array($table)) { if (!isset($table['name'])) { throw new \InvalidArgumentException('A name key is required when passing an array to setTable()'); } $this->table = $table['name']; } else { $this->table = $table; } }
php
public function setTable($table) { if (is_array($table)) { if (!isset($table['name'])) { throw new \InvalidArgumentException('A name key is required when passing an array to setTable()'); } $this->table = $table['name']; } else { $this->table = $table; } }
[ "public", "function", "setTable", "(", "$", "table", ")", "{", "if", "(", "is_array", "(", "$", "table", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "table", "[", "'name'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'A name key is required when passing an array to setTable()'", ")", ";", "}", "$", "this", "->", "table", "=", "$", "table", "[", "'name'", "]", ";", "}", "else", "{", "$", "this", "->", "table", "=", "$", "table", ";", "}", "}" ]
Sets the table this document is mapped to. @param array|string $table The table name. @throws \InvalidArgumentException
[ "Sets", "the", "table", "this", "document", "is", "mapped", "to", "." ]
119d355e2c5cbaef1f867970349b4432f5704fcd
https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Mapping/ClassMetadata.php#L1430-L1440
24,848
anorgan/deployer-common
src/Runner.php
Runner.run
public function run() { foreach ($this->getSteps() as $step) { $this->logger->info('Starting "'.$step->getTitle().'"'); foreach ($this->getServersForStep($step) as $server) { if ($step->isMandatory()) { $server->runCommands(); $this->logger->info('Finished "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } else { try { $server->runCommands(); $this->logger->info('Finished "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } catch (\Exception $e) { $this->logger->info('Failed to run "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } } } } }
php
public function run() { foreach ($this->getSteps() as $step) { $this->logger->info('Starting "'.$step->getTitle().'"'); foreach ($this->getServersForStep($step) as $server) { if ($step->isMandatory()) { $server->runCommands(); $this->logger->info('Finished "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } else { try { $server->runCommands(); $this->logger->info('Finished "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } catch (\Exception $e) { $this->logger->info('Failed to run "'.$step->getTitle().'" on "'.$server->getTitle().'"'); } } } } }
[ "public", "function", "run", "(", ")", "{", "foreach", "(", "$", "this", "->", "getSteps", "(", ")", "as", "$", "step", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Starting \"'", ".", "$", "step", "->", "getTitle", "(", ")", ".", "'\"'", ")", ";", "foreach", "(", "$", "this", "->", "getServersForStep", "(", "$", "step", ")", "as", "$", "server", ")", "{", "if", "(", "$", "step", "->", "isMandatory", "(", ")", ")", "{", "$", "server", "->", "runCommands", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "'Finished \"'", ".", "$", "step", "->", "getTitle", "(", ")", ".", "'\" on \"'", ".", "$", "server", "->", "getTitle", "(", ")", ".", "'\"'", ")", ";", "}", "else", "{", "try", "{", "$", "server", "->", "runCommands", "(", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "'Finished \"'", ".", "$", "step", "->", "getTitle", "(", ")", ".", "'\" on \"'", ".", "$", "server", "->", "getTitle", "(", ")", ".", "'\"'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "'Failed to run \"'", ".", "$", "step", "->", "getTitle", "(", ")", ".", "'\" on \"'", ".", "$", "server", "->", "getTitle", "(", ")", ".", "'\"'", ")", ";", "}", "}", "}", "}", "}" ]
Run commands on every server of every step with steps' commands.
[ "Run", "commands", "on", "every", "server", "of", "every", "step", "with", "steps", "commands", "." ]
8b4bdb6c7ea3f7031aa4ee8eb06a16e49006da6f
https://github.com/anorgan/deployer-common/blob/8b4bdb6c7ea3f7031aa4ee8eb06a16e49006da6f/src/Runner.php#L38-L57
24,849
PenoaksDev/Milky-Framework
src/Milky/Http/View/Compilers/BladeCompiler.php
BladeCompiler.parseSegments
protected function parseSegments( $expression, $requiredSegmentCount ) { $segments = explode( ',', preg_replace( "/[ \(\)\\\"\']/", '', $expression ) ); if ( $requiredSegmentCount > count( $segments ) ) throw new FrameworkException( "Blade directive is short the required number of segments of " . $requiredSegmentCount ); return $segments; }
php
protected function parseSegments( $expression, $requiredSegmentCount ) { $segments = explode( ',', preg_replace( "/[ \(\)\\\"\']/", '', $expression ) ); if ( $requiredSegmentCount > count( $segments ) ) throw new FrameworkException( "Blade directive is short the required number of segments of " . $requiredSegmentCount ); return $segments; }
[ "protected", "function", "parseSegments", "(", "$", "expression", ",", "$", "requiredSegmentCount", ")", "{", "$", "segments", "=", "explode", "(", "','", ",", "preg_replace", "(", "\"/[ \\(\\)\\\\\\\"\\']/\"", ",", "''", ",", "$", "expression", ")", ")", ";", "if", "(", "$", "requiredSegmentCount", ">", "count", "(", "$", "segments", ")", ")", "throw", "new", "FrameworkException", "(", "\"Blade directive is short the required number of segments of \"", ".", "$", "requiredSegmentCount", ")", ";", "return", "$", "segments", ";", "}" ]
Parses out a blade directive arguments @param $expression @param $requiredSegmentCount @return array @throws FrameworkException
[ "Parses", "out", "a", "blade", "directive", "arguments" ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/View/Compilers/BladeCompiler.php#L1071-L1079
24,850
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.getFieldIndex
private function getFieldIndex($prevTag, $tag, $fieldIndex) { if ($prevTag == $tag or '' == $prevTag) { return $fieldIndex; // iteration of field index will continue } $specTag = $this->currentSpec['field']->getTag(); if (preg_match('/'.$specTag.'/', $tag)) { // not same field tag, but field spec tag matches return $fieldIndex; // iteration of field index will continue } // not same field tag, iteration gets reset return $this->spec['field']->getIndexStart(); }
php
private function getFieldIndex($prevTag, $tag, $fieldIndex) { if ($prevTag == $tag or '' == $prevTag) { return $fieldIndex; // iteration of field index will continue } $specTag = $this->currentSpec['field']->getTag(); if (preg_match('/'.$specTag.'/', $tag)) { // not same field tag, but field spec tag matches return $fieldIndex; // iteration of field index will continue } // not same field tag, iteration gets reset return $this->spec['field']->getIndexStart(); }
[ "private", "function", "getFieldIndex", "(", "$", "prevTag", ",", "$", "tag", ",", "$", "fieldIndex", ")", "{", "if", "(", "$", "prevTag", "==", "$", "tag", "or", "''", "==", "$", "prevTag", ")", "{", "return", "$", "fieldIndex", ";", "// iteration of field index will continue", "}", "$", "specTag", "=", "$", "this", "->", "currentSpec", "[", "'field'", "]", "->", "getTag", "(", ")", ";", "if", "(", "preg_match", "(", "'/'", ".", "$", "specTag", ".", "'/'", ",", "$", "tag", ")", ")", "{", "// not same field tag, but field spec tag matches", "return", "$", "fieldIndex", ";", "// iteration of field index will continue", "}", "// not same field tag, iteration gets reset", "return", "$", "this", "->", "spec", "[", "'field'", "]", "->", "getIndexStart", "(", ")", ";", "}" ]
Get the current field index. @param string $prevTag The previous field tag @param string $tag The current field tag @param int $fieldIndex The current field index @return int $fieldIndex The current field index
[ "Get", "the", "current", "field", "index", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L179-L191
24,851
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.iterateSubSpec
private function iterateSubSpec($subSpecs, $fieldIndex, $subfieldIndex = null) { $valid = true; foreach ($subSpecs as $_subSpec) { if (is_array($_subSpec)) { // chained subSpecs (OR) foreach ($_subSpec as $this->currentSubSpec) { $this->setIndexStartEnd($fieldIndex, $subfieldIndex); if ($valid = $this->checkSubSpec()) { break; // at least one of them is true (OR) } } } else { // repeated SubSpecs (AND) $this->currentSubSpec = $_subSpec; $this->setIndexStartEnd($fieldIndex, $subfieldIndex); if (!$valid = $this->checkSubSpec()) { break; // all of them have to be true (AND) } } } return $valid; }
php
private function iterateSubSpec($subSpecs, $fieldIndex, $subfieldIndex = null) { $valid = true; foreach ($subSpecs as $_subSpec) { if (is_array($_subSpec)) { // chained subSpecs (OR) foreach ($_subSpec as $this->currentSubSpec) { $this->setIndexStartEnd($fieldIndex, $subfieldIndex); if ($valid = $this->checkSubSpec()) { break; // at least one of them is true (OR) } } } else { // repeated SubSpecs (AND) $this->currentSubSpec = $_subSpec; $this->setIndexStartEnd($fieldIndex, $subfieldIndex); if (!$valid = $this->checkSubSpec()) { break; // all of them have to be true (AND) } } } return $valid; }
[ "private", "function", "iterateSubSpec", "(", "$", "subSpecs", ",", "$", "fieldIndex", ",", "$", "subfieldIndex", "=", "null", ")", "{", "$", "valid", "=", "true", ";", "foreach", "(", "$", "subSpecs", "as", "$", "_subSpec", ")", "{", "if", "(", "is_array", "(", "$", "_subSpec", ")", ")", "{", "// chained subSpecs (OR)", "foreach", "(", "$", "_subSpec", "as", "$", "this", "->", "currentSubSpec", ")", "{", "$", "this", "->", "setIndexStartEnd", "(", "$", "fieldIndex", ",", "$", "subfieldIndex", ")", ";", "if", "(", "$", "valid", "=", "$", "this", "->", "checkSubSpec", "(", ")", ")", "{", "break", ";", "// at least one of them is true (OR)", "}", "}", "}", "else", "{", "// repeated SubSpecs (AND)", "$", "this", "->", "currentSubSpec", "=", "$", "_subSpec", ";", "$", "this", "->", "setIndexStartEnd", "(", "$", "fieldIndex", ",", "$", "subfieldIndex", ")", ";", "if", "(", "!", "$", "valid", "=", "$", "this", "->", "checkSubSpec", "(", ")", ")", "{", "break", ";", "// all of them have to be true (AND)", "}", "}", "}", "return", "$", "valid", ";", "}" ]
Iterate on subspecs. @param array $subSpecs Array of subspecs @param int $fieldIndex The current field index @param int $subfieldIndex The current subfield index @return bool The validation result
[ "Iterate", "on", "subspecs", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L202-L224
24,852
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.setIndexStartEnd
private function setIndexStartEnd($fieldIndex, $subfieldIndex = null) { foreach (['leftSubTerm', 'rightSubTerm'] as $side) { if (!($this->currentSubSpec[$side] instanceof CK\MARCspec\ComparisonStringInterface)) { // only set new index if subspec field tag equals spec field tag!! if ($this->spec['field']['tag'] == $this->currentSubSpec[$side]['field']['tag']) { $this->currentSubSpec[$side]['field']->setIndexStartEnd($fieldIndex, $fieldIndex); if (!is_null($subfieldIndex)) { if ($this->currentSubSpec[$side]->offsetExists('subfields')) { foreach ($this->currentSubSpec[$side]['subfields'] as $subfieldSpec) { $subfieldSpec->setIndexStartEnd($subfieldIndex, $subfieldIndex); } } } } } } }
php
private function setIndexStartEnd($fieldIndex, $subfieldIndex = null) { foreach (['leftSubTerm', 'rightSubTerm'] as $side) { if (!($this->currentSubSpec[$side] instanceof CK\MARCspec\ComparisonStringInterface)) { // only set new index if subspec field tag equals spec field tag!! if ($this->spec['field']['tag'] == $this->currentSubSpec[$side]['field']['tag']) { $this->currentSubSpec[$side]['field']->setIndexStartEnd($fieldIndex, $fieldIndex); if (!is_null($subfieldIndex)) { if ($this->currentSubSpec[$side]->offsetExists('subfields')) { foreach ($this->currentSubSpec[$side]['subfields'] as $subfieldSpec) { $subfieldSpec->setIndexStartEnd($subfieldIndex, $subfieldIndex); } } } } } } }
[ "private", "function", "setIndexStartEnd", "(", "$", "fieldIndex", ",", "$", "subfieldIndex", "=", "null", ")", "{", "foreach", "(", "[", "'leftSubTerm'", ",", "'rightSubTerm'", "]", "as", "$", "side", ")", "{", "if", "(", "!", "(", "$", "this", "->", "currentSubSpec", "[", "$", "side", "]", "instanceof", "CK", "\\", "MARCspec", "\\", "ComparisonStringInterface", ")", ")", "{", "// only set new index if subspec field tag equals spec field tag!!", "if", "(", "$", "this", "->", "spec", "[", "'field'", "]", "[", "'tag'", "]", "==", "$", "this", "->", "currentSubSpec", "[", "$", "side", "]", "[", "'field'", "]", "[", "'tag'", "]", ")", "{", "$", "this", "->", "currentSubSpec", "[", "$", "side", "]", "[", "'field'", "]", "->", "setIndexStartEnd", "(", "$", "fieldIndex", ",", "$", "fieldIndex", ")", ";", "if", "(", "!", "is_null", "(", "$", "subfieldIndex", ")", ")", "{", "if", "(", "$", "this", "->", "currentSubSpec", "[", "$", "side", "]", "->", "offsetExists", "(", "'subfields'", ")", ")", "{", "foreach", "(", "$", "this", "->", "currentSubSpec", "[", "$", "side", "]", "[", "'subfields'", "]", "as", "$", "subfieldSpec", ")", "{", "$", "subfieldSpec", "->", "setIndexStartEnd", "(", "$", "subfieldIndex", ",", "$", "subfieldIndex", ")", ";", "}", "}", "}", "}", "}", "}", "}" ]
Sets the start and end index of the current spec if it's an instance of CK\MARCspec\PositionOrRangeInterface. @param object $spec The current spec @param int $fieldIndex the start/end index to set @param int $subfieldIndex the start/end index to set
[ "Sets", "the", "start", "and", "end", "index", "of", "the", "current", "spec", "if", "it", "s", "an", "instance", "of", "CK", "\\", "MARCspec", "\\", "PositionOrRangeInterface", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L234-L251
24,853
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.checkSubSpec
private function checkSubSpec() { $validation = $this->cache->validation($this->currentSubSpec); if (!is_null($validation)) { return $validation; } return $this->validateSubSpec(); }
php
private function checkSubSpec() { $validation = $this->cache->validation($this->currentSubSpec); if (!is_null($validation)) { return $validation; } return $this->validateSubSpec(); }
[ "private", "function", "checkSubSpec", "(", ")", "{", "$", "validation", "=", "$", "this", "->", "cache", "->", "validation", "(", "$", "this", "->", "currentSubSpec", ")", ";", "if", "(", "!", "is_null", "(", "$", "validation", ")", ")", "{", "return", "$", "validation", ";", "}", "return", "$", "this", "->", "validateSubSpec", "(", ")", ";", "}" ]
Checks cache for subspec validation result. Validates SubSpec if it's not in cache. @return bool Validation result
[ "Checks", "cache", "for", "subspec", "validation", "result", ".", "Validates", "SubSpec", "if", "it", "s", "not", "in", "cache", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L259-L267
24,854
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.validateSubSpec
private function validateSubSpec() { if ('!' != $this->currentSubSpec['operator'] && '?' != $this->currentSubSpec['operator']) { // skip left subTerm on operators ! and ? if (false === ($this->currentSubSpec['leftSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) { $leftSubTermReference = new self( $this->currentSubSpec['leftSubTerm'], $this->record, $this->cache ); if (!$leftSubTerm = $leftSubTermReference->content) { // see 2.3.4 SubSpec validation return $this->cache->validation($this->currentSubSpec, false); } } else { // is a CK\MARCspec\ComparisonStringInterface $leftSubTerm[] = $this->currentSubSpec['leftSubTerm']['comparable']; } } if (false === ($this->currentSubSpec['rightSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) { $rightSubTermReference = new self( $this->currentSubSpec['rightSubTerm'], $this->record, $this->cache ); $rightSubTerm = $rightSubTermReference->content; // content maybe an empty array } else { // is a CK\MARCspec\ComparisonStringInterface $rightSubTerm[] = $this->currentSubSpec['rightSubTerm']['comparable']; } $validation = false; switch ($this->currentSubSpec['operator']) { case '=': if (0 < count(array_intersect($leftSubTerm, $rightSubTerm))) { $validation = true; } break; case '!=': if (0 < count(array_diff($leftSubTerm, $rightSubTerm))) { $validation = true; } break; case '~': if (0 < count( array_uintersect( $leftSubTerm, $rightSubTerm, function ($v1, $v2) { if (strpos($v1, $v2) !== false) { return 0; } return -1; } ) ) ) { $validation = true; } break; case '!~': if (0 < count( array_uintersect( $leftSubTerm, $rightSubTerm, function ($v1, $v2) { if (strpos($v1, $v2) === false) { return 0; } return -1; } ) ) ) { $validation = true; } break; case '?': if ($rightSubTerm) { $validation = true; } break; case '!': if (!$rightSubTerm) { $validation = true; } break; } $this->cache->validation($this->currentSubSpec, $validation); return $validation; }
php
private function validateSubSpec() { if ('!' != $this->currentSubSpec['operator'] && '?' != $this->currentSubSpec['operator']) { // skip left subTerm on operators ! and ? if (false === ($this->currentSubSpec['leftSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) { $leftSubTermReference = new self( $this->currentSubSpec['leftSubTerm'], $this->record, $this->cache ); if (!$leftSubTerm = $leftSubTermReference->content) { // see 2.3.4 SubSpec validation return $this->cache->validation($this->currentSubSpec, false); } } else { // is a CK\MARCspec\ComparisonStringInterface $leftSubTerm[] = $this->currentSubSpec['leftSubTerm']['comparable']; } } if (false === ($this->currentSubSpec['rightSubTerm'] instanceof CK\MARCspec\ComparisonStringInterface)) { $rightSubTermReference = new self( $this->currentSubSpec['rightSubTerm'], $this->record, $this->cache ); $rightSubTerm = $rightSubTermReference->content; // content maybe an empty array } else { // is a CK\MARCspec\ComparisonStringInterface $rightSubTerm[] = $this->currentSubSpec['rightSubTerm']['comparable']; } $validation = false; switch ($this->currentSubSpec['operator']) { case '=': if (0 < count(array_intersect($leftSubTerm, $rightSubTerm))) { $validation = true; } break; case '!=': if (0 < count(array_diff($leftSubTerm, $rightSubTerm))) { $validation = true; } break; case '~': if (0 < count( array_uintersect( $leftSubTerm, $rightSubTerm, function ($v1, $v2) { if (strpos($v1, $v2) !== false) { return 0; } return -1; } ) ) ) { $validation = true; } break; case '!~': if (0 < count( array_uintersect( $leftSubTerm, $rightSubTerm, function ($v1, $v2) { if (strpos($v1, $v2) === false) { return 0; } return -1; } ) ) ) { $validation = true; } break; case '?': if ($rightSubTerm) { $validation = true; } break; case '!': if (!$rightSubTerm) { $validation = true; } break; } $this->cache->validation($this->currentSubSpec, $validation); return $validation; }
[ "private", "function", "validateSubSpec", "(", ")", "{", "if", "(", "'!'", "!=", "$", "this", "->", "currentSubSpec", "[", "'operator'", "]", "&&", "'?'", "!=", "$", "this", "->", "currentSubSpec", "[", "'operator'", "]", ")", "{", "// skip left subTerm on operators ! and ?", "if", "(", "false", "===", "(", "$", "this", "->", "currentSubSpec", "[", "'leftSubTerm'", "]", "instanceof", "CK", "\\", "MARCspec", "\\", "ComparisonStringInterface", ")", ")", "{", "$", "leftSubTermReference", "=", "new", "self", "(", "$", "this", "->", "currentSubSpec", "[", "'leftSubTerm'", "]", ",", "$", "this", "->", "record", ",", "$", "this", "->", "cache", ")", ";", "if", "(", "!", "$", "leftSubTerm", "=", "$", "leftSubTermReference", "->", "content", ")", "{", "// see 2.3.4 SubSpec validation", "return", "$", "this", "->", "cache", "->", "validation", "(", "$", "this", "->", "currentSubSpec", ",", "false", ")", ";", "}", "}", "else", "{", "// is a CK\\MARCspec\\ComparisonStringInterface", "$", "leftSubTerm", "[", "]", "=", "$", "this", "->", "currentSubSpec", "[", "'leftSubTerm'", "]", "[", "'comparable'", "]", ";", "}", "}", "if", "(", "false", "===", "(", "$", "this", "->", "currentSubSpec", "[", "'rightSubTerm'", "]", "instanceof", "CK", "\\", "MARCspec", "\\", "ComparisonStringInterface", ")", ")", "{", "$", "rightSubTermReference", "=", "new", "self", "(", "$", "this", "->", "currentSubSpec", "[", "'rightSubTerm'", "]", ",", "$", "this", "->", "record", ",", "$", "this", "->", "cache", ")", ";", "$", "rightSubTerm", "=", "$", "rightSubTermReference", "->", "content", ";", "// content maybe an empty array", "}", "else", "{", "// is a CK\\MARCspec\\ComparisonStringInterface", "$", "rightSubTerm", "[", "]", "=", "$", "this", "->", "currentSubSpec", "[", "'rightSubTerm'", "]", "[", "'comparable'", "]", ";", "}", "$", "validation", "=", "false", ";", "switch", "(", "$", "this", "->", "currentSubSpec", "[", "'operator'", "]", ")", "{", "case", "'='", ":", "if", "(", "0", "<", "count", "(", "array_intersect", "(", "$", "leftSubTerm", ",", "$", "rightSubTerm", ")", ")", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "case", "'!='", ":", "if", "(", "0", "<", "count", "(", "array_diff", "(", "$", "leftSubTerm", ",", "$", "rightSubTerm", ")", ")", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "case", "'~'", ":", "if", "(", "0", "<", "count", "(", "array_uintersect", "(", "$", "leftSubTerm", ",", "$", "rightSubTerm", ",", "function", "(", "$", "v1", ",", "$", "v2", ")", "{", "if", "(", "strpos", "(", "$", "v1", ",", "$", "v2", ")", "!==", "false", ")", "{", "return", "0", ";", "}", "return", "-", "1", ";", "}", ")", ")", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "case", "'!~'", ":", "if", "(", "0", "<", "count", "(", "array_uintersect", "(", "$", "leftSubTerm", ",", "$", "rightSubTerm", ",", "function", "(", "$", "v1", ",", "$", "v2", ")", "{", "if", "(", "strpos", "(", "$", "v1", ",", "$", "v2", ")", "===", "false", ")", "{", "return", "0", ";", "}", "return", "-", "1", ";", "}", ")", ")", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "case", "'?'", ":", "if", "(", "$", "rightSubTerm", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "case", "'!'", ":", "if", "(", "!", "$", "rightSubTerm", ")", "{", "$", "validation", "=", "true", ";", "}", "break", ";", "}", "$", "this", "->", "cache", "->", "validation", "(", "$", "this", "->", "currentSubSpec", ",", "$", "validation", ")", ";", "return", "$", "validation", ";", "}" ]
Validates a subSpec. @return bool True if subSpec is valid and false if not
[ "Validates", "a", "subSpec", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L274-L372
24,855
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.referenceFieldsByTag
private function referenceFieldsByTag() { $tag = $this->spec['field']['tag']; if ($this->cache->offsetExists($tag)) { return $this->cache[$tag]; } if ('LDR' !== $tag) { $_fieldRef = $this->record->getFields($tag, true); } else { // tag = LDR $_fieldRef[] = $this->record->getLeader(); } $this->cache[$tag] = $_fieldRef; return $_fieldRef; }
php
private function referenceFieldsByTag() { $tag = $this->spec['field']['tag']; if ($this->cache->offsetExists($tag)) { return $this->cache[$tag]; } if ('LDR' !== $tag) { $_fieldRef = $this->record->getFields($tag, true); } else { // tag = LDR $_fieldRef[] = $this->record->getLeader(); } $this->cache[$tag] = $_fieldRef; return $_fieldRef; }
[ "private", "function", "referenceFieldsByTag", "(", ")", "{", "$", "tag", "=", "$", "this", "->", "spec", "[", "'field'", "]", "[", "'tag'", "]", ";", "if", "(", "$", "this", "->", "cache", "->", "offsetExists", "(", "$", "tag", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "tag", "]", ";", "}", "if", "(", "'LDR'", "!==", "$", "tag", ")", "{", "$", "_fieldRef", "=", "$", "this", "->", "record", "->", "getFields", "(", "$", "tag", ",", "true", ")", ";", "}", "else", "{", "// tag = LDR", "$", "_fieldRef", "[", "]", "=", "$", "this", "->", "record", "->", "getLeader", "(", ")", ";", "}", "$", "this", "->", "cache", "[", "$", "tag", "]", "=", "$", "_fieldRef", ";", "return", "$", "_fieldRef", ";", "}" ]
Reference fields by field tag. @return array Array of referred fields
[ "Reference", "fields", "by", "field", "tag", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L379-L397
24,856
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.referenceFields
private function referenceFields() { if ($this->fields = $this->cache->getData($this->spec['field'])) { return $this->fields; } if (!$this->fields = $this->referenceFieldsByTag()) { return; } /* * filter by indizes */ if ($_indexRange = $this->getIndexRange($this->spec['field'], count($this->fields))) { $prevTag = ''; $index = 0; foreach ($this->fields as $position => $field) { if (false == ($field instanceof File_MARC_Field)) { continue; } $tag = $field->getTag(); $index = ($prevTag == $tag or '' == $prevTag) ? $index : 0; if (!in_array($index, $_indexRange)) { unset($this->fields[$position]); } $index++; $prevTag = $tag; } } /* * filter for indicator values */ if ($this->spec->offsetExists('indicator')) { foreach ($this->fields as $key => $field) { // only filter by indicators for data fields if (!$field->isDataField()) { // control field have no indicators unset($this->fields[$key]); } } } }
php
private function referenceFields() { if ($this->fields = $this->cache->getData($this->spec['field'])) { return $this->fields; } if (!$this->fields = $this->referenceFieldsByTag()) { return; } /* * filter by indizes */ if ($_indexRange = $this->getIndexRange($this->spec['field'], count($this->fields))) { $prevTag = ''; $index = 0; foreach ($this->fields as $position => $field) { if (false == ($field instanceof File_MARC_Field)) { continue; } $tag = $field->getTag(); $index = ($prevTag == $tag or '' == $prevTag) ? $index : 0; if (!in_array($index, $_indexRange)) { unset($this->fields[$position]); } $index++; $prevTag = $tag; } } /* * filter for indicator values */ if ($this->spec->offsetExists('indicator')) { foreach ($this->fields as $key => $field) { // only filter by indicators for data fields if (!$field->isDataField()) { // control field have no indicators unset($this->fields[$key]); } } } }
[ "private", "function", "referenceFields", "(", ")", "{", "if", "(", "$", "this", "->", "fields", "=", "$", "this", "->", "cache", "->", "getData", "(", "$", "this", "->", "spec", "[", "'field'", "]", ")", ")", "{", "return", "$", "this", "->", "fields", ";", "}", "if", "(", "!", "$", "this", "->", "fields", "=", "$", "this", "->", "referenceFieldsByTag", "(", ")", ")", "{", "return", ";", "}", "/*\n * filter by indizes\n */", "if", "(", "$", "_indexRange", "=", "$", "this", "->", "getIndexRange", "(", "$", "this", "->", "spec", "[", "'field'", "]", ",", "count", "(", "$", "this", "->", "fields", ")", ")", ")", "{", "$", "prevTag", "=", "''", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "position", "=>", "$", "field", ")", "{", "if", "(", "false", "==", "(", "$", "field", "instanceof", "File_MARC_Field", ")", ")", "{", "continue", ";", "}", "$", "tag", "=", "$", "field", "->", "getTag", "(", ")", ";", "$", "index", "=", "(", "$", "prevTag", "==", "$", "tag", "or", "''", "==", "$", "prevTag", ")", "?", "$", "index", ":", "0", ";", "if", "(", "!", "in_array", "(", "$", "index", ",", "$", "_indexRange", ")", ")", "{", "unset", "(", "$", "this", "->", "fields", "[", "$", "position", "]", ")", ";", "}", "$", "index", "++", ";", "$", "prevTag", "=", "$", "tag", ";", "}", "}", "/*\n * filter for indicator values\n */", "if", "(", "$", "this", "->", "spec", "->", "offsetExists", "(", "'indicator'", ")", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "key", "=>", "$", "field", ")", "{", "// only filter by indicators for data fields", "if", "(", "!", "$", "field", "->", "isDataField", "(", ")", ")", "{", "// control field have no indicators", "unset", "(", "$", "this", "->", "fields", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
Reference fields. Filter by index and indicator. @return array Array of referenced fields
[ "Reference", "fields", ".", "Filter", "by", "index", "and", "indicator", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L404-L446
24,857
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.referenceSubfields
private function referenceSubfields($currentSubfieldSpec) { $baseSubfieldSpec = $this->baseSpec.$currentSubfieldSpec->getBaseSpec(); if ($subfields = $this->cache->getData($this->currentSpec['field'], $currentSubfieldSpec)) { return $subfields; } $_subfields = $this->field->getSubfields($currentSubfieldSpec['tag']); if (!$_subfields) { $this->cache[$baseSubfieldSpec] = []; return []; } /* filter on indizes */ if ($_indexRange = $this->getIndexRange($currentSubfieldSpec, count($_subfields))) { foreach ($_subfields as $sfkey => $item) { if (!in_array($sfkey, $_indexRange) || $item->isEmpty()) { unset($_subfields[$sfkey]); } } } if ($_subfields) { $sf_values = array_values($_subfields); $this->cache[$baseSubfieldSpec] = $sf_values; return $sf_values; } $this->cache[$baseSubfieldSpec] = []; return []; }
php
private function referenceSubfields($currentSubfieldSpec) { $baseSubfieldSpec = $this->baseSpec.$currentSubfieldSpec->getBaseSpec(); if ($subfields = $this->cache->getData($this->currentSpec['field'], $currentSubfieldSpec)) { return $subfields; } $_subfields = $this->field->getSubfields($currentSubfieldSpec['tag']); if (!$_subfields) { $this->cache[$baseSubfieldSpec] = []; return []; } /* filter on indizes */ if ($_indexRange = $this->getIndexRange($currentSubfieldSpec, count($_subfields))) { foreach ($_subfields as $sfkey => $item) { if (!in_array($sfkey, $_indexRange) || $item->isEmpty()) { unset($_subfields[$sfkey]); } } } if ($_subfields) { $sf_values = array_values($_subfields); $this->cache[$baseSubfieldSpec] = $sf_values; return $sf_values; } $this->cache[$baseSubfieldSpec] = []; return []; }
[ "private", "function", "referenceSubfields", "(", "$", "currentSubfieldSpec", ")", "{", "$", "baseSubfieldSpec", "=", "$", "this", "->", "baseSpec", ".", "$", "currentSubfieldSpec", "->", "getBaseSpec", "(", ")", ";", "if", "(", "$", "subfields", "=", "$", "this", "->", "cache", "->", "getData", "(", "$", "this", "->", "currentSpec", "[", "'field'", "]", ",", "$", "currentSubfieldSpec", ")", ")", "{", "return", "$", "subfields", ";", "}", "$", "_subfields", "=", "$", "this", "->", "field", "->", "getSubfields", "(", "$", "currentSubfieldSpec", "[", "'tag'", "]", ")", ";", "if", "(", "!", "$", "_subfields", ")", "{", "$", "this", "->", "cache", "[", "$", "baseSubfieldSpec", "]", "=", "[", "]", ";", "return", "[", "]", ";", "}", "/* filter on indizes */", "if", "(", "$", "_indexRange", "=", "$", "this", "->", "getIndexRange", "(", "$", "currentSubfieldSpec", ",", "count", "(", "$", "_subfields", ")", ")", ")", "{", "foreach", "(", "$", "_subfields", "as", "$", "sfkey", "=>", "$", "item", ")", "{", "if", "(", "!", "in_array", "(", "$", "sfkey", ",", "$", "_indexRange", ")", "||", "$", "item", "->", "isEmpty", "(", ")", ")", "{", "unset", "(", "$", "_subfields", "[", "$", "sfkey", "]", ")", ";", "}", "}", "}", "if", "(", "$", "_subfields", ")", "{", "$", "sf_values", "=", "array_values", "(", "$", "_subfields", ")", ";", "$", "this", "->", "cache", "[", "$", "baseSubfieldSpec", "]", "=", "$", "sf_values", ";", "return", "$", "sf_values", ";", "}", "$", "this", "->", "cache", "[", "$", "baseSubfieldSpec", "]", "=", "[", "]", ";", "return", "[", "]", ";", "}" ]
Reference subfield contents and filter by index. @param SubfieldInterface $currentSubfieldSpec The current subfield spec @return array An array of referenced subfields
[ "Reference", "subfield", "contents", "and", "filter", "by", "index", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L455-L490
24,858
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.getIndexRange
private function getIndexRange($spec, $total) { $lastIndex = $total - 1; $indexStart = $spec['indexStart']; $indexEnd = $spec['indexEnd']; if ('#' === $indexStart) { if ('#' === $indexEnd or 0 === $indexEnd) { return [$lastIndex]; } $indexStart = $lastIndex; $indexEnd = $lastIndex - $indexEnd; $indexEnd = (0 > $indexEnd) ? 0 : $indexEnd; } else { if ($lastIndex < $indexStart) { return [$indexStart]; // this will result to no hits } $indexEnd = ('#' === $indexEnd) ? $lastIndex : $indexEnd; if ($indexEnd > $lastIndex) { $indexEnd = $lastIndex; } } return range($indexStart, $indexEnd); }
php
private function getIndexRange($spec, $total) { $lastIndex = $total - 1; $indexStart = $spec['indexStart']; $indexEnd = $spec['indexEnd']; if ('#' === $indexStart) { if ('#' === $indexEnd or 0 === $indexEnd) { return [$lastIndex]; } $indexStart = $lastIndex; $indexEnd = $lastIndex - $indexEnd; $indexEnd = (0 > $indexEnd) ? 0 : $indexEnd; } else { if ($lastIndex < $indexStart) { return [$indexStart]; // this will result to no hits } $indexEnd = ('#' === $indexEnd) ? $lastIndex : $indexEnd; if ($indexEnd > $lastIndex) { $indexEnd = $lastIndex; } } return range($indexStart, $indexEnd); }
[ "private", "function", "getIndexRange", "(", "$", "spec", ",", "$", "total", ")", "{", "$", "lastIndex", "=", "$", "total", "-", "1", ";", "$", "indexStart", "=", "$", "spec", "[", "'indexStart'", "]", ";", "$", "indexEnd", "=", "$", "spec", "[", "'indexEnd'", "]", ";", "if", "(", "'#'", "===", "$", "indexStart", ")", "{", "if", "(", "'#'", "===", "$", "indexEnd", "or", "0", "===", "$", "indexEnd", ")", "{", "return", "[", "$", "lastIndex", "]", ";", "}", "$", "indexStart", "=", "$", "lastIndex", ";", "$", "indexEnd", "=", "$", "lastIndex", "-", "$", "indexEnd", ";", "$", "indexEnd", "=", "(", "0", ">", "$", "indexEnd", ")", "?", "0", ":", "$", "indexEnd", ";", "}", "else", "{", "if", "(", "$", "lastIndex", "<", "$", "indexStart", ")", "{", "return", "[", "$", "indexStart", "]", ";", "// this will result to no hits", "}", "$", "indexEnd", "=", "(", "'#'", "===", "$", "indexEnd", ")", "?", "$", "lastIndex", ":", "$", "indexEnd", ";", "if", "(", "$", "indexEnd", ">", "$", "lastIndex", ")", "{", "$", "indexEnd", "=", "$", "lastIndex", ";", "}", "}", "return", "range", "(", "$", "indexStart", ",", "$", "indexEnd", ")", ";", "}" ]
Calculates a range from indexStart and indexEnd. @param array $spec The spec with possible indizes @param int $total Total count of (sub)fields @return array The range of indizes
[ "Calculates", "a", "range", "from", "indexStart", "and", "indexEnd", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L500-L524
24,859
MARCspec/File_MARC_Reference
src/File_MARC_Reference.php
File_MARC_Reference.ref
public function ref($spec, $value) { array_push($this->data, $value); /* * set content */ $value = $this->cache->getContents($spec, [$value]); $this->content = array_merge($this->content, $value); }
php
public function ref($spec, $value) { array_push($this->data, $value); /* * set content */ $value = $this->cache->getContents($spec, [$value]); $this->content = array_merge($this->content, $value); }
[ "public", "function", "ref", "(", "$", "spec", ",", "$", "value", ")", "{", "array_push", "(", "$", "this", "->", "data", ",", "$", "value", ")", ";", "/*\n * set content\n */", "$", "value", "=", "$", "this", "->", "cache", "->", "getContents", "(", "$", "spec", ",", "[", "$", "value", "]", ")", ";", "$", "this", "->", "content", "=", "array_merge", "(", "$", "this", "->", "content", ",", "$", "value", ")", ";", "}" ]
Reference data and set content. @param FieldInterface|SubfieldInterface $spec The corresponding spec @param string|File_MARC_Field|File_MARC_Subfield $value The value to reference
[ "Reference", "data", "and", "set", "content", "." ]
29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e
https://github.com/MARCspec/File_MARC_Reference/blob/29abbff5bec5e3bcfeeb07ba7bee94cc0a0a7f5e/src/File_MARC_Reference.php#L532-L540
24,860
xZ1mEFx/yii2-base
web/User.php
User.cannot
public function cannot($permissionName, $params = [], $allowCaching = TRUE) { return !$this->can($permissionName, $params, $allowCaching); }
php
public function cannot($permissionName, $params = [], $allowCaching = TRUE) { return !$this->can($permissionName, $params, $allowCaching); }
[ "public", "function", "cannot", "(", "$", "permissionName", ",", "$", "params", "=", "[", "]", ",", "$", "allowCaching", "=", "TRUE", ")", "{", "return", "!", "$", "this", "->", "can", "(", "$", "permissionName", ",", "$", "params", ",", "$", "allowCaching", ")", ";", "}" ]
Checks if the user cannot perform the operation as specified by the given permission. Note that you must configure "authManager" application component in order to use this method. Otherwise it will always return false. @param string|array $permissionName the name(s) of the permission (e.g. "edit post") that needs access check. @param array $params name-value pairs that would be passed to the rules associated with the roles and permissions assigned to the user. @param boolean $allowCaching whether to allow caching the result of access check. When this parameter is true (default), if the access check of an operation was performed before, its result will be directly returned when calling this method to check the same operation. If this parameter is false, this method will always call [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this caching is effective only within the same request and only works when `$params = []`. @return boolean whether the user cannot perform the operation as specified by the given permission.
[ "Checks", "if", "the", "user", "cannot", "perform", "the", "operation", "as", "specified", "by", "the", "given", "permission", "." ]
f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a
https://github.com/xZ1mEFx/yii2-base/blob/f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a/web/User.php#L31-L34
24,861
xZ1mEFx/yii2-base
web/User.php
User.can
public function can($permissionName, $params = [], $allowCaching = TRUE) { if (is_array($permissionName)) { foreach (array_unique($permissionName) as $permissionNameItem) { if (parent::can($permissionNameItem, $params, $allowCaching)) { return TRUE; } } return FALSE; } return parent::can($permissionName, $params, $allowCaching); }
php
public function can($permissionName, $params = [], $allowCaching = TRUE) { if (is_array($permissionName)) { foreach (array_unique($permissionName) as $permissionNameItem) { if (parent::can($permissionNameItem, $params, $allowCaching)) { return TRUE; } } return FALSE; } return parent::can($permissionName, $params, $allowCaching); }
[ "public", "function", "can", "(", "$", "permissionName", ",", "$", "params", "=", "[", "]", ",", "$", "allowCaching", "=", "TRUE", ")", "{", "if", "(", "is_array", "(", "$", "permissionName", ")", ")", "{", "foreach", "(", "array_unique", "(", "$", "permissionName", ")", "as", "$", "permissionNameItem", ")", "{", "if", "(", "parent", "::", "can", "(", "$", "permissionNameItem", ",", "$", "params", ",", "$", "allowCaching", ")", ")", "{", "return", "TRUE", ";", "}", "}", "return", "FALSE", ";", "}", "return", "parent", "::", "can", "(", "$", "permissionName", ",", "$", "params", ",", "$", "allowCaching", ")", ";", "}" ]
Checks if the user can perform the operation as specified by the given permission. Note that you must configure "authManager" application component in order to use this method. Otherwise it will always return false. @param string|array $permissionName the name(s) of the permission (e.g. "edit post") that needs access check. @param array $params name-value pairs that would be passed to the rules associated with the roles and permissions assigned to the user. @param boolean $allowCaching whether to allow caching the result of access check. When this parameter is true (default), if the access check of an operation was performed before, its result will be directly returned when calling this method to check the same operation. If this parameter is false, this method will always call [[\yii\rbac\CheckAccessInterface::checkAccess()]] to obtain the up-to-date access result. Note that this caching is effective only within the same request and only works when `$params = []`. @return boolean whether the user can perform the operation as specified by the given permission.
[ "Checks", "if", "the", "user", "can", "perform", "the", "operation", "as", "specified", "by", "the", "given", "permission", "." ]
f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a
https://github.com/xZ1mEFx/yii2-base/blob/f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a/web/User.php#L56-L67
24,862
enikeishik/ufoframework
src/Ufo/Core/Config.php
Config.load
public function load(string $configPath, $overwrite = false): void { if (!file_exists($configPath)) { return; } $config = include $configPath; if (!is_array($config) && !is_object($config)) { return; } if (is_object($config)) { $config = get_object_vars($config); } $this->loadArray($config, $overwrite); }
php
public function load(string $configPath, $overwrite = false): void { if (!file_exists($configPath)) { return; } $config = include $configPath; if (!is_array($config) && !is_object($config)) { return; } if (is_object($config)) { $config = get_object_vars($config); } $this->loadArray($config, $overwrite); }
[ "public", "function", "load", "(", "string", "$", "configPath", ",", "$", "overwrite", "=", "false", ")", ":", "void", "{", "if", "(", "!", "file_exists", "(", "$", "configPath", ")", ")", "{", "return", ";", "}", "$", "config", "=", "include", "$", "configPath", ";", "if", "(", "!", "is_array", "(", "$", "config", ")", "&&", "!", "is_object", "(", "$", "config", ")", ")", "{", "return", ";", "}", "if", "(", "is_object", "(", "$", "config", ")", ")", "{", "$", "config", "=", "get_object_vars", "(", "$", "config", ")", ";", "}", "$", "this", "->", "loadArray", "(", "$", "config", ",", "$", "overwrite", ")", ";", "}" ]
Loads configuration from configuration file. @param string $configPath @param bool $overwrite = false
[ "Loads", "configuration", "from", "configuration", "file", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Config.php#L162-L175
24,863
enikeishik/ufoframework
src/Ufo/Core/Config.php
Config.loadWithDefault
public function loadWithDefault(string $configPath, string $defaultConfigPath): void { if (!file_exists($configPath)) { return; } $configDefault = include $defaultConfigPath; $config = include $configPath; if (!is_array($configDefault) && !is_array($config)) { return; } $this->loadArray(array_merge($configDefault, $config)); }
php
public function loadWithDefault(string $configPath, string $defaultConfigPath): void { if (!file_exists($configPath)) { return; } $configDefault = include $defaultConfigPath; $config = include $configPath; if (!is_array($configDefault) && !is_array($config)) { return; } $this->loadArray(array_merge($configDefault, $config)); }
[ "public", "function", "loadWithDefault", "(", "string", "$", "configPath", ",", "string", "$", "defaultConfigPath", ")", ":", "void", "{", "if", "(", "!", "file_exists", "(", "$", "configPath", ")", ")", "{", "return", ";", "}", "$", "configDefault", "=", "include", "$", "defaultConfigPath", ";", "$", "config", "=", "include", "$", "configPath", ";", "if", "(", "!", "is_array", "(", "$", "configDefault", ")", "&&", "!", "is_array", "(", "$", "config", ")", ")", "{", "return", ";", "}", "$", "this", "->", "loadArray", "(", "array_merge", "(", "$", "configDefault", ",", "$", "config", ")", ")", ";", "}" ]
Loads configuration from configuration file, and from default configuration file. @param string $configPath @param string $defaultConfigPath
[ "Loads", "configuration", "from", "configuration", "file", "and", "from", "default", "configuration", "file", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Config.php#L182-L193
24,864
enikeishik/ufoframework
src/Ufo/Core/Config.php
Config.loadArray
public function loadArray(array $config, $overwrite = false): void { foreach ($config as $name => $value) { if (!$overwrite && property_exists($this, $name)) { continue; } $this->$name = $value; } }
php
public function loadArray(array $config, $overwrite = false): void { foreach ($config as $name => $value) { if (!$overwrite && property_exists($this, $name)) { continue; } $this->$name = $value; } }
[ "public", "function", "loadArray", "(", "array", "$", "config", ",", "$", "overwrite", "=", "false", ")", ":", "void", "{", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "overwrite", "&&", "property_exists", "(", "$", "this", ",", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "}" ]
Loads configuration from array. @param array $config @param bool $overwrite = false
[ "Loads", "configuration", "from", "array", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Config.php#L200-L208
24,865
enikeishik/ufoframework
src/Ufo/Core/Config.php
Config.loadFromIni
public function loadFromIni(string $iniPath, bool $overwrite = false): void { if (!file_exists($iniPath)) { return; } $iniArr = null; try { $iniArr = parse_ini_file($iniPath, false, INI_SCANNER_TYPED); } catch (\Throwable $e) { } if (!is_array($iniArr)) { return; } $iniArr = array_change_key_case($iniArr, CASE_LOWER); $arr = []; foreach ($iniArr as $name => $value) { $arr[lcfirst(str_replace('_', '', ucwords(str_replace('.', '_', $name), '_')))] = $value; } $this->loadArray($arr, $overwrite); }
php
public function loadFromIni(string $iniPath, bool $overwrite = false): void { if (!file_exists($iniPath)) { return; } $iniArr = null; try { $iniArr = parse_ini_file($iniPath, false, INI_SCANNER_TYPED); } catch (\Throwable $e) { } if (!is_array($iniArr)) { return; } $iniArr = array_change_key_case($iniArr, CASE_LOWER); $arr = []; foreach ($iniArr as $name => $value) { $arr[lcfirst(str_replace('_', '', ucwords(str_replace('.', '_', $name), '_')))] = $value; } $this->loadArray($arr, $overwrite); }
[ "public", "function", "loadFromIni", "(", "string", "$", "iniPath", ",", "bool", "$", "overwrite", "=", "false", ")", ":", "void", "{", "if", "(", "!", "file_exists", "(", "$", "iniPath", ")", ")", "{", "return", ";", "}", "$", "iniArr", "=", "null", ";", "try", "{", "$", "iniArr", "=", "parse_ini_file", "(", "$", "iniPath", ",", "false", ",", "INI_SCANNER_TYPED", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "}", "if", "(", "!", "is_array", "(", "$", "iniArr", ")", ")", "{", "return", ";", "}", "$", "iniArr", "=", "array_change_key_case", "(", "$", "iniArr", ",", "CASE_LOWER", ")", ";", "$", "arr", "=", "[", "]", ";", "foreach", "(", "$", "iniArr", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "arr", "[", "lcfirst", "(", "str_replace", "(", "'_'", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'.'", ",", "'_'", ",", "$", "name", ")", ",", "'_'", ")", ")", ")", "]", "=", "$", "value", ";", "}", "$", "this", "->", "loadArray", "(", "$", "arr", ",", "$", "overwrite", ")", ";", "}" ]
Loads configuration from INI file. @param string $iniPath @param bool $overwrite = false
[ "Loads", "configuration", "from", "INI", "file", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/Config.php#L215-L237
24,866
sndsgd/http
src/http/data/decoder/MultipartDataDecoder.php
MultipartDataDecoder.fieldsRemain
protected function fieldsRemain() { $bufferlen = strlen($this->buffer); $minlen = strlen($this->lastBoundary); # if the buffer is too short to contain the last boundary # read enough bytes into the buffer to allow for a strpos test if ($bufferlen < $minlen) { if (feof($this->fp)) { fclose($this->fp); throw new \sndsgd\http\data\DecodeException( "Invalid multipart data encountered; ". "end of content was reached before expected" ); } $bytes = fread($this->fp, $this->bytesPerRead); if ($bytes === false) { fclose($this->fp); throw new \RuntimeException( "failed to read $minlen bytes from input stream" ); } $this->buffer .= $bytes; } # if the buffer starts with the last boundary, there are no more fields return (strpos($this->buffer, $this->lastBoundary) !== 0); }
php
protected function fieldsRemain() { $bufferlen = strlen($this->buffer); $minlen = strlen($this->lastBoundary); # if the buffer is too short to contain the last boundary # read enough bytes into the buffer to allow for a strpos test if ($bufferlen < $minlen) { if (feof($this->fp)) { fclose($this->fp); throw new \sndsgd\http\data\DecodeException( "Invalid multipart data encountered; ". "end of content was reached before expected" ); } $bytes = fread($this->fp, $this->bytesPerRead); if ($bytes === false) { fclose($this->fp); throw new \RuntimeException( "failed to read $minlen bytes from input stream" ); } $this->buffer .= $bytes; } # if the buffer starts with the last boundary, there are no more fields return (strpos($this->buffer, $this->lastBoundary) !== 0); }
[ "protected", "function", "fieldsRemain", "(", ")", "{", "$", "bufferlen", "=", "strlen", "(", "$", "this", "->", "buffer", ")", ";", "$", "minlen", "=", "strlen", "(", "$", "this", "->", "lastBoundary", ")", ";", "# if the buffer is too short to contain the last boundary", "# read enough bytes into the buffer to allow for a strpos test", "if", "(", "$", "bufferlen", "<", "$", "minlen", ")", "{", "if", "(", "feof", "(", "$", "this", "->", "fp", ")", ")", "{", "fclose", "(", "$", "this", "->", "fp", ")", ";", "throw", "new", "\\", "sndsgd", "\\", "http", "\\", "data", "\\", "DecodeException", "(", "\"Invalid multipart data encountered; \"", ".", "\"end of content was reached before expected\"", ")", ";", "}", "$", "bytes", "=", "fread", "(", "$", "this", "->", "fp", ",", "$", "this", "->", "bytesPerRead", ")", ";", "if", "(", "$", "bytes", "===", "false", ")", "{", "fclose", "(", "$", "this", "->", "fp", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "\"failed to read $minlen bytes from input stream\"", ")", ";", "}", "$", "this", "->", "buffer", ".=", "$", "bytes", ";", "}", "# if the buffer starts with the last boundary, there are no more fields", "return", "(", "strpos", "(", "$", "this", "->", "buffer", ",", "$", "this", "->", "lastBoundary", ")", "!==", "0", ")", ";", "}" ]
Determine if any more fields remain in the stream @return bool
[ "Determine", "if", "any", "more", "fields", "remain", "in", "the", "stream" ]
e7f82010a66c6d3241a24ea82baf4593130c723b
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/data/decoder/MultipartDataDecoder.php#L141-L170
24,867
sndsgd/http
src/http/data/decoder/MultipartDataDecoder.php
MultipartDataDecoder.getValueFromField
private function getValueFromField() { $position = $this->readUntil($this->boundary); # there is always a newline after the value and before the boundary # exclude that newline from the value $value = substr($this->buffer, 0, $position - 2); # update the buffer to exclude the value and the pre boundary newline $this->buffer = substr($this->buffer, $position); return $value; }
php
private function getValueFromField() { $position = $this->readUntil($this->boundary); # there is always a newline after the value and before the boundary # exclude that newline from the value $value = substr($this->buffer, 0, $position - 2); # update the buffer to exclude the value and the pre boundary newline $this->buffer = substr($this->buffer, $position); return $value; }
[ "private", "function", "getValueFromField", "(", ")", "{", "$", "position", "=", "$", "this", "->", "readUntil", "(", "$", "this", "->", "boundary", ")", ";", "# there is always a newline after the value and before the boundary", "# exclude that newline from the value", "$", "value", "=", "substr", "(", "$", "this", "->", "buffer", ",", "0", ",", "$", "position", "-", "2", ")", ";", "# update the buffer to exclude the value and the pre boundary newline", "$", "this", "->", "buffer", "=", "substr", "(", "$", "this", "->", "buffer", ",", "$", "position", ")", ";", "return", "$", "value", ";", "}" ]
Get the value of the current field in the input stream @return string
[ "Get", "the", "value", "of", "the", "current", "field", "in", "the", "input", "stream" ]
e7f82010a66c6d3241a24ea82baf4593130c723b
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/data/decoder/MultipartDataDecoder.php#L245-L257
24,868
siriusSupreme/sirius-support
src/Str.php
Str.replaceFirst
public static function replaceFirst($search, $replace, $subject) { if ($search == '') { return $subject; } $position = mb_strpos($subject, $search); if ($position !== false) { return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search)); } return $subject; }
php
public static function replaceFirst($search, $replace, $subject) { if ($search == '') { return $subject; } $position = mb_strpos($subject, $search); if ($position !== false) { return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search)); } return $subject; }
[ "public", "static", "function", "replaceFirst", "(", "$", "search", ",", "$", "replace", ",", "$", "subject", ")", "{", "if", "(", "$", "search", "==", "''", ")", "{", "return", "$", "subject", ";", "}", "$", "position", "=", "mb_strpos", "(", "$", "subject", ",", "$", "search", ")", ";", "if", "(", "$", "position", "!==", "false", ")", "{", "return", "mb_substr", "(", "$", "subject", ",", "0", ",", "$", "position", ")", ".", "$", "replace", ".", "mb_substr", "(", "$", "subject", ",", "$", "position", "+", "mb_strlen", "(", "$", "search", ")", ")", ";", "}", "return", "$", "subject", ";", "}" ]
Replace the first occurrence of a given value in the string. @param string $search @param string $replace @param string $subject @return string
[ "Replace", "the", "first", "occurrence", "of", "a", "given", "value", "in", "the", "string", "." ]
80436cf8ae7b95d96bb34cd7297be00c77fc1033
https://github.com/siriusSupreme/sirius-support/blob/80436cf8ae7b95d96bb34cd7297be00c77fc1033/src/Str.php#L327-L340
24,869
comodojo/foundation
src/Comodojo/Foundation/Logging/Levels.php
Levels.getLevel
public static function getLevel($level = null) { $level = strtoupper($level); if ( array_key_exists($level, self::$levels) ) return self::$levels[$level]; return self::$levels[self::DEFAULT_LOG_LEVEL]; }
php
public static function getLevel($level = null) { $level = strtoupper($level); if ( array_key_exists($level, self::$levels) ) return self::$levels[$level]; return self::$levels[self::DEFAULT_LOG_LEVEL]; }
[ "public", "static", "function", "getLevel", "(", "$", "level", "=", "null", ")", "{", "$", "level", "=", "strtoupper", "(", "$", "level", ")", ";", "if", "(", "array_key_exists", "(", "$", "level", ",", "self", "::", "$", "levels", ")", ")", "return", "self", "::", "$", "levels", "[", "$", "level", "]", ";", "return", "self", "::", "$", "levels", "[", "self", "::", "DEFAULT_LOG_LEVEL", "]", ";", "}" ]
Map provided log level to level code @param string $level @return integer
[ "Map", "provided", "log", "level", "to", "level", "code" ]
21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a
https://github.com/comodojo/foundation/blob/21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a/src/Comodojo/Foundation/Logging/Levels.php#L44-L52
24,870
PatrolServer/patrolsdk-php
lib/PatrolModel.php
PatrolModel._get
protected function _get($url, $parameters = null, $scopes = [], $class = null) { $client = new HttpClient($this->patrol, 'get', $url, $parameters); $client->setScopes($scopes); $data = $client->response(); if (isset($data['error'])) { $this->_error($data); } $data = $data['data']; $callee = $class ? $class : get_called_class(); return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults); }
php
protected function _get($url, $parameters = null, $scopes = [], $class = null) { $client = new HttpClient($this->patrol, 'get', $url, $parameters); $client->setScopes($scopes); $data = $client->response(); if (isset($data['error'])) { $this->_error($data); } $data = $data['data']; $callee = $class ? $class : get_called_class(); return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults); }
[ "protected", "function", "_get", "(", "$", "url", ",", "$", "parameters", "=", "null", ",", "$", "scopes", "=", "[", "]", ",", "$", "class", "=", "null", ")", "{", "$", "client", "=", "new", "HttpClient", "(", "$", "this", "->", "patrol", ",", "'get'", ",", "$", "url", ",", "$", "parameters", ")", ";", "$", "client", "->", "setScopes", "(", "$", "scopes", ")", ";", "$", "data", "=", "$", "client", "->", "response", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'error'", "]", ")", ")", "{", "$", "this", "->", "_error", "(", "$", "data", ")", ";", "}", "$", "data", "=", "$", "data", "[", "'data'", "]", ";", "$", "callee", "=", "$", "class", "?", "$", "class", ":", "get_called_class", "(", ")", ";", "return", "Util", "::", "parseResponseToPatrolObject", "(", "$", "this", "->", "patrol", ",", "$", "data", ",", "$", "callee", ",", "$", "this", "->", "defaults", ")", ";", "}" ]
Perform a GET request based on this model @param string $url @param array $parameters @param array $scopes @param string $class The class type where the result should be casted to @return PatrolSdk\Model
[ "Perform", "a", "GET", "request", "based", "on", "this", "model" ]
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/PatrolModel.php#L32-L47
24,871
PatrolServer/patrolsdk-php
lib/PatrolModel.php
PatrolModel._post
protected function _post($url, $data = [], $class = null) { $client = new HttpClient($this->patrol, 'post', $url, $data); $data = $client->response(); if (isset($data['error'])) { $this->_error($data); } if (!isset($data['data'])) { return $data; } $data = $data['data']; $callee = $class ? $class : get_called_class(); return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults); }
php
protected function _post($url, $data = [], $class = null) { $client = new HttpClient($this->patrol, 'post', $url, $data); $data = $client->response(); if (isset($data['error'])) { $this->_error($data); } if (!isset($data['data'])) { return $data; } $data = $data['data']; $callee = $class ? $class : get_called_class(); return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults); }
[ "protected", "function", "_post", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "class", "=", "null", ")", "{", "$", "client", "=", "new", "HttpClient", "(", "$", "this", "->", "patrol", ",", "'post'", ",", "$", "url", ",", "$", "data", ")", ";", "$", "data", "=", "$", "client", "->", "response", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'error'", "]", ")", ")", "{", "$", "this", "->", "_error", "(", "$", "data", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'data'", "]", ")", ")", "{", "return", "$", "data", ";", "}", "$", "data", "=", "$", "data", "[", "'data'", "]", ";", "$", "callee", "=", "$", "class", "?", "$", "class", ":", "get_called_class", "(", ")", ";", "return", "Util", "::", "parseResponseToPatrolObject", "(", "$", "this", "->", "patrol", ",", "$", "data", ",", "$", "callee", ",", "$", "this", "->", "defaults", ")", ";", "}" ]
Perform a POST request based on this model @param string $url @param array $data @param string $class The class type where the result should be casted to @return PatrolSdk\Model
[ "Perform", "a", "POST", "request", "based", "on", "this", "model" ]
2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2
https://github.com/PatrolServer/patrolsdk-php/blob/2451f0d2ba2bb5bc3d7e47cfc110f7f272620db2/lib/PatrolModel.php#L58-L75
24,872
tonis-io-legacy/tonis
src/Http/Response.php
Response.redirectToRoute
public function redirectToRoute($route, array $params = [], $permanent = false) { $map = $this->app()->getRouteMap(); $url = $map->assemble($route, $params); return $this->redirect($url, $permanent); }
php
public function redirectToRoute($route, array $params = [], $permanent = false) { $map = $this->app()->getRouteMap(); $url = $map->assemble($route, $params); return $this->redirect($url, $permanent); }
[ "public", "function", "redirectToRoute", "(", "$", "route", ",", "array", "$", "params", "=", "[", "]", ",", "$", "permanent", "=", "false", ")", "{", "$", "map", "=", "$", "this", "->", "app", "(", ")", "->", "getRouteMap", "(", ")", ";", "$", "url", "=", "$", "map", "->", "assemble", "(", "$", "route", ",", "$", "params", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "url", ",", "$", "permanent", ")", ";", "}" ]
Redirects to a named route. @see \Tonis\Http\Response::redirect() @param string $route @param array $params @param bool|false $permanent @return ResponseInterface
[ "Redirects", "to", "a", "named", "route", "." ]
8371a277a94232433d882aaf37a85cd469daf501
https://github.com/tonis-io-legacy/tonis/blob/8371a277a94232433d882aaf37a85cd469daf501/src/Http/Response.php#L60-L66
24,873
PenoaksDev/Milky-Framework
src/Milky/Mail/TransportManager.php
TransportManager.getHttpClient
protected function getHttpClient( $config ) { $guzzleConfig = Arr::get( $config, 'guzzle', [] ); return new HttpClient( Arr::add( $guzzleConfig, 'connect_timeout', 60 ) ); }
php
protected function getHttpClient( $config ) { $guzzleConfig = Arr::get( $config, 'guzzle', [] ); return new HttpClient( Arr::add( $guzzleConfig, 'connect_timeout', 60 ) ); }
[ "protected", "function", "getHttpClient", "(", "$", "config", ")", "{", "$", "guzzleConfig", "=", "Arr", "::", "get", "(", "$", "config", ",", "'guzzle'", ",", "[", "]", ")", ";", "return", "new", "HttpClient", "(", "Arr", "::", "add", "(", "$", "guzzleConfig", ",", "'connect_timeout'", ",", "60", ")", ")", ";", "}" ]
Get a fresh Guzzle HTTP client instance. @param array $config @return HttpClient
[ "Get", "a", "fresh", "Guzzle", "HTTP", "client", "instance", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Mail/TransportManager.php#L156-L161
24,874
pluf/tenant
src/Tenant/Views/Resource.php
Tenant_Views_Resource.download
public function download($request, $match) { // GET data $resource = Pluf_Shortcuts_GetObjectOr404('Tenant_Resource', $match['modelId']); // Do $resource->downloads += 1; $resource->update(); return new Pluf_HTTP_Response_File($resource->getAbsloutPath(), $resource->mime_type); }
php
public function download($request, $match) { // GET data $resource = Pluf_Shortcuts_GetObjectOr404('Tenant_Resource', $match['modelId']); // Do $resource->downloads += 1; $resource->update(); return new Pluf_HTTP_Response_File($resource->getAbsloutPath(), $resource->mime_type); }
[ "public", "function", "download", "(", "$", "request", ",", "$", "match", ")", "{", "// GET data", "$", "resource", "=", "Pluf_Shortcuts_GetObjectOr404", "(", "'Tenant_Resource'", ",", "$", "match", "[", "'modelId'", "]", ")", ";", "// Do", "$", "resource", "->", "downloads", "+=", "1", ";", "$", "resource", "->", "update", "(", ")", ";", "return", "new", "Pluf_HTTP_Response_File", "(", "$", "resource", "->", "getAbsloutPath", "(", ")", ",", "$", "resource", "->", "mime_type", ")", ";", "}" ]
Download a resource @param Pluf_HTTP_Request $request @param array $match @return Pluf_HTTP_Response_File
[ "Download", "a", "resource" ]
a06359c52b9a257b5a0a186264e8770acfc54b73
https://github.com/pluf/tenant/blob/a06359c52b9a257b5a0a186264e8770acfc54b73/src/Tenant/Views/Resource.php#L37-L45
24,875
hiqdev/minii-caching
src/ApcCache.php
ApcCache.setValues
protected function setValues($data, $duration) { $result = apc_store($data, null, $duration); return is_array($result) ? array_keys($result) : []; }
php
protected function setValues($data, $duration) { $result = apc_store($data, null, $duration); return is_array($result) ? array_keys($result) : []; }
[ "protected", "function", "setValues", "(", "$", "data", ",", "$", "duration", ")", "{", "$", "result", "=", "apc_store", "(", "$", "data", ",", "null", ",", "$", "duration", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "array_keys", "(", "$", "result", ")", ":", "[", "]", ";", "}" ]
Stores multiple key-value pairs in cache. @param array $data array where key corresponds to cache key while value @param integer $duration the number of seconds in which the cached values will expire. 0 means never expire. @return array array of failed keys
[ "Stores", "multiple", "key", "-", "value", "pairs", "in", "cache", "." ]
04c3f810a4af43b53855ee9c5e3ef6455080b538
https://github.com/hiqdev/minii-caching/blob/04c3f810a4af43b53855ee9c5e3ef6455080b538/src/ApcCache.php#L82-L86
24,876
hiqdev/minii-caching
src/ApcCache.php
ApcCache.addValues
protected function addValues($data, $duration) { $result = apc_add($data, null, $duration); return is_array($result) ? array_keys($result) : []; }
php
protected function addValues($data, $duration) { $result = apc_add($data, null, $duration); return is_array($result) ? array_keys($result) : []; }
[ "protected", "function", "addValues", "(", "$", "data", ",", "$", "duration", ")", "{", "$", "result", "=", "apc_add", "(", "$", "data", ",", "null", ",", "$", "duration", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "array_keys", "(", "$", "result", ")", ":", "[", "]", ";", "}" ]
Adds multiple key-value pairs to cache. @param array $data array where key corresponds to cache key while value is the value stored @param integer $duration the number of seconds in which the cached values will expire. 0 means never expire. @return array array of failed keys
[ "Adds", "multiple", "key", "-", "value", "pairs", "to", "cache", "." ]
04c3f810a4af43b53855ee9c5e3ef6455080b538
https://github.com/hiqdev/minii-caching/blob/04c3f810a4af43b53855ee9c5e3ef6455080b538/src/ApcCache.php#L107-L111
24,877
rutger-speksnijder/restphp
src/RestPHP/Response/ResponseFactory.php
ResponseFactory.build
public function build($type, $data, $hypertextRoutes = []) { if (!isset($this->types[$type])) { throw new \Exception("Unknown response type."); } return new $this->types[$type]($data, $hypertextRoutes); }
php
public function build($type, $data, $hypertextRoutes = []) { if (!isset($this->types[$type])) { throw new \Exception("Unknown response type."); } return new $this->types[$type]($data, $hypertextRoutes); }
[ "public", "function", "build", "(", "$", "type", ",", "$", "data", ",", "$", "hypertextRoutes", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "types", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Unknown response type.\"", ")", ";", "}", "return", "new", "$", "this", "->", "types", "[", "$", "type", "]", "(", "$", "data", ",", "$", "hypertextRoutes", ")", ";", "}" ]
Builds the response object. @param string $type The type of response to build. @param mixed $data The response data. @param optional array $hypertextRoutes An array of hypertext routes. @throws Exception Throws an exception for unknown response types. @return \RestPHP\Response The created object.
[ "Builds", "the", "response", "object", "." ]
326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/ResponseFactory.php#L52-L58
24,878
TeaLabs/collections
src/Collection.php
Collection.default
public function default($key, $default = null) { if($this->has($key)) return $this->get($key); $this->put($key, $default); return $default; }
php
public function default($key, $default = null) { if($this->has($key)) return $this->get($key); $this->put($key, $default); return $default; }
[ "public", "function", "default", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "return", "$", "this", "->", "get", "(", "$", "key", ")", ";", "$", "this", "->", "put", "(", "$", "key", ",", "$", "default", ")", ";", "return", "$", "default", ";", "}" ]
If key is in the collection, return its value. If not, insert key with the given default as value and return default. @param string $key @param mixed $default @return mixed
[ "If", "key", "is", "in", "the", "collection", "return", "its", "value", ".", "If", "not", "insert", "key", "with", "the", "given", "default", "as", "value", "and", "return", "default", "." ]
5d8885b2799791c0bcbff4e6cbacddb270b4288e
https://github.com/TeaLabs/collections/blob/5d8885b2799791c0bcbff4e6cbacddb270b4288e/src/Collection.php#L30-L38
24,879
stevenliebregt/crispysystem
src/Database/Model.php
Model.showTables
public function showTables() { $sql = 'SHOW TABLES'; $query = $this->pdo->prepare($sql); $query->execute(); return $query->fetchAll(PDO::FETCH_ASSOC); }
php
public function showTables() { $sql = 'SHOW TABLES'; $query = $this->pdo->prepare($sql); $query->execute(); return $query->fetchAll(PDO::FETCH_ASSOC); }
[ "public", "function", "showTables", "(", ")", "{", "$", "sql", "=", "'SHOW TABLES'", ";", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "query", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "}" ]
Run a `SHOW TABLES` query and return the results @return array Result of the `SHOW TABLES` query @since 1.1.4
[ "Run", "a", "SHOW", "TABLES", "query", "and", "return", "the", "results" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Database/Model.php#L56-L63
24,880
stevenliebregt/crispysystem
src/Database/Model.php
Model.getAll
public function getAll() { $fields = implode(', ', $this->fields); $sql = 'SELECT ' . $fields . ' FROM ' . $this->table; $query = $this->pdo->prepare($sql); $query->execute(); return $query->fetchAll(PDO::FETCH_ASSOC); }
php
public function getAll() { $fields = implode(', ', $this->fields); $sql = 'SELECT ' . $fields . ' FROM ' . $this->table; $query = $this->pdo->prepare($sql); $query->execute(); return $query->fetchAll(PDO::FETCH_ASSOC); }
[ "public", "function", "getAll", "(", ")", "{", "$", "fields", "=", "implode", "(", "', '", ",", "$", "this", "->", "fields", ")", ";", "$", "sql", "=", "'SELECT '", ".", "$", "fields", ".", "' FROM '", ".", "$", "this", "->", "table", ";", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "query", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "}" ]
Run a SELECT all query @return array Query result @since 1.1.4
[ "Run", "a", "SELECT", "all", "query" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Database/Model.php#L70-L78
24,881
stevenliebregt/crispysystem
src/Database/Model.php
Model.getOneById
public function getOneById($id) { $id = (string)$id; $fields = implode(', ', $this->fields); $sql = 'SELECT ' . $fields . ' FROM ' . $this->table . ' WHERE ' . $this->table . '.id = :id'; $query = $this->pdo->prepare($sql); $query->bindParam(':id', $id); $query->execute(); return $query->fetch(PDO::FETCH_ASSOC); }
php
public function getOneById($id) { $id = (string)$id; $fields = implode(', ', $this->fields); $sql = 'SELECT ' . $fields . ' FROM ' . $this->table . ' WHERE ' . $this->table . '.id = :id'; $query = $this->pdo->prepare($sql); $query->bindParam(':id', $id); $query->execute(); return $query->fetch(PDO::FETCH_ASSOC); }
[ "public", "function", "getOneById", "(", "$", "id", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "$", "fields", "=", "implode", "(", "', '", ",", "$", "this", "->", "fields", ")", ";", "$", "sql", "=", "'SELECT '", ".", "$", "fields", ".", "' FROM '", ".", "$", "this", "->", "table", ".", "' WHERE '", ".", "$", "this", "->", "table", ".", "'.id = :id'", ";", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "query", "->", "bindParam", "(", "':id'", ",", "$", "id", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "query", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "}" ]
Run a SELECT query by ID @param int|string $id The id of the record you want to retrieve @return mixed Query result @since 1.1.4
[ "Run", "a", "SELECT", "query", "by", "ID" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Database/Model.php#L86-L97
24,882
stevenliebregt/crispysystem
src/Database/Model.php
Model.insert
public function insert(array $values) : int { $fields = $this->fields; array_shift($fields); $sql = 'INSERT INTO `' . $this->table . '` (' . implode(', ', $fields) . ') VALUES (:' . implode(', :', $fields) . ')'; $query = $this->pdo->prepare($sql); foreach ($values as $key => &$value) { $query->bindParam(':' . $fields[$key], $value); } $query->execute(); return $this->pdo->lastInsertId(); }
php
public function insert(array $values) : int { $fields = $this->fields; array_shift($fields); $sql = 'INSERT INTO `' . $this->table . '` (' . implode(', ', $fields) . ') VALUES (:' . implode(', :', $fields) . ')'; $query = $this->pdo->prepare($sql); foreach ($values as $key => &$value) { $query->bindParam(':' . $fields[$key], $value); } $query->execute(); return $this->pdo->lastInsertId(); }
[ "public", "function", "insert", "(", "array", "$", "values", ")", ":", "int", "{", "$", "fields", "=", "$", "this", "->", "fields", ";", "array_shift", "(", "$", "fields", ")", ";", "$", "sql", "=", "'INSERT INTO `'", ".", "$", "this", "->", "table", ".", "'` ('", ".", "implode", "(", "', '", ",", "$", "fields", ")", ".", "') VALUES (:'", ".", "implode", "(", "', :'", ",", "$", "fields", ")", ".", "')'", ";", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "$", "query", "->", "bindParam", "(", "':'", ".", "$", "fields", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "this", "->", "pdo", "->", "lastInsertId", "(", ")", ";", "}" ]
Insert a new record in the database @param array $values Values to insert, except id, since it is expected to be AUTO_INCREMENT @return int Return the last inserted id @since 1.1.4
[ "Insert", "a", "new", "record", "in", "the", "database" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Database/Model.php#L105-L118
24,883
stevenliebregt/crispysystem
src/Database/Model.php
Model.deleteById
public function deleteById($id) : int { $sql = 'DELETE FROM `' . $this->table . '` WHERE '; // Assign ids if (is_array($id)) { $i = 0; foreach ($id as $_id) { if ($i === 0) { $sql .= ' id=:id' . $i; } else { $sql .= ' OR id=:id' . $i; } $i++; } $query = $this->pdo->prepare($sql); for ($j = 0; $j < 0; $j++) { $query->bindParam(':id' . $j, $id[$j]); } } else { $sql .= 'id=:id'; $query = $this->pdo->prepare($sql); $query->bindParam(':id', $id); } $query->execute(); return $query->rowCount(); }
php
public function deleteById($id) : int { $sql = 'DELETE FROM `' . $this->table . '` WHERE '; // Assign ids if (is_array($id)) { $i = 0; foreach ($id as $_id) { if ($i === 0) { $sql .= ' id=:id' . $i; } else { $sql .= ' OR id=:id' . $i; } $i++; } $query = $this->pdo->prepare($sql); for ($j = 0; $j < 0; $j++) { $query->bindParam(':id' . $j, $id[$j]); } } else { $sql .= 'id=:id'; $query = $this->pdo->prepare($sql); $query->bindParam(':id', $id); } $query->execute(); return $query->rowCount(); }
[ "public", "function", "deleteById", "(", "$", "id", ")", ":", "int", "{", "$", "sql", "=", "'DELETE FROM `'", ".", "$", "this", "->", "table", ".", "'` WHERE '", ";", "// Assign ids", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "id", "as", "$", "_id", ")", "{", "if", "(", "$", "i", "===", "0", ")", "{", "$", "sql", ".=", "' id=:id'", ".", "$", "i", ";", "}", "else", "{", "$", "sql", ".=", "' OR id=:id'", ".", "$", "i", ";", "}", "$", "i", "++", ";", "}", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "0", ";", "$", "j", "++", ")", "{", "$", "query", "->", "bindParam", "(", "':id'", ".", "$", "j", ",", "$", "id", "[", "$", "j", "]", ")", ";", "}", "}", "else", "{", "$", "sql", ".=", "'id=:id'", ";", "$", "query", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "$", "query", "->", "bindParam", "(", "':id'", ",", "$", "id", ")", ";", "}", "$", "query", "->", "execute", "(", ")", ";", "return", "$", "query", "->", "rowCount", "(", ")", ";", "}" ]
Run a DELETE query @param string|array $id Id(s) to delete @return int Return affected rows @since 1.1.4
[ "Run", "a", "DELETE", "query" ]
06547dae100dae1023a93ec903f2d2abacce9aec
https://github.com/stevenliebregt/crispysystem/blob/06547dae100dae1023a93ec903f2d2abacce9aec/src/Database/Model.php#L175-L203
24,884
Wedeto/FileFormats
src/XML/Reader.php
Reader.readFile
public function readFile(string $file_name) { $reader = new XMLReader; $reader->open($file_name); $data = $this->toArray($reader); $reader->close(); return $data; }
php
public function readFile(string $file_name) { $reader = new XMLReader; $reader->open($file_name); $data = $this->toArray($reader); $reader->close(); return $data; }
[ "public", "function", "readFile", "(", "string", "$", "file_name", ")", "{", "$", "reader", "=", "new", "XMLReader", ";", "$", "reader", "->", "open", "(", "$", "file_name", ")", ";", "$", "data", "=", "$", "this", "->", "toArray", "(", "$", "reader", ")", ";", "$", "reader", "->", "close", "(", ")", ";", "return", "$", "data", ";", "}" ]
Read a XML file into an array @param string $filename The file to read @return array The array representation of the XML Data
[ "Read", "a", "XML", "file", "into", "an", "array" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/XML/Reader.php#L42-L51
24,885
Wedeto/FileFormats
src/XML/Reader.php
Reader.readString
public function readString(string $data) { $reader = new XMLReader; $reader->XML($data); $contents = $this->toArray($reader); $reader->close(); return $contents; }
php
public function readString(string $data) { $reader = new XMLReader; $reader->XML($data); $contents = $this->toArray($reader); $reader->close(); return $contents; }
[ "public", "function", "readString", "(", "string", "$", "data", ")", "{", "$", "reader", "=", "new", "XMLReader", ";", "$", "reader", "->", "XML", "(", "$", "data", ")", ";", "$", "contents", "=", "$", "this", "->", "toArray", "(", "$", "reader", ")", ";", "$", "reader", "->", "close", "(", ")", ";", "return", "$", "contents", ";", "}" ]
Read XML Data from a string @param string $data The data to read @return array the array representation of the XML data
[ "Read", "XML", "Data", "from", "a", "string" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/XML/Reader.php#L59-L68
24,886
Wedeto/FileFormats
src/XML/Reader.php
Reader.parseTree
public function parseTree(XMLReader $reader) { libxml_use_internal_errors(true); $root = new XMLNode; $cur = null; $read_anything = false; while ($reader->read()) { $read_anything = true; if ($reader->nodeType === XMLReader::ELEMENT) { if ($cur === null) { $root->name = $reader->name; $cur = $root; } else { $node = new XMLNode; $node->name = $reader->name; $node->parent = $cur; $cur->children[] = $node; $cur = $node; } if ($reader->hasAttributes) { while ($reader->moveToNextAttribute()) { $node = new XMLNode; $node->name = $reader->name; $node->content = $reader->value; $cur->attributes[] = $node; } } } else if ($reader->nodeType === XMLReader::END_ELEMENT) { $cur = $cur->parent; } else if ($reader->nodeType === XMLReader::TEXT) { $cur->content = $reader->value; } } try { foreach (libxml_get_errors() as $error) throw new XMLException($error); } finally { libxml_clear_errors(); } return $root; }
php
public function parseTree(XMLReader $reader) { libxml_use_internal_errors(true); $root = new XMLNode; $cur = null; $read_anything = false; while ($reader->read()) { $read_anything = true; if ($reader->nodeType === XMLReader::ELEMENT) { if ($cur === null) { $root->name = $reader->name; $cur = $root; } else { $node = new XMLNode; $node->name = $reader->name; $node->parent = $cur; $cur->children[] = $node; $cur = $node; } if ($reader->hasAttributes) { while ($reader->moveToNextAttribute()) { $node = new XMLNode; $node->name = $reader->name; $node->content = $reader->value; $cur->attributes[] = $node; } } } else if ($reader->nodeType === XMLReader::END_ELEMENT) { $cur = $cur->parent; } else if ($reader->nodeType === XMLReader::TEXT) { $cur->content = $reader->value; } } try { foreach (libxml_get_errors() as $error) throw new XMLException($error); } finally { libxml_clear_errors(); } return $root; }
[ "public", "function", "parseTree", "(", "XMLReader", "$", "reader", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "root", "=", "new", "XMLNode", ";", "$", "cur", "=", "null", ";", "$", "read_anything", "=", "false", ";", "while", "(", "$", "reader", "->", "read", "(", ")", ")", "{", "$", "read_anything", "=", "true", ";", "if", "(", "$", "reader", "->", "nodeType", "===", "XMLReader", "::", "ELEMENT", ")", "{", "if", "(", "$", "cur", "===", "null", ")", "{", "$", "root", "->", "name", "=", "$", "reader", "->", "name", ";", "$", "cur", "=", "$", "root", ";", "}", "else", "{", "$", "node", "=", "new", "XMLNode", ";", "$", "node", "->", "name", "=", "$", "reader", "->", "name", ";", "$", "node", "->", "parent", "=", "$", "cur", ";", "$", "cur", "->", "children", "[", "]", "=", "$", "node", ";", "$", "cur", "=", "$", "node", ";", "}", "if", "(", "$", "reader", "->", "hasAttributes", ")", "{", "while", "(", "$", "reader", "->", "moveToNextAttribute", "(", ")", ")", "{", "$", "node", "=", "new", "XMLNode", ";", "$", "node", "->", "name", "=", "$", "reader", "->", "name", ";", "$", "node", "->", "content", "=", "$", "reader", "->", "value", ";", "$", "cur", "->", "attributes", "[", "]", "=", "$", "node", ";", "}", "}", "}", "else", "if", "(", "$", "reader", "->", "nodeType", "===", "XMLReader", "::", "END_ELEMENT", ")", "{", "$", "cur", "=", "$", "cur", "->", "parent", ";", "}", "else", "if", "(", "$", "reader", "->", "nodeType", "===", "XMLReader", "::", "TEXT", ")", "{", "$", "cur", "->", "content", "=", "$", "reader", "->", "value", ";", "}", "}", "try", "{", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "throw", "new", "XMLException", "(", "$", "error", ")", ";", "}", "finally", "{", "libxml_clear_errors", "(", ")", ";", "}", "return", "$", "root", ";", "}" ]
Parse the XML into an array. This will add all nodes and attributes to a tree of XML nodes. This is only basic XML flattening, for full-blown XML support be sure to use a more fully featured solution like SimpleXML @param XMLReader $reader The reader reading the XML @return XMLNode The root node
[ "Parse", "the", "XML", "into", "an", "array", ".", "This", "will", "add", "all", "nodes", "and", "attributes", "to", "a", "tree", "of", "XML", "nodes", ".", "This", "is", "only", "basic", "XML", "flattening", "for", "full", "-", "blown", "XML", "support", "be", "sure", "to", "use", "a", "more", "fully", "featured", "solution", "like", "SimpleXML" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/XML/Reader.php#L93-L152
24,887
ciims/ciims-modules-api
ApiModule.php
ApiModule.init
public function init() { // Autoload the models and components directory $this->setImport(array( 'api.models.*', 'api.components.*', )); // Disable layout rendering $this->layout = false; // Disable logging for the API foreach(Yii::app()->log->routes as $k=>$v) { if (get_class($v) == 'CWebLogRoute' || get_class($v) == "CProfileLogRoute") Yii::app()->log->routes[$k]->enabled = false; } // Set default components and routes Yii::app()->setComponents(array( 'errorHandler' => array( 'errorAction' => 'api/default/error', ), 'messages' => array( 'class' => 'cii.components.CiiPHPMessageSource', 'basePath' => Yii::getPathOfAlias('application.modules.api') ) )); }
php
public function init() { // Autoload the models and components directory $this->setImport(array( 'api.models.*', 'api.components.*', )); // Disable layout rendering $this->layout = false; // Disable logging for the API foreach(Yii::app()->log->routes as $k=>$v) { if (get_class($v) == 'CWebLogRoute' || get_class($v) == "CProfileLogRoute") Yii::app()->log->routes[$k]->enabled = false; } // Set default components and routes Yii::app()->setComponents(array( 'errorHandler' => array( 'errorAction' => 'api/default/error', ), 'messages' => array( 'class' => 'cii.components.CiiPHPMessageSource', 'basePath' => Yii::getPathOfAlias('application.modules.api') ) )); }
[ "public", "function", "init", "(", ")", "{", "// Autoload the models and components directory \r", "$", "this", "->", "setImport", "(", "array", "(", "'api.models.*'", ",", "'api.components.*'", ",", ")", ")", ";", "// Disable layout rendering\r", "$", "this", "->", "layout", "=", "false", ";", "// Disable logging for the API\r", "foreach", "(", "Yii", "::", "app", "(", ")", "->", "log", "->", "routes", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "get_class", "(", "$", "v", ")", "==", "'CWebLogRoute'", "||", "get_class", "(", "$", "v", ")", "==", "\"CProfileLogRoute\"", ")", "Yii", "::", "app", "(", ")", "->", "log", "->", "routes", "[", "$", "k", "]", "->", "enabled", "=", "false", ";", "}", "// Set default components and routes\r", "Yii", "::", "app", "(", ")", "->", "setComponents", "(", "array", "(", "'errorHandler'", "=>", "array", "(", "'errorAction'", "=>", "'api/default/error'", ",", ")", ",", "'messages'", "=>", "array", "(", "'class'", "=>", "'cii.components.CiiPHPMessageSource'", ",", "'basePath'", "=>", "Yii", "::", "getPathOfAlias", "(", "'application.modules.api'", ")", ")", ")", ")", ";", "}" ]
Yii Init method Implements basic configuration for module
[ "Yii", "Init", "method", "Implements", "basic", "configuration", "for", "module" ]
4351855328da0b112ac27bde7e7e07e212be8689
https://github.com/ciims/ciims-modules-api/blob/4351855328da0b112ac27bde7e7e07e212be8689/ApiModule.php#L24-L52
24,888
MatiasNAmendola/slimpower-auth-core
src/Abstracts/AuthenticationMiddleware.php
AuthenticationMiddleware.call
public function call() { /* If rules say we should not authenticate call next and return. */ if (false === $this->shouldAuthenticate()) { $this->next->call(); return; } $this->checkSecure(); $freePass = $this->hasFreePass(); /* If userdata cannot be found return with 401 Unauthorized. */ if ((false === $this->data = $this->fetchData()) && !$freePass) { $this->callError(); return; } if (false === $this->data && $freePass) { $this->next->call(); return; } /* Check if user authenticates. */ $authenticator = $this->options["authenticator"]; if (false === $authenticator($this->data)) { $this->error = $authenticator->getError(); $this->callError(); return; } $this->app->userData = $authenticator->getData(); if (!$this->customValidation()) { $this->callError(); return; } /* If callback returns false return with 401 Unauthorized. */ if (is_callable($this->options["callback"])) { $params = $this->getParams(); if (false === $this->options["callback"]($params)) { $this->error = new Error(); $this->error->setDescription("Callback returned false"); $this->callError(); return; } } /* Everything ok, call next middleware. */ $this->next->call(); }
php
public function call() { /* If rules say we should not authenticate call next and return. */ if (false === $this->shouldAuthenticate()) { $this->next->call(); return; } $this->checkSecure(); $freePass = $this->hasFreePass(); /* If userdata cannot be found return with 401 Unauthorized. */ if ((false === $this->data = $this->fetchData()) && !$freePass) { $this->callError(); return; } if (false === $this->data && $freePass) { $this->next->call(); return; } /* Check if user authenticates. */ $authenticator = $this->options["authenticator"]; if (false === $authenticator($this->data)) { $this->error = $authenticator->getError(); $this->callError(); return; } $this->app->userData = $authenticator->getData(); if (!$this->customValidation()) { $this->callError(); return; } /* If callback returns false return with 401 Unauthorized. */ if (is_callable($this->options["callback"])) { $params = $this->getParams(); if (false === $this->options["callback"]($params)) { $this->error = new Error(); $this->error->setDescription("Callback returned false"); $this->callError(); return; } } /* Everything ok, call next middleware. */ $this->next->call(); }
[ "public", "function", "call", "(", ")", "{", "/* If rules say we should not authenticate call next and return. */", "if", "(", "false", "===", "$", "this", "->", "shouldAuthenticate", "(", ")", ")", "{", "$", "this", "->", "next", "->", "call", "(", ")", ";", "return", ";", "}", "$", "this", "->", "checkSecure", "(", ")", ";", "$", "freePass", "=", "$", "this", "->", "hasFreePass", "(", ")", ";", "/* If userdata cannot be found return with 401 Unauthorized. */", "if", "(", "(", "false", "===", "$", "this", "->", "data", "=", "$", "this", "->", "fetchData", "(", ")", ")", "&&", "!", "$", "freePass", ")", "{", "$", "this", "->", "callError", "(", ")", ";", "return", ";", "}", "if", "(", "false", "===", "$", "this", "->", "data", "&&", "$", "freePass", ")", "{", "$", "this", "->", "next", "->", "call", "(", ")", ";", "return", ";", "}", "/* Check if user authenticates. */", "$", "authenticator", "=", "$", "this", "->", "options", "[", "\"authenticator\"", "]", ";", "if", "(", "false", "===", "$", "authenticator", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "error", "=", "$", "authenticator", "->", "getError", "(", ")", ";", "$", "this", "->", "callError", "(", ")", ";", "return", ";", "}", "$", "this", "->", "app", "->", "userData", "=", "$", "authenticator", "->", "getData", "(", ")", ";", "if", "(", "!", "$", "this", "->", "customValidation", "(", ")", ")", "{", "$", "this", "->", "callError", "(", ")", ";", "return", ";", "}", "/* If callback returns false return with 401 Unauthorized. */", "if", "(", "is_callable", "(", "$", "this", "->", "options", "[", "\"callback\"", "]", ")", ")", "{", "$", "params", "=", "$", "this", "->", "getParams", "(", ")", ";", "if", "(", "false", "===", "$", "this", "->", "options", "[", "\"callback\"", "]", "(", "$", "params", ")", ")", "{", "$", "this", "->", "error", "=", "new", "Error", "(", ")", ";", "$", "this", "->", "error", "->", "setDescription", "(", "\"Callback returned false\"", ")", ";", "$", "this", "->", "callError", "(", ")", ";", "return", ";", "}", "}", "/* Everything ok, call next middleware. */", "$", "this", "->", "next", "->", "call", "(", ")", ";", "}" ]
Call the middleware
[ "Call", "the", "middleware" ]
550ab85d871de8451cb242eaa17f4041ff320b7c
https://github.com/MatiasNAmendola/slimpower-auth-core/blob/550ab85d871de8451cb242eaa17f4041ff320b7c/src/Abstracts/AuthenticationMiddleware.php#L132-L183
24,889
MatiasNAmendola/slimpower-auth-core
src/Abstracts/AuthenticationMiddleware.php
AuthenticationMiddleware.checkSecure
private function checkSecure() { $environment = $this->app->environment; $scheme = $environment["slim.url_scheme"]; if ("https" !== $scheme && true === $this->options["secure"]) { if (!in_array($environment["SERVER_NAME"], $this->options["relaxed"])) { $message = sprintf( "Insecure use of middleware over %s denied by configuration.", strtoupper($scheme) ); throw new \RuntimeException($message); } } }
php
private function checkSecure() { $environment = $this->app->environment; $scheme = $environment["slim.url_scheme"]; if ("https" !== $scheme && true === $this->options["secure"]) { if (!in_array($environment["SERVER_NAME"], $this->options["relaxed"])) { $message = sprintf( "Insecure use of middleware over %s denied by configuration.", strtoupper($scheme) ); throw new \RuntimeException($message); } } }
[ "private", "function", "checkSecure", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "app", "->", "environment", ";", "$", "scheme", "=", "$", "environment", "[", "\"slim.url_scheme\"", "]", ";", "if", "(", "\"https\"", "!==", "$", "scheme", "&&", "true", "===", "$", "this", "->", "options", "[", "\"secure\"", "]", ")", "{", "if", "(", "!", "in_array", "(", "$", "environment", "[", "\"SERVER_NAME\"", "]", ",", "$", "this", "->", "options", "[", "\"relaxed\"", "]", ")", ")", "{", "$", "message", "=", "sprintf", "(", "\"Insecure use of middleware over %s denied by configuration.\"", ",", "strtoupper", "(", "$", "scheme", ")", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "message", ")", ";", "}", "}", "}" ]
HTTP allowed only if secure is false or server is in relaxed array. @throws \RuntimeException
[ "HTTP", "allowed", "only", "if", "secure", "is", "false", "or", "server", "is", "in", "relaxed", "array", "." ]
550ab85d871de8451cb242eaa17f4041ff320b7c
https://github.com/MatiasNAmendola/slimpower-auth-core/blob/550ab85d871de8451cb242eaa17f4041ff320b7c/src/Abstracts/AuthenticationMiddleware.php#L193-L205
24,890
MatiasNAmendola/slimpower-auth-core
src/Abstracts/AuthenticationMiddleware.php
AuthenticationMiddleware.hydrate
private function hydrate($data = array()) { foreach ($data as $key => $value) { $method = "set" . ucfirst($key); if (method_exists($this, $method)) { call_user_func(array($this, $method), $value); } } }
php
private function hydrate($data = array()) { foreach ($data as $key => $value) { $method = "set" . ucfirst($key); if (method_exists($this, $method)) { call_user_func(array($this, $method), $value); } } }
[ "private", "function", "hydrate", "(", "$", "data", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "method", "=", "\"set\"", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "method", ")", ",", "$", "value", ")", ";", "}", "}", "}" ]
Hydate options from given array @param array $data Array of options. @return self
[ "Hydate", "options", "from", "given", "array" ]
550ab85d871de8451cb242eaa17f4041ff320b7c
https://github.com/MatiasNAmendola/slimpower-auth-core/blob/550ab85d871de8451cb242eaa17f4041ff320b7c/src/Abstracts/AuthenticationMiddleware.php#L230-L237
24,891
MatiasNAmendola/slimpower-auth-core
src/Abstracts/AuthenticationMiddleware.php
AuthenticationMiddleware.callError
public function callError() { if (!($this->error instanceof Error)) { $this->error = new Error(); } $status = $this->error->getStatus(); $this->app->response->status($status); if (is_callable($this->options["error"])) { $this->options["error"]($this->error); } }
php
public function callError() { if (!($this->error instanceof Error)) { $this->error = new Error(); } $status = $this->error->getStatus(); $this->app->response->status($status); if (is_callable($this->options["error"])) { $this->options["error"]($this->error); } }
[ "public", "function", "callError", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "error", "instanceof", "Error", ")", ")", "{", "$", "this", "->", "error", "=", "new", "Error", "(", ")", ";", "}", "$", "status", "=", "$", "this", "->", "error", "->", "getStatus", "(", ")", ";", "$", "this", "->", "app", "->", "response", "->", "status", "(", "$", "status", ")", ";", "if", "(", "is_callable", "(", "$", "this", "->", "options", "[", "\"error\"", "]", ")", ")", "{", "$", "this", "->", "options", "[", "\"error\"", "]", "(", "$", "this", "->", "error", ")", ";", "}", "}" ]
Call the error handler if it exists @return void
[ "Call", "the", "error", "handler", "if", "it", "exists" ]
550ab85d871de8451cb242eaa17f4041ff320b7c
https://github.com/MatiasNAmendola/slimpower-auth-core/blob/550ab85d871de8451cb242eaa17f4041ff320b7c/src/Abstracts/AuthenticationMiddleware.php#L259-L270
24,892
MatiasNAmendola/slimpower-auth-core
src/Abstracts/AuthenticationMiddleware.php
AuthenticationMiddleware.setRules
public function setRules(array $rules) { /* Clear the stack */ unset($this->rules); $this->rules = new \SplStack; /* Add the rules */ foreach ($rules as $callable) { $this->addRule($callable); } return $this; }
php
public function setRules(array $rules) { /* Clear the stack */ unset($this->rules); $this->rules = new \SplStack; /* Add the rules */ foreach ($rules as $callable) { $this->addRule($callable); } return $this; }
[ "public", "function", "setRules", "(", "array", "$", "rules", ")", "{", "/* Clear the stack */", "unset", "(", "$", "this", "->", "rules", ")", ";", "$", "this", "->", "rules", "=", "new", "\\", "SplStack", ";", "/* Add the rules */", "foreach", "(", "$", "rules", "as", "$", "callable", ")", "{", "$", "this", "->", "addRule", "(", "$", "callable", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set all rules in the stack @return self
[ "Set", "all", "rules", "in", "the", "stack" ]
550ab85d871de8451cb242eaa17f4041ff320b7c
https://github.com/MatiasNAmendola/slimpower-auth-core/blob/550ab85d871de8451cb242eaa17f4041ff320b7c/src/Abstracts/AuthenticationMiddleware.php#L413-L424
24,893
theopera/framework
src/Component/Http/ParameterBag.php
ParameterBag.add
public function add(string $key, $value, bool $override = false) { if (!$override && $this->exists($key)) { return; } $this->parameters[$key] = $value; }
php
public function add(string $key, $value, bool $override = false) { if (!$override && $this->exists($key)) { return; } $this->parameters[$key] = $value; }
[ "public", "function", "add", "(", "string", "$", "key", ",", "$", "value", ",", "bool", "$", "override", "=", "false", ")", "{", "if", "(", "!", "$", "override", "&&", "$", "this", "->", "exists", "(", "$", "key", ")", ")", "{", "return", ";", "}", "$", "this", "->", "parameters", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Add a parameter to the bag @param string $key @param mixed $value
[ "Add", "a", "parameter", "to", "the", "bag" ]
fa6165d3891a310faa580c81dee49a63c150c711
https://github.com/theopera/framework/blob/fa6165d3891a310faa580c81dee49a63c150c711/src/Component/Http/ParameterBag.php#L57-L64
24,894
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.start
public function start() { $modules = ModuleModel::where('module_status', 1)->get(); foreach($modules as $module) { $path = $this->getModuleDirectory($module->module_name); if ($path) { $name = $module->module_name; $this->modules[$name] = new Module($this->app, $module->module_name, $path); } } }
php
public function start() { $modules = ModuleModel::where('module_status', 1)->get(); foreach($modules as $module) { $path = $this->getModuleDirectory($module->module_name); if ($path) { $name = $module->module_name; $this->modules[$name] = new Module($this->app, $module->module_name, $path); } } }
[ "public", "function", "start", "(", ")", "{", "$", "modules", "=", "ModuleModel", "::", "where", "(", "'module_status'", ",", "1", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "$", "path", "=", "$", "this", "->", "getModuleDirectory", "(", "$", "module", "->", "module_name", ")", ";", "if", "(", "$", "path", ")", "{", "$", "name", "=", "$", "module", "->", "module_name", ";", "$", "this", "->", "modules", "[", "$", "name", "]", "=", "new", "Module", "(", "$", "this", "->", "app", ",", "$", "module", "->", "module_name", ",", "$", "path", ")", ";", "}", "}", "}" ]
Get all module from database and initialize @return void
[ "Get", "all", "module", "from", "database", "and", "initialize" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L120-L132
24,895
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.register
public function register() { foreach ($this->modules as $module) { $module->register(); } $modules = ModuleModel::where('module_status', 1)->get(); foreach ($modules as $module) { if ($module->module_is_installed) { $this->app['events']->fire('modules.install.'.$module->module_name, null); $module->module_is_installed = 0; } if ($module->module_is_updated) { $this->app['events']->fire('modules.update.'.$module->module_name, null); $module->module_is_updated = 0; } if ($module->module_is_enabled) { $this->app['events']->fire('modules.enable.'.$module->module_name, null); $module->module_is_enabled = 0; } $module->save(); } }
php
public function register() { foreach ($this->modules as $module) { $module->register(); } $modules = ModuleModel::where('module_status', 1)->get(); foreach ($modules as $module) { if ($module->module_is_installed) { $this->app['events']->fire('modules.install.'.$module->module_name, null); $module->module_is_installed = 0; } if ($module->module_is_updated) { $this->app['events']->fire('modules.update.'.$module->module_name, null); $module->module_is_updated = 0; } if ($module->module_is_enabled) { $this->app['events']->fire('modules.enable.'.$module->module_name, null); $module->module_is_enabled = 0; } $module->save(); } }
[ "public", "function", "register", "(", ")", "{", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "module", "->", "register", "(", ")", ";", "}", "$", "modules", "=", "ModuleModel", "::", "where", "(", "'module_status'", ",", "1", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "if", "(", "$", "module", "->", "module_is_installed", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.install.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_installed", "=", "0", ";", "}", "if", "(", "$", "module", "->", "module_is_updated", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.update.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_updated", "=", "0", ";", "}", "if", "(", "$", "module", "->", "module_is_enabled", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.enable.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_enabled", "=", "0", ";", "}", "$", "module", "->", "save", "(", ")", ";", "}", "}" ]
Register modules with Moduel class @return void
[ "Register", "modules", "with", "Moduel", "class" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L139-L166
24,896
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.enable
public function enable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if(!$module->module_status) { $module->module_status = 1; $module->module_is_enabled = 1; $module->save(); return true; } return false; } return false; }
php
public function enable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if(!$module->module_status) { $module->module_status = 1; $module->module_is_enabled = 1; $module->save(); return true; } return false; } return false; }
[ "public", "function", "enable", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "if", "(", "!", "$", "module", "->", "module_status", ")", "{", "$", "module", "->", "module_status", "=", "1", ";", "$", "module", "->", "module_is_enabled", "=", "1", ";", "$", "module", "->", "save", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "return", "false", ";", "}" ]
Enable module to load @param string #moduleName @return bool
[ "Enable", "module", "to", "load" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L174-L189
24,897
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.getListModules
protected function getListModules($modulesModel) { $modules = array(); foreach ($modulesModel as $module) { $modules[$module->module_name]['name'] = $this->def($module->module_name, 'name'); $modules[$module->module_name]['icon'] = $this->getConfig('assets').'/'.$module->module_name.'/'.$this->def($module->module_name, 'icon'); $modules[$module->module_name]['description'] = $this->def($module->module_name, 'description'); $modules[$module->module_name]['author'] = $this->def($module->module_name, 'author'); $modules[$module->module_name]['website'] = $this->def($module->module_name, 'website'); $modules[$module->module_name]['version'] = $this->def($module->module_name, 'version'); } return $modules; }
php
protected function getListModules($modulesModel) { $modules = array(); foreach ($modulesModel as $module) { $modules[$module->module_name]['name'] = $this->def($module->module_name, 'name'); $modules[$module->module_name]['icon'] = $this->getConfig('assets').'/'.$module->module_name.'/'.$this->def($module->module_name, 'icon'); $modules[$module->module_name]['description'] = $this->def($module->module_name, 'description'); $modules[$module->module_name]['author'] = $this->def($module->module_name, 'author'); $modules[$module->module_name]['website'] = $this->def($module->module_name, 'website'); $modules[$module->module_name]['version'] = $this->def($module->module_name, 'version'); } return $modules; }
[ "protected", "function", "getListModules", "(", "$", "modulesModel", ")", "{", "$", "modules", "=", "array", "(", ")", ";", "foreach", "(", "$", "modulesModel", "as", "$", "module", ")", "{", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'name'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'name'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'icon'", "]", "=", "$", "this", "->", "getConfig", "(", "'assets'", ")", ".", "'/'", ".", "$", "module", "->", "module_name", ".", "'/'", ".", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'icon'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'description'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'description'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'author'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'author'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'website'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'website'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'version'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'version'", ")", ";", "}", "return", "$", "modules", ";", "}" ]
Get list modules @param model $modulesModel @return array
[ "Get", "list", "modules" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L254-L267
24,898
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.buildAssets
public function buildAssets($moduleName) { $module = $this->getModuleDirectory($moduleName); if ($module) { $module .= '/assets'; if ($this->files->exists($module)) { if (!@$this->files->copyDirectory($module, $this->getAssetDirectory($moduleName))) { $this->errors->add('build_assets', 'Unable to build assets'); return false; } } return true; } return false; }
php
public function buildAssets($moduleName) { $module = $this->getModuleDirectory($moduleName); if ($module) { $module .= '/assets'; if ($this->files->exists($module)) { if (!@$this->files->copyDirectory($module, $this->getAssetDirectory($moduleName))) { $this->errors->add('build_assets', 'Unable to build assets'); return false; } } return true; } return false; }
[ "public", "function", "buildAssets", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "$", "module", ".=", "'/assets'", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "module", ")", ")", "{", "if", "(", "!", "@", "$", "this", "->", "files", "->", "copyDirectory", "(", "$", "module", ",", "$", "this", "->", "getAssetDirectory", "(", "$", "moduleName", ")", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'build_assets'", ",", "'Unable to build assets'", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Move contents assets module to public directory @param string $moduleName @return bool
[ "Move", "contents", "assets", "module", "to", "public", "directory" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L275-L292
24,899
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.removeAssets
public function removeAssets($moduleName) { $assets = $this->getAssetDirectory($moduleName); $this->files->deleteDirectory($assets); if ($this->files->exists($assets)) { $this->errors->add('delete_assets', 'Unable to delete assets in: '.$assets); return false; } return true; }
php
public function removeAssets($moduleName) { $assets = $this->getAssetDirectory($moduleName); $this->files->deleteDirectory($assets); if ($this->files->exists($assets)) { $this->errors->add('delete_assets', 'Unable to delete assets in: '.$assets); return false; } return true; }
[ "public", "function", "removeAssets", "(", "$", "moduleName", ")", "{", "$", "assets", "=", "$", "this", "->", "getAssetDirectory", "(", "$", "moduleName", ")", ";", "$", "this", "->", "files", "->", "deleteDirectory", "(", "$", "assets", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "assets", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'delete_assets'", ",", "'Unable to delete assets in: '", ".", "$", "assets", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Remove assets of a module @param string $moduleName @return bool
[ "Remove", "assets", "of", "a", "module" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L300-L311