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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
7,200
znframework/package-image
CoordinateRateCalculator.php
CoordinateRateCalculator.run
public static function run($size, &$c1, &$c2) { if( $size > 0 ) { if( $size <= $c2 ) { $rate = $c2 / $size; $c2 = $size; $c1 = $c1 / $rate; } else { $rate = $size / $c2; $c2 = $size; $c1 = $c1 * $rate; } } }
php
public static function run($size, &$c1, &$c2) { if( $size > 0 ) { if( $size <= $c2 ) { $rate = $c2 / $size; $c2 = $size; $c1 = $c1 / $rate; } else { $rate = $size / $c2; $c2 = $size; $c1 = $c1 * $rate; } } }
[ "public", "static", "function", "run", "(", "$", "size", ",", "&", "$", "c1", ",", "&", "$", "c2", ")", "{", "if", "(", "$", "size", ">", "0", ")", "{", "if", "(", "$", "size", "<=", "$", "c2", ")", "{", "$", "rate", "=", "$", "c2", "/", "$", "size", ";", "$", "c2", "=", "$", "size", ";", "$", "c1", "=", "$", "c1", "/", "$", "rate", ";", "}", "else", "{", "$", "rate", "=", "$", "size", "/", "$", "c2", ";", "$", "c2", "=", "$", "size", ";", "$", "c1", "=", "$", "c1", "*", "$", "rate", ";", "}", "}", "}" ]
Calculates the ratio according to the entered numerical value. @param float $size @param float &$c1 @param float &$c2
[ "Calculates", "the", "ratio", "according", "to", "the", "entered", "numerical", "value", "." ]
a4eee7468e2c8b9334b121bd358ab8acbccf11a2
https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/CoordinateRateCalculator.php#L21-L34
7,201
gbv/jskos-http
src/Error.php
Error.jsonSerialize
public function jsonSerialize() { $json = []; foreach (['code', 'message', 'description', 'uri'] as $field) { if ($this->$field !== null) { $json[$field] = $this->$field; } } return $json; }
php
public function jsonSerialize() { $json = []; foreach (['code', 'message', 'description', 'uri'] as $field) { if ($this->$field !== null) { $json[$field] = $this->$field; } } return $json; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "json", "=", "[", "]", ";", "foreach", "(", "[", "'code'", ",", "'message'", ",", "'description'", ",", "'uri'", "]", "as", "$", "field", ")", "{", "if", "(", "$", "this", "->", "$", "field", "!==", "null", ")", "{", "$", "json", "[", "$", "field", "]", "=", "$", "this", "->", "$", "field", ";", "}", "}", "return", "$", "json", ";", "}" ]
Only include non-null fields in JSON.
[ "Only", "include", "non", "-", "null", "fields", "in", "JSON", "." ]
3a9e82d875bed409c129401b4bee9285562db265
https://github.com/gbv/jskos-http/blob/3a9e82d875bed409c129401b4bee9285562db265/src/Error.php#L38-L49
7,202
shov/wpci-core
Flow/PromisePool.php
PromisePool.addAnonymousPromise
public function addAnonymousPromise(callable $promise, ?int $priority = null) { $priority = $priority ?? static::DEFAULT_PRIORITY; $this->pool[] = compact('priority', 'promise'); }
php
public function addAnonymousPromise(callable $promise, ?int $priority = null) { $priority = $priority ?? static::DEFAULT_PRIORITY; $this->pool[] = compact('priority', 'promise'); }
[ "public", "function", "addAnonymousPromise", "(", "callable", "$", "promise", ",", "?", "int", "$", "priority", "=", "null", ")", "{", "$", "priority", "=", "$", "priority", "??", "static", "::", "DEFAULT_PRIORITY", ";", "$", "this", "->", "pool", "[", "]", "=", "compact", "(", "'priority'", ",", "'promise'", ")", ";", "}" ]
Add no named callback to the pool @param callable $promise @param int|null $priority
[ "Add", "no", "named", "callback", "to", "the", "pool" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Flow/PromisePool.php#L51-L56
7,203
shov/wpci-core
Flow/PromisePool.php
PromisePool.callAllPromises
public function callAllPromises() { $pool = $this->pool; usort($pool, function ($a, $b) { return $a['priority'] - $b['priority']; }); foreach ($pool as $node) { $promise = $node['promise']; $promise(); } }
php
public function callAllPromises() { $pool = $this->pool; usort($pool, function ($a, $b) { return $a['priority'] - $b['priority']; }); foreach ($pool as $node) { $promise = $node['promise']; $promise(); } }
[ "public", "function", "callAllPromises", "(", ")", "{", "$", "pool", "=", "$", "this", "->", "pool", ";", "usort", "(", "$", "pool", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", "[", "'priority'", "]", "-", "$", "b", "[", "'priority'", "]", ";", "}", ")", ";", "foreach", "(", "$", "pool", "as", "$", "node", ")", "{", "$", "promise", "=", "$", "node", "[", "'promise'", "]", ";", "$", "promise", "(", ")", ";", "}", "}" ]
Call all callbacks ordered by priority
[ "Call", "all", "callbacks", "ordered", "by", "priority" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Flow/PromisePool.php#L61-L73
7,204
tigron/skeleton-core
lib/Skeleton/Core/Web/Media.php
Media.detect
public static function detect($request_uri) { // Don't bother looking up / if ($request_uri == '/') { return; } $request = explode('/', trim($request_uri, '/')); // Find the filename and extension $filename = $request[count($request)-1]; $extension = substr($filename, strrpos($filename, '.')); // If the request does not contain an extension, it's not to be handled by media if (strpos($extension, '.') !== 0) { return; } // Remove the . from the extension $extension = substr($extension, 1); $request_string = implode('/', $request); // Detect if it is a request for multiple files $class = get_called_class(); if (strpos($request_string, '&/') !== false) { $files = explode('&/', $request_string); $mtime = 0; foreach ($files as $file) { $file_mtime = $class::fetch('mtime', $file, $extension); if ($file_mtime === false) { $class::fail(); } if ($file_mtime > $mtime) { $mtime = $file_mtime; } } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == gmdate('D, d M Y H:i:s', $mtime).' GMT') { // Cached version $class::output($extension, '', $mtime); } } $content = ''; foreach ($files as $file) { $content .= $class::fetch('content', $file, $extension) . "\n"; } $content = $content; $filename = 'compacted.' . $extension; } else { $mtime = $class::fetch('mtime', $request_string, $extension); if ($mtime === false) { $class::fail(); } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == gmdate('D, d M Y H:i:s', $mtime).' GMT') { // Cached version $class::output($extension, '', $mtime); } } $content = $class::fetch('content', $request_string, $extension); // If content is null, we don't handle this extension at all. It would be false if the // file could not be found. if ($content === null) { return; } } // .css files can contain URLs and need to be passed through our URL // rewrite method if ($class::get_mime_type($extension) == 'text/css') { // FIXME: this has been disabled for now, but it needs to be fixed. // Only CSS files that have been fetched from the application's // asset directory should be rewritten. //$content = \Skeleton\Core\Util::rewrite_reverse_css($content); } $class::output($extension, $content, $mtime); }
php
public static function detect($request_uri) { // Don't bother looking up / if ($request_uri == '/') { return; } $request = explode('/', trim($request_uri, '/')); // Find the filename and extension $filename = $request[count($request)-1]; $extension = substr($filename, strrpos($filename, '.')); // If the request does not contain an extension, it's not to be handled by media if (strpos($extension, '.') !== 0) { return; } // Remove the . from the extension $extension = substr($extension, 1); $request_string = implode('/', $request); // Detect if it is a request for multiple files $class = get_called_class(); if (strpos($request_string, '&/') !== false) { $files = explode('&/', $request_string); $mtime = 0; foreach ($files as $file) { $file_mtime = $class::fetch('mtime', $file, $extension); if ($file_mtime === false) { $class::fail(); } if ($file_mtime > $mtime) { $mtime = $file_mtime; } } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == gmdate('D, d M Y H:i:s', $mtime).' GMT') { // Cached version $class::output($extension, '', $mtime); } } $content = ''; foreach ($files as $file) { $content .= $class::fetch('content', $file, $extension) . "\n"; } $content = $content; $filename = 'compacted.' . $extension; } else { $mtime = $class::fetch('mtime', $request_string, $extension); if ($mtime === false) { $class::fail(); } if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == gmdate('D, d M Y H:i:s', $mtime).' GMT') { // Cached version $class::output($extension, '', $mtime); } } $content = $class::fetch('content', $request_string, $extension); // If content is null, we don't handle this extension at all. It would be false if the // file could not be found. if ($content === null) { return; } } // .css files can contain URLs and need to be passed through our URL // rewrite method if ($class::get_mime_type($extension) == 'text/css') { // FIXME: this has been disabled for now, but it needs to be fixed. // Only CSS files that have been fetched from the application's // asset directory should be rewritten. //$content = \Skeleton\Core\Util::rewrite_reverse_css($content); } $class::output($extension, $content, $mtime); }
[ "public", "static", "function", "detect", "(", "$", "request_uri", ")", "{", "// Don't bother looking up /", "if", "(", "$", "request_uri", "==", "'/'", ")", "{", "return", ";", "}", "$", "request", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "request_uri", ",", "'/'", ")", ")", ";", "// Find the filename and extension", "$", "filename", "=", "$", "request", "[", "count", "(", "$", "request", ")", "-", "1", "]", ";", "$", "extension", "=", "substr", "(", "$", "filename", ",", "strrpos", "(", "$", "filename", ",", "'.'", ")", ")", ";", "// If the request does not contain an extension, it's not to be handled by media", "if", "(", "strpos", "(", "$", "extension", ",", "'.'", ")", "!==", "0", ")", "{", "return", ";", "}", "// Remove the . from the extension", "$", "extension", "=", "substr", "(", "$", "extension", ",", "1", ")", ";", "$", "request_string", "=", "implode", "(", "'/'", ",", "$", "request", ")", ";", "// Detect if it is a request for multiple files", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "strpos", "(", "$", "request_string", ",", "'&/'", ")", "!==", "false", ")", "{", "$", "files", "=", "explode", "(", "'&/'", ",", "$", "request_string", ")", ";", "$", "mtime", "=", "0", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "file_mtime", "=", "$", "class", "::", "fetch", "(", "'mtime'", ",", "$", "file", ",", "$", "extension", ")", ";", "if", "(", "$", "file_mtime", "===", "false", ")", "{", "$", "class", "::", "fail", "(", ")", ";", "}", "if", "(", "$", "file_mtime", ">", "$", "mtime", ")", "{", "$", "mtime", "=", "$", "file_mtime", ";", "}", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", ")", ")", "{", "if", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", "==", "gmdate", "(", "'D, d M Y H:i:s'", ",", "$", "mtime", ")", ".", "' GMT'", ")", "{", "// Cached version", "$", "class", "::", "output", "(", "$", "extension", ",", "''", ",", "$", "mtime", ")", ";", "}", "}", "$", "content", "=", "''", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "content", ".=", "$", "class", "::", "fetch", "(", "'content'", ",", "$", "file", ",", "$", "extension", ")", ".", "\"\\n\"", ";", "}", "$", "content", "=", "$", "content", ";", "$", "filename", "=", "'compacted.'", ".", "$", "extension", ";", "}", "else", "{", "$", "mtime", "=", "$", "class", "::", "fetch", "(", "'mtime'", ",", "$", "request_string", ",", "$", "extension", ")", ";", "if", "(", "$", "mtime", "===", "false", ")", "{", "$", "class", "::", "fail", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", ")", ")", "{", "if", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", "==", "gmdate", "(", "'D, d M Y H:i:s'", ",", "$", "mtime", ")", ".", "' GMT'", ")", "{", "// Cached version", "$", "class", "::", "output", "(", "$", "extension", ",", "''", ",", "$", "mtime", ")", ";", "}", "}", "$", "content", "=", "$", "class", "::", "fetch", "(", "'content'", ",", "$", "request_string", ",", "$", "extension", ")", ";", "// If content is null, we don't handle this extension at all. It would be false if the", "// file could not be found.", "if", "(", "$", "content", "===", "null", ")", "{", "return", ";", "}", "}", "// .css files can contain URLs and need to be passed through our URL", "// rewrite method", "if", "(", "$", "class", "::", "get_mime_type", "(", "$", "extension", ")", "==", "'text/css'", ")", "{", "// FIXME: this has been disabled for now, but it needs to be fixed.", "// Only CSS files that have been fetched from the application's", "// asset directory should be rewritten.", "//$content = \\Skeleton\\Core\\Util::rewrite_reverse_css($content);", "}", "$", "class", "::", "output", "(", "$", "extension", ",", "$", "content", ",", "$", "mtime", ")", ";", "}" ]
Detect if the request is a request for media @param $request array @access public
[ "Detect", "if", "the", "request", "is", "a", "request", "for", "media" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Media.php#L60-L146
7,205
tigron/skeleton-core
lib/Skeleton/Core/Web/Media.php
Media.fetch
protected static function fetch($type, $path, $extension) { $packages = \Skeleton\Core\Package::get_all(); foreach (self::$filetypes as $filetype => $extensions) { $filepaths = [ \Skeleton\Core\Config::$asset_dir . '/' . $path, // Global asset directory Application::get()->media_path . '/' . $filetype . '/' . $path, // Application asset directory ]; foreach ($packages as $package) { $path_parts = explode('/', $path); if (!isset($path_parts[0]) or $path_parts[0] != $package->name) { continue; } unset($path_parts[0]); $package_path = $package->asset_path . '/' . $filetype . '/' . implode('/', $path_parts); $filepaths[] = $package_path; } if (in_array($extension, $extensions)) { foreach ($filepaths as $filepath) { if (file_exists($filepath)) { if ($type == 'mtime') { return filemtime($filepath); } else { return file_get_contents($filepath); } } } return false; } } return null; }
php
protected static function fetch($type, $path, $extension) { $packages = \Skeleton\Core\Package::get_all(); foreach (self::$filetypes as $filetype => $extensions) { $filepaths = [ \Skeleton\Core\Config::$asset_dir . '/' . $path, // Global asset directory Application::get()->media_path . '/' . $filetype . '/' . $path, // Application asset directory ]; foreach ($packages as $package) { $path_parts = explode('/', $path); if (!isset($path_parts[0]) or $path_parts[0] != $package->name) { continue; } unset($path_parts[0]); $package_path = $package->asset_path . '/' . $filetype . '/' . implode('/', $path_parts); $filepaths[] = $package_path; } if (in_array($extension, $extensions)) { foreach ($filepaths as $filepath) { if (file_exists($filepath)) { if ($type == 'mtime') { return filemtime($filepath); } else { return file_get_contents($filepath); } } } return false; } } return null; }
[ "protected", "static", "function", "fetch", "(", "$", "type", ",", "$", "path", ",", "$", "extension", ")", "{", "$", "packages", "=", "\\", "Skeleton", "\\", "Core", "\\", "Package", "::", "get_all", "(", ")", ";", "foreach", "(", "self", "::", "$", "filetypes", "as", "$", "filetype", "=>", "$", "extensions", ")", "{", "$", "filepaths", "=", "[", "\\", "Skeleton", "\\", "Core", "\\", "Config", "::", "$", "asset_dir", ".", "'/'", ".", "$", "path", ",", "// Global asset directory", "Application", "::", "get", "(", ")", "->", "media_path", ".", "'/'", ".", "$", "filetype", ".", "'/'", ".", "$", "path", ",", "// Application asset directory", "]", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "path_parts", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "if", "(", "!", "isset", "(", "$", "path_parts", "[", "0", "]", ")", "or", "$", "path_parts", "[", "0", "]", "!=", "$", "package", "->", "name", ")", "{", "continue", ";", "}", "unset", "(", "$", "path_parts", "[", "0", "]", ")", ";", "$", "package_path", "=", "$", "package", "->", "asset_path", ".", "'/'", ".", "$", "filetype", ".", "'/'", ".", "implode", "(", "'/'", ",", "$", "path_parts", ")", ";", "$", "filepaths", "[", "]", "=", "$", "package_path", ";", "}", "if", "(", "in_array", "(", "$", "extension", ",", "$", "extensions", ")", ")", "{", "foreach", "(", "$", "filepaths", "as", "$", "filepath", ")", "{", "if", "(", "file_exists", "(", "$", "filepath", ")", ")", "{", "if", "(", "$", "type", "==", "'mtime'", ")", "{", "return", "filemtime", "(", "$", "filepath", ")", ";", "}", "else", "{", "return", "file_get_contents", "(", "$", "filepath", ")", ";", "}", "}", "}", "return", "false", ";", "}", "}", "return", "null", ";", "}" ]
Fetch the contents and mtime of a file @access protected @param string $type @param string $path @param string $extension @return mixed $content Returns a string with the content, false if it couldn't be found or null if it shouldn't be handled by us anyway
[ "Fetch", "the", "contents", "and", "mtime", "of", "a", "file" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Media.php#L171-L205
7,206
tigron/skeleton-core
lib/Skeleton/Core/Web/Media.php
Media.output
private static function output($extension, $content, $mtime) { // Send the Etag before potentially replying with 304 header('Etag: ' . crc32($mtime) . '-' . sha1($content)); self::cache($mtime); header('Content-Type: ' . self::get_mime_type($extension)); echo $content; exit(); }
php
private static function output($extension, $content, $mtime) { // Send the Etag before potentially replying with 304 header('Etag: ' . crc32($mtime) . '-' . sha1($content)); self::cache($mtime); header('Content-Type: ' . self::get_mime_type($extension)); echo $content; exit(); }
[ "private", "static", "function", "output", "(", "$", "extension", ",", "$", "content", ",", "$", "mtime", ")", "{", "// Send the Etag before potentially replying with 304", "header", "(", "'Etag: '", ".", "crc32", "(", "$", "mtime", ")", ".", "'-'", ".", "sha1", "(", "$", "content", ")", ")", ";", "self", "::", "cache", "(", "$", "mtime", ")", ";", "header", "(", "'Content-Type: '", ".", "self", "::", "get_mime_type", "(", "$", "extension", ")", ")", ";", "echo", "$", "content", ";", "exit", "(", ")", ";", "}" ]
Ouput the content of the file and cache it @param string $path @param string $extension @access private
[ "Ouput", "the", "content", "of", "the", "file", "and", "cache", "it" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Media.php#L214-L223
7,207
tigron/skeleton-core
lib/Skeleton/Core/Web/Media.php
Media.cache
private static function cache($mtime) { $gmt_mtime = gmdate('D, d M Y H:i:s', $mtime).' GMT'; header('Cache-Control: public'); header('Pragma: public'); if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { header('Expires: '); HTTP\Status::code_304(); } } header('Last-Modified: '. $gmt_mtime); header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('+30 minutes')).' GMT'); }
php
private static function cache($mtime) { $gmt_mtime = gmdate('D, d M Y H:i:s', $mtime).' GMT'; header('Cache-Control: public'); header('Pragma: public'); if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) { header('Expires: '); HTTP\Status::code_304(); } } header('Last-Modified: '. $gmt_mtime); header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('+30 minutes')).' GMT'); }
[ "private", "static", "function", "cache", "(", "$", "mtime", ")", "{", "$", "gmt_mtime", "=", "gmdate", "(", "'D, d M Y H:i:s'", ",", "$", "mtime", ")", ".", "' GMT'", ";", "header", "(", "'Cache-Control: public'", ")", ";", "header", "(", "'Pragma: public'", ")", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", ")", ")", "{", "if", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", "==", "$", "gmt_mtime", ")", "{", "header", "(", "'Expires: '", ")", ";", "HTTP", "\\", "Status", "::", "code_304", "(", ")", ";", "}", "}", "header", "(", "'Last-Modified: '", ".", "$", "gmt_mtime", ")", ";", "header", "(", "'Expires: '", ".", "gmdate", "(", "'D, d M Y H:i:s'", ",", "strtotime", "(", "'+30 minutes'", ")", ")", ".", "' GMT'", ")", ";", "}" ]
Detect if the file should be resent to the client or if it can use its cache @param string filename requested @access private
[ "Detect", "if", "the", "file", "should", "be", "resent", "to", "the", "client", "or", "if", "it", "can", "use", "its", "cache" ]
543af3cc44326651e3fed869c13078474b787ecb
https://github.com/tigron/skeleton-core/blob/543af3cc44326651e3fed869c13078474b787ecb/lib/Skeleton/Core/Web/Media.php#L279-L294
7,208
FiveLab/ResourceBundle
src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php
GenerateSymfonyRouteHrefListener.onBeforeNormalization
public function onBeforeNormalization(BeforeNormalizationEvent $event): void { $resource = $event->getResource(); if ($resource instanceof RelatedResourceInterface) { $this->fixForRelations($resource); } if ($resource instanceof ActionedResourceInterface) { $this->fixForActions($resource); } }
php
public function onBeforeNormalization(BeforeNormalizationEvent $event): void { $resource = $event->getResource(); if ($resource instanceof RelatedResourceInterface) { $this->fixForRelations($resource); } if ($resource instanceof ActionedResourceInterface) { $this->fixForActions($resource); } }
[ "public", "function", "onBeforeNormalization", "(", "BeforeNormalizationEvent", "$", "event", ")", ":", "void", "{", "$", "resource", "=", "$", "event", "->", "getResource", "(", ")", ";", "if", "(", "$", "resource", "instanceof", "RelatedResourceInterface", ")", "{", "$", "this", "->", "fixForRelations", "(", "$", "resource", ")", ";", "}", "if", "(", "$", "resource", "instanceof", "ActionedResourceInterface", ")", "{", "$", "this", "->", "fixForActions", "(", "$", "resource", ")", ";", "}", "}" ]
Call to this method before normalization @param BeforeNormalizationEvent $event
[ "Call", "to", "this", "method", "before", "normalization" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php#L51-L62
7,209
FiveLab/ResourceBundle
src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php
GenerateSymfonyRouteHrefListener.fixForActions
private function fixForActions(ActionedResourceInterface $resource): void { $actions = $resource->getActions(); foreach ($actions as $action) { $routeHref = $action->getHref(); $href = $this->fixHref($routeHref); $action->setHref($href); } }
php
private function fixForActions(ActionedResourceInterface $resource): void { $actions = $resource->getActions(); foreach ($actions as $action) { $routeHref = $action->getHref(); $href = $this->fixHref($routeHref); $action->setHref($href); } }
[ "private", "function", "fixForActions", "(", "ActionedResourceInterface", "$", "resource", ")", ":", "void", "{", "$", "actions", "=", "$", "resource", "->", "getActions", "(", ")", ";", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "$", "routeHref", "=", "$", "action", "->", "getHref", "(", ")", ";", "$", "href", "=", "$", "this", "->", "fixHref", "(", "$", "routeHref", ")", ";", "$", "action", "->", "setHref", "(", "$", "href", ")", ";", "}", "}" ]
Fix links for actions @param ActionedResourceInterface $resource
[ "Fix", "links", "for", "actions" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php#L69-L78
7,210
FiveLab/ResourceBundle
src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php
GenerateSymfonyRouteHrefListener.fixForRelations
private function fixForRelations(RelatedResourceInterface $resource): void { $relations = $resource->getRelations(); foreach ($relations as $relation) { $routeHref = $relation->getHref(); $href = $this->fixHref($routeHref); $relation->setHref($href); } }
php
private function fixForRelations(RelatedResourceInterface $resource): void { $relations = $resource->getRelations(); foreach ($relations as $relation) { $routeHref = $relation->getHref(); $href = $this->fixHref($routeHref); $relation->setHref($href); } }
[ "private", "function", "fixForRelations", "(", "RelatedResourceInterface", "$", "resource", ")", ":", "void", "{", "$", "relations", "=", "$", "resource", "->", "getRelations", "(", ")", ";", "foreach", "(", "$", "relations", "as", "$", "relation", ")", "{", "$", "routeHref", "=", "$", "relation", "->", "getHref", "(", ")", ";", "$", "href", "=", "$", "this", "->", "fixHref", "(", "$", "routeHref", ")", ";", "$", "relation", "->", "setHref", "(", "$", "href", ")", ";", "}", "}" ]
Fix links for relations @param RelatedResourceInterface $resource
[ "Fix", "links", "for", "relations" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php#L85-L94
7,211
FiveLab/ResourceBundle
src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php
GenerateSymfonyRouteHrefListener.fixHref
private function fixHref(HrefInterface $routeHref): HrefInterface { if (!$routeHref instanceof SymfonyRouteHref) { return $routeHref; } $path = $this->urlGenerator->generate( $routeHref->getRouteName(), $routeHref->getRouteParameters(), $routeHref->getReferenceType() ); return new Href( $path, $routeHref->isTemplated() ); }
php
private function fixHref(HrefInterface $routeHref): HrefInterface { if (!$routeHref instanceof SymfonyRouteHref) { return $routeHref; } $path = $this->urlGenerator->generate( $routeHref->getRouteName(), $routeHref->getRouteParameters(), $routeHref->getReferenceType() ); return new Href( $path, $routeHref->isTemplated() ); }
[ "private", "function", "fixHref", "(", "HrefInterface", "$", "routeHref", ")", ":", "HrefInterface", "{", "if", "(", "!", "$", "routeHref", "instanceof", "SymfonyRouteHref", ")", "{", "return", "$", "routeHref", ";", "}", "$", "path", "=", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "routeHref", "->", "getRouteName", "(", ")", ",", "$", "routeHref", "->", "getRouteParameters", "(", ")", ",", "$", "routeHref", "->", "getReferenceType", "(", ")", ")", ";", "return", "new", "Href", "(", "$", "path", ",", "$", "routeHref", "->", "isTemplated", "(", ")", ")", ";", "}" ]
Try to fix href @param HrefInterface $routeHref @return HrefInterface
[ "Try", "to", "fix", "href" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/GenerateSymfonyRouteHrefListener.php#L103-L119
7,212
DBRisinajumi/d2person
controllers/PprsPersonController.php
PprsPersonController.actionView
public function actionView($pprs_id, $ajax = false, $errors = false) { $model = $this->loadModel($pprs_id); if ($ajax) { $this->renderPartial('_view-relations_grids', array( 'modelMain' => $model, 'ajax' => $ajax, ) ); } else { $this->render('view', array('model' => $model,'errors'=>$errors)); } }
php
public function actionView($pprs_id, $ajax = false, $errors = false) { $model = $this->loadModel($pprs_id); if ($ajax) { $this->renderPartial('_view-relations_grids', array( 'modelMain' => $model, 'ajax' => $ajax, ) ); } else { $this->render('view', array('model' => $model,'errors'=>$errors)); } }
[ "public", "function", "actionView", "(", "$", "pprs_id", ",", "$", "ajax", "=", "false", ",", "$", "errors", "=", "false", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", "$", "pprs_id", ")", ";", "if", "(", "$", "ajax", ")", "{", "$", "this", "->", "renderPartial", "(", "'_view-relations_grids'", ",", "array", "(", "'modelMain'", "=>", "$", "model", ",", "'ajax'", "=>", "$", "ajax", ",", ")", ")", ";", "}", "else", "{", "$", "this", "->", "render", "(", "'view'", ",", "array", "(", "'model'", "=>", "$", "model", ",", "'errors'", "=>", "$", "errors", ")", ")", ";", "}", "}" ]
show person data @param int $pprs_id @param boolean $ajax @param string $errors html created by CHtml::errorSummary()
[ "show", "person", "data" ]
de3967d0ef0646b7f95774743cf2a2ec8128681a
https://github.com/DBRisinajumi/d2person/blob/de3967d0ef0646b7f95774743cf2a2ec8128681a/controllers/PprsPersonController.php#L76-L89
7,213
DBRisinajumi/d2person
controllers/PprsPersonController.php
PprsPersonController.actionCreateUserAccount
public function actionCreateUserAccount($pprs_id){ $model = $this->loadModel($pprs_id); $r = $model->createUser(); if($r !== true){ $this->redirect(array('view', 'pprs_id' => $pprs_id, 'ajax'=>false, 'errors' => $r)); }else{ $this->redirect(array('/user/admin/view', 'id' => $model->getUserId())); } }
php
public function actionCreateUserAccount($pprs_id){ $model = $this->loadModel($pprs_id); $r = $model->createUser(); if($r !== true){ $this->redirect(array('view', 'pprs_id' => $pprs_id, 'ajax'=>false, 'errors' => $r)); }else{ $this->redirect(array('/user/admin/view', 'id' => $model->getUserId())); } }
[ "public", "function", "actionCreateUserAccount", "(", "$", "pprs_id", ")", "{", "$", "model", "=", "$", "this", "->", "loadModel", "(", "$", "pprs_id", ")", ";", "$", "r", "=", "$", "model", "->", "createUser", "(", ")", ";", "if", "(", "$", "r", "!==", "true", ")", "{", "$", "this", "->", "redirect", "(", "array", "(", "'view'", ",", "'pprs_id'", "=>", "$", "pprs_id", ",", "'ajax'", "=>", "false", ",", "'errors'", "=>", "$", "r", ")", ")", ";", "}", "else", "{", "$", "this", "->", "redirect", "(", "array", "(", "'/user/admin/view'", ",", "'id'", "=>", "$", "model", "->", "getUserId", "(", ")", ")", ")", ";", "}", "}" ]
create fro person data user account and redirect to it @param int $pprs_id
[ "create", "fro", "person", "data", "user", "account", "and", "redirect", "to", "it" ]
de3967d0ef0646b7f95774743cf2a2ec8128681a
https://github.com/DBRisinajumi/d2person/blob/de3967d0ef0646b7f95774743cf2a2ec8128681a/controllers/PprsPersonController.php#L95-L103
7,214
DBRisinajumi/d2person
controllers/PprsPersonController.php
PprsPersonController.actionAjaxCreateSpec
public function actionAjaxCreateSpec($ccmp_id) { $model = new PprsPerson; $model->$field = $value; try { if (!$model->save()) { return var_export($model->getErrors()); } } catch (Exception $e) { throw new CHttpException(500, $e->getMessage()); } $ccuc = new CcucUserCompany; $ccuc->ccuc_ccmp_id = $ccmp_id; $ccuc->ccuc_person_id = $model->pprs_id; $ccuc->ccuc_status = CcucUserCompany::CCUC_STATUS_PERSON; $ccuc->save(); }
php
public function actionAjaxCreateSpec($ccmp_id) { $model = new PprsPerson; $model->$field = $value; try { if (!$model->save()) { return var_export($model->getErrors()); } } catch (Exception $e) { throw new CHttpException(500, $e->getMessage()); } $ccuc = new CcucUserCompany; $ccuc->ccuc_ccmp_id = $ccmp_id; $ccuc->ccuc_person_id = $model->pprs_id; $ccuc->ccuc_status = CcucUserCompany::CCUC_STATUS_PERSON; $ccuc->save(); }
[ "public", "function", "actionAjaxCreateSpec", "(", "$", "ccmp_id", ")", "{", "$", "model", "=", "new", "PprsPerson", ";", "$", "model", "->", "$", "field", "=", "$", "value", ";", "try", "{", "if", "(", "!", "$", "model", "->", "save", "(", ")", ")", "{", "return", "var_export", "(", "$", "model", "->", "getErrors", "(", ")", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "CHttpException", "(", "500", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "ccuc", "=", "new", "CcucUserCompany", ";", "$", "ccuc", "->", "ccuc_ccmp_id", "=", "$", "ccmp_id", ";", "$", "ccuc", "->", "ccuc_person_id", "=", "$", "model", "->", "pprs_id", ";", "$", "ccuc", "->", "ccuc_status", "=", "CcucUserCompany", "::", "CCUC_STATUS_PERSON", ";", "$", "ccuc", "->", "save", "(", ")", ";", "}" ]
crreate person for company @param int $ccmp_id company id @return type @throws CHttpException
[ "crreate", "person", "for", "company" ]
de3967d0ef0646b7f95774743cf2a2ec8128681a
https://github.com/DBRisinajumi/d2person/blob/de3967d0ef0646b7f95774743cf2a2ec8128681a/controllers/PprsPersonController.php#L191-L209
7,215
factorio-item-browser/api-database
src/Entity/Recipe.php
Recipe.setCraftingTime
public function setCraftingTime(float $craftingTime): self { $this->craftingTime = (int) ($craftingTime * self::FACTOR_CRAFTING_TIME); return $this; }
php
public function setCraftingTime(float $craftingTime): self { $this->craftingTime = (int) ($craftingTime * self::FACTOR_CRAFTING_TIME); return $this; }
[ "public", "function", "setCraftingTime", "(", "float", "$", "craftingTime", ")", ":", "self", "{", "$", "this", "->", "craftingTime", "=", "(", "int", ")", "(", "$", "craftingTime", "*", "self", "::", "FACTOR_CRAFTING_TIME", ")", ";", "return", "$", "this", ";", "}" ]
Sets the required time in seconds to craft the recipe. @param float $craftingTime @return $this Implementing fluent interface.
[ "Sets", "the", "required", "time", "in", "seconds", "to", "craft", "the", "recipe", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Entity/Recipe.php#L162-L166
7,216
factorio-item-browser/api-database
src/Entity/Recipe.php
Recipe.getOrderedIngredients
public function getOrderedIngredients(): Collection { return $this->ingredients->matching(Criteria::create()->orderBy(['order' => Criteria::ASC])); }
php
public function getOrderedIngredients(): Collection { return $this->ingredients->matching(Criteria::create()->orderBy(['order' => Criteria::ASC])); }
[ "public", "function", "getOrderedIngredients", "(", ")", ":", "Collection", "{", "return", "$", "this", "->", "ingredients", "->", "matching", "(", "Criteria", "::", "create", "(", ")", "->", "orderBy", "(", "[", "'order'", "=>", "Criteria", "::", "ASC", "]", ")", ")", ";", "}" ]
Returns the ordered ingredients of the recipe, in case the ingredients are not already ordered. @return Collection|RecipeIngredient[]
[ "Returns", "the", "ordered", "ingredients", "of", "the", "recipe", "in", "case", "the", "ingredients", "are", "not", "already", "ordered", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Entity/Recipe.php#L210-L213
7,217
factorio-item-browser/api-database
src/Entity/Recipe.php
Recipe.getOrderedProducts
public function getOrderedProducts(): Collection { return $this->products->matching(Criteria::create()->orderBy(['order' => Criteria::ASC])); }
php
public function getOrderedProducts(): Collection { return $this->products->matching(Criteria::create()->orderBy(['order' => Criteria::ASC])); }
[ "public", "function", "getOrderedProducts", "(", ")", ":", "Collection", "{", "return", "$", "this", "->", "products", "->", "matching", "(", "Criteria", "::", "create", "(", ")", "->", "orderBy", "(", "[", "'order'", "=>", "Criteria", "::", "ASC", "]", ")", ")", ";", "}" ]
Returns the ordered products of the recipe, in case the products are not already ordered. @return Collection|RecipeProduct[]
[ "Returns", "the", "ordered", "products", "of", "the", "recipe", "in", "case", "the", "products", "are", "not", "already", "ordered", "." ]
c3a27e5673462a58b5afafc0ea0e0002f6db9803
https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Entity/Recipe.php#L228-L231
7,218
vaccuum/foundation
source/Application.php
Application.ensureResponse
protected function ensureResponse($output) { if ($output instanceof Response) { return $output; } elseif (is_string($output)) { return Response::create($output, 200); } else { $message = "Action response cannot be served."; throw new ApplicationException($message); } }
php
protected function ensureResponse($output) { if ($output instanceof Response) { return $output; } elseif (is_string($output)) { return Response::create($output, 200); } else { $message = "Action response cannot be served."; throw new ApplicationException($message); } }
[ "protected", "function", "ensureResponse", "(", "$", "output", ")", "{", "if", "(", "$", "output", "instanceof", "Response", ")", "{", "return", "$", "output", ";", "}", "elseif", "(", "is_string", "(", "$", "output", ")", ")", "{", "return", "Response", "::", "create", "(", "$", "output", ",", "200", ")", ";", "}", "else", "{", "$", "message", "=", "\"Action response cannot be served.\"", ";", "throw", "new", "ApplicationException", "(", "$", "message", ")", ";", "}", "}" ]
Ensure output is a proper response object. @param mixed $output @throws ApplicationException @return Response
[ "Ensure", "output", "is", "a", "proper", "response", "object", "." ]
ec4d21ce1dd0218632a26e0db5812a2bc7921cec
https://github.com/vaccuum/foundation/blob/ec4d21ce1dd0218632a26e0db5812a2bc7921cec/source/Application.php#L65-L80
7,219
glendmaatita/Tolkien
src/Tolkien/BuildAsset.php
BuildAsset.find_all_files
public function find_all_files($dir) { $root = scandir($dir); foreach($root as $value) { if($value === '.' || $value === '..') { continue; } if(is_file("$dir/$value")) { $result[] = "$dir/$value"; $this->setAsset("$dir/$value"); continue; } foreach($this->find_all_files("$dir/$value") as $value) { $result[] = $value; } } return $result; }
php
public function find_all_files($dir) { $root = scandir($dir); foreach($root as $value) { if($value === '.' || $value === '..') { continue; } if(is_file("$dir/$value")) { $result[] = "$dir/$value"; $this->setAsset("$dir/$value"); continue; } foreach($this->find_all_files("$dir/$value") as $value) { $result[] = $value; } } return $result; }
[ "public", "function", "find_all_files", "(", "$", "dir", ")", "{", "$", "root", "=", "scandir", "(", "$", "dir", ")", ";", "foreach", "(", "$", "root", "as", "$", "value", ")", "{", "if", "(", "$", "value", "===", "'.'", "||", "$", "value", "===", "'..'", ")", "{", "continue", ";", "}", "if", "(", "is_file", "(", "\"$dir/$value\"", ")", ")", "{", "$", "result", "[", "]", "=", "\"$dir/$value\"", ";", "$", "this", "->", "setAsset", "(", "\"$dir/$value\"", ")", ";", "continue", ";", "}", "foreach", "(", "$", "this", "->", "find_all_files", "(", "\"$dir/$value\"", ")", "as", "$", "value", ")", "{", "$", "result", "[", "]", "=", "$", "value", ";", "}", "}", "return", "$", "result", ";", "}" ]
Find All file on asset dir and create array of Model\Asset @param string $dir @return recursive
[ "Find", "All", "file", "on", "asset", "dir", "and", "create", "array", "of", "Model", "\\", "Asset" ]
e7c27a103f1a87411dfb8eef626cba381b27d233
https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildAsset.php#L53-L74
7,220
glendmaatita/Tolkien
src/Tolkien/BuildAsset.php
BuildAsset.setAsset
public function setAsset($path) { $url = $this->config['dir']['site'] . str_replace($this->config['dir']['asset'], '', $path); $this->assets[] = new Asset($path, $url); }
php
public function setAsset($path) { $url = $this->config['dir']['site'] . str_replace($this->config['dir']['asset'], '', $path); $this->assets[] = new Asset($path, $url); }
[ "public", "function", "setAsset", "(", "$", "path", ")", "{", "$", "url", "=", "$", "this", "->", "config", "[", "'dir'", "]", "[", "'site'", "]", ".", "str_replace", "(", "$", "this", "->", "config", "[", "'dir'", "]", "[", "'asset'", "]", ",", "''", ",", "$", "path", ")", ";", "$", "this", "->", "assets", "[", "]", "=", "new", "Asset", "(", "$", "path", ",", "$", "url", ")", ";", "}" ]
Create Asset object instance @param string $path @return Model\Asset
[ "Create", "Asset", "object", "instance" ]
e7c27a103f1a87411dfb8eef626cba381b27d233
https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildAsset.php#L82-L86
7,221
DeprecatedPackages/Bootstrap
src/Configurator.php
Configurator.createContainer
public function createContainer() { $loader = new ContainerLoader( function ($files) { return array_filter($files, function ($file) { foreach ($this->ignorePaths as $path) { if (Strings::startsWith($file, $path)) { return false; } } return true; }); }, $this->getCacheDirectory() . '/Arachne.Configurator', $this->parameters['debugMode'] ); $class = $loader->load( array($this->parameters, $this->files), array($this, 'generateContainer') ); $container = new $class; $container->initialize(); return $container; }
php
public function createContainer() { $loader = new ContainerLoader( function ($files) { return array_filter($files, function ($file) { foreach ($this->ignorePaths as $path) { if (Strings::startsWith($file, $path)) { return false; } } return true; }); }, $this->getCacheDirectory() . '/Arachne.Configurator', $this->parameters['debugMode'] ); $class = $loader->load( array($this->parameters, $this->files), array($this, 'generateContainer') ); $container = new $class; $container->initialize(); return $container; }
[ "public", "function", "createContainer", "(", ")", "{", "$", "loader", "=", "new", "ContainerLoader", "(", "function", "(", "$", "files", ")", "{", "return", "array_filter", "(", "$", "files", ",", "function", "(", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "ignorePaths", "as", "$", "path", ")", "{", "if", "(", "Strings", "::", "startsWith", "(", "$", "file", ",", "$", "path", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", ")", ";", "}", ",", "$", "this", "->", "getCacheDirectory", "(", ")", ".", "'/Arachne.Configurator'", ",", "$", "this", "->", "parameters", "[", "'debugMode'", "]", ")", ";", "$", "class", "=", "$", "loader", "->", "load", "(", "array", "(", "$", "this", "->", "parameters", ",", "$", "this", "->", "files", ")", ",", "array", "(", "$", "this", ",", "'generateContainer'", ")", ")", ";", "$", "container", "=", "new", "$", "class", ";", "$", "container", "->", "initialize", "(", ")", ";", "return", "$", "container", ";", "}" ]
Returns system DI container. @return Container
[ "Returns", "system", "DI", "container", "." ]
d4c5b20aeeec7e9db10efcd35e94ed4ff02da169
https://github.com/DeprecatedPackages/Bootstrap/blob/d4c5b20aeeec7e9db10efcd35e94ed4ff02da169/src/Configurator.php#L33-L59
7,222
xmmedia/XMSecurityBundle
Listener/RegistrationConfirmListener.php
RegistrationConfirmListener.onRegistrationConfirm
public function onRegistrationConfirm(GetResponseUserEvent $event) { if (null === $event->getResponse()) { $url = $this->router->generate('fos_user_security_login'); $event->setResponse(new RedirectResponse($url)); } }
php
public function onRegistrationConfirm(GetResponseUserEvent $event) { if (null === $event->getResponse()) { $url = $this->router->generate('fos_user_security_login'); $event->setResponse(new RedirectResponse($url)); } }
[ "public", "function", "onRegistrationConfirm", "(", "GetResponseUserEvent", "$", "event", ")", "{", "if", "(", "null", "===", "$", "event", "->", "getResponse", "(", ")", ")", "{", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "'fos_user_security_login'", ")", ";", "$", "event", "->", "setResponse", "(", "new", "RedirectResponse", "(", "$", "url", ")", ")", ";", "}", "}" ]
Sets the registration date on the user @param GetResponseUserEvent $event @return void
[ "Sets", "the", "registration", "date", "on", "the", "user" ]
ee71a1bb4fe038e5a08e44f73247c4e03631a840
https://github.com/xmmedia/XMSecurityBundle/blob/ee71a1bb4fe038e5a08e44f73247c4e03631a840/Listener/RegistrationConfirmListener.php#L44-L50
7,223
kuria/phpunit-extras
src/Helper/ComparisonHelper.php
ComparisonHelper.isLooselyIdentical
static function isLooselyIdentical($a, $b, bool $canonicalizeKeys, array &$visited = []): bool { // don't compare twice to allow for cyclic dependencies if (in_array([$a, $b], $visited, true) || in_array([$b, $a], $visited, true)) { return true; } $aType = gettype($a); $bType = gettype($b); // compare different instances of the same class as arrays if ($aType === 'object' && $bType === 'object' && get_class($a) === get_class($b) && $a !== $b) { return static::isLooselyIdentical((array) $a, (array) $b, $canonicalizeKeys, $visited); } // compare arrays recursively if ($aType === 'array' && $bType === 'array') { $visited[] = [$a, $b]; $keys = array_keys($a); $otherKeys = array_keys($b); if ($canonicalizeKeys) { sort($keys); sort($otherKeys); } if ($keys !== $otherKeys) { return false; } foreach ($keys as $key) { if (!static::isLooselyIdentical($a[$key], $b[$key], $canonicalizeKeys, $visited)) { return false; } } return true; } // compare other values directly return $a === $b; }
php
static function isLooselyIdentical($a, $b, bool $canonicalizeKeys, array &$visited = []): bool { // don't compare twice to allow for cyclic dependencies if (in_array([$a, $b], $visited, true) || in_array([$b, $a], $visited, true)) { return true; } $aType = gettype($a); $bType = gettype($b); // compare different instances of the same class as arrays if ($aType === 'object' && $bType === 'object' && get_class($a) === get_class($b) && $a !== $b) { return static::isLooselyIdentical((array) $a, (array) $b, $canonicalizeKeys, $visited); } // compare arrays recursively if ($aType === 'array' && $bType === 'array') { $visited[] = [$a, $b]; $keys = array_keys($a); $otherKeys = array_keys($b); if ($canonicalizeKeys) { sort($keys); sort($otherKeys); } if ($keys !== $otherKeys) { return false; } foreach ($keys as $key) { if (!static::isLooselyIdentical($a[$key], $b[$key], $canonicalizeKeys, $visited)) { return false; } } return true; } // compare other values directly return $a === $b; }
[ "static", "function", "isLooselyIdentical", "(", "$", "a", ",", "$", "b", ",", "bool", "$", "canonicalizeKeys", ",", "array", "&", "$", "visited", "=", "[", "]", ")", ":", "bool", "{", "// don't compare twice to allow for cyclic dependencies", "if", "(", "in_array", "(", "[", "$", "a", ",", "$", "b", "]", ",", "$", "visited", ",", "true", ")", "||", "in_array", "(", "[", "$", "b", ",", "$", "a", "]", ",", "$", "visited", ",", "true", ")", ")", "{", "return", "true", ";", "}", "$", "aType", "=", "gettype", "(", "$", "a", ")", ";", "$", "bType", "=", "gettype", "(", "$", "b", ")", ";", "// compare different instances of the same class as arrays", "if", "(", "$", "aType", "===", "'object'", "&&", "$", "bType", "===", "'object'", "&&", "get_class", "(", "$", "a", ")", "===", "get_class", "(", "$", "b", ")", "&&", "$", "a", "!==", "$", "b", ")", "{", "return", "static", "::", "isLooselyIdentical", "(", "(", "array", ")", "$", "a", ",", "(", "array", ")", "$", "b", ",", "$", "canonicalizeKeys", ",", "$", "visited", ")", ";", "}", "// compare arrays recursively", "if", "(", "$", "aType", "===", "'array'", "&&", "$", "bType", "===", "'array'", ")", "{", "$", "visited", "[", "]", "=", "[", "$", "a", ",", "$", "b", "]", ";", "$", "keys", "=", "array_keys", "(", "$", "a", ")", ";", "$", "otherKeys", "=", "array_keys", "(", "$", "b", ")", ";", "if", "(", "$", "canonicalizeKeys", ")", "{", "sort", "(", "$", "keys", ")", ";", "sort", "(", "$", "otherKeys", ")", ";", "}", "if", "(", "$", "keys", "!==", "$", "otherKeys", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "static", "::", "isLooselyIdentical", "(", "$", "a", "[", "$", "key", "]", ",", "$", "b", "[", "$", "key", "]", ",", "$", "canonicalizeKeys", ",", "$", "visited", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "// compare other values directly", "return", "$", "a", "===", "$", "b", ";", "}" ]
Check whether two values are loosely identical Types are compared the same way as with the "===" operator, but two different instances of the same class are considered identical if they have identical properties. If $canonicalizeKeys = TRUE, then array key order is ignored.
[ "Check", "whether", "two", "values", "are", "loosely", "identical" ]
fca02d4d6af28d98d312a0830d876293397ce611
https://github.com/kuria/phpunit-extras/blob/fca02d4d6af28d98d312a0830d876293397ce611/src/Helper/ComparisonHelper.php#L15-L57
7,224
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.indexAction
public function indexAction($featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } return array( 'feature' => $feature, ); }
php
public function indexAction($featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } return array( 'feature' => $feature, ); }
[ "public", "function", "indexAction", "(", "$", "featureId", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "return", "array", "(", "'feature'", "=>", "$", "feature", ",", ")", ";", "}" ]
Lists all FeatureValue entities. @param int $featureId The feature id @throws NotFoundHttpException @return array @Route("/") @Method("GET") @Template("EcommerceBundle:FeatureValue:index.html.twig")
[ "Lists", "all", "FeatureValue", "entities", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L37-L51
7,225
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.createAction
public function createAction(Request $request, $featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } $entity = new FeatureValue(); $form = $this->createForm(new FeatureValueType(), $entity); $entity->setFeature($feature); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'value.created'); return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $entity->getId()))); } return array( 'entity' => $entity, 'feature' => $feature, 'form' => $form->createView(), ); }
php
public function createAction(Request $request, $featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } $entity = new FeatureValue(); $form = $this->createForm(new FeatureValueType(), $entity); $entity->setFeature($feature); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'value.created'); return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $entity->getId()))); } return array( 'entity' => $entity, 'feature' => $feature, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ",", "$", "featureId", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "$", "entity", "=", "new", "FeatureValue", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "FeatureValueType", "(", ")", ",", "$", "entity", ")", ";", "$", "entity", "->", "setFeature", "(", "$", "feature", ")", ";", "$", "form", "->", "bind", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'value.created'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_featurevalue_show'", ",", "array", "(", "'featureId'", "=>", "$", "featureId", ",", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'feature'", "=>", "$", "feature", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new FeatureValue entity. @param Request $request The request @param int $featureId The feature id @throws NotFoundHttpException @return array|RedirectResponse @Route("/") @Method("POST") @Template("EcommerceBundle:FeatureValue:new.html.twig")
[ "Creates", "a", "new", "FeatureValue", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L90-L122
7,226
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.newAction
public function newAction($featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } $entity = new FeatureValue(); $form = $this->createForm(new FeatureValueType(), $entity); return array( 'entity' => $entity, 'feature' => $feature, 'form' => $form->createView(), ); }
php
public function newAction($featureId) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } $entity = new FeatureValue(); $form = $this->createForm(new FeatureValueType(), $entity); return array( 'entity' => $entity, 'feature' => $feature, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", "$", "featureId", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "$", "entity", "=", "new", "FeatureValue", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "FeatureValueType", "(", ")", ",", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'feature'", "=>", "$", "feature", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new FeatureValue entity. @param int $featureId The feature id @throws NotFoundHttpException @return array @Route("/new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "FeatureValue", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L136-L155
7,227
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.showAction
public function showAction($featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $deleteForm = $this->createDeleteForm($featureId, $id); return array( 'entity' => $entity, 'feature' => $feature, 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction($featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $deleteForm = $this->createDeleteForm($featureId, $id); return array( 'entity' => $entity, 'feature' => $feature, 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "$", "featureId", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "/** @var FeatureValue $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:FeatureValue'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find FeatureValue entity.'", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "featureId", ",", "$", "id", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'feature'", "=>", "$", "feature", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Finds and displays a FeatureValue entity. @param int $featureId The feature id @param int $id The entity id @throws NotFoundHttpException @return array @Route("/{id}") @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "FeatureValue", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L170-L195
7,228
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.editAction
public function editAction($featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $editForm = $this->createForm(new FeatureValueType(), $entity); $deleteForm = $this->createDeleteForm($featureId, $id); return array( 'entity' => $entity, 'feature' => $feature, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function editAction($featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $editForm = $this->createForm(new FeatureValueType(), $entity); $deleteForm = $this->createDeleteForm($featureId, $id); return array( 'entity' => $entity, 'feature' => $feature, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "editAction", "(", "$", "featureId", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "/** @var FeatureValue $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:FeatureValue'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find FeatureValue entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "FeatureValueType", "(", ")", ",", "$", "entity", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "featureId", ",", "$", "id", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'feature'", "=>", "$", "feature", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to edit an existing FeatureValue entity. @param int $featureId The feature id @param int $id The entity id @throws NotFoundHttpException @return array @Route("/{id}/edit") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "FeatureValue", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L210-L237
7,229
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.updateAction
public function updateAction(Request $request, $featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $deleteForm = $this->createDeleteForm($featureId, $id); $editForm = $this->createForm(new FeatureValueType(), $entity); $editForm->bind($request); if ($editForm->isValid()) { $em->persist($entity); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'value.edited'); return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $id))); } return array( 'entity' => $entity, 'feature' => $feature, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
php
public function updateAction(Request $request, $featureId, $id) { $em = $this->getDoctrine()->getManager(); /** @var Feature $feature */ $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId); if (!$feature) { throw $this->createNotFoundException('Unable to find Feature entity.'); } /** @var FeatureValue $entity */ $entity = $em->getRepository('EcommerceBundle:FeatureValue')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find FeatureValue entity.'); } $deleteForm = $this->createDeleteForm($featureId, $id); $editForm = $this->createForm(new FeatureValueType(), $entity); $editForm->bind($request); if ($editForm->isValid()) { $em->persist($entity); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'value.edited'); return $this->redirect($this->generateUrl('ecommerce_featurevalue_show', array('featureId' => $featureId, 'id' => $id))); } return array( 'entity' => $entity, 'feature' => $feature, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "featureId", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Feature $feature */", "$", "feature", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:Feature'", ")", "->", "find", "(", "$", "featureId", ")", ";", "if", "(", "!", "$", "feature", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Feature entity.'", ")", ";", "}", "/** @var FeatureValue $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'EcommerceBundle:FeatureValue'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find FeatureValue entity.'", ")", ";", "}", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "featureId", ",", "$", "id", ")", ";", "$", "editForm", "=", "$", "this", "->", "createForm", "(", "new", "FeatureValueType", "(", ")", ",", "$", "entity", ")", ";", "$", "editForm", "->", "bind", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'value.edited'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'ecommerce_featurevalue_show'", ",", "array", "(", "'featureId'", "=>", "$", "featureId", ",", "'id'", "=>", "$", "id", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'feature'", "=>", "$", "feature", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Edits an existing FeatureValue entity. @param Request $request The request @param int $featureId The feature id @param int $id The entity id @throws NotFoundHttpException @return array|RedirectResponse @Route("/{id}") @Method("PUT") @Template("EcommerceBundle:Feature:edit.html.twig")
[ "Edits", "an", "existing", "FeatureValue", "entity", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L253-L290
7,230
sebardo/ecommerce
EcommerceBundle/Controller/FeatureValueController.php
FeatureValueController.createDeleteForm
private function createDeleteForm($featureId, $id) { return $this->createFormBuilder(array('featureId' => $featureId, 'id' => $id)) ->add('featureId', 'hidden') ->add('id', 'hidden') ->getForm(); }
php
private function createDeleteForm($featureId, $id) { return $this->createFormBuilder(array('featureId' => $featureId, 'id' => $id)) ->add('featureId', 'hidden') ->add('id', 'hidden') ->getForm(); }
[ "private", "function", "createDeleteForm", "(", "$", "featureId", ",", "$", "id", ")", "{", "return", "$", "this", "->", "createFormBuilder", "(", "array", "(", "'featureId'", "=>", "$", "featureId", ",", "'id'", "=>", "$", "id", ")", ")", "->", "add", "(", "'featureId'", ",", "'hidden'", ")", "->", "add", "(", "'id'", ",", "'hidden'", ")", "->", "getForm", "(", ")", ";", "}" ]
Creates a form to delete a FeatureValue entity by id. @param int $featureId The feature id @param int $id The entity id @return Form The form
[ "Creates", "a", "form", "to", "delete", "a", "FeatureValue", "entity", "by", "id", "." ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/FeatureValueController.php#L344-L350
7,231
lrc-se/bth-anax-repository
src/Repository/SoftManagedModelTrait.php
SoftManagedModelTrait.getReferenceSoft
public function getReferenceSoft($name) { if (!isset($this->_manager)) { throw new RepositoryException('Model is not handled by a managed repository'); } if (array_key_exists($name, $this->_references)) { $ref = $this->_references[$name]; $repo = $this->_manager->getByClass($ref['model']); if (!$repo || !($repo instanceof SoftRepositoryInterface)) { throw new RepositoryException('Referenced model is not handled by a managed soft-deletion-aware repository'); } return ($repo->findSoft($ref['key'], $this->{$ref['attribute']}) ?: null); } return null; }
php
public function getReferenceSoft($name) { if (!isset($this->_manager)) { throw new RepositoryException('Model is not handled by a managed repository'); } if (array_key_exists($name, $this->_references)) { $ref = $this->_references[$name]; $repo = $this->_manager->getByClass($ref['model']); if (!$repo || !($repo instanceof SoftRepositoryInterface)) { throw new RepositoryException('Referenced model is not handled by a managed soft-deletion-aware repository'); } return ($repo->findSoft($ref['key'], $this->{$ref['attribute']}) ?: null); } return null; }
[ "public", "function", "getReferenceSoft", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_manager", ")", ")", "{", "throw", "new", "RepositoryException", "(", "'Model is not handled by a managed repository'", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "_references", ")", ")", "{", "$", "ref", "=", "$", "this", "->", "_references", "[", "$", "name", "]", ";", "$", "repo", "=", "$", "this", "->", "_manager", "->", "getByClass", "(", "$", "ref", "[", "'model'", "]", ")", ";", "if", "(", "!", "$", "repo", "||", "!", "(", "$", "repo", "instanceof", "SoftRepositoryInterface", ")", ")", "{", "throw", "new", "RepositoryException", "(", "'Referenced model is not handled by a managed soft-deletion-aware repository'", ")", ";", "}", "return", "(", "$", "repo", "->", "findSoft", "(", "$", "ref", "[", "'key'", "]", ",", "$", "this", "->", "{", "$", "ref", "[", "'attribute'", "]", "}", ")", "?", ":", "null", ")", ";", "}", "return", "null", ";", "}" ]
Retrieve a reference by name, ignoring soft-deleted entries. @param string $name Reference name. @return mixed Model instance if found, null otherwise. @throws RepositoryException If this model or the referenced model is not handled by a managed repository, or the referenced repository is not soft-deletion aware.
[ "Retrieve", "a", "reference", "by", "name", "ignoring", "soft", "-", "deleted", "entries", "." ]
344a0795fbfadf34ea768719dc5cf2f1d90154df
https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/SoftManagedModelTrait.php#L22-L36
7,232
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/fileObject.class.php
fileObject.creerRepertoire
public function creerRepertoire($repertoire, $droits=0777) { if(file_exists($repertoire)) { if(!chmod($repertoire,$droits)) return false; } else { if(!mkdir($repertoire,$droits)) return false; if(!chmod($repertoire,$droits)) return false; } // conversion des noms de fichier au format utf8 si existant exec("convmv -f iso-8859-1 -t utf-8 -r ".$repertoire."/* --notest",$retourExec); // laurent : conversion des noms du repertoire en UTF8 return true; }
php
public function creerRepertoire($repertoire, $droits=0777) { if(file_exists($repertoire)) { if(!chmod($repertoire,$droits)) return false; } else { if(!mkdir($repertoire,$droits)) return false; if(!chmod($repertoire,$droits)) return false; } // conversion des noms de fichier au format utf8 si existant exec("convmv -f iso-8859-1 -t utf-8 -r ".$repertoire."/* --notest",$retourExec); // laurent : conversion des noms du repertoire en UTF8 return true; }
[ "public", "function", "creerRepertoire", "(", "$", "repertoire", ",", "$", "droits", "=", "0777", ")", "{", "if", "(", "file_exists", "(", "$", "repertoire", ")", ")", "{", "if", "(", "!", "chmod", "(", "$", "repertoire", ",", "$", "droits", ")", ")", "return", "false", ";", "}", "else", "{", "if", "(", "!", "mkdir", "(", "$", "repertoire", ",", "$", "droits", ")", ")", "return", "false", ";", "if", "(", "!", "chmod", "(", "$", "repertoire", ",", "$", "droits", ")", ")", "return", "false", ";", "}", "// conversion des noms de fichier au format utf8 si existant", "exec", "(", "\"convmv -f iso-8859-1 -t utf-8 -r \"", ".", "$", "repertoire", ".", "\"/* --notest\"", ",", "$", "retourExec", ")", ";", "// laurent : conversion des noms du repertoire en UTF8", "return", "true", ";", "}" ]
creation d'un repertoire avec mise en place des droits et conversion des nom de fichiers en utf8
[ "creation", "d", "un", "repertoire", "avec", "mise", "en", "place", "des", "droits", "et", "conversion", "des", "nom", "de", "fichiers", "en", "utf8" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/fileObject.class.php#L77-L97
7,233
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/fileObject.class.php
fileObject.getExtensionFromFile
public function getExtensionFromFile($fichier='') { $retour = ""; $split = explode(".",$fichier); if(count($split)>1) { $retour = $split[count($split)-1]; } return $retour; }
php
public function getExtensionFromFile($fichier='') { $retour = ""; $split = explode(".",$fichier); if(count($split)>1) { $retour = $split[count($split)-1]; } return $retour; }
[ "public", "function", "getExtensionFromFile", "(", "$", "fichier", "=", "''", ")", "{", "$", "retour", "=", "\"\"", ";", "$", "split", "=", "explode", "(", "\".\"", ",", "$", "fichier", ")", ";", "if", "(", "count", "(", "$", "split", ")", ">", "1", ")", "{", "$", "retour", "=", "$", "split", "[", "count", "(", "$", "split", ")", "-", "1", "]", ";", "}", "return", "$", "retour", ";", "}" ]
renvoi le nom d'extension du fichier
[ "renvoi", "le", "nom", "d", "extension", "du", "fichier" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/fileObject.class.php#L284-L295
7,234
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/fileObject.class.php
fileObject.getFileNameWithoutExtension
public function getFileNameWithoutExtension($fichier='') { $retour=""; $trouve=false; for($i=pia_strlen($fichier)-1 ; $i>0 && !$trouve ; $i--) { if(pia_substr($fichier,$i,1)=='.') { $trouve = true; } } if($trouve) { $retour=pia_substr($fichier,0,$i+1); } else { $retour = $fichier; } return $retour; }
php
public function getFileNameWithoutExtension($fichier='') { $retour=""; $trouve=false; for($i=pia_strlen($fichier)-1 ; $i>0 && !$trouve ; $i--) { if(pia_substr($fichier,$i,1)=='.') { $trouve = true; } } if($trouve) { $retour=pia_substr($fichier,0,$i+1); } else { $retour = $fichier; } return $retour; }
[ "public", "function", "getFileNameWithoutExtension", "(", "$", "fichier", "=", "''", ")", "{", "$", "retour", "=", "\"\"", ";", "$", "trouve", "=", "false", ";", "for", "(", "$", "i", "=", "pia_strlen", "(", "$", "fichier", ")", "-", "1", ";", "$", "i", ">", "0", "&&", "!", "$", "trouve", ";", "$", "i", "--", ")", "{", "if", "(", "pia_substr", "(", "$", "fichier", ",", "$", "i", ",", "1", ")", "==", "'.'", ")", "{", "$", "trouve", "=", "true", ";", "}", "}", "if", "(", "$", "trouve", ")", "{", "$", "retour", "=", "pia_substr", "(", "$", "fichier", ",", "0", ",", "$", "i", "+", "1", ")", ";", "}", "else", "{", "$", "retour", "=", "$", "fichier", ";", "}", "return", "$", "retour", ";", "}" ]
renvoi la partie gauche du nom de fichier, la partie avant l'extension
[ "renvoi", "la", "partie", "gauche", "du", "nom", "de", "fichier", "la", "partie", "avant", "l", "extension" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/fileObject.class.php#L298-L320
7,235
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/fileObject.class.php
fileObject.getNewFileNameIfFileNameExistsIn
public function getNewFileNameIfFileNameExistsIn($fileName='',$directory='') { $extension = $this->getExtensionFromFile($fileName); $partieGauche = $this->getFileNameWithoutExtension($fileName); $i=0; while(file_exists($directory.$partieGauche.".".$extension)) { $partieGauche.=$i; $i++; } return $partieGauche.".".$extension; }
php
public function getNewFileNameIfFileNameExistsIn($fileName='',$directory='') { $extension = $this->getExtensionFromFile($fileName); $partieGauche = $this->getFileNameWithoutExtension($fileName); $i=0; while(file_exists($directory.$partieGauche.".".$extension)) { $partieGauche.=$i; $i++; } return $partieGauche.".".$extension; }
[ "public", "function", "getNewFileNameIfFileNameExistsIn", "(", "$", "fileName", "=", "''", ",", "$", "directory", "=", "''", ")", "{", "$", "extension", "=", "$", "this", "->", "getExtensionFromFile", "(", "$", "fileName", ")", ";", "$", "partieGauche", "=", "$", "this", "->", "getFileNameWithoutExtension", "(", "$", "fileName", ")", ";", "$", "i", "=", "0", ";", "while", "(", "file_exists", "(", "$", "directory", ".", "$", "partieGauche", ".", "\".\"", ".", "$", "extension", ")", ")", "{", "$", "partieGauche", ".=", "$", "i", ";", "$", "i", "++", ";", "}", "return", "$", "partieGauche", ".", "\".\"", ".", "$", "extension", ";", "}" ]
ajoute un numero a la fin de la partie gauche du fichier , si le fichier existe dans le repertoire en parametre
[ "ajoute", "un", "numero", "a", "la", "fin", "de", "la", "partie", "gauche", "du", "fichier", "si", "le", "fichier", "existe", "dans", "le", "repertoire", "en", "parametre" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/fileObject.class.php#L323-L336
7,236
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/fileObject.class.php
fileObject.convertDirectoryFilesNamesToUTF8
public function convertDirectoryFilesNamesToUTF8($params = array()) { if(isset($params['repertoire']) && $params['repertoire']!='') { $slash = "/"; if(pia_substr($params['repertoire'],-1)=='/') { $slash = ""; } exec("convmv -f iso-8859-1 -t utf-8 -r ".$params['repertoire'].$slash."* --notest"); } }
php
public function convertDirectoryFilesNamesToUTF8($params = array()) { if(isset($params['repertoire']) && $params['repertoire']!='') { $slash = "/"; if(pia_substr($params['repertoire'],-1)=='/') { $slash = ""; } exec("convmv -f iso-8859-1 -t utf-8 -r ".$params['repertoire'].$slash."* --notest"); } }
[ "public", "function", "convertDirectoryFilesNamesToUTF8", "(", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'repertoire'", "]", ")", "&&", "$", "params", "[", "'repertoire'", "]", "!=", "''", ")", "{", "$", "slash", "=", "\"/\"", ";", "if", "(", "pia_substr", "(", "$", "params", "[", "'repertoire'", "]", ",", "-", "1", ")", "==", "'/'", ")", "{", "$", "slash", "=", "\"\"", ";", "}", "exec", "(", "\"convmv -f iso-8859-1 -t utf-8 -r \"", ".", "$", "params", "[", "'repertoire'", "]", ".", "$", "slash", ".", "\"* --notest\"", ")", ";", "}", "}" ]
utile pour que php puisse lire certains nom de fichier
[ "utile", "pour", "que", "php", "puisse", "lire", "certains", "nom", "de", "fichier" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/fileObject.class.php#L434-L445
7,237
gios-asu/nectary
src/facades/feed-facade.php
Feed_Facade.merge_feeds
public function merge_feeds( array $feeds ) { $source_feeds = [ [] ]; foreach ( $feeds as $feed ) { $source_feeds[] = $feed->get_items(); } $merged_feed = array_merge( ...$source_feeds ); $new_feed = $this->service->get_feed( '' ); $new_feed->set_items( $merged_feed ); return $new_feed; }
php
public function merge_feeds( array $feeds ) { $source_feeds = [ [] ]; foreach ( $feeds as $feed ) { $source_feeds[] = $feed->get_items(); } $merged_feed = array_merge( ...$source_feeds ); $new_feed = $this->service->get_feed( '' ); $new_feed->set_items( $merged_feed ); return $new_feed; }
[ "public", "function", "merge_feeds", "(", "array", "$", "feeds", ")", "{", "$", "source_feeds", "=", "[", "[", "]", "]", ";", "foreach", "(", "$", "feeds", "as", "$", "feed", ")", "{", "$", "source_feeds", "[", "]", "=", "$", "feed", "->", "get_items", "(", ")", ";", "}", "$", "merged_feed", "=", "array_merge", "(", "...", "$", "source_feeds", ")", ";", "$", "new_feed", "=", "$", "this", "->", "service", "->", "get_feed", "(", "''", ")", ";", "$", "new_feed", "->", "set_items", "(", "$", "merged_feed", ")", ";", "return", "$", "new_feed", ";", "}" ]
Merge different Feed_Services together. Feeds passed in should have already had retrieve_items called on them. @param $feeds array<Feed>
[ "Merge", "different", "Feed_Services", "together", ".", "Feeds", "passed", "in", "should", "have", "already", "had", "retrieve_items", "called", "on", "them", "." ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/facades/feed-facade.php#L30-L43
7,238
glynnforrest/reform
src/Reform/Validation/Validator.php
Validator.validate
public function validate(array $input, $early_exit = false) { $result = new Result($input); //add custom messages that have been supplied foreach ($this->rules as $name => $rules) { $this->doValidation($result, $input, $name, $rules, $early_exit); } return $result; }
php
public function validate(array $input, $early_exit = false) { $result = new Result($input); //add custom messages that have been supplied foreach ($this->rules as $name => $rules) { $this->doValidation($result, $input, $name, $rules, $early_exit); } return $result; }
[ "public", "function", "validate", "(", "array", "$", "input", ",", "$", "early_exit", "=", "false", ")", "{", "$", "result", "=", "new", "Result", "(", "$", "input", ")", ";", "//add custom messages that have been supplied", "foreach", "(", "$", "this", "->", "rules", "as", "$", "name", "=>", "$", "rules", ")", "{", "$", "this", "->", "doValidation", "(", "$", "result", ",", "$", "input", ",", "$", "name", ",", "$", "rules", ",", "$", "early_exit", ")", ";", "}", "return", "$", "result", ";", "}" ]
Validate an array of values.
[ "Validate", "an", "array", "of", "values", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Validation/Validator.php#L64-L73
7,239
glynnforrest/reform
src/Reform/Validation/Validator.php
Validator.submitted
protected function submitted($value) { if (is_string($value)) { $value = trim($value); } if (empty($value) && !is_numeric($value)) { return false; } return true; }
php
protected function submitted($value) { if (is_string($value)) { $value = trim($value); } if (empty($value) && !is_numeric($value)) { return false; } return true; }
[ "protected", "function", "submitted", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "}", "if", "(", "empty", "(", "$", "value", ")", "&&", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if a value has been submitted. This means not empty or containing only white space.
[ "Check", "if", "a", "value", "has", "been", "submitted", ".", "This", "means", "not", "empty", "or", "containing", "only", "white", "space", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Validation/Validator.php#L103-L113
7,240
bariew/yii2-module-abstract
models/AbstractModel.php
AbstractModel.childClass
public static function childClass($asModel = false, $initData = []) { $data = debug_backtrace(); $callingClassName = get_class($data[1]['object']); $pattern = '#^(.+\\\\)(\w+\\\\\w+)$#'; $formName = preg_replace($pattern, '$2', get_called_class()); $result = preg_replace($pattern, '$1'.$formName, $callingClassName); return $asModel ? new $result($initData) : $result; }
php
public static function childClass($asModel = false, $initData = []) { $data = debug_backtrace(); $callingClassName = get_class($data[1]['object']); $pattern = '#^(.+\\\\)(\w+\\\\\w+)$#'; $formName = preg_replace($pattern, '$2', get_called_class()); $result = preg_replace($pattern, '$1'.$formName, $callingClassName); return $asModel ? new $result($initData) : $result; }
[ "public", "static", "function", "childClass", "(", "$", "asModel", "=", "false", ",", "$", "initData", "=", "[", "]", ")", "{", "$", "data", "=", "debug_backtrace", "(", ")", ";", "$", "callingClassName", "=", "get_class", "(", "$", "data", "[", "1", "]", "[", "'object'", "]", ")", ";", "$", "pattern", "=", "'#^(.+\\\\\\\\)(\\w+\\\\\\\\\\w+)$#'", ";", "$", "formName", "=", "preg_replace", "(", "$", "pattern", ",", "'$2'", ",", "get_called_class", "(", ")", ")", ";", "$", "result", "=", "preg_replace", "(", "$", "pattern", ",", "'$1'", ".", "$", "formName", ",", "$", "callingClassName", ")", ";", "return", "$", "asModel", "?", "new", "$", "result", "(", "$", "initData", ")", ":", "$", "result", ";", "}" ]
Gets class name for a model that inherits current modules model. CAUTION! This works only when called from inside another module model @param bool $asModel @param array $initData @return string|static
[ "Gets", "class", "name", "for", "a", "model", "that", "inherits", "current", "modules", "model", ".", "CAUTION!", "This", "works", "only", "when", "called", "from", "inside", "another", "module", "model" ]
a91dbf770cb12b6d505aa33838c4a94e3f695ec7
https://github.com/bariew/yii2-module-abstract/blob/a91dbf770cb12b6d505aa33838c4a94e3f695ec7/models/AbstractModel.php#L42-L50
7,241
dintel/mongo-object
src/Mapper.php
Mapper.findObject
public function findObject($type, $id) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); if (!($id instanceof MongoId) && $id !== null) { try { $id = new MongoId($id); } catch (MongoException $e) { $id = null; } } $data = $this->cache->fetch("{$table}_{$id}"); if (!is_array($data)) { $data = $this->mongodb->$table->findOne(['_id' => $id]); if (is_array($data)) { $this->cache->store("{$table}_{$id}", $data); } } if ($data === null) { return null; } return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
php
public function findObject($type, $id) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); if (!($id instanceof MongoId) && $id !== null) { try { $id = new MongoId($id); } catch (MongoException $e) { $id = null; } } $data = $this->cache->fetch("{$table}_{$id}"); if (!is_array($data)) { $data = $this->mongodb->$table->findOne(['_id' => $id]); if (is_array($data)) { $this->cache->store("{$table}_{$id}", $data); } } if ($data === null) { return null; } return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
[ "public", "function", "findObject", "(", "$", "type", ",", "$", "id", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "table", "=", "$", "type", "::", "getCollection", "(", ")", ";", "if", "(", "!", "(", "$", "id", "instanceof", "MongoId", ")", "&&", "$", "id", "!==", "null", ")", "{", "try", "{", "$", "id", "=", "new", "MongoId", "(", "$", "id", ")", ";", "}", "catch", "(", "MongoException", "$", "e", ")", "{", "$", "id", "=", "null", ";", "}", "}", "$", "data", "=", "$", "this", "->", "cache", "->", "fetch", "(", "\"{$table}_{$id}\"", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "mongodb", "->", "$", "table", "->", "findOne", "(", "[", "'_id'", "=>", "$", "id", "]", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "this", "->", "cache", "->", "store", "(", "\"{$table}_{$id}\"", ",", "$", "data", ")", ";", "}", "}", "if", "(", "$", "data", "===", "null", ")", "{", "return", "null", ";", "}", "return", "new", "$", "type", "(", "$", "data", ",", "$", "this", "->", "mongodb", "->", "$", "table", ",", "$", "this", "->", "cache", ")", ";", "}", "return", "null", ";", "}" ]
Find object by it's Mongo ID and return it @param string $type Name of class of object that should be returned @param mixed $id ID of document in Mongo collection that holds the object @return mixed null if document not found, object of type $type otherwise
[ "Find", "object", "by", "it", "s", "Mongo", "ID", "and", "return", "it" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L77-L102
7,242
dintel/mongo-object
src/Mapper.php
Mapper.findObjectByProp
public function findObjectByProp($type, $name, $value) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); $data = $this->mongodb->$table->findOne([$name => $value]); if ($data === null) { return null; } return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
php
public function findObjectByProp($type, $name, $value) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); $data = $this->mongodb->$table->findOne([$name => $value]); if ($data === null) { return null; } return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
[ "public", "function", "findObjectByProp", "(", "$", "type", ",", "$", "name", ",", "$", "value", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "table", "=", "$", "type", "::", "getCollection", "(", ")", ";", "$", "data", "=", "$", "this", "->", "mongodb", "->", "$", "table", "->", "findOne", "(", "[", "$", "name", "=>", "$", "value", "]", ")", ";", "if", "(", "$", "data", "===", "null", ")", "{", "return", "null", ";", "}", "return", "new", "$", "type", "(", "$", "data", ",", "$", "this", "->", "mongodb", "->", "$", "table", ",", "$", "this", "->", "cache", ")", ";", "}", "return", "null", ";", "}" ]
Find object by it's property value and return it @param string $type Name of class of object that should be returned @param string $name Name of property to match @param mixed $value Value of property to match @return mixed null if document not found, object of type $type otherwise
[ "Find", "object", "by", "it", "s", "property", "value", "and", "return", "it" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L111-L123
7,243
dintel/mongo-object
src/Mapper.php
Mapper.fetchObjects
public function fetchObjects($type, array $selector = [], array $order = null, $limit = null, $skip = null) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); $cursor = $this->mongodb->$table->find($selector); if ($order) { $cursor->sort($order); } if ($limit) { $cursor->limit($limit); } if ($skip) { $cursor->skip($skip); } $result = []; foreach ($cursor as $data) { $obj = new $type($data, $this->mongodb->$table, $this->cache); $result[] = $obj; } return $result; } return null; }
php
public function fetchObjects($type, array $selector = [], array $order = null, $limit = null, $skip = null) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); $cursor = $this->mongodb->$table->find($selector); if ($order) { $cursor->sort($order); } if ($limit) { $cursor->limit($limit); } if ($skip) { $cursor->skip($skip); } $result = []; foreach ($cursor as $data) { $obj = new $type($data, $this->mongodb->$table, $this->cache); $result[] = $obj; } return $result; } return null; }
[ "public", "function", "fetchObjects", "(", "$", "type", ",", "array", "$", "selector", "=", "[", "]", ",", "array", "$", "order", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "skip", "=", "null", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "table", "=", "$", "type", "::", "getCollection", "(", ")", ";", "$", "cursor", "=", "$", "this", "->", "mongodb", "->", "$", "table", "->", "find", "(", "$", "selector", ")", ";", "if", "(", "$", "order", ")", "{", "$", "cursor", "->", "sort", "(", "$", "order", ")", ";", "}", "if", "(", "$", "limit", ")", "{", "$", "cursor", "->", "limit", "(", "$", "limit", ")", ";", "}", "if", "(", "$", "skip", ")", "{", "$", "cursor", "->", "skip", "(", "$", "skip", ")", ";", "}", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "cursor", "as", "$", "data", ")", "{", "$", "obj", "=", "new", "$", "type", "(", "$", "data", ",", "$", "this", "->", "mongodb", "->", "$", "table", ",", "$", "this", "->", "cache", ")", ";", "$", "result", "[", "]", "=", "$", "obj", ";", "}", "return", "$", "result", ";", "}", "return", "null", ";", "}" ]
Find all objects using Mongo selector and return them optionally ordered @param string $type Name of class of object that should be returned @param array $selector Mongo query used to match documents holding objects @param array|null $order array if properties by which to sort (if value is 1 sorted ascending, if -1 sorted descending) @param int|null $limit maximum number of objects to return @param int|null $skip number of objects to skip @return array array of object matching selector ordered by $order, if specified
[ "Find", "all", "objects", "using", "Mongo", "selector", "and", "return", "them", "optionally", "ordered" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L135-L158
7,244
dintel/mongo-object
src/Mapper.php
Mapper.countObjects
public function countObjects($type, $query = []) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); return $this->mongodb->$table->find($query, ['_id' => true])->count(); } return false; }
php
public function countObjects($type, $query = []) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); return $this->mongodb->$table->find($query, ['_id' => true])->count(); } return false; }
[ "public", "function", "countObjects", "(", "$", "type", ",", "$", "query", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "table", "=", "$", "type", "::", "getCollection", "(", ")", ";", "return", "$", "this", "->", "mongodb", "->", "$", "table", "->", "find", "(", "$", "query", ",", "[", "'_id'", "=>", "true", "]", ")", "->", "count", "(", ")", ";", "}", "return", "false", ";", "}" ]
Count objects in collection matching Mongo query @param string $type Name of class of objects that should be counted @param array $query Mongo select query, only objects matching it are counted @return mixed number of objects matching query or false if class $type does not exist
[ "Count", "objects", "in", "collection", "matching", "Mongo", "query" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L166-L174
7,245
dintel/mongo-object
src/Mapper.php
Mapper.newObject
public function newObject($type, array $data = []) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
php
public function newObject($type, array $data = []) { $type = $this->getFullType($type); if (class_exists($type)) { $table = $type::getCollection(); return new $type($data, $this->mongodb->$table, $this->cache); } return null; }
[ "public", "function", "newObject", "(", "$", "type", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "table", "=", "$", "type", "::", "getCollection", "(", ")", ";", "return", "new", "$", "type", "(", "$", "data", ",", "$", "this", "->", "mongodb", "->", "$", "table", ",", "$", "this", "->", "cache", ")", ";", "}", "return", "null", ";", "}" ]
Construct new object @param string $type Name of class of object that should be constructed @param array $data initial values of properties of new object @return mixed new object of class $type or null if class $type does not exist
[ "Construct", "new", "object" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L182-L190
7,246
dintel/mongo-object
src/Mapper.php
Mapper.updateObjects
public function updateObjects($type, array $query, array $data) { $type = $this->getFullType($type); if (class_exists($type)) { $collection = $type::getCollection(); $result = $this->mongodb->$collection->update($query, ['$set' => $data], ['multiple' => true]); return $result['ok'] ? $result['n'] : false; } return false; }
php
public function updateObjects($type, array $query, array $data) { $type = $this->getFullType($type); if (class_exists($type)) { $collection = $type::getCollection(); $result = $this->mongodb->$collection->update($query, ['$set' => $data], ['multiple' => true]); return $result['ok'] ? $result['n'] : false; } return false; }
[ "public", "function", "updateObjects", "(", "$", "type", ",", "array", "$", "query", ",", "array", "$", "data", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "collection", "=", "$", "type", "::", "getCollection", "(", ")", ";", "$", "result", "=", "$", "this", "->", "mongodb", "->", "$", "collection", "->", "update", "(", "$", "query", ",", "[", "'$set'", "=>", "$", "data", "]", ",", "[", "'multiple'", "=>", "true", "]", ")", ";", "return", "$", "result", "[", "'ok'", "]", "?", "$", "result", "[", "'n'", "]", ":", "false", ";", "}", "return", "false", ";", "}" ]
Update multiple objects @param string $type Name of object which collection should be updated @param array $query Mongo select query, only objects matching it are updated @param array $data new values for fields of objects @return mixed number of objects updated or false in case of error
[ "Update", "multiple", "objects" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L199-L208
7,247
dintel/mongo-object
src/Mapper.php
Mapper.deleteObjects
public function deleteObjects($type, array $query = []) { $type = $this->getFullType($type); if (class_exists($type)) { $collection = $type::getCollection(); $result = $this->mongodb->$collection->remove($query); return (bool) $result['ok']; } return false; }
php
public function deleteObjects($type, array $query = []) { $type = $this->getFullType($type); if (class_exists($type)) { $collection = $type::getCollection(); $result = $this->mongodb->$collection->remove($query); return (bool) $result['ok']; } return false; }
[ "public", "function", "deleteObjects", "(", "$", "type", ",", "array", "$", "query", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "getFullType", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "collection", "=", "$", "type", "::", "getCollection", "(", ")", ";", "$", "result", "=", "$", "this", "->", "mongodb", "->", "$", "collection", "->", "remove", "(", "$", "query", ")", ";", "return", "(", "bool", ")", "$", "result", "[", "'ok'", "]", ";", "}", "return", "false", ";", "}" ]
Delete multiple objects @param string $type Objects of which class should be deleted @param array $query Mongo select query, only objects matching it are deleted @return bool true on succes, false on failure
[ "Delete", "multiple", "objects" ]
3e5a474314e7b71dd2ee40e557bc67d184a38684
https://github.com/dintel/mongo-object/blob/3e5a474314e7b71dd2ee40e557bc67d184a38684/src/Mapper.php#L216-L225
7,248
tonjoo/tiga-framework
src/Router/RouteHandler.php
RouteHandler.defer
public function defer($runLevel, $priority = 10) { $this->deferred = true; $this->runLevel = $runLevel; $this->priority = $priority; }
php
public function defer($runLevel, $priority = 10) { $this->deferred = true; $this->runLevel = $runLevel; $this->priority = $priority; }
[ "public", "function", "defer", "(", "$", "runLevel", ",", "$", "priority", "=", "10", ")", "{", "$", "this", "->", "deferred", "=", "true", ";", "$", "this", "->", "runLevel", "=", "$", "runLevel", ";", "$", "this", "->", "priority", "=", "$", "priority", ";", "}" ]
Defer the route into desired to later wp_action. @param string $runLevel @param int $priority
[ "Defer", "the", "route", "into", "desired", "to", "later", "wp_action", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Router/RouteHandler.php#L70-L75
7,249
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition.equal
public function equal(ColumnInterface $column, WhereCompareInterface $value) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' = ' . $value->getCompareValue(); $this->_addCondition($condition); return $this; }
php
public function equal(ColumnInterface $column, WhereCompareInterface $value) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' = ' . $value->getCompareValue(); $this->_addCondition($condition); return $this; }
[ "public", "function", "equal", "(", "ColumnInterface", "$", "column", ",", "WhereCompareInterface", "$", "value", ")", "{", "$", "columnName", "=", "(", "$", "column", "->", "getAlias", "(", ")", ")", "?", ":", "$", "column", "->", "getColumnName", "(", ")", ";", "$", "condition", "=", "$", "columnName", ".", "' = '", ".", "$", "value", "->", "getCompareValue", "(", ")", ";", "$", "this", "->", "_addCondition", "(", "$", "condition", ")", ";", "return", "$", "this", ";", "}" ]
Add an equal condition to the condition array. The order of the method call is important, in which way the condition string will concatenate. @param ColumnInterface $column Name of the column. @param WhereCompareInterface $value Value for the expression. @return $this The current condition instance to concatenate method invokes. @throws \Exception
[ "Add", "an", "equal", "condition", "to", "the", "condition", "array", ".", "The", "order", "of", "the", "method", "call", "is", "important", "in", "which", "way", "the", "condition", "string", "will", "concatenate", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L78-L85
7,250
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition.greater
public function greater(ColumnInterface $column, WhereNumericCompareInterface $value) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' > ' . $value->getNumericCompareValue(); $this->_addCondition($condition); return $this; }
php
public function greater(ColumnInterface $column, WhereNumericCompareInterface $value) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' > ' . $value->getNumericCompareValue(); $this->_addCondition($condition); return $this; }
[ "public", "function", "greater", "(", "ColumnInterface", "$", "column", ",", "WhereNumericCompareInterface", "$", "value", ")", "{", "$", "columnName", "=", "(", "$", "column", "->", "getAlias", "(", ")", ")", "?", ":", "$", "column", "->", "getColumnName", "(", ")", ";", "$", "condition", "=", "$", "columnName", ".", "' > '", ".", "$", "value", "->", "getNumericCompareValue", "(", ")", ";", "$", "this", "->", "_addCondition", "(", "$", "condition", ")", ";", "return", "$", "this", ";", "}" ]
Add a greater condition to the condition array. The order of the method call is important, in which way the condition string will concatenate. @param ColumnInterface $column Name of the column. @param WhereNumericCompareInterface $value Value for the expression. @return $this The current condition instance to concatenate method invokes. @throws \Exception
[ "Add", "a", "greater", "condition", "to", "the", "condition", "array", ".", "The", "order", "of", "the", "method", "call", "is", "important", "in", "which", "way", "the", "condition", "string", "will", "concatenate", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L120-L127
7,251
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition.between
public function between(ColumnInterface $column, WhereNumericCompareInterface $lowerValue, WhereNumericCompareInterface $greaterValue) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' BETWEEN ' . $lowerValue->getNumericCompareValue() . ' AND ' . $greaterValue->getNumericCompareValue(); $this->_addCondition($condition); return $this; }
php
public function between(ColumnInterface $column, WhereNumericCompareInterface $lowerValue, WhereNumericCompareInterface $greaterValue) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' BETWEEN ' . $lowerValue->getNumericCompareValue() . ' AND ' . $greaterValue->getNumericCompareValue(); $this->_addCondition($condition); return $this; }
[ "public", "function", "between", "(", "ColumnInterface", "$", "column", ",", "WhereNumericCompareInterface", "$", "lowerValue", ",", "WhereNumericCompareInterface", "$", "greaterValue", ")", "{", "$", "columnName", "=", "(", "$", "column", "->", "getAlias", "(", ")", ")", "?", ":", "$", "column", "->", "getColumnName", "(", ")", ";", "$", "condition", "=", "$", "columnName", ".", "' BETWEEN '", ".", "$", "lowerValue", "->", "getNumericCompareValue", "(", ")", ".", "' AND '", ".", "$", "greaterValue", "->", "getNumericCompareValue", "(", ")", ";", "$", "this", "->", "_addCondition", "(", "$", "condition", ")", ";", "return", "$", "this", ";", "}" ]
Add a between condition to the condition array. The order of the method call is important, in which way the condition string will concatenate. @param ColumnInterface $column Name of the column. @param WhereNumericCompareInterface $lowerValue The lower value of the expression. @param WhereNumericCompareInterface $greaterValue The higher value of the expression. @return $this The current condition instance to concatenate method invokes. @throws \Exception
[ "Add", "a", "between", "condition", "to", "the", "condition", "array", ".", "The", "order", "of", "the", "method", "call", "is", "important", "in", "which", "way", "the", "condition", "string", "will", "concatenate", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L205-L214
7,252
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition.like
public function like(ColumnInterface $column, ReferencesInterface $value, $level = 0) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); if($level === 0) { $condition = $columnName . ' LIKE ' . $value->getValue(); } elseif($level === 1) { $condition = $columnName . ' LIKE ' . $this->_likeLevelOne($value); } elseif($level === 2) { $condition = $columnName . ' LIKE ' . $this->_likeLevelTwo($value); } elseif($level === 3) { $condition = $columnName . ' LIKE ' . $this->_likeLevelThree($value); } else { throw new \Exception('invalid level argument'); } $this->_addCondition($condition); return $this; }
php
public function like(ColumnInterface $column, ReferencesInterface $value, $level = 0) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); if($level === 0) { $condition = $columnName . ' LIKE ' . $value->getValue(); } elseif($level === 1) { $condition = $columnName . ' LIKE ' . $this->_likeLevelOne($value); } elseif($level === 2) { $condition = $columnName . ' LIKE ' . $this->_likeLevelTwo($value); } elseif($level === 3) { $condition = $columnName . ' LIKE ' . $this->_likeLevelThree($value); } else { throw new \Exception('invalid level argument'); } $this->_addCondition($condition); return $this; }
[ "public", "function", "like", "(", "ColumnInterface", "$", "column", ",", "ReferencesInterface", "$", "value", ",", "$", "level", "=", "0", ")", "{", "$", "columnName", "=", "(", "$", "column", "->", "getAlias", "(", ")", ")", "?", ":", "$", "column", "->", "getColumnName", "(", ")", ";", "if", "(", "$", "level", "===", "0", ")", "{", "$", "condition", "=", "$", "columnName", ".", "' LIKE '", ".", "$", "value", "->", "getValue", "(", ")", ";", "}", "elseif", "(", "$", "level", "===", "1", ")", "{", "$", "condition", "=", "$", "columnName", ".", "' LIKE '", ".", "$", "this", "->", "_likeLevelOne", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "level", "===", "2", ")", "{", "$", "condition", "=", "$", "columnName", ".", "' LIKE '", ".", "$", "this", "->", "_likeLevelTwo", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "level", "===", "3", ")", "{", "$", "condition", "=", "$", "columnName", ".", "' LIKE '", ".", "$", "this", "->", "_likeLevelThree", "(", "$", "value", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'invalid level argument'", ")", ";", "}", "$", "this", "->", "_addCondition", "(", "$", "condition", ")", ";", "return", "$", "this", ";", "}" ]
Add a like condition to the condition array. The order of the method call is important, in which way the condition string will concatenate. @param ColumnInterface $column Name of the column. @param ReferencesInterface $value Value for the expression. @param int $level The several levels of a like expression, see private likeLevel - methods. @see Alcys\Core\Db\Condition\Condition::_likeLevelOne @see Alcys\Core\Db\Condition\Condition::_likeLevelTwo @see Alcys\Core\Db\Condition\Condition::_likeLevelThree @return $this The current condition instance to concatenate method invokes. @throws \Exception
[ "Add", "a", "like", "condition", "to", "the", "condition", "array", ".", "The", "order", "of", "the", "method", "call", "is", "important", "in", "which", "way", "the", "condition", "string", "will", "concatenate", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L257-L283
7,253
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition.isNull
public function isNull(ColumnInterface $column) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' IS NULL'; $this->_addCondition($condition); return $this; }
php
public function isNull(ColumnInterface $column) { $columnName = ($column->getAlias()) ?: $column->getColumnName(); $condition = $columnName . ' IS NULL'; $this->_addCondition($condition); return $this; }
[ "public", "function", "isNull", "(", "ColumnInterface", "$", "column", ")", "{", "$", "columnName", "=", "(", "$", "column", "->", "getAlias", "(", ")", ")", "?", ":", "$", "column", "->", "getColumnName", "(", ")", ";", "$", "condition", "=", "$", "columnName", ".", "' IS NULL'", ";", "$", "this", "->", "_addCondition", "(", "$", "condition", ")", ";", "return", "$", "this", ";", "}" ]
Add an is null condition to the condition array. The order of the method call is important, in which way the condition string will concatenate. @param ColumnInterface $column Name of the column to compare. @return $this The same instance to concatenate methods.
[ "Add", "an", "is", "null", "condition", "to", "the", "condition", "array", ".", "The", "order", "of", "the", "method", "call", "is", "important", "in", "which", "way", "the", "condition", "string", "will", "concatenate", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L295-L302
7,254
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition._addCondition
private function _addCondition($condition) { if($this->logicOperator === null && $this->invoked === false) { $this->conditionArray[] = array($condition); $this->invoked = true; } elseif($this->logicOperator === null) { throw new \Exception('a logic operator method have to be invoked to continue add conditions'); } else { $this->conditionArray[] = array($this->logicOperator => $condition); $this->logicOperator = null; } }
php
private function _addCondition($condition) { if($this->logicOperator === null && $this->invoked === false) { $this->conditionArray[] = array($condition); $this->invoked = true; } elseif($this->logicOperator === null) { throw new \Exception('a logic operator method have to be invoked to continue add conditions'); } else { $this->conditionArray[] = array($this->logicOperator => $condition); $this->logicOperator = null; } }
[ "private", "function", "_addCondition", "(", "$", "condition", ")", "{", "if", "(", "$", "this", "->", "logicOperator", "===", "null", "&&", "$", "this", "->", "invoked", "===", "false", ")", "{", "$", "this", "->", "conditionArray", "[", "]", "=", "array", "(", "$", "condition", ")", ";", "$", "this", "->", "invoked", "=", "true", ";", "}", "elseif", "(", "$", "this", "->", "logicOperator", "===", "null", ")", "{", "throw", "new", "\\", "Exception", "(", "'a logic operator method have to be invoked to continue add conditions'", ")", ";", "}", "else", "{", "$", "this", "->", "conditionArray", "[", "]", "=", "array", "(", "$", "this", "->", "logicOperator", "=>", "$", "condition", ")", ";", "$", "this", "->", "logicOperator", "=", "null", ";", "}", "}" ]
This method fill the condition array in the expected format. If no logic operator method was invoked after a condition method, it will throw an exception. Otherwise, after the first call, a condition without an logic operator will add to the condition array and at the others calls, a condition with an logic operator will add to the condition array. @param string $condition @throws \Exception
[ "This", "method", "fill", "the", "condition", "array", "in", "the", "expected", "format", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L402-L418
7,255
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition._likeLevelOne
private function _likeLevelOne(ReferencesInterface $value) { $regex = '/"/'; if(preg_match($regex, $value->getValue())) { return preg_replace($regex, '"%', $value->getValue(), 1); } return '%' . $value->getValue(); }
php
private function _likeLevelOne(ReferencesInterface $value) { $regex = '/"/'; if(preg_match($regex, $value->getValue())) { return preg_replace($regex, '"%', $value->getValue(), 1); } return '%' . $value->getValue(); }
[ "private", "function", "_likeLevelOne", "(", "ReferencesInterface", "$", "value", ")", "{", "$", "regex", "=", "'/\"/'", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "value", "->", "getValue", "(", ")", ")", ")", "{", "return", "preg_replace", "(", "$", "regex", ",", "'\"%'", ",", "$", "value", "->", "getValue", "(", ")", ",", "1", ")", ";", "}", "return", "'%'", ".", "$", "value", "->", "getValue", "(", ")", ";", "}" ]
Validate the value and the percentage sign to a valid value for an expression. The sign will passed at the begin of the value. Example: Value: 123 will validated to: %123. Value: "a" will validated to: "%a". @param ReferencesInterface $value The value for the expression. @return string
[ "Validate", "the", "value", "and", "the", "percentage", "sign", "to", "a", "valid", "value", "for", "an", "expression", ".", "The", "sign", "will", "passed", "at", "the", "begin", "of", "the", "value", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L432-L441
7,256
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition._likeLevelTwo
private function _likeLevelTwo(ReferencesInterface $value) { $regex = '/("[a-zA-Z0-9_-]*)"/'; $matches = array(); if(preg_match($regex, $value->getValue(), $matches)) { return $matches[1] . '%"'; } return $value->getValue() . '%'; }
php
private function _likeLevelTwo(ReferencesInterface $value) { $regex = '/("[a-zA-Z0-9_-]*)"/'; $matches = array(); if(preg_match($regex, $value->getValue(), $matches)) { return $matches[1] . '%"'; } return $value->getValue() . '%'; }
[ "private", "function", "_likeLevelTwo", "(", "ReferencesInterface", "$", "value", ")", "{", "$", "regex", "=", "'/(\"[a-zA-Z0-9_-]*)\"/'", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "value", "->", "getValue", "(", ")", ",", "$", "matches", ")", ")", "{", "return", "$", "matches", "[", "1", "]", ".", "'%\"'", ";", "}", "return", "$", "value", "->", "getValue", "(", ")", ".", "'%'", ";", "}" ]
Validate the value and the percentage sign to a valid value for an expression. The sign will passed at the end of the value. Example: Value: 123 will validated to: 123%. Value: "a" will validated to: "a%". @param ReferencesInterface $value The value for the expression. @return string
[ "Validate", "the", "value", "and", "the", "percentage", "sign", "to", "a", "valid", "value", "for", "an", "expression", ".", "The", "sign", "will", "passed", "at", "the", "end", "of", "the", "value", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L455-L465
7,257
AlcyZ/Alcys-ORM
src/Core/Db/Expression/Condition.php
Condition._likeLevelThree
private function _likeLevelThree(ReferencesInterface $value) { $regex = '/"([a-zA-Z0-9_-]*)"/'; $matches = array(); if(preg_match($regex, $value->getValue(), $matches)) { return '"%' . $matches[1] . '%"'; } return '%' . $value->getValue() . '%'; }
php
private function _likeLevelThree(ReferencesInterface $value) { $regex = '/"([a-zA-Z0-9_-]*)"/'; $matches = array(); if(preg_match($regex, $value->getValue(), $matches)) { return '"%' . $matches[1] . '%"'; } return '%' . $value->getValue() . '%'; }
[ "private", "function", "_likeLevelThree", "(", "ReferencesInterface", "$", "value", ")", "{", "$", "regex", "=", "'/\"([a-zA-Z0-9_-]*)\"/'", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "value", "->", "getValue", "(", ")", ",", "$", "matches", ")", ")", "{", "return", "'\"%'", ".", "$", "matches", "[", "1", "]", ".", "'%\"'", ";", "}", "return", "'%'", ".", "$", "value", "->", "getValue", "(", ")", ".", "'%'", ";", "}" ]
Validate the value and the percentage sign to a valid value for an expression. The sign will passed at the begin and at the end of the value. Example: Value: 123 will validated to: 123%. Value: "a" will validated to: "a%". @param ReferencesInterface $value The value for the expression. @return string
[ "Validate", "the", "value", "and", "the", "percentage", "sign", "to", "a", "valid", "value", "for", "an", "expression", ".", "The", "sign", "will", "passed", "at", "the", "begin", "and", "at", "the", "end", "of", "the", "value", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Expression/Condition.php#L479-L489
7,258
ionutmilica/ionix-framework
src/Http/Response.php
Response.prepareContent
public function prepareContent() { $content = $this->content; if ($content instanceof Renderable) { $content = $content->render(); } else if ($this->shouldBeJson($content)) { $content = $this->toJson($content); } return $content; }
php
public function prepareContent() { $content = $this->content; if ($content instanceof Renderable) { $content = $content->render(); } else if ($this->shouldBeJson($content)) { $content = $this->toJson($content); } return $content; }
[ "public", "function", "prepareContent", "(", ")", "{", "$", "content", "=", "$", "this", "->", "content", ";", "if", "(", "$", "content", "instanceof", "Renderable", ")", "{", "$", "content", "=", "$", "content", "->", "render", "(", ")", ";", "}", "else", "if", "(", "$", "this", "->", "shouldBeJson", "(", "$", "content", ")", ")", "{", "$", "content", "=", "$", "this", "->", "toJson", "(", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
Prepare content to be printed out @return string
[ "Prepare", "content", "to", "be", "printed", "out" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Http/Response.php#L60-L71
7,259
ionutmilica/ionix-framework
src/Http/Response.php
Response.sendHeaders
public function sendHeaders() { foreach ($this->headers->all() as $header => $value) { header(sprintf('%s:%s', $header, $value)); } }
php
public function sendHeaders() { foreach ($this->headers->all() as $header => $value) { header(sprintf('%s:%s', $header, $value)); } }
[ "public", "function", "sendHeaders", "(", ")", "{", "foreach", "(", "$", "this", "->", "headers", "->", "all", "(", ")", "as", "$", "header", "=>", "$", "value", ")", "{", "header", "(", "sprintf", "(", "'%s:%s'", ",", "$", "header", ",", "$", "value", ")", ")", ";", "}", "}" ]
Send the header to browser
[ "Send", "the", "header", "to", "browser" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Http/Response.php#L108-L113
7,260
titon/db-mongodb
src/Titon/Db/Mongo/MongoDriver.php
MongoDriver.connect
public function connect() { if ($this->isConnected()) { return true; } if (!$this->isEnabled()) { throw new MissingDriverException('mongodb driver extension is not enabled'); } $options = []; if ($db = $this->getDatabase()) { $options['db'] = $db; } if ($user = $this->getUser()) { $options['username'] = $user; } if ($pass = $this->getPassword()) { $options['password'] = $pass; } if ($rSet = $this->getConfig('replicaSet')) { if (!$this->getConfig('servers')) { throw new MissingServersException('A list of servers is required for replica set functionality'); } $options['replicaSet'] = $rSet; } $connection = new MongoClient($this->getServer(), $options + $this->getConfig('flags')); $this->_connections[$this->getContext()] = $connection; return $connection->connected; }
php
public function connect() { if ($this->isConnected()) { return true; } if (!$this->isEnabled()) { throw new MissingDriverException('mongodb driver extension is not enabled'); } $options = []; if ($db = $this->getDatabase()) { $options['db'] = $db; } if ($user = $this->getUser()) { $options['username'] = $user; } if ($pass = $this->getPassword()) { $options['password'] = $pass; } if ($rSet = $this->getConfig('replicaSet')) { if (!$this->getConfig('servers')) { throw new MissingServersException('A list of servers is required for replica set functionality'); } $options['replicaSet'] = $rSet; } $connection = new MongoClient($this->getServer(), $options + $this->getConfig('flags')); $this->_connections[$this->getContext()] = $connection; return $connection->connected; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "throw", "new", "MissingDriverException", "(", "'mongodb driver extension is not enabled'", ")", ";", "}", "$", "options", "=", "[", "]", ";", "if", "(", "$", "db", "=", "$", "this", "->", "getDatabase", "(", ")", ")", "{", "$", "options", "[", "'db'", "]", "=", "$", "db", ";", "}", "if", "(", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ")", "{", "$", "options", "[", "'username'", "]", "=", "$", "user", ";", "}", "if", "(", "$", "pass", "=", "$", "this", "->", "getPassword", "(", ")", ")", "{", "$", "options", "[", "'password'", "]", "=", "$", "pass", ";", "}", "if", "(", "$", "rSet", "=", "$", "this", "->", "getConfig", "(", "'replicaSet'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "getConfig", "(", "'servers'", ")", ")", "{", "throw", "new", "MissingServersException", "(", "'A list of servers is required for replica set functionality'", ")", ";", "}", "$", "options", "[", "'replicaSet'", "]", "=", "$", "rSet", ";", "}", "$", "connection", "=", "new", "MongoClient", "(", "$", "this", "->", "getServer", "(", ")", ",", "$", "options", "+", "$", "this", "->", "getConfig", "(", "'flags'", ")", ")", ";", "$", "this", "->", "_connections", "[", "$", "this", "->", "getContext", "(", ")", "]", "=", "$", "connection", ";", "return", "$", "connection", "->", "connected", ";", "}" ]
Connect to the Mongo database. @return bool @throws \Titon\Db\Exception\MissingDriverException @throws \Titon\Db\Mongo\Exception\MissingServersException
[ "Connect", "to", "the", "Mongo", "database", "." ]
797536d7b51d3e84d8cabc88d5fdc9fcd2466dfc
https://github.com/titon/db-mongodb/blob/797536d7b51d3e84d8cabc88d5fdc9fcd2466dfc/src/Titon/Db/Mongo/MongoDriver.php#L75-L111
7,261
titon/db-mongodb
src/Titon/Db/Mongo/MongoDriver.php
MongoDriver.getServer
public function getServer() { $server = 'mongodb://'; if ($servers = $this->getConfig('servers')) { $server .= implode(',', $servers); } else { if ($socket = $this->getSocket()) { $server .= $socket; } else { $server .= $this->getHost() . ':' . $this->getPort(); } } return $server; }
php
public function getServer() { $server = 'mongodb://'; if ($servers = $this->getConfig('servers')) { $server .= implode(',', $servers); } else { if ($socket = $this->getSocket()) { $server .= $socket; } else { $server .= $this->getHost() . ':' . $this->getPort(); } } return $server; }
[ "public", "function", "getServer", "(", ")", "{", "$", "server", "=", "'mongodb://'", ";", "if", "(", "$", "servers", "=", "$", "this", "->", "getConfig", "(", "'servers'", ")", ")", "{", "$", "server", ".=", "implode", "(", "','", ",", "$", "servers", ")", ";", "}", "else", "{", "if", "(", "$", "socket", "=", "$", "this", "->", "getSocket", "(", ")", ")", "{", "$", "server", ".=", "$", "socket", ";", "}", "else", "{", "$", "server", ".=", "$", "this", "->", "getHost", "(", ")", ".", "':'", ".", "$", "this", "->", "getPort", "(", ")", ";", "}", "}", "return", "$", "server", ";", "}" ]
Build and return the server connection. @return string
[ "Build", "and", "return", "the", "server", "connection", "." ]
797536d7b51d3e84d8cabc88d5fdc9fcd2466dfc
https://github.com/titon/db-mongodb/blob/797536d7b51d3e84d8cabc88d5fdc9fcd2466dfc/src/Titon/Db/Mongo/MongoDriver.php#L249-L264
7,262
synga-nl/inheritance-finder
src/CacheBuilder.php
CacheBuilder.removeNonExistentClasses
protected function removeNonExistentClasses(&$pathnameArray) { foreach ($pathnameArray as $pathname => $phpClass) { if (!file_exists($pathname)) { unset($pathnameArray[$pathname]); } } }
php
protected function removeNonExistentClasses(&$pathnameArray) { foreach ($pathnameArray as $pathname => $phpClass) { if (!file_exists($pathname)) { unset($pathnameArray[$pathname]); } } }
[ "protected", "function", "removeNonExistentClasses", "(", "&", "$", "pathnameArray", ")", "{", "foreach", "(", "$", "pathnameArray", "as", "$", "pathname", "=>", "$", "phpClass", ")", "{", "if", "(", "!", "file_exists", "(", "$", "pathname", ")", ")", "{", "unset", "(", "$", "pathnameArray", "[", "$", "pathname", "]", ")", ";", "}", "}", "}" ]
Removes files which are no longer present in this directory @param PhpClass[] $pathnameArray @return \Synga\InheritanceFinder\PhpClass[]
[ "Removes", "files", "which", "are", "no", "longer", "present", "in", "this", "directory" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/CacheBuilder.php#L122-L128
7,263
synga-nl/inheritance-finder
src/CacheBuilder.php
CacheBuilder.modifyModifiedClasses
protected function modifyModifiedClasses(&$pathnameArray) { foreach ($pathnameArray as $pathname => $phpClass) { if (file_exists($phpClass->getFile()->getPathname()) && $phpClass->getLastModified()->getTimestamp() != $phpClass->getFile()->getMTime()) { $file = $phpClass->getFile(); $phpClass->clear(); $result = $this->phpClassParser->parse($phpClass, $file); if ($result === false) { unset($pathnameArray[$pathname]); } } } }
php
protected function modifyModifiedClasses(&$pathnameArray) { foreach ($pathnameArray as $pathname => $phpClass) { if (file_exists($phpClass->getFile()->getPathname()) && $phpClass->getLastModified()->getTimestamp() != $phpClass->getFile()->getMTime()) { $file = $phpClass->getFile(); $phpClass->clear(); $result = $this->phpClassParser->parse($phpClass, $file); if ($result === false) { unset($pathnameArray[$pathname]); } } } }
[ "protected", "function", "modifyModifiedClasses", "(", "&", "$", "pathnameArray", ")", "{", "foreach", "(", "$", "pathnameArray", "as", "$", "pathname", "=>", "$", "phpClass", ")", "{", "if", "(", "file_exists", "(", "$", "phpClass", "->", "getFile", "(", ")", "->", "getPathname", "(", ")", ")", "&&", "$", "phpClass", "->", "getLastModified", "(", ")", "->", "getTimestamp", "(", ")", "!=", "$", "phpClass", "->", "getFile", "(", ")", "->", "getMTime", "(", ")", ")", "{", "$", "file", "=", "$", "phpClass", "->", "getFile", "(", ")", ";", "$", "phpClass", "->", "clear", "(", ")", ";", "$", "result", "=", "$", "this", "->", "phpClassParser", "->", "parse", "(", "$", "phpClass", ",", "$", "file", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "unset", "(", "$", "pathnameArray", "[", "$", "pathname", "]", ")", ";", "}", "}", "}", "}" ]
Checks if a file is modified and if so, reparse the file @param phpClass[] $pathnameArray @return \Synga\InheritanceFinder\PhpClass[]
[ "Checks", "if", "a", "file", "is", "modified", "and", "if", "so", "reparse", "the", "file" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/CacheBuilder.php#L136-L149
7,264
synga-nl/inheritance-finder
src/CacheBuilder.php
CacheBuilder.addNewClasses
protected function addNewClasses(&$pathnameArray, &$nonClassFiles, $excludeVendor = true, PhpClass $phpClassClone) { $files = $this->findFiles($excludeVendor); foreach ($files as $file) { /* @var $file \Symfony\Component\Finder\SplFileInfo */ $pathname = $file->getPathname(); if ((!isset($pathnameArray[$pathname]) && !isset($nonClassFiles[$pathname])) || (isset($nonClassFiles[$pathname]) && md5_file($file->getPathname()) !== $nonClassFiles[$pathname])) { $phpClass = clone $phpClassClone; $fileInfo = $this->parseSplFileInfo($file, $phpClass); if (is_object($fileInfo)) { $pathnameArray[$pathname] = $fileInfo; } else { $nonClassFiles[$fileInfo['pathname']] = $fileInfo['md5']; } } } }
php
protected function addNewClasses(&$pathnameArray, &$nonClassFiles, $excludeVendor = true, PhpClass $phpClassClone) { $files = $this->findFiles($excludeVendor); foreach ($files as $file) { /* @var $file \Symfony\Component\Finder\SplFileInfo */ $pathname = $file->getPathname(); if ((!isset($pathnameArray[$pathname]) && !isset($nonClassFiles[$pathname])) || (isset($nonClassFiles[$pathname]) && md5_file($file->getPathname()) !== $nonClassFiles[$pathname])) { $phpClass = clone $phpClassClone; $fileInfo = $this->parseSplFileInfo($file, $phpClass); if (is_object($fileInfo)) { $pathnameArray[$pathname] = $fileInfo; } else { $nonClassFiles[$fileInfo['pathname']] = $fileInfo['md5']; } } } }
[ "protected", "function", "addNewClasses", "(", "&", "$", "pathnameArray", ",", "&", "$", "nonClassFiles", ",", "$", "excludeVendor", "=", "true", ",", "PhpClass", "$", "phpClassClone", ")", "{", "$", "files", "=", "$", "this", "->", "findFiles", "(", "$", "excludeVendor", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "/* @var $file \\Symfony\\Component\\Finder\\SplFileInfo */", "$", "pathname", "=", "$", "file", "->", "getPathname", "(", ")", ";", "if", "(", "(", "!", "isset", "(", "$", "pathnameArray", "[", "$", "pathname", "]", ")", "&&", "!", "isset", "(", "$", "nonClassFiles", "[", "$", "pathname", "]", ")", ")", "||", "(", "isset", "(", "$", "nonClassFiles", "[", "$", "pathname", "]", ")", "&&", "md5_file", "(", "$", "file", "->", "getPathname", "(", ")", ")", "!==", "$", "nonClassFiles", "[", "$", "pathname", "]", ")", ")", "{", "$", "phpClass", "=", "clone", "$", "phpClassClone", ";", "$", "fileInfo", "=", "$", "this", "->", "parseSplFileInfo", "(", "$", "file", ",", "$", "phpClass", ")", ";", "if", "(", "is_object", "(", "$", "fileInfo", ")", ")", "{", "$", "pathnameArray", "[", "$", "pathname", "]", "=", "$", "fileInfo", ";", "}", "else", "{", "$", "nonClassFiles", "[", "$", "fileInfo", "[", "'pathname'", "]", "]", "=", "$", "fileInfo", "[", "'md5'", "]", ";", "}", "}", "}", "}" ]
Finds classes which are not added to the cache @param $pathnameArray @param bool $excludeVendor @param PhpClass $phpClassClone
[ "Finds", "classes", "which", "are", "not", "added", "to", "the", "cache" ]
52669ac662b58dfeb6142b2e1bffbfba6f17d4b0
https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/CacheBuilder.php#L158-L175
7,265
LaBlog/LaBlog
src/Lablog/Lablog/LablogServiceProvider.php
LablogServiceProvider.registerTwigModules
public function registerTwigModules() { $twig = \Config::get('twigbridge::extensions'); $twig[] = 'Lablog\Lablog\Twig\PaginationLoader'; $twig[] = 'Lablog\Lablog\Twig\PostLoader'; $twig[] = 'Lablog\Lablog\Twig\PageLoader'; $twig[] = 'Lablog\Lablog\Twig\CategoryLoader'; $twig[] = 'Lablog\Lablog\Twig\CountLoader'; \Config::set('twigbridge::extensions', $twig); }
php
public function registerTwigModules() { $twig = \Config::get('twigbridge::extensions'); $twig[] = 'Lablog\Lablog\Twig\PaginationLoader'; $twig[] = 'Lablog\Lablog\Twig\PostLoader'; $twig[] = 'Lablog\Lablog\Twig\PageLoader'; $twig[] = 'Lablog\Lablog\Twig\CategoryLoader'; $twig[] = 'Lablog\Lablog\Twig\CountLoader'; \Config::set('twigbridge::extensions', $twig); }
[ "public", "function", "registerTwigModules", "(", ")", "{", "$", "twig", "=", "\\", "Config", "::", "get", "(", "'twigbridge::extensions'", ")", ";", "$", "twig", "[", "]", "=", "'Lablog\\Lablog\\Twig\\PaginationLoader'", ";", "$", "twig", "[", "]", "=", "'Lablog\\Lablog\\Twig\\PostLoader'", ";", "$", "twig", "[", "]", "=", "'Lablog\\Lablog\\Twig\\PageLoader'", ";", "$", "twig", "[", "]", "=", "'Lablog\\Lablog\\Twig\\CategoryLoader'", ";", "$", "twig", "[", "]", "=", "'Lablog\\Lablog\\Twig\\CountLoader'", ";", "\\", "Config", "::", "set", "(", "'twigbridge::extensions'", ",", "$", "twig", ")", ";", "}" ]
Register twig modules. @return void
[ "Register", "twig", "modules", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/Lablog/Lablog/LablogServiceProvider.php#L58-L69
7,266
indigophp-archive/fuel-core
lib/Fuel/Fieldset/Builder/ModelBuilder.php
ModelBuilder.populateForm
public static function populateForm(Form $form) { if (static::$builder === null) { static::setBuilder(new V1Model); static::$builder->setWrapperElement(null); } $elements = static::$builder->generate(get_called_class()); return $form->setContents($elements); }
php
public static function populateForm(Form $form) { if (static::$builder === null) { static::setBuilder(new V1Model); static::$builder->setWrapperElement(null); } $elements = static::$builder->generate(get_called_class()); return $form->setContents($elements); }
[ "public", "static", "function", "populateForm", "(", "Form", "$", "form", ")", "{", "if", "(", "static", "::", "$", "builder", "===", "null", ")", "{", "static", "::", "setBuilder", "(", "new", "V1Model", ")", ";", "static", "::", "$", "builder", "->", "setWrapperElement", "(", "null", ")", ";", "}", "$", "elements", "=", "static", "::", "$", "builder", "->", "generate", "(", "get_called_class", "(", ")", ")", ";", "return", "$", "form", "->", "setContents", "(", "$", "elements", ")", ";", "}" ]
Populates the given form with the needed fields @param Form $form @return Form
[ "Populates", "the", "given", "form", "with", "the", "needed", "fields" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/lib/Fuel/Fieldset/Builder/ModelBuilder.php#L49-L61
7,267
gregoriohc/argentum-common
src/Common/ParametrizedTrait.php
ParametrizedTrait.toArray
public function toArray() { $data = array(); foreach ($this->parameters as $parameter => $value) { if (is_object($value) && method_exists($value, 'toArray')) { $data[$parameter] = $value->toArray(); } elseif (is_object($value)) { $data[$parameter] = get_object_vars($value); } else { $data[$parameter] = $value; } } return $data; }
php
public function toArray() { $data = array(); foreach ($this->parameters as $parameter => $value) { if (is_object($value) && method_exists($value, 'toArray')) { $data[$parameter] = $value->toArray(); } elseif (is_object($value)) { $data[$parameter] = get_object_vars($value); } else { $data[$parameter] = $value; } } return $data; }
[ "public", "function", "toArray", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "parameter", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "&&", "method_exists", "(", "$", "value", ",", "'toArray'", ")", ")", "{", "$", "data", "[", "$", "parameter", "]", "=", "$", "value", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "data", "[", "$", "parameter", "]", "=", "get_object_vars", "(", "$", "value", ")", ";", "}", "else", "{", "$", "data", "[", "$", "parameter", "]", "=", "$", "value", ";", "}", "}", "return", "$", "data", ";", "}" ]
Get an array of the parameters @return array
[ "Get", "an", "array", "of", "the", "parameters" ]
9d914d19aa6ed25d33f00d603eff486484f0f3ba
https://github.com/gregoriohc/argentum-common/blob/9d914d19aa6ed25d33f00d603eff486484f0f3ba/src/Common/ParametrizedTrait.php#L166-L179
7,268
phapi/middleware-content-negotiation
src/Phapi/Middleware/ContentNegotiation/FormatNegotiation.php
FormatNegotiation.getBestFormat
public function getBestFormat($accept, $supported) { // Parse the accept header $parts = $this->parseHeader($accept); // Sort the array based on $parts = $this->sortParts($parts); // Loop through the array foreach ($parts as $part) { // Check if mime type is $supported if (in_array($part['value'], $supported)) { // Return the mime type return $part; } // Match for example image/* if (substr($part['value'], -2) === '/*') { // Get the type $range = substr($part['value'], 0, -2); // Look if type is found in $supported foreach ($supported as $support) { if (strpos($support, $range, 0) === 0) { $part['value'] = $support; return $part; } } } // Check if accepts anything if ($part['value'] === '*/*') { return $this->acceptsAnything($part['quality'], $supported); } } // Return null if no match is found return null; }
php
public function getBestFormat($accept, $supported) { // Parse the accept header $parts = $this->parseHeader($accept); // Sort the array based on $parts = $this->sortParts($parts); // Loop through the array foreach ($parts as $part) { // Check if mime type is $supported if (in_array($part['value'], $supported)) { // Return the mime type return $part; } // Match for example image/* if (substr($part['value'], -2) === '/*') { // Get the type $range = substr($part['value'], 0, -2); // Look if type is found in $supported foreach ($supported as $support) { if (strpos($support, $range, 0) === 0) { $part['value'] = $support; return $part; } } } // Check if accepts anything if ($part['value'] === '*/*') { return $this->acceptsAnything($part['quality'], $supported); } } // Return null if no match is found return null; }
[ "public", "function", "getBestFormat", "(", "$", "accept", ",", "$", "supported", ")", "{", "// Parse the accept header", "$", "parts", "=", "$", "this", "->", "parseHeader", "(", "$", "accept", ")", ";", "// Sort the array based on", "$", "parts", "=", "$", "this", "->", "sortParts", "(", "$", "parts", ")", ";", "// Loop through the array", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "// Check if mime type is $supported", "if", "(", "in_array", "(", "$", "part", "[", "'value'", "]", ",", "$", "supported", ")", ")", "{", "// Return the mime type", "return", "$", "part", ";", "}", "// Match for example image/*", "if", "(", "substr", "(", "$", "part", "[", "'value'", "]", ",", "-", "2", ")", "===", "'/*'", ")", "{", "// Get the type", "$", "range", "=", "substr", "(", "$", "part", "[", "'value'", "]", ",", "0", ",", "-", "2", ")", ";", "// Look if type is found in $supported", "foreach", "(", "$", "supported", "as", "$", "support", ")", "{", "if", "(", "strpos", "(", "$", "support", ",", "$", "range", ",", "0", ")", "===", "0", ")", "{", "$", "part", "[", "'value'", "]", "=", "$", "support", ";", "return", "$", "part", ";", "}", "}", "}", "// Check if accepts anything", "if", "(", "$", "part", "[", "'value'", "]", "===", "'*/*'", ")", "{", "return", "$", "this", "->", "acceptsAnything", "(", "$", "part", "[", "'quality'", "]", ",", "$", "supported", ")", ";", "}", "}", "// Return null if no match is found", "return", "null", ";", "}" ]
Get the best format based on the accept header and the list of supported mime types. @param $accept @param $supported @return mixed|null
[ "Get", "the", "best", "format", "based", "on", "the", "accept", "header", "and", "the", "list", "of", "supported", "mime", "types", "." ]
00197a5f3c36b71f758c035c1cb0ebe8d706e081
https://github.com/phapi/middleware-content-negotiation/blob/00197a5f3c36b71f758c035c1cb0ebe8d706e081/src/Phapi/Middleware/ContentNegotiation/FormatNegotiation.php#L134-L172
7,269
phapi/middleware-content-negotiation
src/Phapi/Middleware/ContentNegotiation/FormatNegotiation.php
FormatNegotiation.parseParts
private function parseParts(array $parts = []) { // Get and unset the mime type $mimeType = $parts[0]; unset($parts[0]); // Set default quality to 1 since the HTTP/1.1 specification says that if no // quality is provided it defaults to 1 $support = [ 'value' => $mimeType, 'quality' => (float) 1 ]; // Loop through the parts foreach ($parts as $part) { // Save all params $param = explode('=', $part); // Make sure we exploded the string if (isset($param[1])) { // Save param if ($param[0] === 'q') { $support['quality'] = (float) $param[1]; } else { $support['parameters'][$param[0]] = $param[1]; } } } return $support; }
php
private function parseParts(array $parts = []) { // Get and unset the mime type $mimeType = $parts[0]; unset($parts[0]); // Set default quality to 1 since the HTTP/1.1 specification says that if no // quality is provided it defaults to 1 $support = [ 'value' => $mimeType, 'quality' => (float) 1 ]; // Loop through the parts foreach ($parts as $part) { // Save all params $param = explode('=', $part); // Make sure we exploded the string if (isset($param[1])) { // Save param if ($param[0] === 'q') { $support['quality'] = (float) $param[1]; } else { $support['parameters'][$param[0]] = $param[1]; } } } return $support; }
[ "private", "function", "parseParts", "(", "array", "$", "parts", "=", "[", "]", ")", "{", "// Get and unset the mime type", "$", "mimeType", "=", "$", "parts", "[", "0", "]", ";", "unset", "(", "$", "parts", "[", "0", "]", ")", ";", "// Set default quality to 1 since the HTTP/1.1 specification says that if no", "// quality is provided it defaults to 1", "$", "support", "=", "[", "'value'", "=>", "$", "mimeType", ",", "'quality'", "=>", "(", "float", ")", "1", "]", ";", "// Loop through the parts", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "// Save all params", "$", "param", "=", "explode", "(", "'='", ",", "$", "part", ")", ";", "// Make sure we exploded the string", "if", "(", "isset", "(", "$", "param", "[", "1", "]", ")", ")", "{", "// Save param", "if", "(", "$", "param", "[", "0", "]", "===", "'q'", ")", "{", "$", "support", "[", "'quality'", "]", "=", "(", "float", ")", "$", "param", "[", "1", "]", ";", "}", "else", "{", "$", "support", "[", "'parameters'", "]", "[", "$", "param", "[", "0", "]", "]", "=", "$", "param", "[", "1", "]", ";", "}", "}", "}", "return", "$", "support", ";", "}" ]
Parse the different parts of the media range @param array $parts @return array
[ "Parse", "the", "different", "parts", "of", "the", "media", "range" ]
00197a5f3c36b71f758c035c1cb0ebe8d706e081
https://github.com/phapi/middleware-content-negotiation/blob/00197a5f3c36b71f758c035c1cb0ebe8d706e081/src/Phapi/Middleware/ContentNegotiation/FormatNegotiation.php#L241-L267
7,270
rawphp/http
src/Matchers/DefaultMatchers.php
DefaultMatchers.matchUrl
public function matchUrl(RequestInterface $request, array $maps) { $matched = []; $uri = (string)$request->getUri(); /** @var RequestMap $map */ foreach ($maps as $map) { if ((string)$map->getRequest()->getUri() === $uri) { $matched[] = $map; } } return $matched; }
php
public function matchUrl(RequestInterface $request, array $maps) { $matched = []; $uri = (string)$request->getUri(); /** @var RequestMap $map */ foreach ($maps as $map) { if ((string)$map->getRequest()->getUri() === $uri) { $matched[] = $map; } } return $matched; }
[ "public", "function", "matchUrl", "(", "RequestInterface", "$", "request", ",", "array", "$", "maps", ")", "{", "$", "matched", "=", "[", "]", ";", "$", "uri", "=", "(", "string", ")", "$", "request", "->", "getUri", "(", ")", ";", "/** @var RequestMap $map */", "foreach", "(", "$", "maps", "as", "$", "map", ")", "{", "if", "(", "(", "string", ")", "$", "map", "->", "getRequest", "(", ")", "->", "getUri", "(", ")", "===", "$", "uri", ")", "{", "$", "matched", "[", "]", "=", "$", "map", ";", "}", "}", "return", "$", "matched", ";", "}" ]
Match Url. @param RequestInterface $request @param array $maps @return RequestMap[]
[ "Match", "Url", "." ]
75c858bbbf7bf1bc74366f1811b37ea2aee7430d
https://github.com/rawphp/http/blob/75c858bbbf7bf1bc74366f1811b37ea2aee7430d/src/Matchers/DefaultMatchers.php#L23-L37
7,271
rawphp/http
src/Matchers/DefaultMatchers.php
DefaultMatchers.matchMethod
public function matchMethod(RequestInterface $request, array $maps) { $matched = []; $method = $request->getMethod(); /** @var RequestMap $map */ foreach ($maps as $map) { if ($map->getRequest()->getMethod() === $method) { $matched[] = $map; } } return $matched; }
php
public function matchMethod(RequestInterface $request, array $maps) { $matched = []; $method = $request->getMethod(); /** @var RequestMap $map */ foreach ($maps as $map) { if ($map->getRequest()->getMethod() === $method) { $matched[] = $map; } } return $matched; }
[ "public", "function", "matchMethod", "(", "RequestInterface", "$", "request", ",", "array", "$", "maps", ")", "{", "$", "matched", "=", "[", "]", ";", "$", "method", "=", "$", "request", "->", "getMethod", "(", ")", ";", "/** @var RequestMap $map */", "foreach", "(", "$", "maps", "as", "$", "map", ")", "{", "if", "(", "$", "map", "->", "getRequest", "(", ")", "->", "getMethod", "(", ")", "===", "$", "method", ")", "{", "$", "matched", "[", "]", "=", "$", "map", ";", "}", "}", "return", "$", "matched", ";", "}" ]
Match method. @param RequestInterface $request @param array $maps @return RequestMap[]
[ "Match", "method", "." ]
75c858bbbf7bf1bc74366f1811b37ea2aee7430d
https://github.com/rawphp/http/blob/75c858bbbf7bf1bc74366f1811b37ea2aee7430d/src/Matchers/DefaultMatchers.php#L47-L61
7,272
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.InitPlaceholders
private function InitPlaceholders() { return array( Placeholders\PhpDocPlaceholders::AUTHOR => "Jeremie Litzler", Placeholders\PhpDocPlaceholders::COPYRIGHT_YEAR => date("Y"), Placeholders\PhpDocPlaceholders::LICENCE => "http://opensource.org/licenses/gpl-license.php GNU Public License", Placeholders\PhpDocPlaceholders::LINK => "https://github.com/Puzzlout/", Placeholders\PhpDocPlaceholders::PACKAGE => $this->className, Placeholders\PhpDocPlaceholders::SUBPACKAGE => "", Placeholders\PhpDocPlaceholders::VERSION_NUMBER => "PACKAGE_VERSION", Placeholders\ClassFilePlaceholders::NAMESPACE_FRAMEWORK => "Puzzlout\Framework\BO", Placeholders\ClassFilePlaceholders::NAMESPACE_APP => "\Applications\"" . "APP_NAME" . "\Models\Dao", Placeholders\ClassFilePlaceholders::CLASS_NAME => $this->className ); }
php
private function InitPlaceholders() { return array( Placeholders\PhpDocPlaceholders::AUTHOR => "Jeremie Litzler", Placeholders\PhpDocPlaceholders::COPYRIGHT_YEAR => date("Y"), Placeholders\PhpDocPlaceholders::LICENCE => "http://opensource.org/licenses/gpl-license.php GNU Public License", Placeholders\PhpDocPlaceholders::LINK => "https://github.com/Puzzlout/", Placeholders\PhpDocPlaceholders::PACKAGE => $this->className, Placeholders\PhpDocPlaceholders::SUBPACKAGE => "", Placeholders\PhpDocPlaceholders::VERSION_NUMBER => "PACKAGE_VERSION", Placeholders\ClassFilePlaceholders::NAMESPACE_FRAMEWORK => "Puzzlout\Framework\BO", Placeholders\ClassFilePlaceholders::NAMESPACE_APP => "\Applications\"" . "APP_NAME" . "\Models\Dao", Placeholders\ClassFilePlaceholders::CLASS_NAME => $this->className ); }
[ "private", "function", "InitPlaceholders", "(", ")", "{", "return", "array", "(", "Placeholders", "\\", "PhpDocPlaceholders", "::", "AUTHOR", "=>", "\"Jeremie Litzler\"", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "COPYRIGHT_YEAR", "=>", "date", "(", "\"Y\"", ")", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "LICENCE", "=>", "\"http://opensource.org/licenses/gpl-license.php GNU Public License\"", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "LINK", "=>", "\"https://github.com/Puzzlout/\"", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "PACKAGE", "=>", "$", "this", "->", "className", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "SUBPACKAGE", "=>", "\"\"", ",", "Placeholders", "\\", "PhpDocPlaceholders", "::", "VERSION_NUMBER", "=>", "\"PACKAGE_VERSION\"", ",", "Placeholders", "\\", "ClassFilePlaceholders", "::", "NAMESPACE_FRAMEWORK", "=>", "\"Puzzlout\\Framework\\BO\"", ",", "Placeholders", "\\", "ClassFilePlaceholders", "::", "NAMESPACE_APP", "=>", "\"\\Applications\\\"\"", ".", "\"APP_NAME\"", ".", "\"\\Models\\Dao\"", ",", "Placeholders", "\\", "ClassFilePlaceholders", "::", "CLASS_NAME", "=>", "$", "this", "->", "className", ")", ";", "}" ]
Builds the associative array of placeholders. @return array : the associative array of placeholder key/value pair.
[ "Builds", "the", "associative", "array", "of", "placeholders", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L110-L123
7,273
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.AddNameSpace
public function AddNameSpace() { $output = ""; if ($this->isFrameworkClass) { $output = strtr(CodeSnippets\ClassFileSnippets::SNIPPET_NAMESPACE_FRAMEWORK, $this->placeholders); } else { $output = strtr(CodeSnippets\ClassFileSnippets::SNIPPET_NAMESPACE_APP, $this->placeholders); } fwrite($this->writer, $output); }
php
public function AddNameSpace() { $output = ""; if ($this->isFrameworkClass) { $output = strtr(CodeSnippets\ClassFileSnippets::SNIPPET_NAMESPACE_FRAMEWORK, $this->placeholders); } else { $output = strtr(CodeSnippets\ClassFileSnippets::SNIPPET_NAMESPACE_APP, $this->placeholders); } fwrite($this->writer, $output); }
[ "public", "function", "AddNameSpace", "(", ")", "{", "$", "output", "=", "\"\"", ";", "if", "(", "$", "this", "->", "isFrameworkClass", ")", "{", "$", "output", "=", "strtr", "(", "CodeSnippets", "\\", "ClassFileSnippets", "::", "SNIPPET_NAMESPACE_FRAMEWORK", ",", "$", "this", "->", "placeholders", ")", ";", "}", "else", "{", "$", "output", "=", "strtr", "(", "CodeSnippets", "\\", "ClassFileSnippets", "::", "SNIPPET_NAMESPACE_APP", ",", "$", "this", "->", "placeholders", ")", ";", "}", "fwrite", "(", "$", "this", "->", "writer", ",", "$", "output", ")", ";", "}" ]
Computes the namespace and writes it to the output.
[ "Computes", "the", "namespace", "and", "writes", "it", "to", "the", "output", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L155-L163
7,274
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.AddFileDescription
public function AddFileDescription() { $output = CodeSnippets\PhpDocSnippets::OPENING . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::AUTHOR, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::COPYRIGHT, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::LICENCE, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::LINK, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::SINCE, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::PACKAGE, $this->placeholders) . $this->_LF . CodeSnippets\PhpDocSnippets::CLOSING . $this->_LF; fwrite($this->writer, $output); }
php
public function AddFileDescription() { $output = CodeSnippets\PhpDocSnippets::OPENING . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::AUTHOR, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::COPYRIGHT, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::LICENCE, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::LINK, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::SINCE, $this->placeholders) . $this->_LF . strtr(CodeSnippets\PhpDocSnippets::PACKAGE, $this->placeholders) . $this->_LF . CodeSnippets\PhpDocSnippets::CLOSING . $this->_LF; fwrite($this->writer, $output); }
[ "public", "function", "AddFileDescription", "(", ")", "{", "$", "output", "=", "CodeSnippets", "\\", "PhpDocSnippets", "::", "OPENING", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "AUTHOR", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "COPYRIGHT", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "LICENCE", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "LINK", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "SINCE", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "PACKAGE", ",", "$", "this", "->", "placeholders", ")", ".", "$", "this", "->", "_LF", ".", "CodeSnippets", "\\", "PhpDocSnippets", "::", "CLOSING", ".", "$", "this", "->", "_LF", ";", "fwrite", "(", "$", "this", "->", "writer", ",", "$", "output", ")", ";", "}" ]
Computes the class description using PhpDoc and writes it to the output.
[ "Computes", "the", "class", "description", "using", "PhpDoc", "and", "writes", "it", "to", "the", "output", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L168-L178
7,275
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.ClassStart
public function ClassStart() { $output = $this->_CRLF . "class " . ucfirst($this->className) . " extends " . $this->baseClass . " {" . $this->_LF; fwrite($this->writer, $output); }
php
public function ClassStart() { $output = $this->_CRLF . "class " . ucfirst($this->className) . " extends " . $this->baseClass . " {" . $this->_LF; fwrite($this->writer, $output); }
[ "public", "function", "ClassStart", "(", ")", "{", "$", "output", "=", "$", "this", "->", "_CRLF", ".", "\"class \"", ".", "ucfirst", "(", "$", "this", "->", "className", ")", ".", "\" extends \"", ".", "$", "this", "->", "baseClass", ".", "\" {\"", ".", "$", "this", "->", "_LF", ";", "fwrite", "(", "$", "this", "->", "writer", ",", "$", "output", ")", ";", "}" ]
Writes the start of the class.
[ "Writes", "the", "start", "of", "the", "class", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L190-L193
7,276
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.AddConstants
private function AddConstants($columnsMetadata) { $output = ""; foreach ($columnsMetadata as $columnName => $columnMetadata) { $output .= $this->_TAB2 . "const " . strtoupper($columnMetadata["Field"]) . " = \"" . $columnMetadata["Field"] . "\";" . $this->_LF; } $output .= $this->_CRLF; fwrite($this->writer, $output); }
php
private function AddConstants($columnsMetadata) { $output = ""; foreach ($columnsMetadata as $columnName => $columnMetadata) { $output .= $this->_TAB2 . "const " . strtoupper($columnMetadata["Field"]) . " = \"" . $columnMetadata["Field"] . "\";" . $this->_LF; } $output .= $this->_CRLF; fwrite($this->writer, $output); }
[ "private", "function", "AddConstants", "(", "$", "columnsMetadata", ")", "{", "$", "output", "=", "\"\"", ";", "foreach", "(", "$", "columnsMetadata", "as", "$", "columnName", "=>", "$", "columnMetadata", ")", "{", "$", "output", ".=", "$", "this", "->", "_TAB2", ".", "\"const \"", ".", "strtoupper", "(", "$", "columnMetadata", "[", "\"Field\"", "]", ")", ".", "\" = \\\"\"", ".", "$", "columnMetadata", "[", "\"Field\"", "]", ".", "\"\\\";\"", ".", "$", "this", "->", "_LF", ";", "}", "$", "output", ".=", "$", "this", "->", "_CRLF", ";", "fwrite", "(", "$", "this", "->", "writer", ",", "$", "output", ")", ";", "}" ]
Writes the constant representation of the class's field properties. @param type $columnsMetadata : List of metadata for each column.
[ "Writes", "the", "constant", "representation", "of", "the", "class", "s", "field", "properties", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L244-L251
7,277
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.AddFields
private function AddFields($columnsMetadata) { //Write the protected fields $output = $this->_TAB2 . "protected " . $this->_LF; $columnCount = 0; foreach ($columnsMetadata as $columnName => $columnMetadata) { if (count($columnsMetadata) - 1 === $columnCount) { $output .= $this->_TAB4 . "$" . $columnMetadata["Field"] . ";" . $this->_CRLF; } else { $output .= $this->_TAB4 . "$" . $columnMetadata["Field"] . "," . $this->_LF; } $columnCount += 1; } fwrite($this->writer, $output); }
php
private function AddFields($columnsMetadata) { //Write the protected fields $output = $this->_TAB2 . "protected " . $this->_LF; $columnCount = 0; foreach ($columnsMetadata as $columnName => $columnMetadata) { if (count($columnsMetadata) - 1 === $columnCount) { $output .= $this->_TAB4 . "$" . $columnMetadata["Field"] . ";" . $this->_CRLF; } else { $output .= $this->_TAB4 . "$" . $columnMetadata["Field"] . "," . $this->_LF; } $columnCount += 1; } fwrite($this->writer, $output); }
[ "private", "function", "AddFields", "(", "$", "columnsMetadata", ")", "{", "//Write the protected fields", "$", "output", "=", "$", "this", "->", "_TAB2", ".", "\"protected \"", ".", "$", "this", "->", "_LF", ";", "$", "columnCount", "=", "0", ";", "foreach", "(", "$", "columnsMetadata", "as", "$", "columnName", "=>", "$", "columnMetadata", ")", "{", "if", "(", "count", "(", "$", "columnsMetadata", ")", "-", "1", "===", "$", "columnCount", ")", "{", "$", "output", ".=", "$", "this", "->", "_TAB4", ".", "\"$\"", ".", "$", "columnMetadata", "[", "\"Field\"", "]", ".", "\";\"", ".", "$", "this", "->", "_CRLF", ";", "}", "else", "{", "$", "output", ".=", "$", "this", "->", "_TAB4", ".", "\"$\"", ".", "$", "columnMetadata", "[", "\"Field\"", "]", ".", "\",\"", ".", "$", "this", "->", "_LF", ";", "}", "$", "columnCount", "+=", "1", ";", "}", "fwrite", "(", "$", "this", "->", "writer", ",", "$", "output", ")", ";", "}" ]
Writes the field properties from the columns metadata. @param type $columnsMetadata : List of metadata for each column.
[ "Writes", "the", "field", "properties", "from", "the", "columns", "metadata", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L258-L271
7,278
Puzzlout/FrameworkMvcLegacy
src/Dal/Generator/DaoClassGenerator.php
DaoClassGenerator.AddPropertyPhpDoc
private function AddPropertyPhpDoc($columnMetadata, $isSetter = true) { $output = $this->_TAB2 . \Puzzlout\Framework\GeneratorEngine\CodeSnippets\PhpDocSnippets::OPENING . $this->_TAB2 . $this->_LF; $placeholders = array( "{{set_dynamic_code}}" => strtr(CodeSnippets\PhpDocSnippets::SET_PROPERTY_SUMMARY, array(Placeholders\PhpDocPlaceholders::SET_PROPERTY => $columnMetadata["Field"])), "{{get_dynamic_code}}" => strtr(CodeSnippets\PhpDocSnippets::GET_PROPERTY_SUMMARY, array(Placeholders\PhpDocPlaceholders::GET_PROPERTY => $columnMetadata["Field"])) ); if ($isSetter) { $output .= $this->_TAB2 . strtr("{{set_dynamic_code}}", $placeholders); } else { $output .= $this->_TAB2 . strtr("{{get_dynamic_code}}", $placeholders); } $output .= $this->_LF . $this->_TAB2 . CodeSnippets\PhpDocSnippets::CLOSING . $this->_LF; return $output; }
php
private function AddPropertyPhpDoc($columnMetadata, $isSetter = true) { $output = $this->_TAB2 . \Puzzlout\Framework\GeneratorEngine\CodeSnippets\PhpDocSnippets::OPENING . $this->_TAB2 . $this->_LF; $placeholders = array( "{{set_dynamic_code}}" => strtr(CodeSnippets\PhpDocSnippets::SET_PROPERTY_SUMMARY, array(Placeholders\PhpDocPlaceholders::SET_PROPERTY => $columnMetadata["Field"])), "{{get_dynamic_code}}" => strtr(CodeSnippets\PhpDocSnippets::GET_PROPERTY_SUMMARY, array(Placeholders\PhpDocPlaceholders::GET_PROPERTY => $columnMetadata["Field"])) ); if ($isSetter) { $output .= $this->_TAB2 . strtr("{{set_dynamic_code}}", $placeholders); } else { $output .= $this->_TAB2 . strtr("{{get_dynamic_code}}", $placeholders); } $output .= $this->_LF . $this->_TAB2 . CodeSnippets\PhpDocSnippets::CLOSING . $this->_LF; return $output; }
[ "private", "function", "AddPropertyPhpDoc", "(", "$", "columnMetadata", ",", "$", "isSetter", "=", "true", ")", "{", "$", "output", "=", "$", "this", "->", "_TAB2", ".", "\\", "Puzzlout", "\\", "Framework", "\\", "GeneratorEngine", "\\", "CodeSnippets", "\\", "PhpDocSnippets", "::", "OPENING", ".", "$", "this", "->", "_TAB2", ".", "$", "this", "->", "_LF", ";", "$", "placeholders", "=", "array", "(", "\"{{set_dynamic_code}}\"", "=>", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "SET_PROPERTY_SUMMARY", ",", "array", "(", "Placeholders", "\\", "PhpDocPlaceholders", "::", "SET_PROPERTY", "=>", "$", "columnMetadata", "[", "\"Field\"", "]", ")", ")", ",", "\"{{get_dynamic_code}}\"", "=>", "strtr", "(", "CodeSnippets", "\\", "PhpDocSnippets", "::", "GET_PROPERTY_SUMMARY", ",", "array", "(", "Placeholders", "\\", "PhpDocPlaceholders", "::", "GET_PROPERTY", "=>", "$", "columnMetadata", "[", "\"Field\"", "]", ")", ")", ")", ";", "if", "(", "$", "isSetter", ")", "{", "$", "output", ".=", "$", "this", "->", "_TAB2", ".", "strtr", "(", "\"{{set_dynamic_code}}\"", ",", "$", "placeholders", ")", ";", "}", "else", "{", "$", "output", ".=", "$", "this", "->", "_TAB2", ".", "strtr", "(", "\"{{get_dynamic_code}}\"", ",", "$", "placeholders", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "_LF", ".", "$", "this", "->", "_TAB2", ".", "CodeSnippets", "\\", "PhpDocSnippets", "::", "CLOSING", ".", "$", "this", "->", "_LF", ";", "return", "$", "output", ";", "}" ]
Writes the PhpDoc for the setter and getter functions from a column metadata. @param type $columnMetadata : Metadata for a column.
[ "Writes", "the", "PhpDoc", "for", "the", "setter", "and", "getter", "functions", "from", "a", "column", "metadata", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Generator/DaoClassGenerator.php#L328-L342
7,279
projek-xyz/ci-common
src/Model.php
Model.undel
public function undel($term) { if ( false === $this->has_table() or true === $this->is_destructive ) { $this->set_error('Model '.get_class($this).' has no recoverable data'); return false; } $term = $this->normalize_term($term); return $this->trash_it($term, false); }
php
public function undel($term) { if ( false === $this->has_table() or true === $this->is_destructive ) { $this->set_error('Model '.get_class($this).' has no recoverable data'); return false; } $term = $this->normalize_term($term); return $this->trash_it($term, false); }
[ "public", "function", "undel", "(", "$", "term", ")", "{", "if", "(", "false", "===", "$", "this", "->", "has_table", "(", ")", "or", "true", "===", "$", "this", "->", "is_destructive", ")", "{", "$", "this", "->", "set_error", "(", "'Model '", ".", "get_class", "(", "$", "this", ")", ".", "' has no recoverable data'", ")", ";", "return", "false", ";", "}", "$", "term", "=", "$", "this", "->", "normalize_term", "(", "$", "term", ")", ";", "return", "$", "this", "->", "trash_it", "(", "$", "term", ",", "false", ")", ";", "}" ]
Restore all deleted data @param mixed $term Data terms: int|array @return mixed
[ "Restore", "all", "deleted", "data" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L259-L272
7,280
projek-xyz/ci-common
src/Model.php
Model.count
public function count($with_deleted = null) { if (false === $this->has_table()) return false; if ($this->count === 0) { $with_deleted !== null or $with_deleted = (! $this->is_destructive); if (false === $with_deleted) { $db = $this->db->where($this->deletion_key, 0); } $this->count = $db->count_all_results($this->table); } return $this->count; }
php
public function count($with_deleted = null) { if (false === $this->has_table()) return false; if ($this->count === 0) { $with_deleted !== null or $with_deleted = (! $this->is_destructive); if (false === $with_deleted) { $db = $this->db->where($this->deletion_key, 0); } $this->count = $db->count_all_results($this->table); } return $this->count; }
[ "public", "function", "count", "(", "$", "with_deleted", "=", "null", ")", "{", "if", "(", "false", "===", "$", "this", "->", "has_table", "(", ")", ")", "return", "false", ";", "if", "(", "$", "this", "->", "count", "===", "0", ")", "{", "$", "with_deleted", "!==", "null", "or", "$", "with_deleted", "=", "(", "!", "$", "this", "->", "is_destructive", ")", ";", "if", "(", "false", "===", "$", "with_deleted", ")", "{", "$", "db", "=", "$", "this", "->", "db", "->", "where", "(", "$", "this", "->", "deletion_key", ",", "0", ")", ";", "}", "$", "this", "->", "count", "=", "$", "db", "->", "count_all_results", "(", "$", "this", "->", "table", ")", ";", "}", "return", "$", "this", "->", "count", ";", "}" ]
Count all rows @param bool $with_deleted Including deleted data? @return int
[ "Count", "all", "rows" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L284-L299
7,281
projek-xyz/ci-common
src/Model.php
Model.has_table
public function has_table() { if (null === $this->table) { $this->set_error('This model is has no table specified', true); } elseif (false === $this->table) { return false; } }
php
public function has_table() { if (null === $this->table) { $this->set_error('This model is has no table specified', true); } elseif (false === $this->table) { return false; } }
[ "public", "function", "has_table", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "table", ")", "{", "$", "this", "->", "set_error", "(", "'This model is has no table specified'", ",", "true", ")", ";", "}", "elseif", "(", "false", "===", "$", "this", "->", "table", ")", "{", "return", "false", ";", "}", "}" ]
Determine is this model has table assigned @return bool
[ "Determine", "is", "this", "model", "has", "table", "assigned" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L306-L313
7,282
projek-xyz/ci-common
src/Model.php
Model.trash_it
public function trash_it($term, $flag = true) { return $this->edit($term, [ $this->deletion_key => (int) $flag ] + $this->timestamp('modification')); }
php
public function trash_it($term, $flag = true) { return $this->edit($term, [ $this->deletion_key => (int) $flag ] + $this->timestamp('modification')); }
[ "public", "function", "trash_it", "(", "$", "term", ",", "$", "flag", "=", "true", ")", "{", "return", "$", "this", "->", "edit", "(", "$", "term", ",", "[", "$", "this", "->", "deletion_key", "=>", "(", "int", ")", "$", "flag", "]", "+", "$", "this", "->", "timestamp", "(", "'modification'", ")", ")", ";", "}" ]
Wanna mark a thing as garbage? @param bool $flag Only true or false should be passed @return bool
[ "Wanna", "mark", "a", "thing", "as", "garbage?" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L321-L326
7,283
projek-xyz/ci-common
src/Model.php
Model.timestamp
public function timestamp($state = 'modification', $user_id = null) { if ( ! in_array($state, ['creation', 'modification'])) { $this->set_error('Unsupported timestamp state '.$state, true); } $is_datetime = strtolower($this->timestamp_format) == 'datetime'; $timestamp = $is_datetime ? date('Y-m-d H:i:s') : time(); if (null === $user_id and !is_cli()) { $user_id = $this->session->user_data('user_id') ?: null; } $stamps = [$this->modification_key => $timestamp]; if ($state == 'creation') { $stamps += [$this->creation_key => $timestamp]; } if ($this->is_autotimestamp) { return $stamps; } return []; }
php
public function timestamp($state = 'modification', $user_id = null) { if ( ! in_array($state, ['creation', 'modification'])) { $this->set_error('Unsupported timestamp state '.$state, true); } $is_datetime = strtolower($this->timestamp_format) == 'datetime'; $timestamp = $is_datetime ? date('Y-m-d H:i:s') : time(); if (null === $user_id and !is_cli()) { $user_id = $this->session->user_data('user_id') ?: null; } $stamps = [$this->modification_key => $timestamp]; if ($state == 'creation') { $stamps += [$this->creation_key => $timestamp]; } if ($this->is_autotimestamp) { return $stamps; } return []; }
[ "public", "function", "timestamp", "(", "$", "state", "=", "'modification'", ",", "$", "user_id", "=", "null", ")", "{", "if", "(", "!", "in_array", "(", "$", "state", ",", "[", "'creation'", ",", "'modification'", "]", ")", ")", "{", "$", "this", "->", "set_error", "(", "'Unsupported timestamp state '", ".", "$", "state", ",", "true", ")", ";", "}", "$", "is_datetime", "=", "strtolower", "(", "$", "this", "->", "timestamp_format", ")", "==", "'datetime'", ";", "$", "timestamp", "=", "$", "is_datetime", "?", "date", "(", "'Y-m-d H:i:s'", ")", ":", "time", "(", ")", ";", "if", "(", "null", "===", "$", "user_id", "and", "!", "is_cli", "(", ")", ")", "{", "$", "user_id", "=", "$", "this", "->", "session", "->", "user_data", "(", "'user_id'", ")", "?", ":", "null", ";", "}", "$", "stamps", "=", "[", "$", "this", "->", "modification_key", "=>", "$", "timestamp", "]", ";", "if", "(", "$", "state", "==", "'creation'", ")", "{", "$", "stamps", "+=", "[", "$", "this", "->", "creation_key", "=>", "$", "timestamp", "]", ";", "}", "if", "(", "$", "this", "->", "is_autotimestamp", ")", "{", "return", "$", "stamps", ";", "}", "return", "[", "]", ";", "}" ]
Generate creation & modification timestamp @param string $state Timestamp type @param int $user_id ID of user who did it @return array
[ "Generate", "creation", "&", "modification", "timestamp" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L335-L359
7,284
projek-xyz/ci-common
src/Model.php
Model.normalize_term
protected function normalize_term($term = null) { if (null === $term) { return []; } if (is_int($term)) { $term = [$this->primary_key => $term]; } if ($_term = $this->call_hook('term.after.normalized', $term)) { $term = $_term; } return $term; }
php
protected function normalize_term($term = null) { if (null === $term) { return []; } if (is_int($term)) { $term = [$this->primary_key => $term]; } if ($_term = $this->call_hook('term.after.normalized', $term)) { $term = $_term; } return $term; }
[ "protected", "function", "normalize_term", "(", "$", "term", "=", "null", ")", "{", "if", "(", "null", "===", "$", "term", ")", "{", "return", "[", "]", ";", "}", "if", "(", "is_int", "(", "$", "term", ")", ")", "{", "$", "term", "=", "[", "$", "this", "->", "primary_key", "=>", "$", "term", "]", ";", "}", "if", "(", "$", "_term", "=", "$", "this", "->", "call_hook", "(", "'term.after.normalized'", ",", "$", "term", ")", ")", "{", "$", "term", "=", "$", "_term", ";", "}", "return", "$", "term", ";", "}" ]
Basic query term normalization @param mixed $term Data term @return array
[ "Basic", "query", "term", "normalization" ]
2cd3f507f378e6a871fcaa87efa88c63ce1282c0
https://github.com/projek-xyz/ci-common/blob/2cd3f507f378e6a871fcaa87efa88c63ce1282c0/src/Model.php#L367-L382
7,285
mszewcz/php-json-schema-validator
src/Validators/NodeValidator.php
NodeValidator.validate
public function validate($subject): bool { foreach ($this->validatorMap as $validatorName => $validatorClass) { if (\array_key_exists($validatorName, $this->schema)) { /** * @var ValidatorInterface $typeValidator */ $typeValidator = new $validatorClass($this->schema, $this->rootSchema); if (!$typeValidator->validate($subject)) { return false; } } } return true; }
php
public function validate($subject): bool { foreach ($this->validatorMap as $validatorName => $validatorClass) { if (\array_key_exists($validatorName, $this->schema)) { /** * @var ValidatorInterface $typeValidator */ $typeValidator = new $validatorClass($this->schema, $this->rootSchema); if (!$typeValidator->validate($subject)) { return false; } } } return true; }
[ "public", "function", "validate", "(", "$", "subject", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "validatorMap", "as", "$", "validatorName", "=>", "$", "validatorClass", ")", "{", "if", "(", "\\", "array_key_exists", "(", "$", "validatorName", ",", "$", "this", "->", "schema", ")", ")", "{", "/**\n * @var ValidatorInterface $typeValidator\n */", "$", "typeValidator", "=", "new", "$", "validatorClass", "(", "$", "this", "->", "schema", ",", "$", "this", "->", "rootSchema", ")", ";", "if", "(", "!", "$", "typeValidator", "->", "validate", "(", "$", "subject", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Single node validator chain @param $subject @return bool
[ "Single", "node", "validator", "chain" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/NodeValidator.php#L81-L95
7,286
tapestry-cloud/database-plugin
src/Hydrators/ContentType.php
ContentType.hydrate
public function hydrate(Model $model, \Tapestry\Entities\ContentType $contentType) { $model->setName($contentType->getName()); $model->setPath($contentType->getPath()); $model->setTemplate($contentType->getTemplate()); $model->setPermalink($contentType->getPermalink()); $model->setEnabled($contentType->isEnabled()); }
php
public function hydrate(Model $model, \Tapestry\Entities\ContentType $contentType) { $model->setName($contentType->getName()); $model->setPath($contentType->getPath()); $model->setTemplate($contentType->getTemplate()); $model->setPermalink($contentType->getPermalink()); $model->setEnabled($contentType->isEnabled()); }
[ "public", "function", "hydrate", "(", "Model", "$", "model", ",", "\\", "Tapestry", "\\", "Entities", "\\", "ContentType", "$", "contentType", ")", "{", "$", "model", "->", "setName", "(", "$", "contentType", "->", "getName", "(", ")", ")", ";", "$", "model", "->", "setPath", "(", "$", "contentType", "->", "getPath", "(", ")", ")", ";", "$", "model", "->", "setTemplate", "(", "$", "contentType", "->", "getTemplate", "(", ")", ")", ";", "$", "model", "->", "setPermalink", "(", "$", "contentType", "->", "getPermalink", "(", ")", ")", ";", "$", "model", "->", "setEnabled", "(", "$", "contentType", "->", "isEnabled", "(", ")", ")", ";", "}" ]
ContentType Hydration. @param Model $model @param \Tapestry\Entities\ContentType $contentType
[ "ContentType", "Hydration", "." ]
b9d0e42c84e1691b8b4b269f81a85723d5e9ac8c
https://github.com/tapestry-cloud/database-plugin/blob/b9d0e42c84e1691b8b4b269f81a85723d5e9ac8c/src/Hydrators/ContentType.php#L15-L22
7,287
canis-io/yii2-canis-lib
lib/base/FileStorage.php
FileStorage.deleteTempFiles
public function deleteTempFiles() { foreach ($this->_tempFiles as $tmp) { if (is_dir($tmp)) { FileHelper::removeDirectory($tmp); } else { @unlink($tmp); } } return true; }
php
public function deleteTempFiles() { foreach ($this->_tempFiles as $tmp) { if (is_dir($tmp)) { FileHelper::removeDirectory($tmp); } else { @unlink($tmp); } } return true; }
[ "public", "function", "deleteTempFiles", "(", ")", "{", "foreach", "(", "$", "this", "->", "_tempFiles", "as", "$", "tmp", ")", "{", "if", "(", "is_dir", "(", "$", "tmp", ")", ")", "{", "FileHelper", "::", "removeDirectory", "(", "$", "tmp", ")", ";", "}", "else", "{", "@", "unlink", "(", "$", "tmp", ")", ";", "}", "}", "return", "true", ";", "}" ]
Delete the tracked temporary file. @return boolean status of temp file deletion
[ "Delete", "the", "tracked", "temporary", "file", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/base/FileStorage.php#L51-L62
7,288
canis-io/yii2-canis-lib
lib/base/FileStorage.php
FileStorage.getTempFile
public function getTempFile($keep = false, $ext = null) { $tmp = tempnam($this->tempPath, "tmp_"); $tmpExt = ''; if (!is_null($ext)) { $tmpExt .= ".{$ext}"; } if (!$keep) { $this->_tempFiles[] = $tmp; if (!empty($tmpExt)) { $tmp = $tmp . $tmpExt; $this->_tempFiles[] = $tmp; } } else { if (!empty($tmpExt)) { $tmp = $tmp . $tmpExt; } } return $tmp; }
php
public function getTempFile($keep = false, $ext = null) { $tmp = tempnam($this->tempPath, "tmp_"); $tmpExt = ''; if (!is_null($ext)) { $tmpExt .= ".{$ext}"; } if (!$keep) { $this->_tempFiles[] = $tmp; if (!empty($tmpExt)) { $tmp = $tmp . $tmpExt; $this->_tempFiles[] = $tmp; } } else { if (!empty($tmpExt)) { $tmp = $tmp . $tmpExt; } } return $tmp; }
[ "public", "function", "getTempFile", "(", "$", "keep", "=", "false", ",", "$", "ext", "=", "null", ")", "{", "$", "tmp", "=", "tempnam", "(", "$", "this", "->", "tempPath", ",", "\"tmp_\"", ")", ";", "$", "tmpExt", "=", "''", ";", "if", "(", "!", "is_null", "(", "$", "ext", ")", ")", "{", "$", "tmpExt", ".=", "\".{$ext}\"", ";", "}", "if", "(", "!", "$", "keep", ")", "{", "$", "this", "->", "_tempFiles", "[", "]", "=", "$", "tmp", ";", "if", "(", "!", "empty", "(", "$", "tmpExt", ")", ")", "{", "$", "tmp", "=", "$", "tmp", ".", "$", "tmpExt", ";", "$", "this", "->", "_tempFiles", "[", "]", "=", "$", "tmp", ";", "}", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "tmpExt", ")", ")", "{", "$", "tmp", "=", "$", "tmp", ".", "$", "tmpExt", ";", "}", "}", "return", "$", "tmp", ";", "}" ]
Get a temporary file. @param boolean $keep Keep the file after request has been processed (optional) @param unknown $ext Extension of temporary file (optional) @return string Temporary file path
[ "Get", "a", "temporary", "file", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/base/FileStorage.php#L72-L92
7,289
canis-io/yii2-canis-lib
lib/base/FileStorage.php
FileStorage.getTempPath
public function getTempPath() { if (is_null($this->_tempPath)) { $this->_tempPath = sys_get_temp_dir(); } if (!is_dir($this->_tempPath)) { @mkdir($this->_tempPath, 0755, true); if (!is_dir($this->_tempPath)) { throw new Exception("Unable to create temporary path folder {$this->_tempPath}"); } } return $this->_tempPath; }
php
public function getTempPath() { if (is_null($this->_tempPath)) { $this->_tempPath = sys_get_temp_dir(); } if (!is_dir($this->_tempPath)) { @mkdir($this->_tempPath, 0755, true); if (!is_dir($this->_tempPath)) { throw new Exception("Unable to create temporary path folder {$this->_tempPath}"); } } return $this->_tempPath; }
[ "public", "function", "getTempPath", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "_tempPath", ")", ")", "{", "$", "this", "->", "_tempPath", "=", "sys_get_temp_dir", "(", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "this", "->", "_tempPath", ")", ")", "{", "@", "mkdir", "(", "$", "this", "->", "_tempPath", ",", "0755", ",", "true", ")", ";", "if", "(", "!", "is_dir", "(", "$", "this", "->", "_tempPath", ")", ")", "{", "throw", "new", "Exception", "(", "\"Unable to create temporary path folder {$this->_tempPath}\"", ")", ";", "}", "}", "return", "$", "this", "->", "_tempPath", ";", "}" ]
Get a temporary path. @throws Exception [[@doctodo exception_description:Exception]] @return string Temporary file path
[ "Get", "a", "temporary", "path", "." ]
97d533521f65b084dc805c5f312c364b469142d2
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/base/FileStorage.php#L105-L118
7,290
n0m4dz/laracasa
Zend/Gdata/App/Feed.php
Zend_Gdata_App_Feed.getDOM
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) { $element = parent::getDOM($doc, $majorVersion, $minorVersion); foreach ($this->_entry as $entry) { $element->appendChild($entry->getDOM($element->ownerDocument)); } return $element; }
php
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) { $element = parent::getDOM($doc, $majorVersion, $minorVersion); foreach ($this->_entry as $entry) { $element->appendChild($entry->getDOM($element->ownerDocument)); } return $element; }
[ "public", "function", "getDOM", "(", "$", "doc", "=", "null", ",", "$", "majorVersion", "=", "1", ",", "$", "minorVersion", "=", "null", ")", "{", "$", "element", "=", "parent", "::", "getDOM", "(", "$", "doc", ",", "$", "majorVersion", ",", "$", "minorVersion", ")", ";", "foreach", "(", "$", "this", "->", "_entry", "as", "$", "entry", ")", "{", "$", "element", "->", "appendChild", "(", "$", "entry", "->", "getDOM", "(", "$", "element", "->", "ownerDocument", ")", ")", ";", "}", "return", "$", "element", ";", "}" ]
Retrieves the DOM model representing this object and all children @param DOMDocument $doc @return DOMElement
[ "Retrieves", "the", "DOM", "model", "representing", "this", "object", "and", "all", "children" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/Feed.php#L95-L102
7,291
n0m4dz/laracasa
Zend/Gdata/App/Feed.php
Zend_Gdata_App_Feed.getNextFeed
public function getNextFeed() { $nextLink = $this->getNextLink(); if (!$nextLink) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_Exception('No link to next set ' . 'of results found.'); } $nextLinkHref = $nextLink->getHref(); $service = new Zend_Gdata_App($this->getHttpClient()); return $service->getFeed($nextLinkHref, get_class($this)); }
php
public function getNextFeed() { $nextLink = $this->getNextLink(); if (!$nextLink) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_Exception('No link to next set ' . 'of results found.'); } $nextLinkHref = $nextLink->getHref(); $service = new Zend_Gdata_App($this->getHttpClient()); return $service->getFeed($nextLinkHref, get_class($this)); }
[ "public", "function", "getNextFeed", "(", ")", "{", "$", "nextLink", "=", "$", "this", "->", "getNextLink", "(", ")", ";", "if", "(", "!", "$", "nextLink", ")", "{", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_Exception", "(", "'No link to next set '", ".", "'of results found.'", ")", ";", "}", "$", "nextLinkHref", "=", "$", "nextLink", "->", "getHref", "(", ")", ";", "$", "service", "=", "new", "Zend_Gdata_App", "(", "$", "this", "->", "getHttpClient", "(", ")", ")", ";", "return", "$", "service", "->", "getFeed", "(", "$", "nextLinkHref", ",", "get_class", "(", "$", "this", ")", ")", ";", "}" ]
Retrieve the next set of results from this feed. @throws Zend_Gdata_App_Exception @return mixed|null Returns the next set of results as a feed of the same class as this feed, or null if no results exist.
[ "Retrieve", "the", "next", "set", "of", "results", "from", "this", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/Feed.php#L280-L292
7,292
n0m4dz/laracasa
Zend/Gdata/App/Feed.php
Zend_Gdata_App_Feed.getPreviousFeed
public function getPreviousFeed() { $previousLink = $this->getPreviousLink(); if (!$previousLink) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_Exception('No link to previous set ' . 'of results found.'); } $previousLinkHref = $previousLink->getHref(); $service = new Zend_Gdata_App($this->getHttpClient()); return $service->getFeed($previousLinkHref, get_class($this)); }
php
public function getPreviousFeed() { $previousLink = $this->getPreviousLink(); if (!$previousLink) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_Exception('No link to previous set ' . 'of results found.'); } $previousLinkHref = $previousLink->getHref(); $service = new Zend_Gdata_App($this->getHttpClient()); return $service->getFeed($previousLinkHref, get_class($this)); }
[ "public", "function", "getPreviousFeed", "(", ")", "{", "$", "previousLink", "=", "$", "this", "->", "getPreviousLink", "(", ")", ";", "if", "(", "!", "$", "previousLink", ")", "{", "require_once", "'Zend/Gdata/App/HttpException.php'", ";", "throw", "new", "Zend_Gdata_App_Exception", "(", "'No link to previous set '", ".", "'of results found.'", ")", ";", "}", "$", "previousLinkHref", "=", "$", "previousLink", "->", "getHref", "(", ")", ";", "$", "service", "=", "new", "Zend_Gdata_App", "(", "$", "this", "->", "getHttpClient", "(", ")", ")", ";", "return", "$", "service", "->", "getFeed", "(", "$", "previousLinkHref", ",", "get_class", "(", "$", "this", ")", ")", ";", "}" ]
Retrieve the previous set of results from this feed. @throws Zend_Gdata_App_Exception @return mixed|null Returns the previous set of results as a feed of the same class as this feed, or null if no results exist.
[ "Retrieve", "the", "previous", "set", "of", "results", "from", "this", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/Feed.php#L301-L313
7,293
n0m4dz/laracasa
Zend/Gdata/App/Feed.php
Zend_Gdata_App_Feed.setMajorProtocolVersion
public function setMajorProtocolVersion($value) { parent::setMajorProtocolVersion($value); foreach ($this->entries as $entry) { $entry->setMajorProtocolVersion($value); } }
php
public function setMajorProtocolVersion($value) { parent::setMajorProtocolVersion($value); foreach ($this->entries as $entry) { $entry->setMajorProtocolVersion($value); } }
[ "public", "function", "setMajorProtocolVersion", "(", "$", "value", ")", "{", "parent", "::", "setMajorProtocolVersion", "(", "$", "value", ")", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "$", "entry", "->", "setMajorProtocolVersion", "(", "$", "value", ")", ";", "}", "}" ]
Set the major protocol version that should be used. Values < 1 will cause a Zend_Gdata_App_InvalidArgumentException to be thrown. This value will be propogated to all child entries. @see _majorProtocolVersion @param (int|NULL) $value The major protocol version to use. @throws Zend_Gdata_App_InvalidArgumentException
[ "Set", "the", "major", "protocol", "version", "that", "should", "be", "used", ".", "Values", "<", "1", "will", "cause", "a", "Zend_Gdata_App_InvalidArgumentException", "to", "be", "thrown", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/Feed.php#L325-L331
7,294
n0m4dz/laracasa
Zend/Gdata/App/Feed.php
Zend_Gdata_App_Feed.setMinorProtocolVersion
public function setMinorProtocolVersion($value) { parent::setMinorProtocolVersion($value); foreach ($this->entries as $entry) { $entry->setMinorProtocolVersion($value); } }
php
public function setMinorProtocolVersion($value) { parent::setMinorProtocolVersion($value); foreach ($this->entries as $entry) { $entry->setMinorProtocolVersion($value); } }
[ "public", "function", "setMinorProtocolVersion", "(", "$", "value", ")", "{", "parent", "::", "setMinorProtocolVersion", "(", "$", "value", ")", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "$", "entry", "->", "setMinorProtocolVersion", "(", "$", "value", ")", ";", "}", "}" ]
Set the minor protocol version that should be used. If set to NULL, no minor protocol version will be sent to the server. Values < 0 will cause a Zend_Gdata_App_InvalidArgumentException to be thrown. This value will be propogated to all child entries. @see _minorProtocolVersion @param (int|NULL) $value The minor protocol version to use. @throws Zend_Gdata_App_InvalidArgumentException
[ "Set", "the", "minor", "protocol", "version", "that", "should", "be", "used", ".", "If", "set", "to", "NULL", "no", "minor", "protocol", "version", "will", "be", "sent", "to", "the", "server", ".", "Values", "<", "0", "will", "cause", "a", "Zend_Gdata_App_InvalidArgumentException", "to", "be", "thrown", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/App/Feed.php#L344-L350
7,295
open-orchestra/open-orchestra-media-admin-bundle
MediaAdminBundle/DataFixtures/MongoDB/LoadMediaThumbnailData.php
LoadMediaThumbnailData.deployThumbnail
protected function deployThumbnail($thumbnailName) { $mediaStorageManager = $this->container->get('open_orchestra_media.manager.storage'); $fileDir = 'web/bundles/openorchestramediaadmin/images/'; $mediaStorageManager->uploadFile($thumbnailName, $fileDir . DIRECTORY_SEPARATOR . $thumbnailName, false); }
php
protected function deployThumbnail($thumbnailName) { $mediaStorageManager = $this->container->get('open_orchestra_media.manager.storage'); $fileDir = 'web/bundles/openorchestramediaadmin/images/'; $mediaStorageManager->uploadFile($thumbnailName, $fileDir . DIRECTORY_SEPARATOR . $thumbnailName, false); }
[ "protected", "function", "deployThumbnail", "(", "$", "thumbnailName", ")", "{", "$", "mediaStorageManager", "=", "$", "this", "->", "container", "->", "get", "(", "'open_orchestra_media.manager.storage'", ")", ";", "$", "fileDir", "=", "'web/bundles/openorchestramediaadmin/images/'", ";", "$", "mediaStorageManager", "->", "uploadFile", "(", "$", "thumbnailName", ",", "$", "fileDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "thumbnailName", ",", "false", ")", ";", "}" ]
Deploy a logo on the media storage @param string $thumbnailName
[ "Deploy", "a", "logo", "on", "the", "media", "storage" ]
743fa00a6491b84d67221e215a806d8b210bf773
https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdminBundle/DataFixtures/MongoDB/LoadMediaThumbnailData.php#L46-L52
7,296
XTAIN/JoomlaBundle
Resources/joomla/com_symfony/site/router.php
SymfonyRouter.parse
public function parse(&$segments) { $active = $this->menu->getActive(); $vars = []; if (!empty($active)) { $vars = $active->query; } return array_merge( $vars, array( 'path' => implode('/', $segments) ) ); }
php
public function parse(&$segments) { $active = $this->menu->getActive(); $vars = []; if (!empty($active)) { $vars = $active->query; } return array_merge( $vars, array( 'path' => implode('/', $segments) ) ); }
[ "public", "function", "parse", "(", "&", "$", "segments", ")", "{", "$", "active", "=", "$", "this", "->", "menu", "->", "getActive", "(", ")", ";", "$", "vars", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "active", ")", ")", "{", "$", "vars", "=", "$", "active", "->", "query", ";", "}", "return", "array_merge", "(", "$", "vars", ",", "array", "(", "'path'", "=>", "implode", "(", "'/'", ",", "$", "segments", ")", ")", ")", ";", "}" ]
Parse method for URLs This method is meant to transform the human readable URL back into query parameters. It is only executed when SEF mode is switched on. @param array &$segments The segments of the URL to parse. @return array The URL attributes to be used by the application. @since 3.3
[ "Parse", "method", "for", "URLs", "This", "method", "is", "meant", "to", "transform", "the", "human", "readable", "URL", "back", "into", "query", "parameters", ".", "It", "is", "only", "executed", "when", "SEF", "mode", "is", "switched", "on", "." ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Resources/joomla/com_symfony/site/router.php#L82-L97
7,297
Talesoft/tale-stream
src/Stream/Iterator/WriteIterator.php
WriteIterator.getIterator
public function getIterator(): \Generator { foreach ($this->sourceIterable as $content) { try { yield $this->stream->write($content); } catch (\InvalidArgumentException $ex) { throw new \RuntimeException('The iterable generated values that are not writable', 0, $ex); } } }
php
public function getIterator(): \Generator { foreach ($this->sourceIterable as $content) { try { yield $this->stream->write($content); } catch (\InvalidArgumentException $ex) { throw new \RuntimeException('The iterable generated values that are not writable', 0, $ex); } } }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Generator", "{", "foreach", "(", "$", "this", "->", "sourceIterable", "as", "$", "content", ")", "{", "try", "{", "yield", "$", "this", "->", "stream", "->", "write", "(", "$", "content", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "ex", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'The iterable generated values that are not writable'", ",", "0", ",", "$", "ex", ")", ";", "}", "}", "}" ]
Generates integer values for the amount of written bytes in each iteration. @return \Generator
[ "Generates", "integer", "values", "for", "the", "amount", "of", "written", "bytes", "in", "each", "iteration", "." ]
13cdaa8cbc2daf833af98c67bf14121ea18c80aa
https://github.com/Talesoft/tale-stream/blob/13cdaa8cbc2daf833af98c67bf14121ea18c80aa/src/Stream/Iterator/WriteIterator.php#L69-L78
7,298
projek-xyz/ci-console
src/Cli.php
Cli.force_ansi
public function force_ansi($enable = true) { if ($enable) { $this->climate->forceAnsiOn(); } else { $this->climate->forceAnsiOff(); } return $this; }
php
public function force_ansi($enable = true) { if ($enable) { $this->climate->forceAnsiOn(); } else { $this->climate->forceAnsiOff(); } return $this; }
[ "public", "function", "force_ansi", "(", "$", "enable", "=", "true", ")", "{", "if", "(", "$", "enable", ")", "{", "$", "this", "->", "climate", "->", "forceAnsiOn", "(", ")", ";", "}", "else", "{", "$", "this", "->", "climate", "->", "forceAnsiOff", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Toggle ANSI support on or off @param bool $enable Switcer on or off @param \Projek\CI\Console\Cli
[ "Toggle", "ANSI", "support", "on", "or", "off" ]
1944b97c25fba06886c70917d93c551d93e89129
https://github.com/projek-xyz/ci-console/blob/1944b97c25fba06886c70917d93c551d93e89129/src/Cli.php#L194-L203
7,299
projek-xyz/ci-console
src/Cli.php
Cli.set_description
public function set_description($desc) { if (substr($desc, 0, 5) == 'lang:') { $desc = substr($desc, 5); if ($_desc = self::lang($desc)) { return $this->climate->arguments->description($_desc); } } return $this->climate->arguments->description($desc); }
php
public function set_description($desc) { if (substr($desc, 0, 5) == 'lang:') { $desc = substr($desc, 5); if ($_desc = self::lang($desc)) { return $this->climate->arguments->description($_desc); } } return $this->climate->arguments->description($desc); }
[ "public", "function", "set_description", "(", "$", "desc", ")", "{", "if", "(", "substr", "(", "$", "desc", ",", "0", ",", "5", ")", "==", "'lang:'", ")", "{", "$", "desc", "=", "substr", "(", "$", "desc", ",", "5", ")", ";", "if", "(", "$", "_desc", "=", "self", "::", "lang", "(", "$", "desc", ")", ")", "{", "return", "$", "this", "->", "climate", "->", "arguments", "->", "description", "(", "$", "_desc", ")", ";", "}", "}", "return", "$", "this", "->", "climate", "->", "arguments", "->", "description", "(", "$", "desc", ")", ";", "}" ]
Set a program's description. @param string $desc
[ "Set", "a", "program", "s", "description", "." ]
1944b97c25fba06886c70917d93c551d93e89129
https://github.com/projek-xyz/ci-console/blob/1944b97c25fba06886c70917d93c551d93e89129/src/Cli.php#L228-L237