id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
39,000
ikkez/f3-fal
lib/fal.php
FAL.instance
static public function instance() { $f3 = \Base::instance(); $dir = $f3->split($f3->get('UI')); $localFS = new \FAL\LocalFS($dir[0]); return new self($localFS); }
php
static public function instance() { $f3 = \Base::instance(); $dir = $f3->split($f3->get('UI')); $localFS = new \FAL\LocalFS($dir[0]); return new self($localFS); }
[ "static", "public", "function", "instance", "(", ")", "{", "$", "f3", "=", "\\", "Base", "::", "instance", "(", ")", ";", "$", "dir", "=", "$", "f3", "->", "split", "(", "$", "f3", "->", "get", "(", "'UI'", ")", ")", ";", "$", "localFS", "=", ...
create FAL on local filesystem as prefab default @return mixed
[ "create", "FAL", "on", "local", "filesystem", "as", "prefab", "default" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L57-L62
39,001
ikkez/f3-fal
lib/fal.php
FAL.load
public function load($file,$ttl = 0) { $this->reset(); $cache = \Cache::instance(); $this->file = $file; $this->changed = false; $this->ttl = $ttl; $cacheHash = $this->getCacheHash($file); if ($this->f3->get('CACHE') && $ttl && ($cached = $cache->exists( $cacheHash,$content)) && $cached[0] + $ttl > microtime(TRUE) ) { // load from cache $this->content = $content; $this->meta = $this->metaHandle->load($file,$ttl); } elseif ($this->fs->exists($file)) { // load from FS $this->meta = $this->metaHandle->load($file,$ttl); // if caching is on, save content to cache backend, otherwise it gets lazy loaded if ($this->f3->get('CACHE') && $ttl) { $this->content = $this->fs->read($file); $cache->set($cacheHash, $this->content, $ttl); } } }
php
public function load($file,$ttl = 0) { $this->reset(); $cache = \Cache::instance(); $this->file = $file; $this->changed = false; $this->ttl = $ttl; $cacheHash = $this->getCacheHash($file); if ($this->f3->get('CACHE') && $ttl && ($cached = $cache->exists( $cacheHash,$content)) && $cached[0] + $ttl > microtime(TRUE) ) { // load from cache $this->content = $content; $this->meta = $this->metaHandle->load($file,$ttl); } elseif ($this->fs->exists($file)) { // load from FS $this->meta = $this->metaHandle->load($file,$ttl); // if caching is on, save content to cache backend, otherwise it gets lazy loaded if ($this->f3->get('CACHE') && $ttl) { $this->content = $this->fs->read($file); $cache->set($cacheHash, $this->content, $ttl); } } }
[ "public", "function", "load", "(", "$", "file", ",", "$", "ttl", "=", "0", ")", "{", "$", "this", "->", "reset", "(", ")", ";", "$", "cache", "=", "\\", "Cache", "::", "instance", "(", ")", ";", "$", "this", "->", "file", "=", "$", "file", ";...
loads a file and it's meta data @param string $file @param int $ttl
[ "loads", "a", "file", "and", "it", "s", "meta", "data" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L102-L125
39,002
ikkez/f3-fal
lib/fal.php
FAL.delete
public function delete($file = null) { $file = $file ?: $this->file; if ($this->fs->exists($file)) $this->fs->delete($file); if ($this->f3->get('CACHE')) { $cache = \Cache::instance(); if($cache->exists($cacheHash = $this->getCacheHash($file))) $cache->clear($cacheHash); } $this->metaHandle->delete($file); }
php
public function delete($file = null) { $file = $file ?: $this->file; if ($this->fs->exists($file)) $this->fs->delete($file); if ($this->f3->get('CACHE')) { $cache = \Cache::instance(); if($cache->exists($cacheHash = $this->getCacheHash($file))) $cache->clear($cacheHash); } $this->metaHandle->delete($file); }
[ "public", "function", "delete", "(", "$", "file", "=", "null", ")", "{", "$", "file", "=", "$", "file", "?", ":", "$", "this", "->", "file", ";", "if", "(", "$", "this", "->", "fs", "->", "exists", "(", "$", "file", ")", ")", "$", "this", "->...
delete a file and it's meta data @param null $file
[ "delete", "a", "file", "and", "it", "s", "meta", "data" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L146-L157
39,003
ikkez/f3-fal
lib/fal.php
FAL.&
public function &get($key) { $out = ($this->exists($key)) ? $this->meta[$key] : false; return $out; }
php
public function &get($key) { $out = ($this->exists($key)) ? $this->meta[$key] : false; return $out; }
[ "public", "function", "&", "get", "(", "$", "key", ")", "{", "$", "out", "=", "(", "$", "this", "->", "exists", "(", "$", "key", ")", ")", "?", "$", "this", "->", "meta", "[", "$", "key", "]", ":", "false", ";", "return", "$", "out", ";", "...
get meta data field @param $key @return bool
[ "get", "meta", "data", "field" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L182-L186
39,004
ikkez/f3-fal
lib/fal.php
FAL.exists
public function exists($key) { if(empty($this->meta)) return false; return array_key_exists($key, $this->meta); }
php
public function exists($key) { if(empty($this->meta)) return false; return array_key_exists($key, $this->meta); }
[ "public", "function", "exists", "(", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "meta", ")", ")", "return", "false", ";", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "meta", ")", ";", "}" ]
check whether meta field exists @param $key @return bool
[ "check", "whether", "meta", "field", "exists" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L204-L208
39,005
ikkez/f3-fal
lib/fal.php
FAL.reset
public function reset() { $this->meta = false; $this->file = false; $this->content = false; $this->changed = false; $this->ttl = 0; $this->cacheHash = null; }
php
public function reset() { $this->meta = false; $this->file = false; $this->content = false; $this->changed = false; $this->ttl = 0; $this->cacheHash = null; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "meta", "=", "false", ";", "$", "this", "->", "file", "=", "false", ";", "$", "this", "->", "content", "=", "false", ";", "$", "this", "->", "changed", "=", "false", ";", "$", "this...
free the layer of loaded data
[ "free", "the", "layer", "of", "loaded", "data" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L222-L230
39,006
ikkez/f3-fal
lib/fal.php
FAL.getContent
public function getContent() { if(!empty($this->content)) return $this->content; elseif ($this->fs->exists($this->file)) { $this->content = $this->fs->read($this->file); return $this->content; } else return false; }
php
public function getContent() { if(!empty($this->content)) return $this->content; elseif ($this->fs->exists($this->file)) { $this->content = $this->fs->read($this->file); return $this->content; } else return false; }
[ "public", "function", "getContent", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "content", ")", ")", "return", "$", "this", "->", "content", ";", "elseif", "(", "$", "this", "->", "fs", "->", "exists", "(", "$", "this", "->", ...
lazy load file contents @return mixed|bool
[ "lazy", "load", "file", "contents" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L236-L245
39,007
ikkez/f3-fal
lib/fal.php
FAL.getFileStream
public function getFileStream() { $stream = new \FAL\FileStream(); $pt = $stream->getProtocolName(); file_put_contents($path = $pt.'://'.$this->file,$this->getContent()); return $path; }
php
public function getFileStream() { $stream = new \FAL\FileStream(); $pt = $stream->getProtocolName(); file_put_contents($path = $pt.'://'.$this->file,$this->getContent()); return $path; }
[ "public", "function", "getFileStream", "(", ")", "{", "$", "stream", "=", "new", "\\", "FAL", "\\", "FileStream", "(", ")", ";", "$", "pt", "=", "$", "stream", "->", "getProtocolName", "(", ")", ";", "file_put_contents", "(", "$", "path", "=", "$", "...
return file stream path @return string
[ "return", "file", "stream", "path" ]
ebd593306bab008210b2d16ffffca599c667d7fe
https://github.com/ikkez/f3-fal/blob/ebd593306bab008210b2d16ffffca599c667d7fe/lib/fal.php#L261-L266
39,008
raoul2000/yii2-bootswatch-asset
BootswatchAsset.php
BootswatchAsset.init
public function init() { if ( self::$theme != null) { if ( ! is_string(self::$theme) ) { throw new InvalidConfigException('No theme Bootswatch configured : set BootswatchAsset::$theme to the theme name you want to use'); } $this->css = [ strtolower(self::$theme).'/bootstrap'.( YII_ENV_DEV ? '.css' : '.min.css' ) ]; // optimized asset publication : only publish bootswatch theme folders and font folder. $this->publishOptions['beforeCopy'] = function ($from, $to) { if ( is_dir($from)) { $name = pathinfo($from,PATHINFO_BASENAME); return ! in_array($name, ['2','api','assets','bower_components','tests','help','global','default']); } else { $ext = pathinfo($from,PATHINFO_EXTENSION); return in_array($ext,['css','eot','svg','ttf','woff','woff2']); } }; } parent::init(); }
php
public function init() { if ( self::$theme != null) { if ( ! is_string(self::$theme) ) { throw new InvalidConfigException('No theme Bootswatch configured : set BootswatchAsset::$theme to the theme name you want to use'); } $this->css = [ strtolower(self::$theme).'/bootstrap'.( YII_ENV_DEV ? '.css' : '.min.css' ) ]; // optimized asset publication : only publish bootswatch theme folders and font folder. $this->publishOptions['beforeCopy'] = function ($from, $to) { if ( is_dir($from)) { $name = pathinfo($from,PATHINFO_BASENAME); return ! in_array($name, ['2','api','assets','bower_components','tests','help','global','default']); } else { $ext = pathinfo($from,PATHINFO_EXTENSION); return in_array($ext,['css','eot','svg','ttf','woff','woff2']); } }; } parent::init(); }
[ "public", "function", "init", "(", ")", "{", "if", "(", "self", "::", "$", "theme", "!=", "null", ")", "{", "if", "(", "!", "is_string", "(", "self", "::", "$", "theme", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "'No theme Bootswatc...
Initialize the class properties depending on the current active theme. When debug mode is disabled, the minified version of the css is used. @see \yii\web\AssetBundle::init()
[ "Initialize", "the", "class", "properties", "depending", "on", "the", "current", "active", "theme", "." ]
39d89d94d892c0162334a5927a308f781e075da1
https://github.com/raoul2000/yii2-bootswatch-asset/blob/39d89d94d892c0162334a5927a308f781e075da1/BootswatchAsset.php#L36-L59
39,009
raoul2000/yii2-bootswatch-asset
BootswatchAsset.php
BootswatchAsset.isSupportedTheme
static function isSupportedTheme($theme) { if (! is_string($theme) || empty($theme)) { throw new InvalidCallException('Invalid theme value : empty or null value'); } return file_exists(Yii::getAlias(BootswatchAsset::VENDOR_ALIAS . '/' . strtolower($theme) . '/bootstrap.min.css')); }
php
static function isSupportedTheme($theme) { if (! is_string($theme) || empty($theme)) { throw new InvalidCallException('Invalid theme value : empty or null value'); } return file_exists(Yii::getAlias(BootswatchAsset::VENDOR_ALIAS . '/' . strtolower($theme) . '/bootstrap.min.css')); }
[ "static", "function", "isSupportedTheme", "(", "$", "theme", ")", "{", "if", "(", "!", "is_string", "(", "$", "theme", ")", "||", "empty", "(", "$", "theme", ")", ")", "{", "throw", "new", "InvalidCallException", "(", "'Invalid theme value : empty or null valu...
Chekcs if a theme is a valid bootswatch theme. This basic method assumes the $theme name passed as argument is an existing subfolder of the vendor alias folder (@vendor/thomaspark/bootswatch) that contains the file 'bootstrap.min.css'. If this condition is not true, the theme is invalid. @param string $theme the theme name to test @return boolean TRUE if $theme is a valid bootswatch theme, FALSE otherwise
[ "Chekcs", "if", "a", "theme", "is", "a", "valid", "bootswatch", "theme", "." ]
39d89d94d892c0162334a5927a308f781e075da1
https://github.com/raoul2000/yii2-bootswatch-asset/blob/39d89d94d892c0162334a5927a308f781e075da1/BootswatchAsset.php#L71-L77
39,010
gpslab/domain-event
src/Aggregator/AggregateEventsRaiseInSelfTrait.php
AggregateEventsRaiseInSelfTrait.eventHandlerName
protected function eventHandlerName(Event $event) { $class = get_class($event); if ('Event' === substr($class, -5)) { $class = substr($class, 0, -5); } $class = str_replace('_', '\\', $class); // convert names for classes not in namespace $parts = explode('\\', $class); return 'on'.end($parts); }
php
protected function eventHandlerName(Event $event) { $class = get_class($event); if ('Event' === substr($class, -5)) { $class = substr($class, 0, -5); } $class = str_replace('_', '\\', $class); // convert names for classes not in namespace $parts = explode('\\', $class); return 'on'.end($parts); }
[ "protected", "function", "eventHandlerName", "(", "Event", "$", "event", ")", "{", "$", "class", "=", "get_class", "(", "$", "event", ")", ";", "if", "(", "'Event'", "===", "substr", "(", "$", "class", ",", "-", "5", ")", ")", "{", "$", "class", "=...
Get handler method name from event. Override this method if you want to change algorithm to generate the handler method name. @param Event $event @return string
[ "Get", "handler", "method", "name", "from", "event", "." ]
3db48d8f4b85c8da14aa2ff113fe79aa021394b4
https://github.com/gpslab/domain-event/blob/3db48d8f4b85c8da14aa2ff113fe79aa021394b4/src/Aggregator/AggregateEventsRaiseInSelfTrait.php#L63-L75
39,011
tavo1987/ec-validador-cedula-ruc
src/ValidadorEc.php
ValidadorEc.validarRucSociedadPrivada
public function validarRucSociedadPrivada($numero = '') { // fuerzo parametro de entrada a string $numero = (string) $numero; // borro por si acaso errores de llamadas anteriores. $this->setError(''); // validaciones try { $this->validarInicial($numero, '13'); $this->validarCodigoProvincia(substr($numero, 0, 2)); $this->validarTercerDigito($numero[2], 'ruc_privada'); $this->validarCodigoEstablecimiento(substr($numero, 10, 3)); $this->algoritmoModulo11(substr($numero, 0, 9), $numero[9], 'ruc_privada'); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } return true; }
php
public function validarRucSociedadPrivada($numero = '') { // fuerzo parametro de entrada a string $numero = (string) $numero; // borro por si acaso errores de llamadas anteriores. $this->setError(''); // validaciones try { $this->validarInicial($numero, '13'); $this->validarCodigoProvincia(substr($numero, 0, 2)); $this->validarTercerDigito($numero[2], 'ruc_privada'); $this->validarCodigoEstablecimiento(substr($numero, 10, 3)); $this->algoritmoModulo11(substr($numero, 0, 9), $numero[9], 'ruc_privada'); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } return true; }
[ "public", "function", "validarRucSociedadPrivada", "(", "$", "numero", "=", "''", ")", "{", "// fuerzo parametro de entrada a string", "$", "numero", "=", "(", "string", ")", "$", "numero", ";", "// borro por si acaso errores de llamadas anteriores.", "$", "this", "->",...
Validar RUC sociedad privada. @param string $numero Número de RUC sociedad privada @return bool
[ "Validar", "RUC", "sociedad", "privada", "." ]
379b50bc5dfda20d935df2bdd3c0de94e4fc024e
https://github.com/tavo1987/ec-validador-cedula-ruc/blob/379b50bc5dfda20d935df2bdd3c0de94e4fc024e/src/ValidadorEc.php#L96-L118
39,012
gpslab/domain-event
src/Bus/ListenerLocatedEventBus.php
ListenerLocatedEventBus.publish
public function publish(Event $event) { foreach ($this->locator->listenersOfEvent($event) as $listener) { call_user_func($listener, $event); } }
php
public function publish(Event $event) { foreach ($this->locator->listenersOfEvent($event) as $listener) { call_user_func($listener, $event); } }
[ "public", "function", "publish", "(", "Event", "$", "event", ")", "{", "foreach", "(", "$", "this", "->", "locator", "->", "listenersOfEvent", "(", "$", "event", ")", "as", "$", "listener", ")", "{", "call_user_func", "(", "$", "listener", ",", "$", "e...
Publishes the event to every listener that wants to. @param Event $event
[ "Publishes", "the", "event", "to", "every", "listener", "that", "wants", "to", "." ]
3db48d8f4b85c8da14aa2ff113fe79aa021394b4
https://github.com/gpslab/domain-event/blob/3db48d8f4b85c8da14aa2ff113fe79aa021394b4/src/Bus/ListenerLocatedEventBus.php#L36-L41
39,013
gpslab/domain-event
src/Queue/Subscribe/PredisSubscribeEventQueue.php
PredisSubscribeEventQueue.subscribe
public function subscribe(callable $handler) { $this->handlers[] = $handler; // laze subscribe if (!$this->subscribed) { $this->client->subscribe($this->queue_name, function ($message) { $this->handle($message); }); $this->subscribed = true; } }
php
public function subscribe(callable $handler) { $this->handlers[] = $handler; // laze subscribe if (!$this->subscribed) { $this->client->subscribe($this->queue_name, function ($message) { $this->handle($message); }); $this->subscribed = true; } }
[ "public", "function", "subscribe", "(", "callable", "$", "handler", ")", "{", "$", "this", "->", "handlers", "[", "]", "=", "$", "handler", ";", "// laze subscribe", "if", "(", "!", "$", "this", "->", "subscribed", ")", "{", "$", "this", "->", "client"...
Subscribe on event queue. @param callable $handler
[ "Subscribe", "on", "event", "queue", "." ]
3db48d8f4b85c8da14aa2ff113fe79aa021394b4
https://github.com/gpslab/domain-event/blob/3db48d8f4b85c8da14aa2ff113fe79aa021394b4/src/Queue/Subscribe/PredisSubscribeEventQueue.php#L88-L99
39,014
gpslab/domain-event
src/Queue/Subscribe/PredisSubscribeEventQueue.php
PredisSubscribeEventQueue.unsubscribe
public function unsubscribe(callable $handler) { $index = array_search($handler, $this->handlers); if ($index === false) { return false; } unset($this->handlers[$index]); return true; }
php
public function unsubscribe(callable $handler) { $index = array_search($handler, $this->handlers); if ($index === false) { return false; } unset($this->handlers[$index]); return true; }
[ "public", "function", "unsubscribe", "(", "callable", "$", "handler", ")", "{", "$", "index", "=", "array_search", "(", "$", "handler", ",", "$", "this", "->", "handlers", ")", ";", "if", "(", "$", "index", "===", "false", ")", "{", "return", "false", ...
Unsubscribe on event queue. @param callable $handler @return bool
[ "Unsubscribe", "on", "event", "queue", "." ]
3db48d8f4b85c8da14aa2ff113fe79aa021394b4
https://github.com/gpslab/domain-event/blob/3db48d8f4b85c8da14aa2ff113fe79aa021394b4/src/Queue/Subscribe/PredisSubscribeEventQueue.php#L108-L119
39,015
sjaakp/yii2-illustrated-behavior
Illustration.php
Illustration.deleteFiles
public function deleteFiles() { $fileName = $this->_model->{$this->attribute}; if (! empty($fileName)) { $size = $this->cropSize; if ($this->sizeSteps && $size > 0) { $minSize = $size >> ($this->sizeSteps - 1); while ($size >= $minSize) { $path = $this->imgBaseDir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . $fileName; if (file_exists($path)) unlink($path); $size >>= 1; } } else { $path = $this->imgBaseDir . DIRECTORY_SEPARATOR . $fileName; if (file_exists($path)) unlink($path); } $this->_model->{$this->attribute} = null; if (! is_numeric($this->aspectRatio)) $this->_model->{$this->aspectRatio} = null; } }
php
public function deleteFiles() { $fileName = $this->_model->{$this->attribute}; if (! empty($fileName)) { $size = $this->cropSize; if ($this->sizeSteps && $size > 0) { $minSize = $size >> ($this->sizeSteps - 1); while ($size >= $minSize) { $path = $this->imgBaseDir . DIRECTORY_SEPARATOR . $size . DIRECTORY_SEPARATOR . $fileName; if (file_exists($path)) unlink($path); $size >>= 1; } } else { $path = $this->imgBaseDir . DIRECTORY_SEPARATOR . $fileName; if (file_exists($path)) unlink($path); } $this->_model->{$this->attribute} = null; if (! is_numeric($this->aspectRatio)) $this->_model->{$this->aspectRatio} = null; } }
[ "public", "function", "deleteFiles", "(", ")", "{", "$", "fileName", "=", "$", "this", "->", "_model", "->", "{", "$", "this", "->", "attribute", "}", ";", "if", "(", "!", "empty", "(", "$", "fileName", ")", ")", "{", "$", "size", "=", "$", "this...
Delete image files and clear imgAttribute
[ "Delete", "image", "files", "and", "clear", "imgAttribute" ]
940d93fd84d008bacd4a0716c773e442a6299724
https://github.com/sjaakp/yii2-illustrated-behavior/blob/940d93fd84d008bacd4a0716c773e442a6299724/Illustration.php#L237-L259
39,016
jralph/Twig-Markdown
src/Node.php
Node.compile
public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this) ->write('ob_start();' . PHP_EOL) ->subcompile($this->getNode('value')) ->write('$content = ob_get_clean();' . PHP_EOL) ->write('preg_match("/^\s*/", $content, $matches);' . PHP_EOL) ->write('$lines = explode("\n", $content);'.PHP_EOL) ->write('$content = preg_replace(\'/^\' . $matches[0]. \'/\', "", $lines);' . PHP_EOL) ->write('$content = implode("\n", $content);' . PHP_EOL) ->write('echo $this->env->getTags()["markdown"] ->getMarkdown() ->parse($content); '.PHP_EOL); }
php
public function compile(Twig_Compiler $compiler) { $compiler->addDebugInfo($this) ->write('ob_start();' . PHP_EOL) ->subcompile($this->getNode('value')) ->write('$content = ob_get_clean();' . PHP_EOL) ->write('preg_match("/^\s*/", $content, $matches);' . PHP_EOL) ->write('$lines = explode("\n", $content);'.PHP_EOL) ->write('$content = preg_replace(\'/^\' . $matches[0]. \'/\', "", $lines);' . PHP_EOL) ->write('$content = implode("\n", $content);' . PHP_EOL) ->write('echo $this->env->getTags()["markdown"] ->getMarkdown() ->parse($content); '.PHP_EOL); }
[ "public", "function", "compile", "(", "Twig_Compiler", "$", "compiler", ")", "{", "$", "compiler", "->", "addDebugInfo", "(", "$", "this", ")", "->", "write", "(", "'ob_start();'", ".", "PHP_EOL", ")", "->", "subcompile", "(", "$", "this", "->", "getNode",...
Compile the provided markdown into html. @param Twig_Compiler $compiler @return void
[ "Compile", "the", "provided", "markdown", "into", "html", "." ]
3f4bb7cfdbde05712fc861c4d96ff8f5e47501fd
https://github.com/jralph/Twig-Markdown/blob/3f4bb7cfdbde05712fc861c4d96ff8f5e47501fd/src/Node.php#L25-L39
39,017
jralph/Twig-Markdown
src/TokenParser.php
TokenParser.parse
public function parse(Twig_Token $token) { $line = $token->getLine(); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(function(Twig_Token $token) { return $token->test('endmarkdown'); }, true); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); return new Node($body, $line, $this->getTag()); }
php
public function parse(Twig_Token $token) { $line = $token->getLine(); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(function(Twig_Token $token) { return $token->test('endmarkdown'); }, true); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); return new Node($body, $line, $this->getTag()); }
[ "public", "function", "parse", "(", "Twig_Token", "$", "token", ")", "{", "$", "line", "=", "$", "token", "->", "getLine", "(", ")", ";", "$", "this", "->", "parser", "->", "getStream", "(", ")", "->", "expect", "(", "Twig_Token", "::", "BLOCK_END_TYPE...
Parse the twig tag. @param Twig_Token $token @return Node
[ "Parse", "the", "twig", "tag", "." ]
3f4bb7cfdbde05712fc861c4d96ff8f5e47501fd
https://github.com/jralph/Twig-Markdown/blob/3f4bb7cfdbde05712fc861c4d96ff8f5e47501fd/src/TokenParser.php#L27-L41
39,018
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.getResponseStructure
public function getResponseStructure($success = false, $payload = null, $message = '', $debug = null) { if (isset($debug)) { $data = [ 'success' => $success, 'message' => $message, 'payload' => $payload, 'debug' => $debug ]; } else { $data = [ 'success' => $success, 'message' => $message, 'payload' => $payload ]; } return $data; }
php
public function getResponseStructure($success = false, $payload = null, $message = '', $debug = null) { if (isset($debug)) { $data = [ 'success' => $success, 'message' => $message, 'payload' => $payload, 'debug' => $debug ]; } else { $data = [ 'success' => $success, 'message' => $message, 'payload' => $payload ]; } return $data; }
[ "public", "function", "getResponseStructure", "(", "$", "success", "=", "false", ",", "$", "payload", "=", "null", ",", "$", "message", "=", "''", ",", "$", "debug", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "debug", ")", ")", "{", "$", ...
create API structure. @param boolean $success @param null $payload @param string $message @param null $debug @return object
[ "create", "API", "structure", "." ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L99-L116
39,019
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondWithData
public function respondWithData(array $data) { $responseData = $this->getResponseStructure(true, $data, ''); $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders()); return $response; }
php
public function respondWithData(array $data) { $responseData = $this->getResponseStructure(true, $data, ''); $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders()); return $response; }
[ "public", "function", "respondWithData", "(", "array", "$", "data", ")", "{", "$", "responseData", "=", "$", "this", "->", "getResponseStructure", "(", "true", ",", "$", "data", ",", "''", ")", ";", "$", "response", "=", "new", "JsonResponse", "(", "$", ...
Responds with data @param array $data @return JsonResponse
[ "Responds", "with", "data" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L125-L131
39,020
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondWithMessage
public function respondWithMessage($message = "Ok") { $data = $this->getResponseStructure(true, null, $message); return $this->respond($data); }
php
public function respondWithMessage($message = "Ok") { $data = $this->getResponseStructure(true, null, $message); return $this->respond($data); }
[ "public", "function", "respondWithMessage", "(", "$", "message", "=", "\"Ok\"", ")", "{", "$", "data", "=", "$", "this", "->", "getResponseStructure", "(", "true", ",", "null", ",", "$", "message", ")", ";", "return", "$", "this", "->", "respond", "(", ...
Use this for responding with messages. @param string $message @return JsonResponse
[ "Use", "this", "for", "responding", "with", "messages", "." ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L140-L145
39,021
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondWithMessageAndPayload
public function respondWithMessageAndPayload($payload = null, $message = "Ok") { $data = $this->getResponseStructure(true, $payload, $message); $reponse = $this->respond($data); return $reponse; }
php
public function respondWithMessageAndPayload($payload = null, $message = "Ok") { $data = $this->getResponseStructure(true, $payload, $message); $reponse = $this->respond($data); return $reponse; }
[ "public", "function", "respondWithMessageAndPayload", "(", "$", "payload", "=", "null", ",", "$", "message", "=", "\"Ok\"", ")", "{", "$", "data", "=", "$", "this", "->", "getResponseStructure", "(", "true", ",", "$", "payload", ",", "$", "message", ")", ...
Use this for responding with messages and payload. @param null $payload @param string $message @return JsonResponse
[ "Use", "this", "for", "responding", "with", "messages", "and", "payload", "." ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L155-L160
39,022
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondWithError
public function respondWithError($message = "Error", $e = null, $data = null) { $response = null; if (\App::environment('local', 'staging') && isset($e)) { $debug_message = $e; $data = $this->getResponseStructure(false, $data, $message, $debug_message); } else { $data = $this->getResponseStructure(false, $data, $message); } $response = $this->respond($data); return $response; }
php
public function respondWithError($message = "Error", $e = null, $data = null) { $response = null; if (\App::environment('local', 'staging') && isset($e)) { $debug_message = $e; $data = $this->getResponseStructure(false, $data, $message, $debug_message); } else { $data = $this->getResponseStructure(false, $data, $message); } $response = $this->respond($data); return $response; }
[ "public", "function", "respondWithError", "(", "$", "message", "=", "\"Error\"", ",", "$", "e", "=", "null", ",", "$", "data", "=", "null", ")", "{", "$", "response", "=", "null", ";", "if", "(", "\\", "App", "::", "environment", "(", "'local'", ",",...
Responds with error @param string $message @param null $e @param null $data @return JsonResponse|null
[ "Responds", "with", "error" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L171-L184
39,023
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondCreatedWithPayload
public function respondCreatedWithPayload($payload = null, $message = "Created") { $reponse = $this->setStatusCode(ResponseHTTP::HTTP_CREATED) ->respondWithMessageAndPayload($payload, $message); return $reponse; }
php
public function respondCreatedWithPayload($payload = null, $message = "Created") { $reponse = $this->setStatusCode(ResponseHTTP::HTTP_CREATED) ->respondWithMessageAndPayload($payload, $message); return $reponse; }
[ "public", "function", "respondCreatedWithPayload", "(", "$", "payload", "=", "null", ",", "$", "message", "=", "\"Created\"", ")", "{", "$", "reponse", "=", "$", "this", "->", "setStatusCode", "(", "ResponseHTTP", "::", "HTTP_CREATED", ")", "->", "respondWithM...
Respond created with the payload @param null $payload @param string $message @return mixed
[ "Respond", "created", "with", "the", "payload" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L221-L227
39,024
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondUpdatedWithPayload
public function respondUpdatedWithPayload($payload = null, $message = "Updated") { $reponse = $this->setStatusCode(ResponseHTTP::HTTP_ACCEPTED) ->respondWithMessageAndPayload($payload, $message); return $reponse; }
php
public function respondUpdatedWithPayload($payload = null, $message = "Updated") { $reponse = $this->setStatusCode(ResponseHTTP::HTTP_ACCEPTED) ->respondWithMessageAndPayload($payload, $message); return $reponse; }
[ "public", "function", "respondUpdatedWithPayload", "(", "$", "payload", "=", "null", ",", "$", "message", "=", "\"Updated\"", ")", "{", "$", "reponse", "=", "$", "this", "->", "setStatusCode", "(", "ResponseHTTP", "::", "HTTP_ACCEPTED", ")", "->", "respondWith...
Respond is updated wih payload @param null $payload @param string $message @return mixed
[ "Respond", "is", "updated", "wih", "payload" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L251-L256
39,025
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondValidationError
public function respondValidationError($message = "Validation Error", $data = null) { return $this->setStatusCode(ResponseHTTP::HTTP_UNPROCESSABLE_ENTITY) ->respondWithError($message, null, $data); }
php
public function respondValidationError($message = "Validation Error", $data = null) { return $this->setStatusCode(ResponseHTTP::HTTP_UNPROCESSABLE_ENTITY) ->respondWithError($message, null, $data); }
[ "public", "function", "respondValidationError", "(", "$", "message", "=", "\"Validation Error\"", ",", "$", "data", "=", "null", ")", "{", "return", "$", "this", "->", "setStatusCode", "(", "ResponseHTTP", "::", "HTTP_UNPROCESSABLE_ENTITY", ")", "->", "respondWith...
Use this when response validation error @param string $message @param null $data @return mixed
[ "Use", "this", "when", "response", "validation", "error" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L334-L338
39,026
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondResourceConflictWithData
public function respondResourceConflictWithData( $payload = null, $message = "Resource Already Exists", $responseCode = ResponseHTTP::HTTP_CONFLICT ) { return $this->setStatusCode($responseCode) ->respondWithMessageAndPayload($payload, $message); }
php
public function respondResourceConflictWithData( $payload = null, $message = "Resource Already Exists", $responseCode = ResponseHTTP::HTTP_CONFLICT ) { return $this->setStatusCode($responseCode) ->respondWithMessageAndPayload($payload, $message); }
[ "public", "function", "respondResourceConflictWithData", "(", "$", "payload", "=", "null", ",", "$", "message", "=", "\"Resource Already Exists\"", ",", "$", "responseCode", "=", "ResponseHTTP", "::", "HTTP_CONFLICT", ")", "{", "return", "$", "this", "->", "setSta...
Used when response resource conflict with data @param null $payload @param string $message @param int $responseCode @return mixed
[ "Used", "when", "response", "resource", "conflict", "with", "data" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L417-L424
39,027
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.respondWithFile
public function respondWithFile($file, $mime) { return (new \Illuminate\Http\Response($file, ResponseHTTP::HTTP_OK)) ->header('Content-Type', $mime); }
php
public function respondWithFile($file, $mime) { return (new \Illuminate\Http\Response($file, ResponseHTTP::HTTP_OK)) ->header('Content-Type', $mime); }
[ "public", "function", "respondWithFile", "(", "$", "file", ",", "$", "mime", ")", "{", "return", "(", "new", "\\", "Illuminate", "\\", "Http", "\\", "Response", "(", "$", "file", ",", "ResponseHTTP", "::", "HTTP_OK", ")", ")", "->", "header", "(", "'Co...
Response with file @param \Illuminate\Contracts\Filesystem\Filesystem $file @param $mime @return mixed
[ "Response", "with", "file" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L434-L439
39,028
dharmvijay/laravel-api-response
src/APIResponse.php
APIResponse.handleAndResponseException
public function handleAndResponseException(\Exception $ex) { $response = ''; switch (true) { case $ex instanceof \Illuminate\Database\Eloquent\ModelNotFoundException: $response = $this->respondNotFound('Record not found'); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException: $response = $this->respondNotFound("Not found"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: $response = $this->respondForbidden("Access denied"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\BadRequestHttpException: $response = $this->respondBadRequest("Bad request"); break; case $ex instanceof BadMethodCallException: $response = $this->respondBadRequest("Bad method Call"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: $response = $this->respondForbidden("Method not found"); break; case $ex instanceof \Illuminate\Database\QueryException: $response = $this->respondValidationError("Some thing went wrong with your query", [$ex->getMessage()]); break; case $ex instanceof \Illuminate\Http\Exceptions\HttpResponseException: $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]); break; case $ex instanceof \Illuminate\Auth\AuthenticationException: $response = $this->respondUnauthorized("Unauthorized request"); break; case $ex instanceof \Illuminate\Validation\ValidationException: $response = $this->respondValidationError("In valid request", [$ex->getMessage()]); break; case $ex instanceof NotAcceptableHttpException: $response = $this->respondUnauthorized("Unauthorized request"); break; case $ex instanceof \Illuminate\Validation\UnauthorizedException: $response = $this->respondUnauthorized("Unauthorized request", [$ex->getMessage()]); break; case $ex instanceof \Exception: $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]); break; } return $response; }
php
public function handleAndResponseException(\Exception $ex) { $response = ''; switch (true) { case $ex instanceof \Illuminate\Database\Eloquent\ModelNotFoundException: $response = $this->respondNotFound('Record not found'); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException: $response = $this->respondNotFound("Not found"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: $response = $this->respondForbidden("Access denied"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\BadRequestHttpException: $response = $this->respondBadRequest("Bad request"); break; case $ex instanceof BadMethodCallException: $response = $this->respondBadRequest("Bad method Call"); break; case $ex instanceof \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: $response = $this->respondForbidden("Method not found"); break; case $ex instanceof \Illuminate\Database\QueryException: $response = $this->respondValidationError("Some thing went wrong with your query", [$ex->getMessage()]); break; case $ex instanceof \Illuminate\Http\Exceptions\HttpResponseException: $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]); break; case $ex instanceof \Illuminate\Auth\AuthenticationException: $response = $this->respondUnauthorized("Unauthorized request"); break; case $ex instanceof \Illuminate\Validation\ValidationException: $response = $this->respondValidationError("In valid request", [$ex->getMessage()]); break; case $ex instanceof NotAcceptableHttpException: $response = $this->respondUnauthorized("Unauthorized request"); break; case $ex instanceof \Illuminate\Validation\UnauthorizedException: $response = $this->respondUnauthorized("Unauthorized request", [$ex->getMessage()]); break; case $ex instanceof \Exception: $response = $this->respondInternalError("Something went wrong with our system", [$ex->getMessage()]); break; } return $response; }
[ "public", "function", "handleAndResponseException", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "response", "=", "''", ";", "switch", "(", "true", ")", "{", "case", "$", "ex", "instanceof", "\\", "Illuminate", "\\", "Database", "\\", "Eloquent", "\\"...
handle all type of exceptions @param \Exception $ex @return mixed|string
[ "handle", "all", "type", "of", "exceptions" ]
f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1
https://github.com/dharmvijay/laravel-api-response/blob/f51ded129bd50fbd33f627d1d9a6dd4d5031bdc1/src/APIResponse.php#L502-L548
39,029
simplito/bn-php
lib/BN.php
BN.iuor
public function iuor(BN $num) { $this->bi = $this->bi->binaryOr($num->bi); return $this; }
php
public function iuor(BN $num) { $this->bi = $this->bi->binaryOr($num->bi); return $this; }
[ "public", "function", "iuor", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "binaryOr", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
Or `num` with `this` in-place
[ "Or", "num", "with", "this", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L159-L162
39,030
simplito/bn-php
lib/BN.php
BN._or
public function _or(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->ior($num); return $num->_clone()->ior($this); }
php
public function _or(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->ior($num); return $num->_clone()->ior($this); }
[ "public", "function", "_or", "(", "BN", "$", "num", ")", "{", "if", "(", "$", "this", "->", "ucmp", "(", "$", "num", ")", ">", "0", ")", "return", "$", "this", "->", "_clone", "(", ")", "->", "ior", "(", "$", "num", ")", ";", "return", "$", ...
Or `num` with `this`
[ "Or", "num", "with", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L170-L174
39,031
simplito/bn-php
lib/BN.php
BN.iuand
public function iuand(BN $num) { $this->bi = $this->bi->binaryAnd($num->bi); return $this; }
php
public function iuand(BN $num) { $this->bi = $this->bi->binaryAnd($num->bi); return $this; }
[ "public", "function", "iuand", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "binaryAnd", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
And `num` with `this` in-place
[ "And", "num", "with", "this", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L183-L186
39,032
simplito/bn-php
lib/BN.php
BN._and
public function _and(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->iand($num); return $num->_clone()->iand($this); }
php
public function _and(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->iand($num); return $num->_clone()->iand($this); }
[ "public", "function", "_and", "(", "BN", "$", "num", ")", "{", "if", "(", "$", "this", "->", "ucmp", "(", "$", "num", ")", ">", "0", ")", "return", "$", "this", "->", "_clone", "(", ")", "->", "iand", "(", "$", "num", ")", ";", "return", "$",...
And `num` with `this`
[ "And", "num", "with", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L194-L198
39,033
simplito/bn-php
lib/BN.php
BN.iuxor
public function iuxor(BN $num) { $this->bi = $this->bi->binaryXor($num->bi); return $this; }
php
public function iuxor(BN $num) { $this->bi = $this->bi->binaryXor($num->bi); return $this; }
[ "public", "function", "iuxor", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "binaryXor", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
Xor `num` with `this` in-place
[ "Xor", "num", "with", "this", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L207-L210
39,034
simplito/bn-php
lib/BN.php
BN._xor
public function _xor(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->ixor($num); return $num->_clone()->ixor($this); }
php
public function _xor(BN $num) { if( $this->ucmp($num) > 0 ) return $this->_clone()->ixor($num); return $num->_clone()->ixor($this); }
[ "public", "function", "_xor", "(", "BN", "$", "num", ")", "{", "if", "(", "$", "this", "->", "ucmp", "(", "$", "num", ")", ">", "0", ")", "return", "$", "this", "->", "_clone", "(", ")", "->", "ixor", "(", "$", "num", ")", ";", "return", "$",...
Xor `num` with `this`
[ "Xor", "num", "with", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L218-L222
39,035
simplito/bn-php
lib/BN.php
BN.inotn
public function inotn($width) { assert(is_integer($width) && $width >= 0); $neg = false; if( $this->isNeg() ) { $this->negi(); $neg = true; } for($i = 0; $i < $width; $i++) $this->bi = $this->bi->setbit($i, !$this->bi->testbit($i)); return $neg ? $this->negi() : $this; }
php
public function inotn($width) { assert(is_integer($width) && $width >= 0); $neg = false; if( $this->isNeg() ) { $this->negi(); $neg = true; } for($i = 0; $i < $width; $i++) $this->bi = $this->bi->setbit($i, !$this->bi->testbit($i)); return $neg ? $this->negi() : $this; }
[ "public", "function", "inotn", "(", "$", "width", ")", "{", "assert", "(", "is_integer", "(", "$", "width", ")", "&&", "$", "width", ">=", "0", ")", ";", "$", "neg", "=", "false", ";", "if", "(", "$", "this", "->", "isNeg", "(", ")", ")", "{", ...
Not ``this`` with ``width`` bitwidth
[ "Not", "this", "with", "width", "bitwidth" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L231-L245
39,036
simplito/bn-php
lib/BN.php
BN.setn
public function setn($bit, $val) { assert(is_integer($bit) && $bit > 0); $this->bi = $this->bi->setbit($bit, !!$val); return $this; }
php
public function setn($bit, $val) { assert(is_integer($bit) && $bit > 0); $this->bi = $this->bi->setbit($bit, !!$val); return $this; }
[ "public", "function", "setn", "(", "$", "bit", ",", "$", "val", ")", "{", "assert", "(", "is_integer", "(", "$", "bit", ")", "&&", "$", "bit", ">", "0", ")", ";", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "setbit", "(", "$"...
Set `bit` of `this`
[ "Set", "bit", "of", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L252-L256
39,037
simplito/bn-php
lib/BN.php
BN.iadd
public function iadd(BN $num) { $this->bi = $this->bi->add($num->bi); return $this; }
php
public function iadd(BN $num) { $this->bi = $this->bi->add($num->bi); return $this; }
[ "public", "function", "iadd", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "add", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
Add `num` to `this` in-place
[ "Add", "num", "to", "this", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L259-L262
39,038
simplito/bn-php
lib/BN.php
BN.isub
public function isub(BN $num) { $this->bi = $this->bi->sub($num->bi); return $this; }
php
public function isub(BN $num) { $this->bi = $this->bi->sub($num->bi); return $this; }
[ "public", "function", "isub", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "sub", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
Subtract `num` from `this` in-place
[ "Subtract", "num", "from", "this", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L270-L273
39,039
simplito/bn-php
lib/BN.php
BN.imul
public function imul(BN $num) { $this->bi = $this->bi->mul($num->bi); return $this; }
php
public function imul(BN $num) { $this->bi = $this->bi->mul($num->bi); return $this; }
[ "public", "function", "imul", "(", "BN", "$", "num", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "mul", "(", "$", "num", "->", "bi", ")", ";", "return", "$", "this", ";", "}" ]
In-place Multiplication
[ "In", "-", "place", "Multiplication" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L286-L289
39,040
simplito/bn-php
lib/BN.php
BN.iushln
public function iushln($bits) { assert(is_integer($bits) && $bits >= 0); if ($bits < 54) { $this->bi = $this->bi->mul(1 << $bits); } else { $this->bi = $this->bi->mul((new BigInteger(2))->pow($bits)); } return $this; }
php
public function iushln($bits) { assert(is_integer($bits) && $bits >= 0); if ($bits < 54) { $this->bi = $this->bi->mul(1 << $bits); } else { $this->bi = $this->bi->mul((new BigInteger(2))->pow($bits)); } return $this; }
[ "public", "function", "iushln", "(", "$", "bits", ")", "{", "assert", "(", "is_integer", "(", "$", "bits", ")", "&&", "$", "bits", ">=", "0", ")", ";", "if", "(", "$", "bits", "<", "54", ")", "{", "$", "this", "->", "bi", "=", "$", "this", "-...
Shift-left in-place
[ "Shift", "-", "left", "in", "-", "place" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L340-L348
39,041
simplito/bn-php
lib/BN.php
BN.iaddn
public function iaddn($num) { assert(is_numeric($num)); $this->bi = $this->bi->add(intval($num)); return $this; }
php
public function iaddn($num) { assert(is_numeric($num)); $this->bi = $this->bi->add(intval($num)); return $this; }
[ "public", "function", "iaddn", "(", "$", "num", ")", "{", "assert", "(", "is_numeric", "(", "$", "num", ")", ")", ";", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "add", "(", "intval", "(", "$", "num", ")", ")", ";", "return", ...
Add plain number `num` to `this`
[ "Add", "plain", "number", "num", "to", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L420-L424
39,042
simplito/bn-php
lib/BN.php
BN.isubn
public function isubn($num) { assert(is_numeric($num)); $this->bi = $this->bi->sub(intval($num)); return $this; }
php
public function isubn($num) { assert(is_numeric($num)); $this->bi = $this->bi->sub(intval($num)); return $this; }
[ "public", "function", "isubn", "(", "$", "num", ")", "{", "assert", "(", "is_numeric", "(", "$", "num", ")", ")", ";", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "sub", "(", "intval", "(", "$", "num", ")", ")", ";", "return", ...
Subtract plain number `num` from `this`
[ "Subtract", "plain", "number", "num", "from", "this" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L427-L431
39,043
simplito/bn-php
lib/BN.php
BN.mod
public function mod(BN $num) { if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero()); $res = clone($this); $res->bi = $res->bi->divR($num->bi); return $res; }
php
public function mod(BN $num) { if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero()); $res = clone($this); $res->bi = $res->bi->divR($num->bi); return $res; }
[ "public", "function", "mod", "(", "BN", "$", "num", ")", "{", "if", "(", "assert_options", "(", "ASSERT_ACTIVE", ")", ")", "assert", "(", "!", "$", "num", "->", "isZero", "(", ")", ")", ";", "$", "res", "=", "clone", "(", "$", "this", ")", ";", ...
Find `this` % `num`
[ "Find", "this", "%", "num" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L464-L469
39,044
simplito/bn-php
lib/BN.php
BN.idivn
public function idivn($num) { assert(is_numeric($num) && $num != 0); $this->bi = $this->bi->div(intval($num)); return $this; }
php
public function idivn($num) { assert(is_numeric($num) && $num != 0); $this->bi = $this->bi->div(intval($num)); return $this; }
[ "public", "function", "idivn", "(", "$", "num", ")", "{", "assert", "(", "is_numeric", "(", "$", "num", ")", "&&", "$", "num", "!=", "0", ")", ";", "$", "this", "->", "bi", "=", "$", "this", "->", "bi", "->", "div", "(", "intval", "(", "$", "...
In-place division by number
[ "In", "-", "place", "division", "by", "number" ]
e852fcd27e4acbc32459606d7606e45a85e42465
https://github.com/simplito/bn-php/blob/e852fcd27e4acbc32459606d7606e45a85e42465/lib/BN.php#L501-L505
39,045
Kirouane/interval
src/Rule/Interval/NeighborhoodAfter.php
NeighborhoodAfter.assert
public function assert(Interval $first, Interval $second): bool { return $first->getStart()->equalTo($second->getEnd()); }
php
public function assert(Interval $first, Interval $second): bool { return $first->getStart()->equalTo($second->getEnd()); }
[ "public", "function", "assert", "(", "Interval", "$", "first", ",", "Interval", "$", "second", ")", ":", "bool", "{", "return", "$", "first", "->", "getStart", "(", ")", "->", "equalTo", "(", "$", "second", "->", "getEnd", "(", ")", ")", ";", "}" ]
Returns true if the second interval is neighbor of the first one @param Interval $first @param Interval $second @return bool
[ "Returns", "true", "if", "the", "second", "interval", "is", "neighbor", "of", "the", "first", "one" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Rule/Interval/NeighborhoodAfter.php#L20-L23
39,046
Kirouane/interval
src/Parser/IntervalParser.php
IntervalParser.parse
public function parse(string $expression): Interval { $parse = \explode(',', $expression); if (self::BOUNDARIES !== count($parse)) { throw new \ErrorException('Parse interval expression'); } $startTerm = \reset($parse); $endTerm = \end($parse); $startTerm = $this->parseStartTerm($startTerm); $endTerm = $this->parseEndTerm($endTerm); return new Interval( $startTerm, $endTerm ); }
php
public function parse(string $expression): Interval { $parse = \explode(',', $expression); if (self::BOUNDARIES !== count($parse)) { throw new \ErrorException('Parse interval expression'); } $startTerm = \reset($parse); $endTerm = \end($parse); $startTerm = $this->parseStartTerm($startTerm); $endTerm = $this->parseEndTerm($endTerm); return new Interval( $startTerm, $endTerm ); }
[ "public", "function", "parse", "(", "string", "$", "expression", ")", ":", "Interval", "{", "$", "parse", "=", "\\", "explode", "(", "','", ",", "$", "expression", ")", ";", "if", "(", "self", "::", "BOUNDARIES", "!==", "count", "(", "$", "parse", ")...
Create a Interval from an expression @param string $expression @return Interval @throws \InvalidArgumentException @throws \UnexpectedValueException @throws \RangeException @throws \ErrorException
[ "Create", "a", "Interval", "from", "an", "expression" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L31-L48
39,047
Kirouane/interval
src/Parser/IntervalParser.php
IntervalParser.parseStartTerm
private function parseStartTerm(string $startTerm) { if ('' === $startTerm) { throw new \ErrorException('Parse interval expression'); } $startInclusion = $startTerm[0]; if (!\in_array($startInclusion, [self::LEFT, self::RIGHT], true)) { throw new \ErrorException('Parse interval expression'); } $isOpen = $startInclusion === self::LEFT; $startValue = \substr($startTerm, 1); return $this->parseValue($startValue, true, $isOpen); }
php
private function parseStartTerm(string $startTerm) { if ('' === $startTerm) { throw new \ErrorException('Parse interval expression'); } $startInclusion = $startTerm[0]; if (!\in_array($startInclusion, [self::LEFT, self::RIGHT], true)) { throw new \ErrorException('Parse interval expression'); } $isOpen = $startInclusion === self::LEFT; $startValue = \substr($startTerm, 1); return $this->parseValue($startValue, true, $isOpen); }
[ "private", "function", "parseStartTerm", "(", "string", "$", "startTerm", ")", "{", "if", "(", "''", "===", "$", "startTerm", ")", "{", "throw", "new", "\\", "ErrorException", "(", "'Parse interval expression'", ")", ";", "}", "$", "startInclusion", "=", "$"...
Parses the start term @param string $startTerm @return float|int|string @throws \InvalidArgumentException @throws \ErrorException
[ "Parses", "the", "start", "term" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L57-L72
39,048
Kirouane/interval
src/Parser/IntervalParser.php
IntervalParser.parseEndTerm
private function parseEndTerm(string $endTerm) { if ('' === $endTerm) { throw new \ErrorException('Parse interval expression'); } $endInclusion = \substr($endTerm, -1); if (!\in_array($endInclusion, [self::LEFT, self::RIGHT], true)) { throw new \ErrorException('Parse interval expression'); } $isOpen = $endInclusion === self::RIGHT; $endValue = \substr($endTerm, 0, -1); return $this->parseValue($endValue, false, $isOpen); }
php
private function parseEndTerm(string $endTerm) { if ('' === $endTerm) { throw new \ErrorException('Parse interval expression'); } $endInclusion = \substr($endTerm, -1); if (!\in_array($endInclusion, [self::LEFT, self::RIGHT], true)) { throw new \ErrorException('Parse interval expression'); } $isOpen = $endInclusion === self::RIGHT; $endValue = \substr($endTerm, 0, -1); return $this->parseValue($endValue, false, $isOpen); }
[ "private", "function", "parseEndTerm", "(", "string", "$", "endTerm", ")", "{", "if", "(", "''", "===", "$", "endTerm", ")", "{", "throw", "new", "\\", "ErrorException", "(", "'Parse interval expression'", ")", ";", "}", "$", "endInclusion", "=", "\\", "su...
Pareses the end term @param string $endTerm @return float|int|string @throws \InvalidArgumentException @throws \ErrorException
[ "Pareses", "the", "end", "term" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L81-L96
39,049
Kirouane/interval
src/Parser/IntervalParser.php
IntervalParser.parseValue
private function parseValue($value, bool $isLeft, bool $isOpen) { if ($this->isInt($value)) { return new Integer((int)$value, $isLeft, $isOpen); } if ($this->isInfinity($value)) { $value = '-INF' === $value ? -\INF : \INF; return new Infinity($value, $isLeft, $isOpen); } if ($this->isFloat($value)) { return new Real((float)$value, $isLeft, $isOpen); } if ($this->isDate($value)) { $value = \DateTimeImmutable::createFromFormat('U', (string)\strtotime($value)); $value = $value->setTimezone(new \DateTimeZone(\date_default_timezone_get())); return new DateTime($value, $isLeft, $isOpen); } throw new \InvalidArgumentException('Unexpected $value type'); }
php
private function parseValue($value, bool $isLeft, bool $isOpen) { if ($this->isInt($value)) { return new Integer((int)$value, $isLeft, $isOpen); } if ($this->isInfinity($value)) { $value = '-INF' === $value ? -\INF : \INF; return new Infinity($value, $isLeft, $isOpen); } if ($this->isFloat($value)) { return new Real((float)$value, $isLeft, $isOpen); } if ($this->isDate($value)) { $value = \DateTimeImmutable::createFromFormat('U', (string)\strtotime($value)); $value = $value->setTimezone(new \DateTimeZone(\date_default_timezone_get())); return new DateTime($value, $isLeft, $isOpen); } throw new \InvalidArgumentException('Unexpected $value type'); }
[ "private", "function", "parseValue", "(", "$", "value", ",", "bool", "$", "isLeft", ",", "bool", "$", "isOpen", ")", "{", "if", "(", "$", "this", "->", "isInt", "(", "$", "value", ")", ")", "{", "return", "new", "Integer", "(", "(", "int", ")", "...
Cast a value to its expected type @param mixed $value @param bool $isLeft @param bool $isOpen @return float|int|string @throws \InvalidArgumentException
[ "Cast", "a", "value", "to", "its", "expected", "type" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L106-L128
39,050
Kirouane/interval
src/Parser/IntervalParser.php
IntervalParser.isInt
private function isInt(string $value): bool { return \is_numeric($value) && (float)\round($value, 0) === (float)$value; }
php
private function isInt(string $value): bool { return \is_numeric($value) && (float)\round($value, 0) === (float)$value; }
[ "private", "function", "isInt", "(", "string", "$", "value", ")", ":", "bool", "{", "return", "\\", "is_numeric", "(", "$", "value", ")", "&&", "(", "float", ")", "\\", "round", "(", "$", "value", ",", "0", ")", "===", "(", "float", ")", "$", "va...
Returns true if the value is an integer @param $value @return bool
[ "Returns", "true", "if", "the", "value", "is", "an", "integer" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Parser/IntervalParser.php#L135-L138
39,051
Kirouane/interval
src/Intervals.php
Intervals.exclude
public function exclude(Intervals $intervals) : Intervals { /** @var \Interval\Operation\Intervals\Exclusion $operation */ $operation = self::$di->get(Di::OPERATION_INTERVALS_EXCLUSION); return $operation($this, $intervals); }
php
public function exclude(Intervals $intervals) : Intervals { /** @var \Interval\Operation\Intervals\Exclusion $operation */ $operation = self::$di->get(Di::OPERATION_INTERVALS_EXCLUSION); return $operation($this, $intervals); }
[ "public", "function", "exclude", "(", "Intervals", "$", "intervals", ")", ":", "Intervals", "{", "/** @var \\Interval\\Operation\\Intervals\\Exclusion $operation */", "$", "operation", "=", "self", "::", "$", "di", "->", "get", "(", "Di", "::", "OPERATION_INTERVALS_EX...
Excludes this interval from another one. Exp |________________________________________________________________________________| - |_________________| |_________________| = |___________| |___________________| |____________| @param Intervals $intervals @return Intervals
[ "Excludes", "this", "interval", "from", "another", "one", ".", "Exp" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Intervals.php#L65-L70
39,052
Kirouane/interval
src/Interval.php
Interval.toComparable
public static function toComparable($boundary) { $isInternallyType = \is_numeric($boundary) || \is_bool($boundary) || \is_string($boundary); $comparable = null; if ($isInternallyType) { $comparable = $boundary; } elseif ($boundary instanceof \DateTimeInterface) { $comparable = $boundary->getTimestamp(); } else { throw new \UnexpectedValueException('Unexpected boundary type'); } return $comparable; }
php
public static function toComparable($boundary) { $isInternallyType = \is_numeric($boundary) || \is_bool($boundary) || \is_string($boundary); $comparable = null; if ($isInternallyType) { $comparable = $boundary; } elseif ($boundary instanceof \DateTimeInterface) { $comparable = $boundary->getTimestamp(); } else { throw new \UnexpectedValueException('Unexpected boundary type'); } return $comparable; }
[ "public", "static", "function", "toComparable", "(", "$", "boundary", ")", "{", "$", "isInternallyType", "=", "\\", "is_numeric", "(", "$", "boundary", ")", "||", "\\", "is_bool", "(", "$", "boundary", ")", "||", "\\", "is_string", "(", "$", "boundary", ...
Convert an boundary to comparable @param mixed $boundary @return mixed @throws \UnexpectedValueException
[ "Convert", "an", "boundary", "to", "comparable" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Interval.php#L333-L347
39,053
Kirouane/interval
src/Rule/Interval/Overlapping.php
Overlapping.assert
public function assert(Interval $first, Interval $second): bool { return $first->getEnd()->greaterThan($second->getStart()) && $first->getStart()->lessThan($second->getEnd()); }
php
public function assert(Interval $first, Interval $second): bool { return $first->getEnd()->greaterThan($second->getStart()) && $first->getStart()->lessThan($second->getEnd()); }
[ "public", "function", "assert", "(", "Interval", "$", "first", ",", "Interval", "$", "second", ")", ":", "bool", "{", "return", "$", "first", "->", "getEnd", "(", ")", "->", "greaterThan", "(", "$", "second", "->", "getStart", "(", ")", ")", "&&", "$...
Returns true if the second interval overlaps the first one @param Interval $first @param Interval $second @return bool
[ "Returns", "true", "if", "the", "second", "interval", "overlaps", "the", "first", "one" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Rule/Interval/Overlapping.php#L20-L25
39,054
Kirouane/interval
src/Operation/Interval/Intersection.php
Intersection.compute
public function compute(Interval $first, Interval $second): ?Interval { if ($first->isNeighborBefore($second)) { return new Interval( $first->getEnd()->changeSide(), $second->getStart()->changeSide() ); } if ($first->isNeighborAfter($second)) { return new Interval( $second->getEnd()->changeSide(), $first->getStart()->changeSide() ); } if (!$first->overlaps($second)) { return null; } return new Interval( $first->getStart()->greaterThan($second->getStart()) ? $first->getStart() : $second->getStart(), $first->getEnd()->lessThan($second->getEnd()) ? $first->getEnd() : $second->getEnd() ); }
php
public function compute(Interval $first, Interval $second): ?Interval { if ($first->isNeighborBefore($second)) { return new Interval( $first->getEnd()->changeSide(), $second->getStart()->changeSide() ); } if ($first->isNeighborAfter($second)) { return new Interval( $second->getEnd()->changeSide(), $first->getStart()->changeSide() ); } if (!$first->overlaps($second)) { return null; } return new Interval( $first->getStart()->greaterThan($second->getStart()) ? $first->getStart() : $second->getStart(), $first->getEnd()->lessThan($second->getEnd()) ? $first->getEnd() : $second->getEnd() ); }
[ "public", "function", "compute", "(", "Interval", "$", "first", ",", "Interval", "$", "second", ")", ":", "?", "Interval", "{", "if", "(", "$", "first", "->", "isNeighborBefore", "(", "$", "second", ")", ")", "{", "return", "new", "Interval", "(", "$",...
Compute the intersection of two intervals. Exp |_________________| ∩ |_________________| = |_____| @param Interval $first @param Interval $second @return Interval @throws \InvalidArgumentException @throws \UnexpectedValueException @throws \RangeException
[ "Compute", "the", "intersection", "of", "two", "intervals", ".", "Exp" ]
8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8
https://github.com/Kirouane/interval/blob/8fb6f2e3b16bc4ba17dde1932a4cc83cd12c42c8/src/Operation/Interval/Intersection.php#L46-L70
39,055
TypistTech/wp-contained-hook
src/Loader.php
Loader.add
public function add(HookInterface ...$hooks): void { $this->hooks = array_values( array_unique( array_merge($this->hooks, $hooks), SORT_REGULAR ) ); }
php
public function add(HookInterface ...$hooks): void { $this->hooks = array_values( array_unique( array_merge($this->hooks, $hooks), SORT_REGULAR ) ); }
[ "public", "function", "add", "(", "HookInterface", "...", "$", "hooks", ")", ":", "void", "{", "$", "this", "->", "hooks", "=", "array_values", "(", "array_unique", "(", "array_merge", "(", "$", "this", "->", "hooks", ",", "$", "hooks", ")", ",", "SORT...
Add new hooks to the collection to be registered with WordPress. @param HookInterface|HookInterface[] ...$hooks Hooks to be registered. @return void
[ "Add", "new", "hooks", "to", "the", "collection", "to", "be", "registered", "with", "WordPress", "." ]
0601190269f28877f2d21698f7fedebeb6bce738
https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Loader.php#L45-L53
39,056
TypistTech/wp-contained-hook
src/Loader.php
Loader.run
public function run(): void { foreach ($this->hooks as $hook) { $hook->setContainer($this->container); $hook->register(); } }
php
public function run(): void { foreach ($this->hooks as $hook) { $hook->setContainer($this->container); $hook->register(); } }
[ "public", "function", "run", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "hooks", "as", "$", "hook", ")", "{", "$", "hook", "->", "setContainer", "(", "$", "this", "->", "container", ")", ";", "$", "hook", "->", "register", "(", ...
Register the hooks to the container and WordPress. @return void
[ "Register", "the", "hooks", "to", "the", "container", "and", "WordPress", "." ]
0601190269f28877f2d21698f7fedebeb6bce738
https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Loader.php#L60-L66
39,057
TypistTech/wp-contained-hook
src/Hooks/Action.php
Action.run
public function run(...$args): void { $container = $this->getContainer(); $instance = $container->get($this->classIdentifier); $instance->{$this->callbackMethod}(...$args); }
php
public function run(...$args): void { $container = $this->getContainer(); $instance = $container->get($this->classIdentifier); $instance->{$this->callbackMethod}(...$args); }
[ "public", "function", "run", "(", "...", "$", "args", ")", ":", "void", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "instance", "=", "$", "container", "->", "get", "(", "$", "this", "->", "classIdentifier", ")",...
The actual callback that WordPress going to fire. @param mixed ...$args Arguments which pass on to the actual instance. @return void
[ "The", "actual", "callback", "that", "WordPress", "going", "to", "fire", "." ]
0601190269f28877f2d21698f7fedebeb6bce738
https://github.com/TypistTech/wp-contained-hook/blob/0601190269f28877f2d21698f7fedebeb6bce738/src/Hooks/Action.php#L29-L35
39,058
clue/php-commander
src/Tokens/Tokenizer.php
Tokenizer.createToken
public function createToken($input) { $i = 0; $token = $this->readAlternativeSentenceOrSingle($input, $i); if (isset($input[$i])) { throw new \InvalidArgumentException('Invalid root token, expression has superfluous contents'); } return $token; }
php
public function createToken($input) { $i = 0; $token = $this->readAlternativeSentenceOrSingle($input, $i); if (isset($input[$i])) { throw new \InvalidArgumentException('Invalid root token, expression has superfluous contents'); } return $token; }
[ "public", "function", "createToken", "(", "$", "input", ")", "{", "$", "i", "=", "0", ";", "$", "token", "=", "$", "this", "->", "readAlternativeSentenceOrSingle", "(", "$", "input", ",", "$", "i", ")", ";", "if", "(", "isset", "(", "$", "input", "...
Creates a Token from the given route expression @param string $input @return TokenInterface @throws InvalidArgumentException if the route expression can not be parsed
[ "Creates", "a", "Token", "from", "the", "given", "route", "expression" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Tokens/Tokenizer.php#L43-L53
39,059
clue/php-commander
src/Tokens/Tokenizer.php
Tokenizer.readAlternativeSentenceOrSingle
private function readAlternativeSentenceOrSingle($input, &$i) { $tokens = array(); while (true) { $tokens []= $this->readSentenceOrSingle($input, $i); // end of input reached or end token found if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) { break; } // cursor now at alternative symbol (all other symbols are already handled) // skip alternative mark and continue with next alternative $i++; } // return a single token as-is if (isset($tokens[0]) && !isset($tokens[1])) { return $tokens[0]; } return new AlternativeToken($tokens); }
php
private function readAlternativeSentenceOrSingle($input, &$i) { $tokens = array(); while (true) { $tokens []= $this->readSentenceOrSingle($input, $i); // end of input reached or end token found if (!isset($input[$i]) || strpos('])', $input[$i]) !== false) { break; } // cursor now at alternative symbol (all other symbols are already handled) // skip alternative mark and continue with next alternative $i++; } // return a single token as-is if (isset($tokens[0]) && !isset($tokens[1])) { return $tokens[0]; } return new AlternativeToken($tokens); }
[ "private", "function", "readAlternativeSentenceOrSingle", "(", "$", "input", ",", "&", "$", "i", ")", "{", "$", "tokens", "=", "array", "(", ")", ";", "while", "(", "true", ")", "{", "$", "tokens", "[", "]", "=", "$", "this", "->", "readSentenceOrSingl...
reads a complete sentence token until end of group An "alternative sentence" may contain the following tokens: - an alternative group (which may consist of individual sentences separated by `|`) - a sentence (which may consist of multiple tokens) - a single token @param string $input @param int $i @throws InvalidArgumentException @return TokenInterface
[ "reads", "a", "complete", "sentence", "token", "until", "end", "of", "group" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Tokens/Tokenizer.php#L188-L211
39,060
skymeyer/Vatsimphp
src/Vatsimphp/Parser/DataParser.php
DataParser.timestampHasExpired
protected function timestampHasExpired($ts, $expire) { if (empty($expire)) { return false; } $diff = time() - $ts; if ($diff > $expire) { return true; } return false; }
php
protected function timestampHasExpired($ts, $expire) { if (empty($expire)) { return false; } $diff = time() - $ts; if ($diff > $expire) { return true; } return false; }
[ "protected", "function", "timestampHasExpired", "(", "$", "ts", ",", "$", "expire", ")", "{", "if", "(", "empty", "(", "$", "expire", ")", ")", "{", "return", "false", ";", "}", "$", "diff", "=", "time", "(", ")", "-", "$", "ts", ";", "if", "(", ...
Check if given timestamp is expired. @param int $ts @return bool
[ "Check", "if", "given", "timestamp", "is", "expired", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L97-L108
39,061
skymeyer/Vatsimphp
src/Vatsimphp/Parser/DataParser.php
DataParser.parseSections
protected function parseSections() { foreach (array_keys($this->sections) as $section) { // section headers $header = new HeaderFilter($this->rawData); $header->setFilter($section); $headerData = $header->toArray(); $headerData = array_shift($headerData); // skip section if no headers found if (empty($headerData)) { $this->log->debug("No header for section $section"); continue; } // save header separately $this->results->append( $this->scrubKey("{$section}_header"), $headerData ); // section data $data = new SectionDataFilter($this->rawData); $data->setFilter($section); $data->setHeader($headerData); $this->results->append( $this->scrubKey($section), $data ); $this->log->debug("Parsed section '{$this->scrubKey($section)}'"); } }
php
protected function parseSections() { foreach (array_keys($this->sections) as $section) { // section headers $header = new HeaderFilter($this->rawData); $header->setFilter($section); $headerData = $header->toArray(); $headerData = array_shift($headerData); // skip section if no headers found if (empty($headerData)) { $this->log->debug("No header for section $section"); continue; } // save header separately $this->results->append( $this->scrubKey("{$section}_header"), $headerData ); // section data $data = new SectionDataFilter($this->rawData); $data->setFilter($section); $data->setHeader($headerData); $this->results->append( $this->scrubKey($section), $data ); $this->log->debug("Parsed section '{$this->scrubKey($section)}'"); } }
[ "protected", "function", "parseSections", "(", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "sections", ")", "as", "$", "section", ")", "{", "// section headers", "$", "header", "=", "new", "HeaderFilter", "(", "$", "this", "->", "rawDat...
Parse data sections.
[ "Parse", "data", "sections", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L113-L145
39,062
skymeyer/Vatsimphp
src/Vatsimphp/Parser/DataParser.php
DataParser.convertTs
protected function convertTs($str) { if (empty($str) || strlen($str) != 14) { return false; } $y = (int) substr($str, 0, 4); $m = (int) substr($str, 4, 2); $d = (int) substr($str, 6, 2); $h = (int) substr($str, 8, 2); $i = (int) substr($str, 10, 2); $s = (int) substr($str, 12, 2); $dt = new \DateTime(); $dt->setTimezone(new \DateTimeZone('UTC')); $dt->setDate($y, $m, $d); $dt->setTime($h, $i, $s); return $dt->getTimestamp(); }
php
protected function convertTs($str) { if (empty($str) || strlen($str) != 14) { return false; } $y = (int) substr($str, 0, 4); $m = (int) substr($str, 4, 2); $d = (int) substr($str, 6, 2); $h = (int) substr($str, 8, 2); $i = (int) substr($str, 10, 2); $s = (int) substr($str, 12, 2); $dt = new \DateTime(); $dt->setTimezone(new \DateTimeZone('UTC')); $dt->setDate($y, $m, $d); $dt->setTime($h, $i, $s); return $dt->getTimestamp(); }
[ "protected", "function", "convertTs", "(", "$", "str", ")", "{", "if", "(", "empty", "(", "$", "str", ")", "||", "strlen", "(", "$", "str", ")", "!=", "14", ")", "{", "return", "false", ";", "}", "$", "y", "=", "(", "int", ")", "substr", "(", ...
Timestamp convertor to unix time. @param string $str @return int
[ "Timestamp", "convertor", "to", "unix", "time", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/DataParser.php#L197-L215
39,063
skymeyer/Vatsimphp
src/Vatsimphp/Log/Logger.php
Logger.getHandler
protected function getHandler($file, $level) { if (empty(self::$handler)) { $handler = new StreamHandler($file, $level); $handler->setFormatter($this->getCustomFormatter()); self::$handler = $handler; } return self::$handler; }
php
protected function getHandler($file, $level) { if (empty(self::$handler)) { $handler = new StreamHandler($file, $level); $handler->setFormatter($this->getCustomFormatter()); self::$handler = $handler; } return self::$handler; }
[ "protected", "function", "getHandler", "(", "$", "file", ",", "$", "level", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "handler", ")", ")", "{", "$", "handler", "=", "new", "StreamHandler", "(", "$", "file", ",", "$", "level", ")", ";", ...
Get streamhandler. @param string $file @param int $level @return \Monolog\Handler\StreamHandler
[ "Get", "streamhandler", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/Logger.php#L62-L71
39,064
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.loadData
public function loadData() { $this->filePath = "{$this->cacheDir}/{$this->cacheFile}"; $this->validateConfig(); $urls = $this->prepareUrls($this->filePath, $this->urls, $this->forceRefresh, $this->cacheOnly); // we need at least one location if (!count($urls)) { throw new SyncException( 'No location(s) available to sync from', $this->errors ); } // cycle urls until valid data is found while (count($urls) && empty($validData)) { $nextUrl = array_shift($urls); if ($this->getData($nextUrl)) { $validData = true; } } // we should have valid data at this point if (!$this->parser->isValid() || empty($validData)) { throw new SyncException( 'Unable to download data or data invalid', $this->errors ); } return $this->parser->getParsedData(); }
php
public function loadData() { $this->filePath = "{$this->cacheDir}/{$this->cacheFile}"; $this->validateConfig(); $urls = $this->prepareUrls($this->filePath, $this->urls, $this->forceRefresh, $this->cacheOnly); // we need at least one location if (!count($urls)) { throw new SyncException( 'No location(s) available to sync from', $this->errors ); } // cycle urls until valid data is found while (count($urls) && empty($validData)) { $nextUrl = array_shift($urls); if ($this->getData($nextUrl)) { $validData = true; } } // we should have valid data at this point if (!$this->parser->isValid() || empty($validData)) { throw new SyncException( 'Unable to download data or data invalid', $this->errors ); } return $this->parser->getParsedData(); }
[ "public", "function", "loadData", "(", ")", "{", "$", "this", "->", "filePath", "=", "\"{$this->cacheDir}/{$this->cacheFile}\"", ";", "$", "this", "->", "validateConfig", "(", ")", ";", "$", "urls", "=", "$", "this", "->", "prepareUrls", "(", "$", "this", ...
Return parsed data. @throws SyncException @return \Vatsimphp\Result\ResultContainer
[ "Return", "parsed", "data", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L184-L215
39,065
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.validateConfig
protected function validateConfig() { $this->validateUrls(); $this->validateRefreshInterval(); $this->validateCacheFile(); $this->validateFilePath(); $this->validateParser(); return true; }
php
protected function validateConfig() { $this->validateUrls(); $this->validateRefreshInterval(); $this->validateCacheFile(); $this->validateFilePath(); $this->validateParser(); return true; }
[ "protected", "function", "validateConfig", "(", ")", "{", "$", "this", "->", "validateUrls", "(", ")", ";", "$", "this", "->", "validateRefreshInterval", "(", ")", ";", "$", "this", "->", "validateCacheFile", "(", ")", ";", "$", "this", "->", "validateFile...
Validate config wrapper.
[ "Validate", "config", "wrapper", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L286-L295
39,066
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.validateFilePath
protected function validateFilePath() { if (file_exists($this->filePath)) { if (!is_writable($this->filePath)) { throw new RuntimeException( "File '{$this->filePath}' exist but is not writable" ); } } else { if (!is_writable(dirname($this->filePath))) { throw new RuntimeException( "File '{$this->filePath}' is not writable" ); } } }
php
protected function validateFilePath() { if (file_exists($this->filePath)) { if (!is_writable($this->filePath)) { throw new RuntimeException( "File '{$this->filePath}' exist but is not writable" ); } } else { if (!is_writable(dirname($this->filePath))) { throw new RuntimeException( "File '{$this->filePath}' is not writable" ); } } }
[ "protected", "function", "validateFilePath", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "filePath", ")", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "filePath", ")", ")", "{", "throw", "new", "RuntimeException",...
Validate filePath. @throws RuntimeException
[ "Validate", "filePath", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L344-L359
39,067
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.initCurl
protected function initCurl() { if (empty($this->curl)) { $this->curl = curl_init(); curl_setopt_array($this->curl, $this->curlOpts); $this->log->debug('cURL object initialized', $this->curlOpts); } }
php
protected function initCurl() { if (empty($this->curl)) { $this->curl = curl_init(); curl_setopt_array($this->curl, $this->curlOpts); $this->log->debug('cURL object initialized', $this->curlOpts); } }
[ "protected", "function", "initCurl", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "curl", ")", ")", "{", "$", "this", "->", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt_array", "(", "$", "this", "->", "curl", ",", "$", "this"...
Initialize curl resource.
[ "Initialize", "curl", "resource", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L378-L385
39,068
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.loadFromUrl
protected function loadFromUrl($url) { $url = $this->overrideUrl($url); $this->log->debug("Load from url $url"); $this->initCurl(); curl_setopt($this->curl, CURLOPT_URL, $url); if (!$data = $this->getDataFromCurl()) { return false; } // fix encoding $data = iconv('ISO-8859-15', 'UTF-8', $data); // validate data through parser if (!$this->isDataValid($data)) { $this->addError($url, 'Data not valid according to parser'); return false; } // save result to disk $this->saveToCache($data); return true; }
php
protected function loadFromUrl($url) { $url = $this->overrideUrl($url); $this->log->debug("Load from url $url"); $this->initCurl(); curl_setopt($this->curl, CURLOPT_URL, $url); if (!$data = $this->getDataFromCurl()) { return false; } // fix encoding $data = iconv('ISO-8859-15', 'UTF-8', $data); // validate data through parser if (!$this->isDataValid($data)) { $this->addError($url, 'Data not valid according to parser'); return false; } // save result to disk $this->saveToCache($data); return true; }
[ "protected", "function", "loadFromUrl", "(", "$", "url", ")", "{", "$", "url", "=", "$", "this", "->", "overrideUrl", "(", "$", "url", ")", ";", "$", "this", "->", "log", "->", "debug", "(", "\"Load from url $url\"", ")", ";", "$", "this", "->", "ini...
Load data from url and pass it to the parser If successful save raw data to cache. @param string $url @return bool
[ "Load", "data", "from", "url", "and", "pass", "it", "to", "the", "parser", "If", "successful", "save", "raw", "data", "to", "cache", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L411-L435
39,069
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.getDataFromCurl
protected function getDataFromCurl() { $data = curl_exec($this->curl); if (curl_errno($this->curl)) { $this->addError(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL), curl_error($this->curl)); return false; } return $data; }
php
protected function getDataFromCurl() { $data = curl_exec($this->curl); if (curl_errno($this->curl)) { $this->addError(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL), curl_error($this->curl)); return false; } return $data; }
[ "protected", "function", "getDataFromCurl", "(", ")", "{", "$", "data", "=", "curl_exec", "(", "$", "this", "->", "curl", ")", ";", "if", "(", "curl_errno", "(", "$", "this", "->", "curl", ")", ")", "{", "$", "this", "->", "addError", "(", "curl_geti...
Load data from curl resource. @codeCoverageIgnore @return false|string
[ "Load", "data", "from", "curl", "resource", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L444-L454
39,070
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.loadFromCache
protected function loadFromCache() { $this->log->debug("Load from cache file {$this->filePath}"); $data = $this->getDataFromFile(); if ($data === false) { $data = ''; } // validate data through parser if (!$this->isDataValid($data)) { $this->addError($this->filePath, 'Data not valid according to parser'); return false; } // verify if local cache is expired if ($this->isCacheExpired()) { $this->addError($this->filePath, 'Local cache is expired'); return false; } return true; }
php
protected function loadFromCache() { $this->log->debug("Load from cache file {$this->filePath}"); $data = $this->getDataFromFile(); if ($data === false) { $data = ''; } // validate data through parser if (!$this->isDataValid($data)) { $this->addError($this->filePath, 'Data not valid according to parser'); return false; } // verify if local cache is expired if ($this->isCacheExpired()) { $this->addError($this->filePath, 'Local cache is expired'); return false; } return true; }
[ "protected", "function", "loadFromCache", "(", ")", "{", "$", "this", "->", "log", "->", "debug", "(", "\"Load from cache file {$this->filePath}\"", ")", ";", "$", "data", "=", "$", "this", "->", "getDataFromFile", "(", ")", ";", "if", "(", "$", "data", "=...
Load data from file and pass it to the parser Fails if content is expired. @return bool
[ "Load", "data", "from", "file", "and", "pass", "it", "to", "the", "parser", "Fails", "if", "content", "is", "expired", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L462-L485
39,071
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.isDataValid
protected function isDataValid($data) { $this->parser->setData($data); $this->parser->parseData(); return $this->parser->isValid(); }
php
protected function isDataValid($data) { $this->parser->setData($data); $this->parser->parseData(); return $this->parser->isValid(); }
[ "protected", "function", "isDataValid", "(", "$", "data", ")", "{", "$", "this", "->", "parser", "->", "setData", "(", "$", "data", ")", ";", "$", "this", "->", "parser", "->", "parseData", "(", ")", ";", "return", "$", "this", "->", "parser", "->", ...
Validate the raw data using parser object. @param string $data @return bool
[ "Validate", "the", "raw", "data", "using", "parser", "object", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L506-L512
39,072
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.saveToCache
protected function saveToCache($data) { $fh = fopen($this->filePath, 'w'); if (flock($fh, LOCK_EX)) { fwrite($fh, $data); flock($fh, LOCK_UN); } fclose($fh); $this->log->debug("Cache file {$this->filePath} saved"); }
php
protected function saveToCache($data) { $fh = fopen($this->filePath, 'w'); if (flock($fh, LOCK_EX)) { fwrite($fh, $data); flock($fh, LOCK_UN); } fclose($fh); $this->log->debug("Cache file {$this->filePath} saved"); }
[ "protected", "function", "saveToCache", "(", "$", "data", ")", "{", "$", "fh", "=", "fopen", "(", "$", "this", "->", "filePath", ",", "'w'", ")", ";", "if", "(", "flock", "(", "$", "fh", ",", "LOCK_EX", ")", ")", "{", "fwrite", "(", "$", "fh", ...
Atomic save raw data to cache file. @param string $data
[ "Atomic", "save", "raw", "data", "to", "cache", "file", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L519-L528
39,073
skymeyer/Vatsimphp
src/Vatsimphp/Sync/AbstractSync.php
AbstractSync.isCacheExpired
protected function isCacheExpired() { $ts = filemtime($this->filePath); if (!$this->cacheOnly && time() - $ts >= $this->refreshInterval) { $this->log->debug("Cache content {$this->filePath} expired ({$this->refreshInterval})"); return true; } return false; }
php
protected function isCacheExpired() { $ts = filemtime($this->filePath); if (!$this->cacheOnly && time() - $ts >= $this->refreshInterval) { $this->log->debug("Cache content {$this->filePath} expired ({$this->refreshInterval})"); return true; } return false; }
[ "protected", "function", "isCacheExpired", "(", ")", "{", "$", "ts", "=", "filemtime", "(", "$", "this", "->", "filePath", ")", ";", "if", "(", "!", "$", "this", "->", "cacheOnly", "&&", "time", "(", ")", "-", "$", "ts", ">=", "$", "this", "->", ...
Verify if file content is outdated based on the file last modification timestamp. @return bool
[ "Verify", "if", "file", "content", "is", "outdated", "based", "on", "the", "file", "last", "modification", "timestamp", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/AbstractSync.php#L536-L546
39,074
skymeyer/Vatsimphp
src/Vatsimphp/Filter/AbstractFilter.php
AbstractFilter.isComment
protected function isComment($line) { if (is_string($line) && (substr($line, 0, 1) == ';' || trim($line) == '')) { return true; } return false; }
php
protected function isComment($line) { if (is_string($line) && (substr($line, 0, 1) == ';' || trim($line) == '')) { return true; } return false; }
[ "protected", "function", "isComment", "(", "$", "line", ")", "{", "if", "(", "is_string", "(", "$", "line", ")", "&&", "(", "substr", "(", "$", "line", ",", "0", ",", "1", ")", "==", "';'", "||", "trim", "(", "$", "line", ")", "==", "''", ")", ...
Check if current element is a comment. @params mixed $line @return bool
[ "Check", "if", "current", "element", "is", "a", "comment", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Filter/AbstractFilter.php#L139-L146
39,075
skymeyer/Vatsimphp
src/Vatsimphp/Sync/BaseSync.php
BaseSync.registerUrlFromStatus
public function registerUrlFromStatus(\Vatsimphp\Sync\StatusSync $sync, $type) { $urls = $sync->loadData()->get($type)->toArray(); if (empty($urls)) { throw new RuntimeException( 'Error loading urls from StatusSync' ); } $this->registerUrl($urls, true); return true; }
php
public function registerUrlFromStatus(\Vatsimphp\Sync\StatusSync $sync, $type) { $urls = $sync->loadData()->get($type)->toArray(); if (empty($urls)) { throw new RuntimeException( 'Error loading urls from StatusSync' ); } $this->registerUrl($urls, true); return true; }
[ "public", "function", "registerUrlFromStatus", "(", "\\", "Vatsimphp", "\\", "Sync", "\\", "StatusSync", "$", "sync", ",", "$", "type", ")", "{", "$", "urls", "=", "$", "sync", "->", "loadData", "(", ")", "->", "get", "(", "$", "type", ")", "->", "to...
Use StatusSync to dynamically add the available data urls to poll new data from. @param \Vatsimphp\Sync\StatusSync $sync @param string $type - the type of urls to use (ie dataUrls) @throws \Vatsimphp\Exception\RuntimeException
[ "Use", "StatusSync", "to", "dynamically", "add", "the", "available", "data", "urls", "to", "poll", "new", "data", "from", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/BaseSync.php#L42-L53
39,076
clue/php-commander
src/Router.php
Router.add
public function add($route, $handler) { if (trim($route) === '') { $token = null; } else { $token = $this->tokenizer->createToken($route); } $route = new Route($token, $handler); $this->routes[] = $route; return $route; }
php
public function add($route, $handler) { if (trim($route) === '') { $token = null; } else { $token = $this->tokenizer->createToken($route); } $route = new Route($token, $handler); $this->routes[] = $route; return $route; }
[ "public", "function", "add", "(", "$", "route", ",", "$", "handler", ")", "{", "if", "(", "trim", "(", "$", "route", ")", "===", "''", ")", "{", "$", "token", "=", "null", ";", "}", "else", "{", "$", "token", "=", "$", "this", "->", "tokenizer"...
Registers a new Route with this Router @param string $route the route expression to match @param callable $handler route callback that will be executed when this route expression matches @return Route @throws InvalidArgumentException if the route expression is invalid
[ "Registers", "a", "new", "Route", "with", "this", "Router" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L41-L53
39,077
clue/php-commander
src/Router.php
Router.remove
public function remove(Route $route) { $id = array_search($route, $this->routes); if ($id === false) { throw new \UnderflowException('Given Route not found'); } unset($this->routes[$id]); }
php
public function remove(Route $route) { $id = array_search($route, $this->routes); if ($id === false) { throw new \UnderflowException('Given Route not found'); } unset($this->routes[$id]); }
[ "public", "function", "remove", "(", "Route", "$", "route", ")", "{", "$", "id", "=", "array_search", "(", "$", "route", ",", "$", "this", "->", "routes", ")", ";", "if", "(", "$", "id", "===", "false", ")", "{", "throw", "new", "\\", "UnderflowExc...
Removes the given route object from the registered routes @param Route $route @throws \UnderflowException if the route does not exist
[ "Removes", "the", "given", "route", "object", "from", "the", "registered", "routes" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L61-L69
39,078
clue/php-commander
src/Router.php
Router.execArgv
public function execArgv(array $argv = null) { try { $this->handleArgv($argv); // @codeCoverageIgnoreStart } catch (NoRouteFoundException $e) { fwrite(STDERR, 'Usage Error: ' . $e->getMessage() . PHP_EOL); // sysexits.h: #define EX_USAGE 64 /* command line usage error */ exit(64); } catch (Exception $e) { fwrite(STDERR, 'Program Error: ' . $e->getMessage() . PHP_EOL); // stdlib.h: #define EXIT_FAILURE 1 exit(1); } // @codeCoverageIgnoreEnd }
php
public function execArgv(array $argv = null) { try { $this->handleArgv($argv); // @codeCoverageIgnoreStart } catch (NoRouteFoundException $e) { fwrite(STDERR, 'Usage Error: ' . $e->getMessage() . PHP_EOL); // sysexits.h: #define EX_USAGE 64 /* command line usage error */ exit(64); } catch (Exception $e) { fwrite(STDERR, 'Program Error: ' . $e->getMessage() . PHP_EOL); // stdlib.h: #define EXIT_FAILURE 1 exit(1); } // @codeCoverageIgnoreEnd }
[ "public", "function", "execArgv", "(", "array", "$", "argv", "=", "null", ")", "{", "try", "{", "$", "this", "->", "handleArgv", "(", "$", "argv", ")", ";", "// @codeCoverageIgnoreStart", "}", "catch", "(", "NoRouteFoundException", "$", "e", ")", "{", "f...
Executes by matching the `argv` against all registered routes and then exits This is a convenience method that will match and execute a route and then exit the program without returning. If no route could be found or if the route callback throws an Exception, it will print out an error message to STDERR and set an appropriate non-zero exit code. Note that this is for convenience only and only useful for the most simple of all programs. If you need more control, then consider using the underlying `handleArgv()` method and handle any error situations yourself. You can explicitly pass in your `argv` or it will automatically use the values from the $_SERVER superglobal. The `argv` is an array that will always start with the calling program as the first element. We simply ignore this first element and then process the remaining elements according to the registered routes. @param array $argv @uses self::handleArgv()
[ "Executes", "by", "matching", "the", "argv", "against", "all", "registered", "routes", "and", "then", "exits" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L105-L122
39,079
clue/php-commander
src/Router.php
Router.handleArgv
public function handleArgv(array $argv = null) { if ($argv === null) { $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); } array_shift($argv); return $this->handleArgs($argv); }
php
public function handleArgv(array $argv = null) { if ($argv === null) { $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array(); } array_shift($argv); return $this->handleArgs($argv); }
[ "public", "function", "handleArgv", "(", "array", "$", "argv", "=", "null", ")", "{", "if", "(", "$", "argv", "===", "null", ")", "{", "$", "argv", "=", "isset", "(", "$", "_SERVER", "[", "'argv'", "]", ")", "?", "$", "_SERVER", "[", "'argv'", "]...
Executes by matching the `argv` against all registered routes and then returns Unlike `execArgv()` this method will try to execute the route callback and then return whatever the route callback returned. If no route could be found or if the route callback throws an Exception, it will throw an Exception. You can explicitly pass in your `argv` or it will automatically use the values from the $_SERVER superglobal. The `argv` is an array that will always start with the calling program as the first element. We simply ignore this first element and then process the remaining elements according to the registered routes. @param array|null $argv @return mixed will be the return value from the matched route callback @throws Exception if the executed route callback throws an exception @throws NoRouteFoundException If no matching route could be found @uses self::handleArgs()
[ "Executes", "by", "matching", "the", "argv", "against", "all", "registered", "routes", "and", "then", "returns" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L145-L153
39,080
clue/php-commander
src/Router.php
Router.handleArgs
public function handleArgs(array $args) { foreach ($this->routes as $route) { $input = $args; $output = array(); if ($route->matches($input, $output)) { return $route($output); } } throw new NoRouteFoundException('No matching route found'); }
php
public function handleArgs(array $args) { foreach ($this->routes as $route) { $input = $args; $output = array(); if ($route->matches($input, $output)) { return $route($output); } } throw new NoRouteFoundException('No matching route found'); }
[ "public", "function", "handleArgs", "(", "array", "$", "args", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "$", "input", "=", "$", "args", ";", "$", "output", "=", "array", "(", ")", ";", "if", "(", "$", ...
Executes by matching the given args against all registered routes and then returns Unlike `handleArgv()` this method will use the complete `$args` array to match the registered routes (i.e. it will not ignore the first element). This is particularly useful if you build this array yourself or if you use an interactive command line interface (CLI) and ask your user to supply the arguments. The arguments have to be given as an array of individual elements. If you only have a command line string that you want to split into an array of individual command line arguments, consider using clue/arguments. @param array $args @return mixed will be the return value from the matched route callback @throws Exception if the executed route callback throws an exception @throws NoRouteFoundException If no matching route could be found
[ "Executes", "by", "matching", "the", "given", "args", "against", "all", "registered", "routes", "and", "then", "returns" ]
9b28ac3f9b3d968c24255b0e484bb35e2fd5783c
https://github.com/clue/php-commander/blob/9b28ac3f9b3d968c24255b0e484bb35e2fd5783c/src/Router.php#L173-L184
39,081
skymeyer/Vatsimphp
src/Vatsimphp/Log/LoggerFactory.php
LoggerFactory.get
public static function get($channel) { // in case an object is passed in we use the base class name as the channel if (is_object($channel)) { $ref = new \ReflectionClass($channel); $channel = $ref->getShortName(); } // custom log channels need to be registered in advance using self::register() if (!self::channelExists($channel)) { // use default logger object if set or fallback to builtin logger if (self::channelExists(self::DEFAULT_LOGGER)) { self::$loggers[$channel] = self::$loggers[self::DEFAULT_LOGGER]; } else { $file = empty(self::$file) ? __DIR__.'/../../../app/logs/vatsimphp.log' : self::$file; self::$loggers[$channel] = new Logger($channel, $file, self::$level); } } return self::$loggers[$channel]; }
php
public static function get($channel) { // in case an object is passed in we use the base class name as the channel if (is_object($channel)) { $ref = new \ReflectionClass($channel); $channel = $ref->getShortName(); } // custom log channels need to be registered in advance using self::register() if (!self::channelExists($channel)) { // use default logger object if set or fallback to builtin logger if (self::channelExists(self::DEFAULT_LOGGER)) { self::$loggers[$channel] = self::$loggers[self::DEFAULT_LOGGER]; } else { $file = empty(self::$file) ? __DIR__.'/../../../app/logs/vatsimphp.log' : self::$file; self::$loggers[$channel] = new Logger($channel, $file, self::$level); } } return self::$loggers[$channel]; }
[ "public", "static", "function", "get", "(", "$", "channel", ")", "{", "// in case an object is passed in we use the base class name as the channel", "if", "(", "is_object", "(", "$", "channel", ")", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "...
Load logger object. @param string|object $channel @return \Psr\Log\LoggerInterface
[ "Load", "logger", "object", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/LoggerFactory.php#L63-L84
39,082
skymeyer/Vatsimphp
src/Vatsimphp/Log/LoggerFactory.php
LoggerFactory.register
public static function register($channel, \Psr\Log\LoggerInterface $logger) { self::$loggers[$channel] = $logger; return $logger; }
php
public static function register($channel, \Psr\Log\LoggerInterface $logger) { self::$loggers[$channel] = $logger; return $logger; }
[ "public", "static", "function", "register", "(", "$", "channel", ",", "\\", "Psr", "\\", "Log", "\\", "LoggerInterface", "$", "logger", ")", "{", "self", "::", "$", "loggers", "[", "$", "channel", "]", "=", "$", "logger", ";", "return", "$", "logger", ...
Register log object for given channel. @param string $channel @param \Psr\Log\AbstractLogger $logger
[ "Register", "log", "object", "for", "given", "channel", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Log/LoggerFactory.php#L92-L97
39,083
skymeyer/Vatsimphp
src/Vatsimphp/VatsimData.php
VatsimData.getMetar
public function getMetar($icao) { if ($this->loadMetar($icao)) { $metar = $this->getArray('metar'); } return (empty($metar)) ? '' : array_shift($metar); }
php
public function getMetar($icao) { if ($this->loadMetar($icao)) { $metar = $this->getArray('metar'); } return (empty($metar)) ? '' : array_shift($metar); }
[ "public", "function", "getMetar", "(", "$", "icao", ")", "{", "if", "(", "$", "this", "->", "loadMetar", "(", "$", "icao", ")", ")", "{", "$", "metar", "=", "$", "this", "->", "getArray", "(", "'metar'", ")", ";", "}", "return", "(", "empty", "("...
Get METAR. @param string $icao @return string
[ "Get", "METAR", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L217-L224
39,084
skymeyer/Vatsimphp
src/Vatsimphp/VatsimData.php
VatsimData.loadData
public function loadData() { try { LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $data = $this->getDataSync(); $data->setDefaults(); $data->cacheDir = $this->config['cacheDir']; $data->cacheOnly = $this->config['cacheOnly']; $data->dataExpire = $this->config['dataExpire']; $data->refreshInterval = $this->config['dataRefresh']; $data->forceRefresh = $this->config['forceDataRefresh']; // use statussync for non-cache mode if (!$data->cacheOnly) { $status = $this->prepareSync(); $data->registerUrlFromStatus($status, 'dataUrls'); } $this->results = $data->loadData(); } catch (\Exception $e) { $this->exceptionStack[] = $e; return false; } return true; }
php
public function loadData() { try { LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $data = $this->getDataSync(); $data->setDefaults(); $data->cacheDir = $this->config['cacheDir']; $data->cacheOnly = $this->config['cacheOnly']; $data->dataExpire = $this->config['dataExpire']; $data->refreshInterval = $this->config['dataRefresh']; $data->forceRefresh = $this->config['forceDataRefresh']; // use statussync for non-cache mode if (!$data->cacheOnly) { $status = $this->prepareSync(); $data->registerUrlFromStatus($status, 'dataUrls'); } $this->results = $data->loadData(); } catch (\Exception $e) { $this->exceptionStack[] = $e; return false; } return true; }
[ "public", "function", "loadData", "(", ")", "{", "try", "{", "LoggerFactory", "::", "$", "file", "=", "$", "this", "->", "config", "[", "'logFile'", "]", ";", "LoggerFactory", "::", "$", "level", "=", "$", "this", "->", "config", "[", "'logLevel'", "]"...
Load data from Vatsim network. @return bool
[ "Load", "data", "from", "Vatsim", "network", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L233-L260
39,085
skymeyer/Vatsimphp
src/Vatsimphp/VatsimData.php
VatsimData.loadMetar
public function loadMetar($icao) { try { $metar = $this->prepareMetarSync(); $metar->setAirport($icao); $this->results = $metar->loadData(); } catch (\Exception $e) { $this->exceptionStack[] = $e; return false; } return true; }
php
public function loadMetar($icao) { try { $metar = $this->prepareMetarSync(); $metar->setAirport($icao); $this->results = $metar->loadData(); } catch (\Exception $e) { $this->exceptionStack[] = $e; return false; } return true; }
[ "public", "function", "loadMetar", "(", "$", "icao", ")", "{", "try", "{", "$", "metar", "=", "$", "this", "->", "prepareMetarSync", "(", ")", ";", "$", "metar", "->", "setAirport", "(", "$", "icao", ")", ";", "$", "this", "->", "results", "=", "$"...
Load METAR data for given airport. @param string $icao @return bool
[ "Load", "METAR", "data", "for", "given", "airport", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L269-L282
39,086
skymeyer/Vatsimphp
src/Vatsimphp/VatsimData.php
VatsimData.prepareSync
protected function prepareSync() { if (!empty($this->statusSync)) { return $this->statusSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->statusSync = $this->getStatusSync(); $this->statusSync->setDefaults(); $this->statusSync->cacheDir = $this->config['cacheDir']; $this->statusSync->refreshInterval = $this->config['statusRefresh']; if (!empty($this->config['statusUrl'])) { $this->statusSync->registerUrl($this->config['statusUrl'], true); } return $this->statusSync; }
php
protected function prepareSync() { if (!empty($this->statusSync)) { return $this->statusSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->statusSync = $this->getStatusSync(); $this->statusSync->setDefaults(); $this->statusSync->cacheDir = $this->config['cacheDir']; $this->statusSync->refreshInterval = $this->config['statusRefresh']; if (!empty($this->config['statusUrl'])) { $this->statusSync->registerUrl($this->config['statusUrl'], true); } return $this->statusSync; }
[ "protected", "function", "prepareSync", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "statusSync", ")", ")", "{", "return", "$", "this", "->", "statusSync", ";", "}", "LoggerFactory", "::", "$", "file", "=", "$", "this", "->", "con...
Prepare StatusSync object for reusage. @return StatusSync
[ "Prepare", "StatusSync", "object", "for", "reusage", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L388-L404
39,087
skymeyer/Vatsimphp
src/Vatsimphp/VatsimData.php
VatsimData.prepareMetarSync
protected function prepareMetarSync() { if (!empty($this->metarSync)) { return $this->metarSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->metarSync = $this->getMetarSync(); $this->metarSync->setDefaults(); $this->metarSync->cacheDir = $this->config['cacheDir']; $this->metarSync->cacheOnly = false; $this->metarSync->refreshInterval = $this->config['metarRefresh']; $this->metarSync->forceRefresh = $this->config['forceMetarRefresh']; $this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls'); return $this->metarSync; }
php
protected function prepareMetarSync() { if (!empty($this->metarSync)) { return $this->metarSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->metarSync = $this->getMetarSync(); $this->metarSync->setDefaults(); $this->metarSync->cacheDir = $this->config['cacheDir']; $this->metarSync->cacheOnly = false; $this->metarSync->refreshInterval = $this->config['metarRefresh']; $this->metarSync->forceRefresh = $this->config['forceMetarRefresh']; $this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls'); return $this->metarSync; }
[ "protected", "function", "prepareMetarSync", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "metarSync", ")", ")", "{", "return", "$", "this", "->", "metarSync", ";", "}", "LoggerFactory", "::", "$", "file", "=", "$", "this", "->", "...
Prepare MetarSync object for reusage. @return MetarSync
[ "Prepare", "MetarSync", "object", "for", "reusage", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/VatsimData.php#L411-L427
39,088
skymeyer/Vatsimphp
src/Vatsimphp/Parser/AbstractParser.php
AbstractParser.setData
public function setData($data) { $this->valid = false; $this->hash = md5($data, false); $this->rawData = explode("\n", $data); }
php
public function setData($data) { $this->valid = false; $this->hash = md5($data, false); $this->rawData = explode("\n", $data); }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "$", "this", "->", "valid", "=", "false", ";", "$", "this", "->", "hash", "=", "md5", "(", "$", "data", ",", "false", ")", ";", "$", "this", "->", "rawData", "=", "explode", "(", "\"\\n...
Set raw data. @param string $data
[ "Set", "raw", "data", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Parser/AbstractParser.php#L80-L85
39,089
skymeyer/Vatsimphp
src/Vatsimphp/Result/ResultContainer.php
ResultContainer.get
public function get($name) { if (isset($this->container[$name])) { return $this->container[$name]; } else { return new Iterator([]); } }
php
public function get($name) { if (isset($this->container[$name])) { return $this->container[$name]; } else { return new Iterator([]); } }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "container", "[", "$", "name", "]", ";", "}", "else", "{", "ret...
Get result object from container. @param string $name @return \Vatsimphp\Filter\AbstractFilter
[ "Get", "result", "object", "from", "container", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Result/ResultContainer.php#L80-L87
39,090
skymeyer/Vatsimphp
src/Vatsimphp/Result/ResultContainer.php
ResultContainer.search
public function search($objectType, $query = []) { $results = []; if ($this->isSearchable($objectType)) { foreach ($this->get($objectType) as $line) { foreach ($query as $field => $needle) { if (isset($line[$field])) { if (stripos($line[$field], $needle) !== false) { $results[] = $line; } } } } } return new Iterator($results); }
php
public function search($objectType, $query = []) { $results = []; if ($this->isSearchable($objectType)) { foreach ($this->get($objectType) as $line) { foreach ($query as $field => $needle) { if (isset($line[$field])) { if (stripos($line[$field], $needle) !== false) { $results[] = $line; } } } } } return new Iterator($results); }
[ "public", "function", "search", "(", "$", "objectType", ",", "$", "query", "=", "[", "]", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isSearchable", "(", "$", "objectType", ")", ")", "{", "foreach", "(", "$", "thi...
Base search functionality. @param string $objectType @param array $query @return \Vatsimphp\Filter\Iterator
[ "Base", "search", "functionality", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Result/ResultContainer.php#L115-L131
39,091
skymeyer/Vatsimphp
src/Vatsimphp/Filter/SectionDataFilter.php
SectionDataFilter.fixData
protected function fixData($data) { $addCols = count($this->header) - count($data); for ($i = 1; $i <= $addCols; $i++) { $data[] = ''; } return $data; }
php
protected function fixData($data) { $addCols = count($this->header) - count($data); for ($i = 1; $i <= $addCols; $i++) { $data[] = ''; } return $data; }
[ "protected", "function", "fixData", "(", "$", "data", ")", "{", "$", "addCols", "=", "count", "(", "$", "this", "->", "header", ")", "-", "count", "(", "$", "data", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "addCols", ...
Fix data points. It seems some data points are empty at the end which got truncated in the data resulting in an offset between header and actual data points. This method corrects the data by adding missing empty values at the end. @param array $data @return array
[ "Fix", "data", "points", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Filter/SectionDataFilter.php#L88-L96
39,092
wpreadme2markdown/wp-readme-to-markdown
src/Converter.php
Converter.findScreenshot
private static function findScreenshot($number, $plugin_slug) { $extensions = array('png', 'jpg', 'jpeg', 'gif'); // this seems to now be the correct URL, not s.wordpress.org/plugins $base_url = 'https://s.w.org/plugins/' . $plugin_slug . '/'; $assets_url = 'https://ps.w.org/' . $plugin_slug . '/assets/'; /* check assets for all extensions first, because if there's a gif in the assets directory and a jpg in the base directory, the one in the assets directory needs to win. */ foreach (array($assets_url, $base_url) as $prefix_url) { foreach ($extensions as $ext) { $url = $prefix_url . 'screenshot-' . $number . '.' . $ext; if (self::validateUrl($url)) { return $url; } } } return false; }
php
private static function findScreenshot($number, $plugin_slug) { $extensions = array('png', 'jpg', 'jpeg', 'gif'); // this seems to now be the correct URL, not s.wordpress.org/plugins $base_url = 'https://s.w.org/plugins/' . $plugin_slug . '/'; $assets_url = 'https://ps.w.org/' . $plugin_slug . '/assets/'; /* check assets for all extensions first, because if there's a gif in the assets directory and a jpg in the base directory, the one in the assets directory needs to win. */ foreach (array($assets_url, $base_url) as $prefix_url) { foreach ($extensions as $ext) { $url = $prefix_url . 'screenshot-' . $number . '.' . $ext; if (self::validateUrl($url)) { return $url; } } } return false; }
[ "private", "static", "function", "findScreenshot", "(", "$", "number", ",", "$", "plugin_slug", ")", "{", "$", "extensions", "=", "array", "(", "'png'", ",", "'jpg'", ",", "'jpeg'", ",", "'gif'", ")", ";", "// this seems to now be the correct URL, not s.wordpress....
Finds the correct screenshot file with the given number and plugin slug. As per the WordPress plugin repo, file extensions may be any of: (png|jpg|jpeg|gif). We look in the /assets directory first, then in the base directory. @param int $number Screenshot number to look for @param string $plugin_slug @return string|false Valid screenshot URL or false if none found @uses url_validate @link http://wordpress.org/plugins/about/readme.txt
[ "Finds", "the", "correct", "screenshot", "file", "with", "the", "given", "number", "and", "plugin", "slug", "." ]
7f92cb393eb1265baea8a5c2391ac2d0490e1f40
https://github.com/wpreadme2markdown/wp-readme-to-markdown/blob/7f92cb393eb1265baea8a5c2391ac2d0490e1f40/src/Converter.php#L92-L114
39,093
wpreadme2markdown/wp-readme-to-markdown
src/Converter.php
Converter.validateUrl
private static function validateUrl($link) { $url_parts = @parse_url($link); if (empty($url_parts['host'])) { return false; } $host = $url_parts['host']; if (!empty($url_parts['path'])) { $documentpath = $url_parts['path']; } else { $documentpath = '/'; } if (!empty($url_parts['query'])) { $documentpath .= '?' . $url_parts['query']; } if (!empty($url_parts['port'])) { $port = $url_parts['port']; } else { $port = '80'; } $socket = @fsockopen($host, $port, $errno, $errstr, 30); if (!$socket) { return false; } else { fwrite($socket, "HEAD " . $documentpath . " HTTP/1.0\r\nHost: $host\r\n\r\n"); $http_response = fgets($socket, 22); if (preg_match('/200 OK/', $http_response, $regs)) { fclose($socket); return true; } else { return false; } } }
php
private static function validateUrl($link) { $url_parts = @parse_url($link); if (empty($url_parts['host'])) { return false; } $host = $url_parts['host']; if (!empty($url_parts['path'])) { $documentpath = $url_parts['path']; } else { $documentpath = '/'; } if (!empty($url_parts['query'])) { $documentpath .= '?' . $url_parts['query']; } if (!empty($url_parts['port'])) { $port = $url_parts['port']; } else { $port = '80'; } $socket = @fsockopen($host, $port, $errno, $errstr, 30); if (!$socket) { return false; } else { fwrite($socket, "HEAD " . $documentpath . " HTTP/1.0\r\nHost: $host\r\n\r\n"); $http_response = fgets($socket, 22); if (preg_match('/200 OK/', $http_response, $regs)) { fclose($socket); return true; } else { return false; } } }
[ "private", "static", "function", "validateUrl", "(", "$", "link", ")", "{", "$", "url_parts", "=", "@", "parse_url", "(", "$", "link", ")", ";", "if", "(", "empty", "(", "$", "url_parts", "[", "'host'", "]", ")", ")", "{", "return", "false", ";", "...
Test whether a file exists at the given URL. To do this as quickly as possible, we use fsockopen to just get the HTTP headers and see if the response is "200 OK". This is better than fopen (which would download the entire file) and cURL (which might not be installed on all systems). @param string $link URL to validate @return boolean @link http://www.php.net/manual/en/function.fsockopen.php#39948
[ "Test", "whether", "a", "file", "exists", "at", "the", "given", "URL", "." ]
7f92cb393eb1265baea8a5c2391ac2d0490e1f40
https://github.com/wpreadme2markdown/wp-readme-to-markdown/blob/7f92cb393eb1265baea8a5c2391ac2d0490e1f40/src/Converter.php#L128-L168
39,094
skymeyer/Vatsimphp
src/Vatsimphp/Sync/MetarSync.php
MetarSync.setAirport
public function setAirport($icao) { if (strlen($icao) != 4) { throw new RuntimeException('invalid ICAO code'); } $this->icao = strtoupper($icao); $this->cacheFile = "metar-{$this->icao}.txt"; }
php
public function setAirport($icao) { if (strlen($icao) != 4) { throw new RuntimeException('invalid ICAO code'); } $this->icao = strtoupper($icao); $this->cacheFile = "metar-{$this->icao}.txt"; }
[ "public", "function", "setAirport", "(", "$", "icao", ")", "{", "if", "(", "strlen", "(", "$", "icao", ")", "!=", "4", ")", "{", "throw", "new", "RuntimeException", "(", "'invalid ICAO code'", ")", ";", "}", "$", "this", "->", "icao", "=", "strtoupper"...
Set airport - cache file is based on this. @param string $icao @throws Vatsimphp\Exception\RuntimeException
[ "Set", "airport", "-", "cache", "file", "is", "based", "on", "this", "." ]
cc458a3962f9512cb042d65972b99d88ef75164c
https://github.com/skymeyer/Vatsimphp/blob/cc458a3962f9512cb042d65972b99d88ef75164c/src/Vatsimphp/Sync/MetarSync.php#L53-L60
39,095
richardfullmer/php-rabbitmq-management-api
src/Api/Permission.php
Permission.get
public function get($vhost, $user) { return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user))); }
php
public function get($vhost, $user) { return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user))); }
[ "public", "function", "get", "(", "$", "vhost", ",", "$", "user", ")", "{", "return", "$", "this", "->", "client", "->", "send", "(", "sprintf", "(", "'/api/permissions/%s/%s'", ",", "urlencode", "(", "$", "vhost", ")", ",", "urlencode", "(", "$", "use...
An individual permission of a user and virtual host. @param string $vhost @param string $user @return array
[ "An", "individual", "permission", "of", "a", "user", "and", "virtual", "host", "." ]
047383f9fc9dd0287e914f4a6f6c8ba9115e9aba
https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Permission.php#L31-L34
39,096
richardfullmer/php-rabbitmq-management-api
src/Api/Permission.php
Permission.delete
public function delete($vhost, $user) { return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)), 'DELETE'); }
php
public function delete($vhost, $user) { return $this->client->send(sprintf('/api/permissions/%s/%s', urlencode($vhost), urlencode($user)), 'DELETE'); }
[ "public", "function", "delete", "(", "$", "vhost", ",", "$", "user", ")", "{", "return", "$", "this", "->", "client", "->", "send", "(", "sprintf", "(", "'/api/permissions/%s/%s'", ",", "urlencode", "(", "$", "vhost", ")", ",", "urlencode", "(", "$", "...
Delete a specific set of permissions @param string $vhost @param string $user @return array
[ "Delete", "a", "specific", "set", "of", "permissions" ]
047383f9fc9dd0287e914f4a6f6c8ba9115e9aba
https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Permission.php#L65-L68
39,097
richardfullmer/php-rabbitmq-management-api
src/Api/Policy.php
Policy.get
public function get($vhost, $name = null) { if ($name) { return $this->client->send(sprintf('/api/policies/%s/%s', urlencode($vhost), urlencode($name))); } return $this->client->send(sprintf('/api/policies/%s', urlencode($vhost))); }
php
public function get($vhost, $name = null) { if ($name) { return $this->client->send(sprintf('/api/policies/%s/%s', urlencode($vhost), urlencode($name))); } return $this->client->send(sprintf('/api/policies/%s', urlencode($vhost))); }
[ "public", "function", "get", "(", "$", "vhost", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", ")", "{", "return", "$", "this", "->", "client", "->", "send", "(", "sprintf", "(", "'/api/policies/%s/%s'", ",", "urlencode", "(", "$", ...
A list of all policies in a given virtual host. OR An individual policy. @param string $vhost @param string|null $name @return array
[ "A", "list", "of", "all", "policies", "in", "a", "given", "virtual", "host", "." ]
047383f9fc9dd0287e914f4a6f6c8ba9115e9aba
https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Policy.php#L33-L40
39,098
richardfullmer/php-rabbitmq-management-api
src/Api/Parameter.php
Parameter.get
public function get($component, $vhost = null, $name = null) { if ($vhost && $name) { return $this->client->send(sprintf('/api/parameters/%s/%s/%s', urlencode($component), urlencode($vhost), urlencode($name))); } elseif ($vhost) { return $this->client->send(sprintf('/api/parameters/%s/%s', urlencode($component), urlencode($vhost))); } else { return $this->client->send(sprintf('/api/parameters/%s', urlencode($component))); } }
php
public function get($component, $vhost = null, $name = null) { if ($vhost && $name) { return $this->client->send(sprintf('/api/parameters/%s/%s/%s', urlencode($component), urlencode($vhost), urlencode($name))); } elseif ($vhost) { return $this->client->send(sprintf('/api/parameters/%s/%s', urlencode($component), urlencode($vhost))); } else { return $this->client->send(sprintf('/api/parameters/%s', urlencode($component))); } }
[ "public", "function", "get", "(", "$", "component", ",", "$", "vhost", "=", "null", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "vhost", "&&", "$", "name", ")", "{", "return", "$", "this", "->", "client", "->", "send", "(", "sprintf"...
A list of all parameters for a given component and virtual host. @param string $component @param string|null $vhost @param string|null $name @return array
[ "A", "list", "of", "all", "parameters", "for", "a", "given", "component", "and", "virtual", "host", "." ]
047383f9fc9dd0287e914f4a6f6c8ba9115e9aba
https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Parameter.php#L30-L39
39,099
richardfullmer/php-rabbitmq-management-api
src/Api/Queue.php
Queue.bindings
public function bindings($vhost, $queue) { return $this->client->send(sprintf('/api/queues/%s/%s/bindings', urlencode($vhost), urlencode($queue))); }
php
public function bindings($vhost, $queue) { return $this->client->send(sprintf('/api/queues/%s/%s/bindings', urlencode($vhost), urlencode($queue))); }
[ "public", "function", "bindings", "(", "$", "vhost", ",", "$", "queue", ")", "{", "return", "$", "this", "->", "client", "->", "send", "(", "sprintf", "(", "'/api/queues/%s/%s/bindings'", ",", "urlencode", "(", "$", "vhost", ")", ",", "urlencode", "(", "...
A list of all bindings on a given queue. @param string $vhost @param string $queue @return array
[ "A", "list", "of", "all", "bindings", "on", "a", "given", "queue", "." ]
047383f9fc9dd0287e914f4a6f6c8ba9115e9aba
https://github.com/richardfullmer/php-rabbitmq-management-api/blob/047383f9fc9dd0287e914f4a6f6c8ba9115e9aba/src/Api/Queue.php#L82-L85