repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
phpnfe/tools
src/Builder/Builder.php
Builder.formatar
protected function formatar($nome, $valor) { $ref = new \ReflectionProperty(get_class($this), $nome); $factory = DocBlockFactory::createInstance(); $info = $factory->create($ref->getDocComment()); // Pegar o tipo da variavel $tipo = $info->getTagsByName('var'); $tipo = (count($tipo) == 0) ? 'string' : $tipo[0]->getType(); $tipo = strtolower($tipo); switch ($tipo) { case 'string': case 'string|null': case '\string': case '\string|null': $valor = str_replace(['@'], ['#1#'], utf8_encode($valor)); // Ignorar alguns caracteres no ascii $valor = Str::ascii($valor); $valor = str_replace(['&'], ['e'], $valor); $valor = str_replace(['#1#'], ['@'], $valor); // Retornar caracteres ignorados $valor = Str::upper($valor); $valor = trim($valor); // Max $max = $info->getTagsByName('max'); if (count($max) > 0) { $max = intval($max[0]->getDescription()->render()); $valor = trim(substr($valor, 0, $max)); } return $valor; case 'float|null': case 'float': $dec = $info->getTagsByName('dec'); if (count($dec) == 0) { return $valor; } // Valor do @dec $dec = $dec[0]->getDescription()->render(); return number_format($valor, $dec, '.', ''); case 'datetime': case '\datetime': case '\datetime|null': case 'date': case 'date|null': case '\date': case '\date|null': if (is_int($valor)) { $valor = Carbon::createFromTimestamp($valor); } if (is_string($valor)) { return $valor; } $format = in_array($tipo, ['date', 'date|null', '\date', '\date|null']) ? 'Y-m-d' : Carbon::ATOM; return $valor->format($format); default: return $valor; } }
php
protected function formatar($nome, $valor) { $ref = new \ReflectionProperty(get_class($this), $nome); $factory = DocBlockFactory::createInstance(); $info = $factory->create($ref->getDocComment()); // Pegar o tipo da variavel $tipo = $info->getTagsByName('var'); $tipo = (count($tipo) == 0) ? 'string' : $tipo[0]->getType(); $tipo = strtolower($tipo); switch ($tipo) { case 'string': case 'string|null': case '\string': case '\string|null': $valor = str_replace(['@'], ['#1#'], utf8_encode($valor)); // Ignorar alguns caracteres no ascii $valor = Str::ascii($valor); $valor = str_replace(['&'], ['e'], $valor); $valor = str_replace(['#1#'], ['@'], $valor); // Retornar caracteres ignorados $valor = Str::upper($valor); $valor = trim($valor); // Max $max = $info->getTagsByName('max'); if (count($max) > 0) { $max = intval($max[0]->getDescription()->render()); $valor = trim(substr($valor, 0, $max)); } return $valor; case 'float|null': case 'float': $dec = $info->getTagsByName('dec'); if (count($dec) == 0) { return $valor; } // Valor do @dec $dec = $dec[0]->getDescription()->render(); return number_format($valor, $dec, '.', ''); case 'datetime': case '\datetime': case '\datetime|null': case 'date': case 'date|null': case '\date': case '\date|null': if (is_int($valor)) { $valor = Carbon::createFromTimestamp($valor); } if (is_string($valor)) { return $valor; } $format = in_array($tipo, ['date', 'date|null', '\date', '\date|null']) ? 'Y-m-d' : Carbon::ATOM; return $valor->format($format); default: return $valor; } }
[ "protected", "function", "formatar", "(", "$", "nome", ",", "$", "valor", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionProperty", "(", "get_class", "(", "$", "this", ")", ",", "$", "nome", ")", ";", "$", "factory", "=", "DocBlockFactory", "::", "createInstance", "(", ")", ";", "$", "info", "=", "$", "factory", "->", "create", "(", "$", "ref", "->", "getDocComment", "(", ")", ")", ";", "// Pegar o tipo da variavel", "$", "tipo", "=", "$", "info", "->", "getTagsByName", "(", "'var'", ")", ";", "$", "tipo", "=", "(", "count", "(", "$", "tipo", ")", "==", "0", ")", "?", "'string'", ":", "$", "tipo", "[", "0", "]", "->", "getType", "(", ")", ";", "$", "tipo", "=", "strtolower", "(", "$", "tipo", ")", ";", "switch", "(", "$", "tipo", ")", "{", "case", "'string'", ":", "case", "'string|null'", ":", "case", "'\\string'", ":", "case", "'\\string|null'", ":", "$", "valor", "=", "str_replace", "(", "[", "'@'", "]", ",", "[", "'#1#'", "]", ",", "utf8_encode", "(", "$", "valor", ")", ")", ";", "// Ignorar alguns caracteres no ascii", "$", "valor", "=", "Str", "::", "ascii", "(", "$", "valor", ")", ";", "$", "valor", "=", "str_replace", "(", "[", "'&'", "]", ",", "[", "'e'", "]", ",", "$", "valor", ")", ";", "$", "valor", "=", "str_replace", "(", "[", "'#1#'", "]", ",", "[", "'@'", "]", ",", "$", "valor", ")", ";", "// Retornar caracteres ignorados", "$", "valor", "=", "Str", "::", "upper", "(", "$", "valor", ")", ";", "$", "valor", "=", "trim", "(", "$", "valor", ")", ";", "// Max", "$", "max", "=", "$", "info", "->", "getTagsByName", "(", "'max'", ")", ";", "if", "(", "count", "(", "$", "max", ")", ">", "0", ")", "{", "$", "max", "=", "intval", "(", "$", "max", "[", "0", "]", "->", "getDescription", "(", ")", "->", "render", "(", ")", ")", ";", "$", "valor", "=", "trim", "(", "substr", "(", "$", "valor", ",", "0", ",", "$", "max", ")", ")", ";", "}", "return", "$", "valor", ";", "case", "'float|null'", ":", "case", "'float'", ":", "$", "dec", "=", "$", "info", "->", "getTagsByName", "(", "'dec'", ")", ";", "if", "(", "count", "(", "$", "dec", ")", "==", "0", ")", "{", "return", "$", "valor", ";", "}", "// Valor do @dec", "$", "dec", "=", "$", "dec", "[", "0", "]", "->", "getDescription", "(", ")", "->", "render", "(", ")", ";", "return", "number_format", "(", "$", "valor", ",", "$", "dec", ",", "'.'", ",", "''", ")", ";", "case", "'datetime'", ":", "case", "'\\datetime'", ":", "case", "'\\datetime|null'", ":", "case", "'date'", ":", "case", "'date|null'", ":", "case", "'\\date'", ":", "case", "'\\date|null'", ":", "if", "(", "is_int", "(", "$", "valor", ")", ")", "{", "$", "valor", "=", "Carbon", "::", "createFromTimestamp", "(", "$", "valor", ")", ";", "}", "if", "(", "is_string", "(", "$", "valor", ")", ")", "{", "return", "$", "valor", ";", "}", "$", "format", "=", "in_array", "(", "$", "tipo", ",", "[", "'date'", ",", "'date|null'", ",", "'\\date'", ",", "'\\date|null'", "]", ")", "?", "'Y-m-d'", ":", "Carbon", "::", "ATOM", ";", "return", "$", "valor", "->", "format", "(", "$", "format", ")", ";", "default", ":", "return", "$", "valor", ";", "}", "}" ]
Formatar float para o número de casas decimais correto. @param $nome @param $valor @return string
[ "Formatar", "float", "para", "o", "número", "de", "casas", "decimais", "correto", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Builder/Builder.php#L84-L151
kenphp/ken
src/Factory/ComponentFactory.php
ComponentFactory.createObject
public function createObject($builder, $parameters = array()) { if (is_callable($builder)) { return call_user_func_array($builder, $parameters); } elseif (is_string($builder)) { if (is_subclass_of($builder, '\\Ken\\Base\\Buildable')) { return $builder::build($parameters); } } throw new InvalidArgumentException("Invalid argument when calling 'createObject' method."); }
php
public function createObject($builder, $parameters = array()) { if (is_callable($builder)) { return call_user_func_array($builder, $parameters); } elseif (is_string($builder)) { if (is_subclass_of($builder, '\\Ken\\Base\\Buildable')) { return $builder::build($parameters); } } throw new InvalidArgumentException("Invalid argument when calling 'createObject' method."); }
[ "public", "function", "createObject", "(", "$", "builder", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "if", "(", "is_callable", "(", "$", "builder", ")", ")", "{", "return", "call_user_func_array", "(", "$", "builder", ",", "$", "parameters", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "builder", ")", ")", "{", "if", "(", "is_subclass_of", "(", "$", "builder", ",", "'\\\\Ken\\\\Base\\\\Buildable'", ")", ")", "{", "return", "$", "builder", "::", "build", "(", "$", "parameters", ")", ";", "}", "}", "throw", "new", "InvalidArgumentException", "(", "\"Invalid argument when calling 'createObject' method.\"", ")", ";", "}" ]
Creates an object. @param mixed $builder Builder can be an instance of callable that returns an object, or a string that contains a fully qualified class name that implements Ken\Base\Buildable interface @param array $parameters List of parameters for creating object @return object @throws \InvalidArgumentException
[ "Creates", "an", "object", "." ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Factory/ComponentFactory.php#L24-L35
spiral-modules/listing
source/Listing/Sorters/ComplexSorter.php
ComplexSorter.apply
public function apply($selector) { if ($this->direction == self::ASC) { return $this->ascSorter->apply($selector); } return $this->descSorter->apply($selector); }
php
public function apply($selector) { if ($this->direction == self::ASC) { return $this->ascSorter->apply($selector); } return $this->descSorter->apply($selector); }
[ "public", "function", "apply", "(", "$", "selector", ")", "{", "if", "(", "$", "this", "->", "direction", "==", "self", "::", "ASC", ")", "{", "return", "$", "this", "->", "ascSorter", "->", "apply", "(", "$", "selector", ")", ";", "}", "return", "$", "this", "->", "descSorter", "->", "apply", "(", "$", "selector", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Sorters/ComplexSorter.php#L45-L52
spiral-modules/listing
source/Listing/Sorters/ComplexSorter.php
ComplexSorter.withDirection
public function withDirection($direction) { if (!in_array($direction, [self::ASC, self::DESC])) { throw new SorterException("Invalid sorting direction '{$direction}'"); } $sorter = clone $this; $sorter->direction = $direction; return $sorter; }
php
public function withDirection($direction) { if (!in_array($direction, [self::ASC, self::DESC])) { throw new SorterException("Invalid sorting direction '{$direction}'"); } $sorter = clone $this; $sorter->direction = $direction; return $sorter; }
[ "public", "function", "withDirection", "(", "$", "direction", ")", "{", "if", "(", "!", "in_array", "(", "$", "direction", ",", "[", "self", "::", "ASC", ",", "self", "::", "DESC", "]", ")", ")", "{", "throw", "new", "SorterException", "(", "\"Invalid sorting direction '{$direction}'\"", ")", ";", "}", "$", "sorter", "=", "clone", "$", "this", ";", "$", "sorter", "->", "direction", "=", "$", "direction", ";", "return", "$", "sorter", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Sorters/ComplexSorter.php#L67-L77
OKTOTV/OktolabMediaBundle
Model/GenerateThumbnailSpriteJob.php
GenerateThumbnailSpriteJob.generateThumbs
private function generateThumbs($episode, $cache_asset) { $uri = $this->asset_helper->getAbsoluteUrl($episode->getVideo()); $path = $this->asset_helper->getPath($cache_asset, true); $cmd = sprintf( "ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1", $uri, $this->sprite_width, $this->sprite_height, $this->sprite_interval, $path ); // open (ffmpeg) process, read stdout to get duration if unknown to this point. $fp = popen($cmd, "r"); while(!feof($fp)) { // read outputstream of ffmpeg $chunk = fread($fp, 1024); // try to get the duration information at the beginning of the ffmpeg output. if (!$episode->getDuration()) { preg_match("/Duration: (.*?), start:/", $chunk, $matches); if (array_key_exists(1, $matches)) { list($hours,$minutes,$seconds) = explode(":",$matches[1]); // calculate the duration in seconds. Used to calculate overall progress in percent. $episode->setDuration((($hours * 3600) + ($minutes * 60) + $seconds)); } } // flush the content to the browser flush(); } fclose($fp); }
php
private function generateThumbs($episode, $cache_asset) { $uri = $this->asset_helper->getAbsoluteUrl($episode->getVideo()); $path = $this->asset_helper->getPath($cache_asset, true); $cmd = sprintf( "ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1", $uri, $this->sprite_width, $this->sprite_height, $this->sprite_interval, $path ); // open (ffmpeg) process, read stdout to get duration if unknown to this point. $fp = popen($cmd, "r"); while(!feof($fp)) { // read outputstream of ffmpeg $chunk = fread($fp, 1024); // try to get the duration information at the beginning of the ffmpeg output. if (!$episode->getDuration()) { preg_match("/Duration: (.*?), start:/", $chunk, $matches); if (array_key_exists(1, $matches)) { list($hours,$minutes,$seconds) = explode(":",$matches[1]); // calculate the duration in seconds. Used to calculate overall progress in percent. $episode->setDuration((($hours * 3600) + ($minutes * 60) + $seconds)); } } // flush the content to the browser flush(); } fclose($fp); }
[ "private", "function", "generateThumbs", "(", "$", "episode", ",", "$", "cache_asset", ")", "{", "$", "uri", "=", "$", "this", "->", "asset_helper", "->", "getAbsoluteUrl", "(", "$", "episode", "->", "getVideo", "(", ")", ")", ";", "$", "path", "=", "$", "this", "->", "asset_helper", "->", "getPath", "(", "$", "cache_asset", ",", "true", ")", ";", "$", "cmd", "=", "sprintf", "(", "\"ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1\"", ",", "$", "uri", ",", "$", "this", "->", "sprite_width", ",", "$", "this", "->", "sprite_height", ",", "$", "this", "->", "sprite_interval", ",", "$", "path", ")", ";", "// open (ffmpeg) process, read stdout to get duration if unknown to this point.", "$", "fp", "=", "popen", "(", "$", "cmd", ",", "\"r\"", ")", ";", "while", "(", "!", "feof", "(", "$", "fp", ")", ")", "{", "// read outputstream of ffmpeg", "$", "chunk", "=", "fread", "(", "$", "fp", ",", "1024", ")", ";", "// try to get the duration information at the beginning of the ffmpeg output.", "if", "(", "!", "$", "episode", "->", "getDuration", "(", ")", ")", "{", "preg_match", "(", "\"/Duration: (.*?), start:/\"", ",", "$", "chunk", ",", "$", "matches", ")", ";", "if", "(", "array_key_exists", "(", "1", ",", "$", "matches", ")", ")", "{", "list", "(", "$", "hours", ",", "$", "minutes", ",", "$", "seconds", ")", "=", "explode", "(", "\":\"", ",", "$", "matches", "[", "1", "]", ")", ";", "// calculate the duration in seconds. Used to calculate overall progress in percent.", "$", "episode", "->", "setDuration", "(", "(", "(", "$", "hours", "*", "3600", ")", "+", "(", "$", "minutes", "*", "60", ")", "+", "$", "seconds", ")", ")", ";", "}", "}", "// flush the content to the browser", "flush", "(", ")", ";", "}", "fclose", "(", "$", "fp", ")", ";", "}" ]
takes episode and creates thumbnails in given width and height
[ "takes", "episode", "and", "creates", "thumbnails", "in", "given", "width", "and", "height" ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/GenerateThumbnailSpriteJob.php#L59-L90
OKTOTV/OktolabMediaBundle
Model/GenerateThumbnailSpriteJob.php
GenerateThumbnailSpriteJob.stitchThumbs
private function stitchThumbs($episode, $cache_asset) { $path = $this->asset_helper->getPath($cache_asset, true); // calculate total number of thumbs based on length and timeinterval. $numberOfSprites = ceil($episode->getDuration()/$this->sprite_interval); //one long image, with every image below it. $spriteImage = imagecreatetruecolor($this->sprite_width, $numberOfSprites*$this->sprite_height); // create a long image containing all thumbnails on top of each other for ($number = 1; $number <= $numberOfSprites; $number++) { $currentSprite = sprintf($path, $number); $image = \imagecreatefromjpeg($currentSprite); imagecopy( $spriteImage, // destination image $image, // image to copy onto destination image 0, // start point x on destination $this->sprite_height*($number-1), // start point y on destination 0, // start point x on image 0, // start point y on image $this->sprite_width, // width of image to copy onto destination $this->sprite_height // height of image to copy onto destinaion ); } // get final image content ob_start(); header('Content-Type: image/jpeg'); imagejpeg($spriteImage); $sprite = ob_get_contents(); ob_end_clean(); $filesystem = $this->asset_helper->getFilesystem($cache_asset->getAdapter()); // delete thumbnails for ($number = 0; $number <= $numberOfSprites; $number++) { if ($filesystem->has(sprintf($cache_asset->getFilekey(), $number+1))) { $filesystem->delete(sprintf($cache_asset->getFilekey(), $number+1)); } } // finalize asset, write to adapter, link to episode $cache_asset->setFilekey(uniqID()); $filesystem->write($cache_asset, $sprite); $this->getContainer()->get('oktolab_media_helper')->deleteEpisodeSprite($episode); $episode->setSprite($cache_asset); $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $em->persist($episode); $em->flush(); // move sprite to correct destination $this->getContainer()->get('bprs.asset_job')->addMoveAssetJob( $cache_asset, $this->getContainer()->getParameter('oktolab_media.sprite_filesystem'), $this->getContainer()->getParameter('oktolab_media.sprite_worker_queue') ); }
php
private function stitchThumbs($episode, $cache_asset) { $path = $this->asset_helper->getPath($cache_asset, true); // calculate total number of thumbs based on length and timeinterval. $numberOfSprites = ceil($episode->getDuration()/$this->sprite_interval); //one long image, with every image below it. $spriteImage = imagecreatetruecolor($this->sprite_width, $numberOfSprites*$this->sprite_height); // create a long image containing all thumbnails on top of each other for ($number = 1; $number <= $numberOfSprites; $number++) { $currentSprite = sprintf($path, $number); $image = \imagecreatefromjpeg($currentSprite); imagecopy( $spriteImage, // destination image $image, // image to copy onto destination image 0, // start point x on destination $this->sprite_height*($number-1), // start point y on destination 0, // start point x on image 0, // start point y on image $this->sprite_width, // width of image to copy onto destination $this->sprite_height // height of image to copy onto destinaion ); } // get final image content ob_start(); header('Content-Type: image/jpeg'); imagejpeg($spriteImage); $sprite = ob_get_contents(); ob_end_clean(); $filesystem = $this->asset_helper->getFilesystem($cache_asset->getAdapter()); // delete thumbnails for ($number = 0; $number <= $numberOfSprites; $number++) { if ($filesystem->has(sprintf($cache_asset->getFilekey(), $number+1))) { $filesystem->delete(sprintf($cache_asset->getFilekey(), $number+1)); } } // finalize asset, write to adapter, link to episode $cache_asset->setFilekey(uniqID()); $filesystem->write($cache_asset, $sprite); $this->getContainer()->get('oktolab_media_helper')->deleteEpisodeSprite($episode); $episode->setSprite($cache_asset); $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $em->persist($episode); $em->flush(); // move sprite to correct destination $this->getContainer()->get('bprs.asset_job')->addMoveAssetJob( $cache_asset, $this->getContainer()->getParameter('oktolab_media.sprite_filesystem'), $this->getContainer()->getParameter('oktolab_media.sprite_worker_queue') ); }
[ "private", "function", "stitchThumbs", "(", "$", "episode", ",", "$", "cache_asset", ")", "{", "$", "path", "=", "$", "this", "->", "asset_helper", "->", "getPath", "(", "$", "cache_asset", ",", "true", ")", ";", "// calculate total number of thumbs based on length and timeinterval.", "$", "numberOfSprites", "=", "ceil", "(", "$", "episode", "->", "getDuration", "(", ")", "/", "$", "this", "->", "sprite_interval", ")", ";", "//one long image, with every image below it.", "$", "spriteImage", "=", "imagecreatetruecolor", "(", "$", "this", "->", "sprite_width", ",", "$", "numberOfSprites", "*", "$", "this", "->", "sprite_height", ")", ";", "// create a long image containing all thumbnails on top of each other", "for", "(", "$", "number", "=", "1", ";", "$", "number", "<=", "$", "numberOfSprites", ";", "$", "number", "++", ")", "{", "$", "currentSprite", "=", "sprintf", "(", "$", "path", ",", "$", "number", ")", ";", "$", "image", "=", "\\", "imagecreatefromjpeg", "(", "$", "currentSprite", ")", ";", "imagecopy", "(", "$", "spriteImage", ",", "// destination image", "$", "image", ",", "// image to copy onto destination image", "0", ",", "// start point x on destination", "$", "this", "->", "sprite_height", "*", "(", "$", "number", "-", "1", ")", ",", "// start point y on destination", "0", ",", "// start point x on image", "0", ",", "// start point y on image", "$", "this", "->", "sprite_width", ",", "// width of image to copy onto destination", "$", "this", "->", "sprite_height", "// height of image to copy onto destinaion", ")", ";", "}", "// get final image content", "ob_start", "(", ")", ";", "header", "(", "'Content-Type: image/jpeg'", ")", ";", "imagejpeg", "(", "$", "spriteImage", ")", ";", "$", "sprite", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "$", "filesystem", "=", "$", "this", "->", "asset_helper", "->", "getFilesystem", "(", "$", "cache_asset", "->", "getAdapter", "(", ")", ")", ";", "// delete thumbnails", "for", "(", "$", "number", "=", "0", ";", "$", "number", "<=", "$", "numberOfSprites", ";", "$", "number", "++", ")", "{", "if", "(", "$", "filesystem", "->", "has", "(", "sprintf", "(", "$", "cache_asset", "->", "getFilekey", "(", ")", ",", "$", "number", "+", "1", ")", ")", ")", "{", "$", "filesystem", "->", "delete", "(", "sprintf", "(", "$", "cache_asset", "->", "getFilekey", "(", ")", ",", "$", "number", "+", "1", ")", ")", ";", "}", "}", "// finalize asset, write to adapter, link to episode", "$", "cache_asset", "->", "setFilekey", "(", "uniqID", "(", ")", ")", ";", "$", "filesystem", "->", "write", "(", "$", "cache_asset", ",", "$", "sprite", ")", ";", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'oktolab_media_helper'", ")", "->", "deleteEpisodeSprite", "(", "$", "episode", ")", ";", "$", "episode", "->", "setSprite", "(", "$", "cache_asset", ")", ";", "$", "em", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", ";", "$", "em", "->", "persist", "(", "$", "episode", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// move sprite to correct destination", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'bprs.asset_job'", ")", "->", "addMoveAssetJob", "(", "$", "cache_asset", ",", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'oktolab_media.sprite_filesystem'", ")", ",", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'oktolab_media.sprite_worker_queue'", ")", ")", ";", "}" ]
at a res of 1280*720
[ "at", "a", "res", "of", "1280", "*", "720" ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/GenerateThumbnailSpriteJob.php#L96-L151
php-lug/lug
src/Bundle/GridBundle/Form/EventSubscriber/Batch/Doctrine/ORM/GridBatchSubscriber.php
GridBatchSubscriber.findChoices
protected function findChoices(GridInterface $grid, RepositoryInterface $repository, array $choices) { $queryBuilder = $repository->createQueryBuilderForCollection(); $result = $queryBuilder ->andWhere($queryBuilder->expr()->in( $repository->getProperty($grid->getResource()->getIdPropertyPath(), $queryBuilder), ':'.($placeholder = 'lug_id_'.str_replace('.', '', uniqid(null, true))) )) ->setParameter($placeholder, $choices) ->getQuery() ->getResult(); return count($result) === count($choices) ? $result : []; }
php
protected function findChoices(GridInterface $grid, RepositoryInterface $repository, array $choices) { $queryBuilder = $repository->createQueryBuilderForCollection(); $result = $queryBuilder ->andWhere($queryBuilder->expr()->in( $repository->getProperty($grid->getResource()->getIdPropertyPath(), $queryBuilder), ':'.($placeholder = 'lug_id_'.str_replace('.', '', uniqid(null, true))) )) ->setParameter($placeholder, $choices) ->getQuery() ->getResult(); return count($result) === count($choices) ? $result : []; }
[ "protected", "function", "findChoices", "(", "GridInterface", "$", "grid", ",", "RepositoryInterface", "$", "repository", ",", "array", "$", "choices", ")", "{", "$", "queryBuilder", "=", "$", "repository", "->", "createQueryBuilderForCollection", "(", ")", ";", "$", "result", "=", "$", "queryBuilder", "->", "andWhere", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "$", "repository", "->", "getProperty", "(", "$", "grid", "->", "getResource", "(", ")", "->", "getIdPropertyPath", "(", ")", ",", "$", "queryBuilder", ")", ",", "':'", ".", "(", "$", "placeholder", "=", "'lug_id_'", ".", "str_replace", "(", "'.'", ",", "''", ",", "uniqid", "(", "null", ",", "true", ")", ")", ")", ")", ")", "->", "setParameter", "(", "$", "placeholder", ",", "$", "choices", ")", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "return", "count", "(", "$", "result", ")", "===", "count", "(", "$", "choices", ")", "?", "$", "result", ":", "[", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/EventSubscriber/Batch/Doctrine/ORM/GridBatchSubscriber.php#L26-L40
joomla-framework/date
src/Date.php
Date.format
public function format($format, $local = false) { // If the returned time should not be local use GMT. if ($local == false) { parent::setTimezone(static::$gmt); } // Format the date. $return = parent::format($format); if ($local == false) { parent::setTimezone($this->tz); } return $return; }
php
public function format($format, $local = false) { // If the returned time should not be local use GMT. if ($local == false) { parent::setTimezone(static::$gmt); } // Format the date. $return = parent::format($format); if ($local == false) { parent::setTimezone($this->tz); } return $return; }
[ "public", "function", "format", "(", "$", "format", ",", "$", "local", "=", "false", ")", "{", "// If the returned time should not be local use GMT.", "if", "(", "$", "local", "==", "false", ")", "{", "parent", "::", "setTimezone", "(", "static", "::", "$", "gmt", ")", ";", "}", "// Format the date.", "$", "return", "=", "parent", "::", "format", "(", "$", "format", ")", ";", "if", "(", "$", "local", "==", "false", ")", "{", "parent", "::", "setTimezone", "(", "$", "this", "->", "tz", ")", ";", "}", "return", "$", "return", ";", "}" ]
Gets the date as a formatted string. @param string $format The date format specification string (see {@link PHP_MANUAL#date}) @param boolean $local True to return the date string in the local time zone, false to return it in GMT. @return string The date string in the specified format format. @since 1.0
[ "Gets", "the", "date", "as", "a", "formatted", "string", "." ]
train
https://github.com/joomla-framework/date/blob/720a0ec3adcb6107cae5cebfc9875cf2f604572d/src/Date.php#L225-L242
oroinc/OroLayoutComponent
Block/Extension/ClassAttributeExtension.php
ClassAttributeExtension.finishView
public function finishView(BlockView $view, BlockInterface $block) { $this->normalizeClassAttribute($view, 'attr'); $this->normalizeClassAttribute($view, 'label_attr'); }
php
public function finishView(BlockView $view, BlockInterface $block) { $this->normalizeClassAttribute($view, 'attr'); $this->normalizeClassAttribute($view, 'label_attr'); }
[ "public", "function", "finishView", "(", "BlockView", "$", "view", ",", "BlockInterface", "$", "block", ")", "{", "$", "this", "->", "normalizeClassAttribute", "(", "$", "view", ",", "'attr'", ")", ";", "$", "this", "->", "normalizeClassAttribute", "(", "$", "view", ",", "'label_attr'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Block/Extension/ClassAttributeExtension.php#L21-L25
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Behaviour/Collection.php
Collection.removeBehaviour
public function removeBehaviour(BehaviourAbstract $behaviour) { foreach ($this->behaviours as $key => $thisBehaviour) { if ($behaviour == $thisBehaviour) { unset($this->behaviours[$key]); } } }
php
public function removeBehaviour(BehaviourAbstract $behaviour) { foreach ($this->behaviours as $key => $thisBehaviour) { if ($behaviour == $thisBehaviour) { unset($this->behaviours[$key]); } } }
[ "public", "function", "removeBehaviour", "(", "BehaviourAbstract", "$", "behaviour", ")", "{", "foreach", "(", "$", "this", "->", "behaviours", "as", "$", "key", "=>", "$", "thisBehaviour", ")", "{", "if", "(", "$", "behaviour", "==", "$", "thisBehaviour", ")", "{", "unset", "(", "$", "this", "->", "behaviours", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Removes a behaviour from the collection @param BehaviourAbstract $behaviour Behaviour to remove from the collection. @return void
[ "Removes", "a", "behaviour", "from", "the", "collection" ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Behaviour/Collection.php#L53-L60
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Behaviour/Collection.php
Collection.process
public function process(ProjectDescriptor $project) { foreach ($this->behaviours as $behaviour) { $project = $behaviour->process($project); } return $project; }
php
public function process(ProjectDescriptor $project) { foreach ($this->behaviours as $behaviour) { $project = $behaviour->process($project); } return $project; }
[ "public", "function", "process", "(", "ProjectDescriptor", "$", "project", ")", "{", "foreach", "(", "$", "this", "->", "behaviours", "as", "$", "behaviour", ")", "{", "$", "project", "=", "$", "behaviour", "->", "process", "(", "$", "project", ")", ";", "}", "return", "$", "project", ";", "}" ]
Executes the behaviour on the given object model, @param ProjectDescriptor $project @return ProjectDescriptor
[ "Executes", "the", "behaviour", "on", "the", "given", "object", "model" ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Behaviour/Collection.php#L69-L76
gruzilla/hydra
src/Hydra/Commands/ConfigCommandTrait.php
ConfigCommandTrait.getConfigHelper
protected function getConfigHelper($serviceName) { $storage = new HydraTokenStorage(); $provider = new DefaultServiceProvider($storage); $className = $this->getConfigHelperClassName($serviceName); return new $className( $storage, $provider, $serviceName ); }
php
protected function getConfigHelper($serviceName) { $storage = new HydraTokenStorage(); $provider = new DefaultServiceProvider($storage); $className = $this->getConfigHelperClassName($serviceName); return new $className( $storage, $provider, $serviceName ); }
[ "protected", "function", "getConfigHelper", "(", "$", "serviceName", ")", "{", "$", "storage", "=", "new", "HydraTokenStorage", "(", ")", ";", "$", "provider", "=", "new", "DefaultServiceProvider", "(", "$", "storage", ")", ";", "$", "className", "=", "$", "this", "->", "getConfigHelperClassName", "(", "$", "serviceName", ")", ";", "return", "new", "$", "className", "(", "$", "storage", ",", "$", "provider", ",", "$", "serviceName", ")", ";", "}" ]
overwrite for dependency injection
[ "overwrite", "for", "dependency", "injection" ]
train
https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Commands/ConfigCommandTrait.php#L156-L168
rhosocial/yii2-user
security/UserPasswordHistoryTrait.php
UserPasswordHistoryTrait.getPasswordHistories
public function getPasswordHistories() { if (empty($this->passwordHistoryClass) || !class_exists($this->passwordHistoryClass)) { return false; } $class = $this->passwordHistoryClass; return $class::find()->createdBy($this)->orderByCreatedAt(SORT_DESC)->all(); }
php
public function getPasswordHistories() { if (empty($this->passwordHistoryClass) || !class_exists($this->passwordHistoryClass)) { return false; } $class = $this->passwordHistoryClass; return $class::find()->createdBy($this)->orderByCreatedAt(SORT_DESC)->all(); }
[ "public", "function", "getPasswordHistories", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "passwordHistoryClass", ")", "||", "!", "class_exists", "(", "$", "this", "->", "passwordHistoryClass", ")", ")", "{", "return", "false", ";", "}", "$", "class", "=", "$", "this", "->", "passwordHistoryClass", ";", "return", "$", "class", "::", "find", "(", ")", "->", "createdBy", "(", "$", "this", ")", "->", "orderByCreatedAt", "(", "SORT_DESC", ")", "->", "all", "(", ")", ";", "}" ]
Get all password histories sorted by creation time in descending order. @return boolean|PasswordHistory[] False if password history class is invalid.
[ "Get", "all", "password", "histories", "sorted", "by", "creation", "time", "in", "descending", "order", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L43-L50
rhosocial/yii2-user
security/UserPasswordHistoryTrait.php
UserPasswordHistoryTrait.onAddPasswordToHistory
public function onAddPasswordToHistory($event) { $password = $event->data; $sender = $event->sender; /* @var $sender static */ if (empty($sender->passwordHistoryClass) || !class_exists($sender->passwordHistoryClass) || empty($sender->passwordHashAttribute) || !is_string($sender->passwordHashAttribute)) { return false; } if (empty($password)) { $password = ['pass_hash' => $sender->{$sender->passwordHashAttribute}]; } $class = $sender->passwordHistoryClass; if (array_key_exists('pass_hash', $password)) { return $class::addHash($password['pass_hash'], $sender); } if (array_key_exists('password', $password)) { return $class::add($password['password'], $sender); } return false; }
php
public function onAddPasswordToHistory($event) { $password = $event->data; $sender = $event->sender; /* @var $sender static */ if (empty($sender->passwordHistoryClass) || !class_exists($sender->passwordHistoryClass) || empty($sender->passwordHashAttribute) || !is_string($sender->passwordHashAttribute)) { return false; } if (empty($password)) { $password = ['pass_hash' => $sender->{$sender->passwordHashAttribute}]; } $class = $sender->passwordHistoryClass; if (array_key_exists('pass_hash', $password)) { return $class::addHash($password['pass_hash'], $sender); } if (array_key_exists('password', $password)) { return $class::add($password['password'], $sender); } return false; }
[ "public", "function", "onAddPasswordToHistory", "(", "$", "event", ")", "{", "$", "password", "=", "$", "event", "->", "data", ";", "$", "sender", "=", "$", "event", "->", "sender", ";", "/* @var $sender static */", "if", "(", "empty", "(", "$", "sender", "->", "passwordHistoryClass", ")", "||", "!", "class_exists", "(", "$", "sender", "->", "passwordHistoryClass", ")", "||", "empty", "(", "$", "sender", "->", "passwordHashAttribute", ")", "||", "!", "is_string", "(", "$", "sender", "->", "passwordHashAttribute", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "password", ")", ")", "{", "$", "password", "=", "[", "'pass_hash'", "=>", "$", "sender", "->", "{", "$", "sender", "->", "passwordHashAttribute", "}", "]", ";", "}", "$", "class", "=", "$", "sender", "->", "passwordHistoryClass", ";", "if", "(", "array_key_exists", "(", "'pass_hash'", ",", "$", "password", ")", ")", "{", "return", "$", "class", "::", "addHash", "(", "$", "password", "[", "'pass_hash'", "]", ",", "$", "sender", ")", ";", "}", "if", "(", "array_key_exists", "(", "'password'", ",", "$", "password", ")", ")", "{", "return", "$", "class", "::", "add", "(", "$", "password", "[", "'password'", "]", ",", "$", "sender", ")", ";", "}", "return", "false", ";", "}" ]
This event is ONLY used for adding password to history. You SHOULD NOT call this method directly, or you know the consequences of doing so @param ModelEvent $event @return boolean False if no password was added to history.
[ "This", "event", "is", "ONLY", "used", "for", "adding", "password", "to", "history", ".", "You", "SHOULD", "NOT", "call", "this", "method", "directly", "or", "you", "know", "the", "consequences", "of", "doing", "so" ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L58-L80
rhosocial/yii2-user
security/UserPasswordHistoryTrait.php
UserPasswordHistoryTrait.addPasswordHistory
public function addPasswordHistory($password) { if (!empty($this->passwordHistoryClass) && class_exists($this->passwordHistoryClass)) { $class = $this->passwordHistoryClass; return $class::add($password, $this); } return false; }
php
public function addPasswordHistory($password) { if (!empty($this->passwordHistoryClass) && class_exists($this->passwordHistoryClass)) { $class = $this->passwordHistoryClass; return $class::add($password, $this); } return false; }
[ "public", "function", "addPasswordHistory", "(", "$", "password", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "passwordHistoryClass", ")", "&&", "class_exists", "(", "$", "this", "->", "passwordHistoryClass", ")", ")", "{", "$", "class", "=", "$", "this", "->", "passwordHistoryClass", ";", "return", "$", "class", "::", "add", "(", "$", "password", ",", "$", "this", ")", ";", "}", "return", "false", ";", "}" ]
Add password to history. Note: Please specify password history class before using this method. @param string $password the password to be added. @return boolean whether the password added. False if password history class not specified. @throws InvalidParamException throw if password existed.
[ "Add", "password", "to", "history", ".", "Note", ":", "Please", "specify", "password", "history", "class", "before", "using", "this", "method", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L90-L97
rhosocial/yii2-user
security/UserPasswordHistoryTrait.php
UserPasswordHistoryTrait.addPasswordHashToHistory
public function addPasswordHashToHistory($passHash) { if (!empty($this->passwordHistoryClass) && class_exists($this->passwordHistoryClass)) { $class = $this->passwordHistoryClass; return $class::addHash($passHash, $this); } return false; }
php
public function addPasswordHashToHistory($passHash) { if (!empty($this->passwordHistoryClass) && class_exists($this->passwordHistoryClass)) { $class = $this->passwordHistoryClass; return $class::addHash($passHash, $this); } return false; }
[ "public", "function", "addPasswordHashToHistory", "(", "$", "passHash", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "passwordHistoryClass", ")", "&&", "class_exists", "(", "$", "this", "->", "passwordHistoryClass", ")", ")", "{", "$", "class", "=", "$", "this", "->", "passwordHistoryClass", ";", "return", "$", "class", "::", "addHash", "(", "$", "passHash", ",", "$", "this", ")", ";", "}", "return", "false", ";", "}" ]
Add password hash to history. Note: Please specify password history class before using this method. @param string $passHash Password hash to be added. @return boolean whether the password hash added. False if password history class not specified. @throws InvalidParamException throw if password existed.
[ "Add", "password", "hash", "to", "history", ".", "Note", ":", "Please", "specify", "password", "history", "class", "before", "using", "this", "method", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L107-L114
rhosocial/yii2-user
security/UserPasswordHistoryTrait.php
UserPasswordHistoryTrait.checkPasswordNotUsed
public function checkPasswordNotUsed($attribute, $params, $validator) { $class = $this->passwordHistoryClass; $result = $class::isUsed($this->_password, $this); if ($result != false) { $this->trigger(static::$eventPasswordUsed); $this->addError($attribute, $this->passwordUsedMessage); } }
php
public function checkPasswordNotUsed($attribute, $params, $validator) { $class = $this->passwordHistoryClass; $result = $class::isUsed($this->_password, $this); if ($result != false) { $this->trigger(static::$eventPasswordUsed); $this->addError($attribute, $this->passwordUsedMessage); } }
[ "public", "function", "checkPasswordNotUsed", "(", "$", "attribute", ",", "$", "params", ",", "$", "validator", ")", "{", "$", "class", "=", "$", "this", "->", "passwordHistoryClass", ";", "$", "result", "=", "$", "class", "::", "isUsed", "(", "$", "this", "->", "_password", ",", "$", "this", ")", ";", "if", "(", "$", "result", "!=", "false", ")", "{", "$", "this", "->", "trigger", "(", "static", "::", "$", "eventPasswordUsed", ")", ";", "$", "this", "->", "addError", "(", "$", "attribute", ",", "$", "this", "->", "passwordUsedMessage", ")", ";", "}", "}" ]
This method is only used for password hash attribute validation. If password is used, the `eventPasswordUsed` event will be triggered. @param string $attribute @param mixed $params @param type $validator
[ "This", "method", "is", "only", "used", "for", "password", "hash", "attribute", "validation", ".", "If", "password", "is", "used", "the", "eventPasswordUsed", "event", "will", "be", "triggered", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L149-L157
Eresus/EresusCMS
src/core/lib/accounts.php
EresusAccounts.fields
public function fields() { if (isset($this->cache['fields'])) { $result = $this->cache['fields']; } else { $result = Eresus_CMS::getLegacyKernel()->db->fields($this->table); $this->cache['fields'] = $result; } return $result; }
php
public function fields() { if (isset($this->cache['fields'])) { $result = $this->cache['fields']; } else { $result = Eresus_CMS::getLegacyKernel()->db->fields($this->table); $this->cache['fields'] = $result; } return $result; }
[ "public", "function", "fields", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "'fields'", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "cache", "[", "'fields'", "]", ";", "}", "else", "{", "$", "result", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "fields", "(", "$", "this", "->", "table", ")", ";", "$", "this", "->", "cache", "[", "'fields'", "]", "=", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Возвращает список полей @access public @return array Список полей
[ "Возвращает", "список", "полей" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/accounts.php#L55-L67
Eresus/EresusCMS
src/core/lib/accounts.php
EresusAccounts.get
public function get($id) { if (is_array($id)) { $what = "FIND_IN_SET(`id`, '".implode(',', $id)."')"; } elseif (is_numeric($id)) { $what = "`id`=$id"; } else { $what = $id; } $result = Eresus_CMS::getLegacyKernel()->db->select($this->table, $what); if ($result) { for ($i=0; $i<count($result); $i++) { $result[$i]['profile'] = decodeOptions($result[$i]['profile']); } } if (is_numeric($id) && $result && count($result)) { $result = $result[0]; } return $result; }
php
public function get($id) { if (is_array($id)) { $what = "FIND_IN_SET(`id`, '".implode(',', $id)."')"; } elseif (is_numeric($id)) { $what = "`id`=$id"; } else { $what = $id; } $result = Eresus_CMS::getLegacyKernel()->db->select($this->table, $what); if ($result) { for ($i=0; $i<count($result); $i++) { $result[$i]['profile'] = decodeOptions($result[$i]['profile']); } } if (is_numeric($id) && $result && count($result)) { $result = $result[0]; } return $result; }
[ "public", "function", "get", "(", "$", "id", ")", "{", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "$", "what", "=", "\"FIND_IN_SET(`id`, '\"", ".", "implode", "(", "','", ",", "$", "id", ")", ".", "\"')\"", ";", "}", "elseif", "(", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "what", "=", "\"`id`=$id\"", ";", "}", "else", "{", "$", "what", "=", "$", "id", ";", "}", "$", "result", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "select", "(", "$", "this", "->", "table", ",", "$", "what", ")", ";", "if", "(", "$", "result", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "result", ")", ";", "$", "i", "++", ")", "{", "$", "result", "[", "$", "i", "]", "[", "'profile'", "]", "=", "decodeOptions", "(", "$", "result", "[", "$", "i", "]", "[", "'profile'", "]", ")", ";", "}", "}", "if", "(", "is_numeric", "(", "$", "id", ")", "&&", "$", "result", "&&", "count", "(", "$", "result", ")", ")", "{", "$", "result", "=", "$", "result", "[", "0", "]", ";", "}", "return", "$", "result", ";", "}" ]
Возвращает учётную запись или список записей @access public @param int|array|string $id ID пользователя, список идентификаторов или SQL-условие @return array
[ "Возвращает", "учётную", "запись", "или", "список", "записей" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/accounts.php#L78-L105
Eresus/EresusCMS
src/core/lib/accounts.php
EresusAccounts.add
public function add($item) { $result = false; if (isset($item['id'])) unset($item['id']); if (!isset($item['profile'])) $item['profile'] = array(); $item['profile'] = encodeOptions($item['profile']); if (Eresus_CMS::getLegacyKernel()->db->insert($this->table, $item)) $result = $this->get(Eresus_CMS::getLegacyKernel()->db->getInsertedId()); return $result; }
php
public function add($item) { $result = false; if (isset($item['id'])) unset($item['id']); if (!isset($item['profile'])) $item['profile'] = array(); $item['profile'] = encodeOptions($item['profile']); if (Eresus_CMS::getLegacyKernel()->db->insert($this->table, $item)) $result = $this->get(Eresus_CMS::getLegacyKernel()->db->getInsertedId()); return $result; }
[ "public", "function", "add", "(", "$", "item", ")", "{", "$", "result", "=", "false", ";", "if", "(", "isset", "(", "$", "item", "[", "'id'", "]", ")", ")", "unset", "(", "$", "item", "[", "'id'", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "item", "[", "'profile'", "]", ")", ")", "$", "item", "[", "'profile'", "]", "=", "array", "(", ")", ";", "$", "item", "[", "'profile'", "]", "=", "encodeOptions", "(", "$", "item", "[", "'profile'", "]", ")", ";", "if", "(", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "insert", "(", "$", "this", "->", "table", ",", "$", "item", ")", ")", "$", "result", "=", "$", "this", "->", "get", "(", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "getInsertedId", "(", ")", ")", ";", "return", "$", "result", ";", "}" ]
Добавляет учётную запись @param array $item Учётная запись @return mixed Описание записи или false в случае неудачи
[ "Добавляет", "учётную", "запись" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/accounts.php#L123-L132
Eresus/EresusCMS
src/core/lib/accounts.php
EresusAccounts.update
public function update($item) { $item['profile'] = encodeOptions($item['profile']); $result = Eresus_CMS::getLegacyKernel()->db-> updateItem($this->table, $item, "`id`={$item['id']}"); return $result; }
php
public function update($item) { $item['profile'] = encodeOptions($item['profile']); $result = Eresus_CMS::getLegacyKernel()->db-> updateItem($this->table, $item, "`id`={$item['id']}"); return $result; }
[ "public", "function", "update", "(", "$", "item", ")", "{", "$", "item", "[", "'profile'", "]", "=", "encodeOptions", "(", "$", "item", "[", "'profile'", "]", ")", ";", "$", "result", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "updateItem", "(", "$", "this", "->", "table", ",", "$", "item", ",", "\"`id`={$item['id']}\"", ")", ";", "return", "$", "result", ";", "}" ]
Изменяет учётную запись @param array $item Учётная запись @return mixed Описание изменённой записи или false в случае неудачи
[ "Изменяет", "учётную", "запись" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/accounts.php#L141-L147
Eresus/EresusCMS
src/core/lib/accounts.php
EresusAccounts.delete
public function delete($id) { $result = Eresus_CMS::getLegacyKernel()->db->delete($this->table, "`id`=$id"); return $result; }
php
public function delete($id) { $result = Eresus_CMS::getLegacyKernel()->db->delete($this->table, "`id`=$id"); return $result; }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "result", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "db", "->", "delete", "(", "$", "this", "->", "table", ",", "\"`id`=$id\"", ")", ";", "return", "$", "result", ";", "}" ]
Удаляет учётную запись @access public @param int $id Идентификатор записи @return bool Результат операции
[ "Удаляет", "учётную", "запись" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/accounts.php#L158-L162
zhouyl/mellivora
Mellivora/Database/Connectors/SqlServerConnector.php
SqlServerConnector.getSqlSrvDsn
protected function getSqlSrvDsn(array $config) { $arguments = [ 'Server' => $this->buildHostString($config, ','), ]; if (isset($config['database'])) { $arguments['Database'] = $config['database']; } if (isset($config['readonly'])) { $arguments['ApplicationIntent'] = 'ReadOnly'; } if (isset($config['pooling']) && $config['pooling'] === false) { $arguments['ConnectionPooling'] = '0'; } if (isset($config['appname'])) { $arguments['APP'] = $config['appname']; } return $this->buildConnectString('sqlsrv', $arguments); }
php
protected function getSqlSrvDsn(array $config) { $arguments = [ 'Server' => $this->buildHostString($config, ','), ]; if (isset($config['database'])) { $arguments['Database'] = $config['database']; } if (isset($config['readonly'])) { $arguments['ApplicationIntent'] = 'ReadOnly'; } if (isset($config['pooling']) && $config['pooling'] === false) { $arguments['ConnectionPooling'] = '0'; } if (isset($config['appname'])) { $arguments['APP'] = $config['appname']; } return $this->buildConnectString('sqlsrv', $arguments); }
[ "protected", "function", "getSqlSrvDsn", "(", "array", "$", "config", ")", "{", "$", "arguments", "=", "[", "'Server'", "=>", "$", "this", "->", "buildHostString", "(", "$", "config", ",", "','", ")", ",", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'database'", "]", ")", ")", "{", "$", "arguments", "[", "'Database'", "]", "=", "$", "config", "[", "'database'", "]", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'readonly'", "]", ")", ")", "{", "$", "arguments", "[", "'ApplicationIntent'", "]", "=", "'ReadOnly'", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'pooling'", "]", ")", "&&", "$", "config", "[", "'pooling'", "]", "===", "false", ")", "{", "$", "arguments", "[", "'ConnectionPooling'", "]", "=", "'0'", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'appname'", "]", ")", ")", "{", "$", "arguments", "[", "'APP'", "]", "=", "$", "config", "[", "'appname'", "]", ";", "}", "return", "$", "this", "->", "buildConnectString", "(", "'sqlsrv'", ",", "$", "arguments", ")", ";", "}" ]
Get the DSN string for a SqlSrv connection. @param array $config @return string
[ "Get", "the", "DSN", "string", "for", "a", "SqlSrv", "connection", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Connectors/SqlServerConnector.php#L106-L129
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18nQuery.php
CustomerGroupI18nQuery.filterByCustomerGroup
public function filterByCustomerGroup($customerGroup, $comparison = null) { if ($customerGroup instanceof \CustomerGroup\Model\CustomerGroup) { return $this ->addUsingAlias(CustomerGroupI18nTableMap::ID, $customerGroup->getId(), $comparison); } elseif ($customerGroup instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(CustomerGroupI18nTableMap::ID, $customerGroup->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomerGroup() only accepts arguments of type \CustomerGroup\Model\CustomerGroup or Collection'); } }
php
public function filterByCustomerGroup($customerGroup, $comparison = null) { if ($customerGroup instanceof \CustomerGroup\Model\CustomerGroup) { return $this ->addUsingAlias(CustomerGroupI18nTableMap::ID, $customerGroup->getId(), $comparison); } elseif ($customerGroup instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(CustomerGroupI18nTableMap::ID, $customerGroup->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByCustomerGroup() only accepts arguments of type \CustomerGroup\Model\CustomerGroup or Collection'); } }
[ "public", "function", "filterByCustomerGroup", "(", "$", "customerGroup", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "customerGroup", "instanceof", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerGroup", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupI18nTableMap", "::", "ID", ",", "$", "customerGroup", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "customerGroup", "instanceof", "ObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupI18nTableMap", "::", "ID", ",", "$", "customerGroup", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByCustomerGroup() only accepts arguments of type \\CustomerGroup\\Model\\CustomerGroup or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \CustomerGroup\Model\CustomerGroup object @param \CustomerGroup\Model\CustomerGroup|ObjectCollection $customerGroup The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerGroupI18nQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerGroup", "object" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18nQuery.php#L381-L396
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18nQuery.php
CustomerGroupI18nQuery.useCustomerGroupQuery
public function useCustomerGroupQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinCustomerGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerGroup', '\CustomerGroup\Model\CustomerGroupQuery'); }
php
public function useCustomerGroupQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinCustomerGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerGroup', '\CustomerGroup\Model\CustomerGroupQuery'); }
[ "public", "function", "useCustomerGroupQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "'LEFT JOIN'", ")", "{", "return", "$", "this", "->", "joinCustomerGroup", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'CustomerGroup'", ",", "'\\CustomerGroup\\Model\\CustomerGroupQuery'", ")", ";", "}" ]
Use the CustomerGroup relation CustomerGroup object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \CustomerGroup\Model\CustomerGroupQuery A secondary query class using the current class as primary query
[ "Use", "the", "CustomerGroup", "relation", "CustomerGroup", "object" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18nQuery.php#L441-L446
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18nQuery.php
CustomerGroupI18nQuery.prune
public function prune($customerGroupI18n = null) { if ($customerGroupI18n) { $this->addCond('pruneCond0', $this->getAliasedColName(CustomerGroupI18nTableMap::ID), $customerGroupI18n->getId(), Criteria::NOT_EQUAL); $this->addCond('pruneCond1', $this->getAliasedColName(CustomerGroupI18nTableMap::LOCALE), $customerGroupI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; }
php
public function prune($customerGroupI18n = null) { if ($customerGroupI18n) { $this->addCond('pruneCond0', $this->getAliasedColName(CustomerGroupI18nTableMap::ID), $customerGroupI18n->getId(), Criteria::NOT_EQUAL); $this->addCond('pruneCond1', $this->getAliasedColName(CustomerGroupI18nTableMap::LOCALE), $customerGroupI18n->getLocale(), Criteria::NOT_EQUAL); $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); } return $this; }
[ "public", "function", "prune", "(", "$", "customerGroupI18n", "=", "null", ")", "{", "if", "(", "$", "customerGroupI18n", ")", "{", "$", "this", "->", "addCond", "(", "'pruneCond0'", ",", "$", "this", "->", "getAliasedColName", "(", "CustomerGroupI18nTableMap", "::", "ID", ")", ",", "$", "customerGroupI18n", "->", "getId", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "$", "this", "->", "addCond", "(", "'pruneCond1'", ",", "$", "this", "->", "getAliasedColName", "(", "CustomerGroupI18nTableMap", "::", "LOCALE", ")", ",", "$", "customerGroupI18n", "->", "getLocale", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "$", "this", "->", "combine", "(", "array", "(", "'pruneCond0'", ",", "'pruneCond1'", ")", ",", "Criteria", "::", "LOGICAL_OR", ")", ";", "}", "return", "$", "this", ";", "}" ]
Exclude object from result @param ChildCustomerGroupI18n $customerGroupI18n Object to remove from the list of results @return ChildCustomerGroupI18nQuery The current query, for fluid interface
[ "Exclude", "object", "from", "result" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18nQuery.php#L455-L464
surebert/surebert-framework
src/sb/Web/Visitor.php
Visitor.log
public function log($db=null) { if($db instanceof \PDO){ \sb\Web\Visitors::$db=$db; } return \sb\Web\Visitors::log($this); }
php
public function log($db=null) { if($db instanceof \PDO){ \sb\Web\Visitors::$db=$db; } return \sb\Web\Visitors::log($this); }
[ "public", "function", "log", "(", "$", "db", "=", "null", ")", "{", "if", "(", "$", "db", "instanceof", "\\", "PDO", ")", "{", "\\", "sb", "\\", "Web", "\\", "Visitors", "::", "$", "db", "=", "$", "db", ";", "}", "return", "\\", "sb", "\\", "Web", "\\", "Visitors", "::", "log", "(", "$", "this", ")", ";", "}" ]
Logs a \sb\Web_Visitor in the database @param PDO $db Optional database connection to use for \sb\Web_Vistors
[ "Logs", "a", "\\", "sb", "\\", "Web_Visitor", "in", "the", "database" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Visitor.php#L75-L84
sleeping-owl/route-priority
src/SleepingOwl/RoutePriority/RoutePriorityServiceProvider.php
RoutePriorityServiceProvider.register
public function register() { $this->app['router'] = $this->app->share(function($app) { $router = \App::make('SleepingOwl\RoutePriority\Router'); return $router; }); }
php
public function register() { $this->app['router'] = $this->app->share(function($app) { $router = \App::make('SleepingOwl\RoutePriority\Router'); return $router; }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "app", "[", "'router'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "$", "router", "=", "\\", "App", "::", "make", "(", "'SleepingOwl\\RoutePriority\\Router'", ")", ";", "return", "$", "router", ";", "}", ")", ";", "}" ]
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/sleeping-owl/route-priority/blob/fd311e5cdb2135e3aa34e9ef37c8f4f02c635089/src/SleepingOwl/RoutePriority/RoutePriorityServiceProvider.php#L19-L26
sleeping-owl/route-priority
src/SleepingOwl/RoutePriority/Router.php
Router.newRoute
protected function newRoute($methods, $uri, $action) { $route = new Route($methods, $uri, $action); $priority = Router::MEDIUM - $this->routes->count(); $route->setPriority($priority); return $route; }
php
protected function newRoute($methods, $uri, $action) { $route = new Route($methods, $uri, $action); $priority = Router::MEDIUM - $this->routes->count(); $route->setPriority($priority); return $route; }
[ "protected", "function", "newRoute", "(", "$", "methods", ",", "$", "uri", ",", "$", "action", ")", "{", "$", "route", "=", "new", "Route", "(", "$", "methods", ",", "$", "uri", ",", "$", "action", ")", ";", "$", "priority", "=", "Router", "::", "MEDIUM", "-", "$", "this", "->", "routes", "->", "count", "(", ")", ";", "$", "route", "->", "setPriority", "(", "$", "priority", ")", ";", "return", "$", "route", ";", "}" ]
Create a new Route object. @param array|string $methods @param string $uri @param mixed $action @return Route
[ "Create", "a", "new", "Route", "object", "." ]
train
https://github.com/sleeping-owl/route-priority/blob/fd311e5cdb2135e3aa34e9ef37c8f4f02c635089/src/SleepingOwl/RoutePriority/Router.php#L36-L42
lokhman/silex-tools
src/Silex/Util/DynamicContainer.php
DynamicContainer.offsetGet
public function offsetGet($id) { if (!isset($this[$id]) && $this->dynamic) { $dynamic = $this->dynamic; $this[$id] = $dynamic($id, $this); } return parent::offsetGet($id); }
php
public function offsetGet($id) { if (!isset($this[$id]) && $this->dynamic) { $dynamic = $this->dynamic; $this[$id] = $dynamic($id, $this); } return parent::offsetGet($id); }
[ "public", "function", "offsetGet", "(", "$", "id", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "[", "$", "id", "]", ")", "&&", "$", "this", "->", "dynamic", ")", "{", "$", "dynamic", "=", "$", "this", "->", "dynamic", ";", "$", "this", "[", "$", "id", "]", "=", "$", "dynamic", "(", "$", "id", ",", "$", "this", ")", ";", "}", "return", "parent", "::", "offsetGet", "(", "$", "id", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Util/DynamicContainer.php#L48-L56
antaresproject/notifications
src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onList
protected function onList() { Breadcrumbs::register('notifications', function($breadcrumbs) { $breadcrumbs->push(trans('antares/notifications::messages.notification_templates'), handles('antares::notifications/index')); }); view()->share('breadcrumbs', Breadcrumbs::render('notifications')); }
php
protected function onList() { Breadcrumbs::register('notifications', function($breadcrumbs) { $breadcrumbs->push(trans('antares/notifications::messages.notification_templates'), handles('antares::notifications/index')); }); view()->share('breadcrumbs', Breadcrumbs::render('notifications')); }
[ "protected", "function", "onList", "(", ")", "{", "Breadcrumbs", "::", "register", "(", "'notifications'", ",", "function", "(", "$", "breadcrumbs", ")", "{", "$", "breadcrumbs", "->", "push", "(", "trans", "(", "'antares/notifications::messages.notification_templates'", ")", ",", "handles", "(", "'antares::notifications/index'", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'notifications'", ")", ")", ";", "}" ]
on list notifications
[ "on", "list", "notifications" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L32-L38
antaresproject/notifications
src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onTable
public function onTable($type = null) { if (!is_null($type)) { Breadcrumbs::register('notifications-' . $type, function($breadcrumbs) use($type) { $breadcrumbs->push('Notifications ' . ucfirst($type), handles('antares::notifications/index')); }); view()->share('breadcrumbs', Breadcrumbs::render('notifications-' . $type)); } }
php
public function onTable($type = null) { if (!is_null($type)) { Breadcrumbs::register('notifications-' . $type, function($breadcrumbs) use($type) { $breadcrumbs->push('Notifications ' . ucfirst($type), handles('antares::notifications/index')); }); view()->share('breadcrumbs', Breadcrumbs::render('notifications-' . $type)); } }
[ "public", "function", "onTable", "(", "$", "type", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "type", ")", ")", "{", "Breadcrumbs", "::", "register", "(", "'notifications-'", ".", "$", "type", ",", "function", "(", "$", "breadcrumbs", ")", "use", "(", "$", "type", ")", "{", "$", "breadcrumbs", "->", "push", "(", "'Notifications '", ".", "ucfirst", "(", "$", "type", ")", ",", "handles", "(", "'antares::notifications/index'", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'notifications-'", ".", "$", "type", ")", ")", ";", "}", "}" ]
when shows notifications list @param type $type
[ "when", "shows", "notifications", "list" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L45-L53
antaresproject/notifications
src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onEdit
public function onEdit(Model $eloquent) { $this->onList(); $title = null; $langId = lang_id(); foreach ($eloquent->contents as $content) { if ($langId == $content->lang_id) { $title = $content->title; } } Breadcrumbs::register('notification-edit', function($breadcrumbs) use($title) { $breadcrumbs->parent('notifications'); $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_edit', ['name' => $title])); }); view()->share('breadcrumbs', Breadcrumbs::render('notification-edit')); }
php
public function onEdit(Model $eloquent) { $this->onList(); $title = null; $langId = lang_id(); foreach ($eloquent->contents as $content) { if ($langId == $content->lang_id) { $title = $content->title; } } Breadcrumbs::register('notification-edit', function($breadcrumbs) use($title) { $breadcrumbs->parent('notifications'); $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_edit', ['name' => $title])); }); view()->share('breadcrumbs', Breadcrumbs::render('notification-edit')); }
[ "public", "function", "onEdit", "(", "Model", "$", "eloquent", ")", "{", "$", "this", "->", "onList", "(", ")", ";", "$", "title", "=", "null", ";", "$", "langId", "=", "lang_id", "(", ")", ";", "foreach", "(", "$", "eloquent", "->", "contents", "as", "$", "content", ")", "{", "if", "(", "$", "langId", "==", "$", "content", "->", "lang_id", ")", "{", "$", "title", "=", "$", "content", "->", "title", ";", "}", "}", "Breadcrumbs", "::", "register", "(", "'notification-edit'", ",", "function", "(", "$", "breadcrumbs", ")", "use", "(", "$", "title", ")", "{", "$", "breadcrumbs", "->", "parent", "(", "'notifications'", ")", ";", "$", "breadcrumbs", "->", "push", "(", "trans", "(", "'antares/notifications::messages.notification_templates_edit'", ",", "[", "'name'", "=>", "$", "title", "]", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'notification-edit'", ")", ")", ";", "}" ]
when shows edit notification form @param Model $eloquent
[ "when", "shows", "edit", "notification", "form" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L60-L76
antaresproject/notifications
src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onCreate
public function onCreate($type = null) { $this->onList(); Breadcrumbs::register('notification-create', function($breadcrumbs) { $breadcrumbs->parent('notifications'); $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_create')); }); view()->share('breadcrumbs', Breadcrumbs::render('notification-create')); }
php
public function onCreate($type = null) { $this->onList(); Breadcrumbs::register('notification-create', function($breadcrumbs) { $breadcrumbs->parent('notifications'); $breadcrumbs->push(trans('antares/notifications::messages.notification_templates_create')); }); view()->share('breadcrumbs', Breadcrumbs::render('notification-create')); }
[ "public", "function", "onCreate", "(", "$", "type", "=", "null", ")", "{", "$", "this", "->", "onList", "(", ")", ";", "Breadcrumbs", "::", "register", "(", "'notification-create'", ",", "function", "(", "$", "breadcrumbs", ")", "{", "$", "breadcrumbs", "->", "parent", "(", "'notifications'", ")", ";", "$", "breadcrumbs", "->", "push", "(", "trans", "(", "'antares/notifications::messages.notification_templates_create'", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'notification-create'", ")", ")", ";", "}" ]
when shows create new notification form @param String $type
[ "when", "shows", "create", "new", "notification", "form" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L83-L91
zhouyl/mellivora
Mellivora/Database/Eloquent/Concerns/HasAttributes.php
HasAttributes.setAttribute
public function setAttribute($key, $value) { // First we will check for the presence of a mutator for the set operation // which simply lets the developers tweak the attribute as it is set on // the model, such as "json_encoding" an listing of data for storage. if ($this->hasSetMutator($key)) { $method = 'set' . Str::studly($key) . 'Attribute'; return $this->{$method}($value); } // If an attribute is listed as a "date", we'll convert it from a DateTime // instance into a form proper for storage on the database tables using // the connection grammar's date format. We will auto set the values. if ($value && $this->isDateAttribute($key)) { $value = $this->fromDateTime($value); } if ($this->isJsonCastable($key) && !is_null($value)) { $value = $this->asJson($value); } // If this attribute contains a JSON ->, we'll set the proper value in the // attribute's underlying array. This takes care of properly nesting an // attribute in the array's value in the case of deeply nested items. if (Str::contains($key, '->')) { return $this->fillJsonAttribute($key, $value); } $this->attributes[$key] = $value; return $this; }
php
public function setAttribute($key, $value) { // First we will check for the presence of a mutator for the set operation // which simply lets the developers tweak the attribute as it is set on // the model, such as "json_encoding" an listing of data for storage. if ($this->hasSetMutator($key)) { $method = 'set' . Str::studly($key) . 'Attribute'; return $this->{$method}($value); } // If an attribute is listed as a "date", we'll convert it from a DateTime // instance into a form proper for storage on the database tables using // the connection grammar's date format. We will auto set the values. if ($value && $this->isDateAttribute($key)) { $value = $this->fromDateTime($value); } if ($this->isJsonCastable($key) && !is_null($value)) { $value = $this->asJson($value); } // If this attribute contains a JSON ->, we'll set the proper value in the // attribute's underlying array. This takes care of properly nesting an // attribute in the array's value in the case of deeply nested items. if (Str::contains($key, '->')) { return $this->fillJsonAttribute($key, $value); } $this->attributes[$key] = $value; return $this; }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "// First we will check for the presence of a mutator for the set operation", "// which simply lets the developers tweak the attribute as it is set on", "// the model, such as \"json_encoding\" an listing of data for storage.", "if", "(", "$", "this", "->", "hasSetMutator", "(", "$", "key", ")", ")", "{", "$", "method", "=", "'set'", ".", "Str", "::", "studly", "(", "$", "key", ")", ".", "'Attribute'", ";", "return", "$", "this", "->", "{", "$", "method", "}", "(", "$", "value", ")", ";", "}", "// If an attribute is listed as a \"date\", we'll convert it from a DateTime", "// instance into a form proper for storage on the database tables using", "// the connection grammar's date format. We will auto set the values.", "if", "(", "$", "value", "&&", "$", "this", "->", "isDateAttribute", "(", "$", "key", ")", ")", "{", "$", "value", "=", "$", "this", "->", "fromDateTime", "(", "$", "value", ")", ";", "}", "if", "(", "$", "this", "->", "isJsonCastable", "(", "$", "key", ")", "&&", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "asJson", "(", "$", "value", ")", ";", "}", "// If this attribute contains a JSON ->, we'll set the proper value in the", "// attribute's underlying array. This takes care of properly nesting an", "// attribute in the array's value in the case of deeply nested items.", "if", "(", "Str", "::", "contains", "(", "$", "key", ",", "'->'", ")", ")", "{", "return", "$", "this", "->", "fillJsonAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a given attribute on the model. @param string $key @param mixed $value @return $this
[ "Set", "a", "given", "attribute", "on", "the", "model", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Concerns/HasAttributes.php#L529-L561
zhouyl/mellivora
Mellivora/Database/Eloquent/Concerns/HasAttributes.php
HasAttributes.asDateTime
protected function asDateTime($value) { // If this value is already a Carbon instance, we shall just return it as is. // This prevents us having to re-instantiate a Carbon instance when we know // it already is one, which wouldn't be fulfilled by the DateTime check. if ($value instanceof Carbon) { return $value; } // If the value is already a DateTime instance, we will just skip the rest of // these checks since they will be a waste of time, and hinder performance // when checking the field. We will just return the DateTime right away. if ($value instanceof DateTimeInterface) { return new Carbon( $value->format('Y-m-d H:i:s.u'), $value->getTimezone() ); } // If this value is an integer, we will assume it is a UNIX timestamp's value // and format a Carbon object from this timestamp. This allows flexibility // when defining your date fields as they might be UNIX timestamps here. if (is_numeric($value)) { return Carbon::createFromTimestamp($value); } // If the value is in simply year, month, day format, we will instantiate the // Carbon instances from that format. Again, this provides for simple date // fields on the database, while still supporting Carbonized conversion. if ($this->isStandardDateFormat($value)) { return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); } // Finally, we will just assume this date is in the format used by default on // the database connection and use that format to create the Carbon object // that is returned back out to the developers after we convert it here. return Carbon::createFromFormat( $this->getDateFormat(), $value ); }
php
protected function asDateTime($value) { // If this value is already a Carbon instance, we shall just return it as is. // This prevents us having to re-instantiate a Carbon instance when we know // it already is one, which wouldn't be fulfilled by the DateTime check. if ($value instanceof Carbon) { return $value; } // If the value is already a DateTime instance, we will just skip the rest of // these checks since they will be a waste of time, and hinder performance // when checking the field. We will just return the DateTime right away. if ($value instanceof DateTimeInterface) { return new Carbon( $value->format('Y-m-d H:i:s.u'), $value->getTimezone() ); } // If this value is an integer, we will assume it is a UNIX timestamp's value // and format a Carbon object from this timestamp. This allows flexibility // when defining your date fields as they might be UNIX timestamps here. if (is_numeric($value)) { return Carbon::createFromTimestamp($value); } // If the value is in simply year, month, day format, we will instantiate the // Carbon instances from that format. Again, this provides for simple date // fields on the database, while still supporting Carbonized conversion. if ($this->isStandardDateFormat($value)) { return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); } // Finally, we will just assume this date is in the format used by default on // the database connection and use that format to create the Carbon object // that is returned back out to the developers after we convert it here. return Carbon::createFromFormat( $this->getDateFormat(), $value ); }
[ "protected", "function", "asDateTime", "(", "$", "value", ")", "{", "// If this value is already a Carbon instance, we shall just return it as is.", "// This prevents us having to re-instantiate a Carbon instance when we know", "// it already is one, which wouldn't be fulfilled by the DateTime check.", "if", "(", "$", "value", "instanceof", "Carbon", ")", "{", "return", "$", "value", ";", "}", "// If the value is already a DateTime instance, we will just skip the rest of", "// these checks since they will be a waste of time, and hinder performance", "// when checking the field. We will just return the DateTime right away.", "if", "(", "$", "value", "instanceof", "DateTimeInterface", ")", "{", "return", "new", "Carbon", "(", "$", "value", "->", "format", "(", "'Y-m-d H:i:s.u'", ")", ",", "$", "value", "->", "getTimezone", "(", ")", ")", ";", "}", "// If this value is an integer, we will assume it is a UNIX timestamp's value", "// and format a Carbon object from this timestamp. This allows flexibility", "// when defining your date fields as they might be UNIX timestamps here.", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "Carbon", "::", "createFromTimestamp", "(", "$", "value", ")", ";", "}", "// If the value is in simply year, month, day format, we will instantiate the", "// Carbon instances from that format. Again, this provides for simple date", "// fields on the database, while still supporting Carbonized conversion.", "if", "(", "$", "this", "->", "isStandardDateFormat", "(", "$", "value", ")", ")", "{", "return", "Carbon", "::", "createFromFormat", "(", "'Y-m-d'", ",", "$", "value", ")", "->", "startOfDay", "(", ")", ";", "}", "// Finally, we will just assume this date is in the format used by default on", "// the database connection and use that format to create the Carbon object", "// that is returned back out to the developers after we convert it here.", "return", "Carbon", "::", "createFromFormat", "(", "$", "this", "->", "getDateFormat", "(", ")", ",", "$", "value", ")", ";", "}" ]
Return a timestamp as DateTime object. @param mixed $value @return \Carbon\Carbon
[ "Return", "a", "timestamp", "as", "DateTime", "object", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Concerns/HasAttributes.php#L682-L722
caffeinated/beverage
src/Sorter.php
Sorter.add
public function add(array $items, $allowNumericitem = false) { foreach ($items as $item => $_deps) { if (! $allowNumericitem and is_int($item)) { $this->addItem($_deps); } else { $this->addItem($item, $_deps); } } }
php
public function add(array $items, $allowNumericitem = false) { foreach ($items as $item => $_deps) { if (! $allowNumericitem and is_int($item)) { $this->addItem($_deps); } else { $this->addItem($item, $_deps); } } }
[ "public", "function", "add", "(", "array", "$", "items", ",", "$", "allowNumericitem", "=", "false", ")", "{", "foreach", "(", "$", "items", "as", "$", "item", "=>", "$", "_deps", ")", "{", "if", "(", "!", "$", "allowNumericitem", "and", "is_int", "(", "$", "item", ")", ")", "{", "$", "this", "->", "addItem", "(", "$", "_deps", ")", ";", "}", "else", "{", "$", "this", "->", "addItem", "(", "$", "item", ",", "$", "_deps", ")", ";", "}", "}", "}" ]
add @param array $items @param bool $allowNumericitem
[ "add" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L64-L73
caffeinated/beverage
src/Sorter.php
Sorter.addItem
public function addItem($item, $_deps = null) { list($item, $_deps) = $this->prepNewItem($item, $_deps); $this->setItem($item, $_deps); }
php
public function addItem($item, $_deps = null) { list($item, $_deps) = $this->prepNewItem($item, $_deps); $this->setItem($item, $_deps); }
[ "public", "function", "addItem", "(", "$", "item", ",", "$", "_deps", "=", "null", ")", "{", "list", "(", "$", "item", ",", "$", "_deps", ")", "=", "$", "this", "->", "prepNewItem", "(", "$", "item", ",", "$", "_deps", ")", ";", "$", "this", "->", "setItem", "(", "$", "item", ",", "$", "_deps", ")", ";", "}" ]
addItem @param $item @param null $_deps
[ "addItem" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L81-L85
caffeinated/beverage
src/Sorter.php
Sorter.sort
public function sort() { $this->sorted = array(); $hasChanged = true; while (count($this->sorted) < count($this->items) && $hasChanged) { $hasChanged = false; foreach ($this->dependencies as $item => $deps) { if ($this->satisfied($item)) { $this->setSorted($item); $this->removeDependents($item); $hasChanged = true; } $this->hits[$item]++; } } return $this->sorted; }
php
public function sort() { $this->sorted = array(); $hasChanged = true; while (count($this->sorted) < count($this->items) && $hasChanged) { $hasChanged = false; foreach ($this->dependencies as $item => $deps) { if ($this->satisfied($item)) { $this->setSorted($item); $this->removeDependents($item); $hasChanged = true; } $this->hits[$item]++; } } return $this->sorted; }
[ "public", "function", "sort", "(", ")", "{", "$", "this", "->", "sorted", "=", "array", "(", ")", ";", "$", "hasChanged", "=", "true", ";", "while", "(", "count", "(", "$", "this", "->", "sorted", ")", "<", "count", "(", "$", "this", "->", "items", ")", "&&", "$", "hasChanged", ")", "{", "$", "hasChanged", "=", "false", ";", "foreach", "(", "$", "this", "->", "dependencies", "as", "$", "item", "=>", "$", "deps", ")", "{", "if", "(", "$", "this", "->", "satisfied", "(", "$", "item", ")", ")", "{", "$", "this", "->", "setSorted", "(", "$", "item", ")", ";", "$", "this", "->", "removeDependents", "(", "$", "item", ")", ";", "$", "hasChanged", "=", "true", ";", "}", "$", "this", "->", "hits", "[", "$", "item", "]", "++", ";", "}", "}", "return", "$", "this", "->", "sorted", ";", "}" ]
sort @return array
[ "sort" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L92-L109
caffeinated/beverage
src/Sorter.php
Sorter.setItem
protected function setItem($item, array $_deps) { $this->items[] = $item; foreach ($_deps as $_dep) { $this->items[] = $_dep; $this->dependsOn[$_dep][$item] = $item; $this->hits[$_dep] = 0; } $this->items = array_unique($this->items); $this->dependencies[$item] = $_deps; $this->hits[$item] = 0; }
php
protected function setItem($item, array $_deps) { $this->items[] = $item; foreach ($_deps as $_dep) { $this->items[] = $_dep; $this->dependsOn[$_dep][$item] = $item; $this->hits[$_dep] = 0; } $this->items = array_unique($this->items); $this->dependencies[$item] = $_deps; $this->hits[$item] = 0; }
[ "protected", "function", "setItem", "(", "$", "item", ",", "array", "$", "_deps", ")", "{", "$", "this", "->", "items", "[", "]", "=", "$", "item", ";", "foreach", "(", "$", "_deps", "as", "$", "_dep", ")", "{", "$", "this", "->", "items", "[", "]", "=", "$", "_dep", ";", "$", "this", "->", "dependsOn", "[", "$", "_dep", "]", "[", "$", "item", "]", "=", "$", "item", ";", "$", "this", "->", "hits", "[", "$", "_dep", "]", "=", "0", ";", "}", "$", "this", "->", "items", "=", "array_unique", "(", "$", "this", "->", "items", ")", ";", "$", "this", "->", "dependencies", "[", "$", "item", "]", "=", "$", "_deps", ";", "$", "this", "->", "hits", "[", "$", "item", "]", "=", "0", ";", "}" ]
setItem @param $item @param array $_deps
[ "setItem" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L117-L128
caffeinated/beverage
src/Sorter.php
Sorter.prepNewItem
protected function prepNewItem($item, $_deps) { if ($item instanceof Dependable) { $_deps = $item->getDependencies(); $item = $item->getHandle(); } elseif ($_deps instanceof Dependable) { $_deps = $_deps->getDependencies(); } if (empty($_deps)) { $_deps = []; } elseif (is_string($_deps)) { $_deps = (array)preg_split('/,\s?/', $_deps); } return [$item, $_deps]; }
php
protected function prepNewItem($item, $_deps) { if ($item instanceof Dependable) { $_deps = $item->getDependencies(); $item = $item->getHandle(); } elseif ($_deps instanceof Dependable) { $_deps = $_deps->getDependencies(); } if (empty($_deps)) { $_deps = []; } elseif (is_string($_deps)) { $_deps = (array)preg_split('/,\s?/', $_deps); } return [$item, $_deps]; }
[ "protected", "function", "prepNewItem", "(", "$", "item", ",", "$", "_deps", ")", "{", "if", "(", "$", "item", "instanceof", "Dependable", ")", "{", "$", "_deps", "=", "$", "item", "->", "getDependencies", "(", ")", ";", "$", "item", "=", "$", "item", "->", "getHandle", "(", ")", ";", "}", "elseif", "(", "$", "_deps", "instanceof", "Dependable", ")", "{", "$", "_deps", "=", "$", "_deps", "->", "getDependencies", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "_deps", ")", ")", "{", "$", "_deps", "=", "[", "]", ";", "}", "elseif", "(", "is_string", "(", "$", "_deps", ")", ")", "{", "$", "_deps", "=", "(", "array", ")", "preg_split", "(", "'/,\\s?/'", ",", "$", "_deps", ")", ";", "}", "return", "[", "$", "item", ",", "$", "_deps", "]", ";", "}" ]
prepNewItem @param $item @param $_deps @return array
[ "prepNewItem" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L137-L152
caffeinated/beverage
src/Sorter.php
Sorter.satisfied
protected function satisfied($item) { $pass = true; foreach ($this->getDependents($item) as $dep) { if ($this->isSorted($dep)) { continue; } if (! $this->exists($item)) { $this->setMissing($item, $dep); if ($pass) { $pass = false; } } if (! $this->hasDependents($dep)) { if ($pass) { $pass = false; } } else { $this->setFound($item, $dep); } if ($this->isDependent($item, $dep)) { $this->setCircular($item, $dep); if ($pass) { $pass = false; } } } return $pass; }
php
protected function satisfied($item) { $pass = true; foreach ($this->getDependents($item) as $dep) { if ($this->isSorted($dep)) { continue; } if (! $this->exists($item)) { $this->setMissing($item, $dep); if ($pass) { $pass = false; } } if (! $this->hasDependents($dep)) { if ($pass) { $pass = false; } } else { $this->setFound($item, $dep); } if ($this->isDependent($item, $dep)) { $this->setCircular($item, $dep); if ($pass) { $pass = false; } } } return $pass; }
[ "protected", "function", "satisfied", "(", "$", "item", ")", "{", "$", "pass", "=", "true", ";", "foreach", "(", "$", "this", "->", "getDependents", "(", "$", "item", ")", "as", "$", "dep", ")", "{", "if", "(", "$", "this", "->", "isSorted", "(", "$", "dep", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "item", ")", ")", "{", "$", "this", "->", "setMissing", "(", "$", "item", ",", "$", "dep", ")", ";", "if", "(", "$", "pass", ")", "{", "$", "pass", "=", "false", ";", "}", "}", "if", "(", "!", "$", "this", "->", "hasDependents", "(", "$", "dep", ")", ")", "{", "if", "(", "$", "pass", ")", "{", "$", "pass", "=", "false", ";", "}", "}", "else", "{", "$", "this", "->", "setFound", "(", "$", "item", ",", "$", "dep", ")", ";", "}", "if", "(", "$", "this", "->", "isDependent", "(", "$", "item", ",", "$", "dep", ")", ")", "{", "$", "this", "->", "setCircular", "(", "$", "item", ",", "$", "dep", ")", ";", "if", "(", "$", "pass", ")", "{", "$", "pass", "=", "false", ";", "}", "}", "}", "return", "$", "pass", ";", "}" ]
satisfied @param $item @return bool
[ "satisfied" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L160-L190
caffeinated/beverage
src/Sorter.php
Sorter.setFound
protected function setFound($item, $item2) { if (isset($this->missing[$item])) { unset($this->missing[$item][$item2]); if (empty($this->missing[$item])) { unset($this->missing[$item]); } } }
php
protected function setFound($item, $item2) { if (isset($this->missing[$item])) { unset($this->missing[$item][$item2]); if (empty($this->missing[$item])) { unset($this->missing[$item]); } } }
[ "protected", "function", "setFound", "(", "$", "item", ",", "$", "item2", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "missing", "[", "$", "item", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "missing", "[", "$", "item", "]", "[", "$", "item2", "]", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "missing", "[", "$", "item", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "missing", "[", "$", "item", "]", ")", ";", "}", "}", "}" ]
setFound @param $item @param $item2
[ "setFound" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L251-L259
caffeinated/beverage
src/Sorter.php
Sorter.isMissing
public function isMissing($dep) { foreach ($this->missing as $item => $deps) { if (in_array($dep, $deps)) { return true; } } }
php
public function isMissing($dep) { foreach ($this->missing as $item => $deps) { if (in_array($dep, $deps)) { return true; } } }
[ "public", "function", "isMissing", "(", "$", "dep", ")", "{", "foreach", "(", "$", "this", "->", "missing", "as", "$", "item", "=>", "$", "deps", ")", "{", "if", "(", "in_array", "(", "$", "dep", ",", "$", "deps", ")", ")", "{", "return", "true", ";", "}", "}", "}" ]
isMissing @param mixed|string $dep @return bool
[ "isMissing" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L317-L324
caffeinated/beverage
src/Sorter.php
Sorter.isCircular
public function isCircular($dep) { foreach ($this->circular as $item => $deps) { if (in_array($dep, $deps)) { return true; } } }
php
public function isCircular($dep) { foreach ($this->circular as $item => $deps) { if (in_array($dep, $deps)) { return true; } } }
[ "public", "function", "isCircular", "(", "$", "dep", ")", "{", "foreach", "(", "$", "this", "->", "circular", "as", "$", "item", "=>", "$", "deps", ")", "{", "if", "(", "in_array", "(", "$", "dep", ",", "$", "deps", ")", ")", "{", "return", "true", ";", "}", "}", "}" ]
isCircular @param mixed|string $dep @return bool
[ "isCircular" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Sorter.php#L343-L350
php-lug/lug
src/Component/Resource/Repository/Doctrine/MongoDB/RepositoryFactory.php
RepositoryFactory.createRepository
protected function createRepository(DocumentManager $documentManager, $documentName) { $metadata = $documentManager->getClassMetadata($documentName); $repository = $metadata->customRepositoryClassName; if ($repository === null) { $repository = $documentManager->getConfiguration()->getDefaultRepositoryClassName(); } return $this->createResourceRepository( $repository, $documentManager, $metadata, $this->resolveResource($metadata->getName()) ); }
php
protected function createRepository(DocumentManager $documentManager, $documentName) { $metadata = $documentManager->getClassMetadata($documentName); $repository = $metadata->customRepositoryClassName; if ($repository === null) { $repository = $documentManager->getConfiguration()->getDefaultRepositoryClassName(); } return $this->createResourceRepository( $repository, $documentManager, $metadata, $this->resolveResource($metadata->getName()) ); }
[ "protected", "function", "createRepository", "(", "DocumentManager", "$", "documentManager", ",", "$", "documentName", ")", "{", "$", "metadata", "=", "$", "documentManager", "->", "getClassMetadata", "(", "$", "documentName", ")", ";", "$", "repository", "=", "$", "metadata", "->", "customRepositoryClassName", ";", "if", "(", "$", "repository", "===", "null", ")", "{", "$", "repository", "=", "$", "documentManager", "->", "getConfiguration", "(", ")", "->", "getDefaultRepositoryClassName", "(", ")", ";", "}", "return", "$", "this", "->", "createResourceRepository", "(", "$", "repository", ",", "$", "documentManager", ",", "$", "metadata", ",", "$", "this", "->", "resolveResource", "(", "$", "metadata", "->", "getName", "(", ")", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/MongoDB/RepositoryFactory.php#L43-L58
php-lug/lug
src/Component/Resource/Repository/Doctrine/MongoDB/RepositoryFactory.php
RepositoryFactory.createResourceRepository
protected function createResourceRepository( $class, DocumentManager $documentManager, ClassMetadata $metadata, ResourceInterface $resource = null ) { if ($resource !== null && is_a($class, BaseRepositoryInterface::class, true)) { return new $class($documentManager, $documentManager->getUnitOfWork(), $metadata, $resource); } return parent::createRepository($documentManager, $metadata->getName()); }
php
protected function createResourceRepository( $class, DocumentManager $documentManager, ClassMetadata $metadata, ResourceInterface $resource = null ) { if ($resource !== null && is_a($class, BaseRepositoryInterface::class, true)) { return new $class($documentManager, $documentManager->getUnitOfWork(), $metadata, $resource); } return parent::createRepository($documentManager, $metadata->getName()); }
[ "protected", "function", "createResourceRepository", "(", "$", "class", ",", "DocumentManager", "$", "documentManager", ",", "ClassMetadata", "$", "metadata", ",", "ResourceInterface", "$", "resource", "=", "null", ")", "{", "if", "(", "$", "resource", "!==", "null", "&&", "is_a", "(", "$", "class", ",", "BaseRepositoryInterface", "::", "class", ",", "true", ")", ")", "{", "return", "new", "$", "class", "(", "$", "documentManager", ",", "$", "documentManager", "->", "getUnitOfWork", "(", ")", ",", "$", "metadata", ",", "$", "resource", ")", ";", "}", "return", "parent", "::", "createRepository", "(", "$", "documentManager", ",", "$", "metadata", "->", "getName", "(", ")", ")", ";", "}" ]
@param string $class @param DocumentManager $documentManager @param ClassMetadata $metadata @param ResourceInterface|null $resource @return ObjectRepository
[ "@param", "string", "$class", "@param", "DocumentManager", "$documentManager", "@param", "ClassMetadata", "$metadata", "@param", "ResourceInterface|null", "$resource" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/MongoDB/RepositoryFactory.php#L68-L79
mergado/mergado-api-client-php
src/mergadoclient/OAuth2/MergadoProvider.php
MergadoProvider.getAuthorizationParameters
protected function getAuthorizationParameters(array $options) { // I removed this from application authorization flow // if (empty($options['state'])) { // $options['state'] = $this->getRandomState(); // } // if (empty($options['scope'])) { // $options['scope'] = $this->getDefaultScopes(); // } if (empty($options['entity_id'])) { $options['entity_id'] = ''; } $options += [ 'response_type' => 'code', 'approval_prompt' => 'auto' ]; // if (is_array($options['scope'])) { // $separator = $this->getScopeSeparator(); // $options['scope'] = implode($separator, $options['scope']); // } // Store the state as it may need to be accessed later on. // $this->state = $options['state']; return [ 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, 'entity_id' => $options['entity_id'], // 'state' => $this->state, // 'scope' => $options['scope'], 'response_type' => $options['response_type'], 'approval_prompt' => $options['approval_prompt'], ]; }
php
protected function getAuthorizationParameters(array $options) { // I removed this from application authorization flow // if (empty($options['state'])) { // $options['state'] = $this->getRandomState(); // } // if (empty($options['scope'])) { // $options['scope'] = $this->getDefaultScopes(); // } if (empty($options['entity_id'])) { $options['entity_id'] = ''; } $options += [ 'response_type' => 'code', 'approval_prompt' => 'auto' ]; // if (is_array($options['scope'])) { // $separator = $this->getScopeSeparator(); // $options['scope'] = implode($separator, $options['scope']); // } // Store the state as it may need to be accessed later on. // $this->state = $options['state']; return [ 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUri, 'entity_id' => $options['entity_id'], // 'state' => $this->state, // 'scope' => $options['scope'], 'response_type' => $options['response_type'], 'approval_prompt' => $options['approval_prompt'], ]; }
[ "protected", "function", "getAuthorizationParameters", "(", "array", "$", "options", ")", "{", "// I removed this from application authorization flow", "// if (empty($options['state'])) {", "// $options['state'] = $this->getRandomState();", "// }", "// if (empty($options['scope'])) {", "// $options['scope'] = $this->getDefaultScopes();", "// }", "if", "(", "empty", "(", "$", "options", "[", "'entity_id'", "]", ")", ")", "{", "$", "options", "[", "'entity_id'", "]", "=", "''", ";", "}", "$", "options", "+=", "[", "'response_type'", "=>", "'code'", ",", "'approval_prompt'", "=>", "'auto'", "]", ";", "// if (is_array($options['scope'])) {", "// $separator = $this->getScopeSeparator();", "// $options['scope'] = implode($separator, $options['scope']);", "// }", "// Store the state as it may need to be accessed later on.", "// $this->state = $options['state'];", "return", "[", "'client_id'", "=>", "$", "this", "->", "clientId", ",", "'redirect_uri'", "=>", "$", "this", "->", "redirectUri", ",", "'entity_id'", "=>", "$", "options", "[", "'entity_id'", "]", ",", "// 'state' => $this->state,", "// 'scope' => $options['scope'],", "'response_type'", "=>", "$", "options", "[", "'response_type'", "]", ",", "'approval_prompt'", "=>", "$", "options", "[", "'approval_prompt'", "]", ",", "]", ";", "}" ]
Returns authorization parameters based on provided options. @param array $options @return array Authorization parameters
[ "Returns", "authorization", "parameters", "based", "on", "provided", "options", "." ]
train
https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/OAuth2/MergadoProvider.php#L162-L199
mergado/mergado-api-client-php
src/mergadoclient/OAuth2/MergadoProvider.php
MergadoProvider.getAccessToken
public function getAccessToken($grant, array $options = []) { if($grant == 'offline_token') { $grant = 'refresh_token'; if(isset($options["entity_id"])) { $options["refresh_token"] = base64_encode($options["entity_id"]); unset($options["entity_id"]); } } elseif ($grant == 'refresh_token') { if(isset($options["entity_id"])) { $options["refresh_token"] = base64_encode($options["entity_id"]); unset($options["entity_id"]); } } $grant = $this->verifyGrant($grant); $params = [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, ]; $params = $grant->prepareRequestParameters($params, $options); $request = $this->getAccessTokenRequest($params); $response = $this->getResponse($request); if (gettype($response) == "string") { throw new UnauthorizedException("Request error. Didn't get json response back.", $request); } $prepared = $this->prepareAccessTokenResponse($response); $token = $this->createAccessToken($prepared, $grant); return $token; }
php
public function getAccessToken($grant, array $options = []) { if($grant == 'offline_token') { $grant = 'refresh_token'; if(isset($options["entity_id"])) { $options["refresh_token"] = base64_encode($options["entity_id"]); unset($options["entity_id"]); } } elseif ($grant == 'refresh_token') { if(isset($options["entity_id"])) { $options["refresh_token"] = base64_encode($options["entity_id"]); unset($options["entity_id"]); } } $grant = $this->verifyGrant($grant); $params = [ 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, ]; $params = $grant->prepareRequestParameters($params, $options); $request = $this->getAccessTokenRequest($params); $response = $this->getResponse($request); if (gettype($response) == "string") { throw new UnauthorizedException("Request error. Didn't get json response back.", $request); } $prepared = $this->prepareAccessTokenResponse($response); $token = $this->createAccessToken($prepared, $grant); return $token; }
[ "public", "function", "getAccessToken", "(", "$", "grant", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "grant", "==", "'offline_token'", ")", "{", "$", "grant", "=", "'refresh_token'", ";", "if", "(", "isset", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ")", "{", "$", "options", "[", "\"refresh_token\"", "]", "=", "base64_encode", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ";", "unset", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ";", "}", "}", "elseif", "(", "$", "grant", "==", "'refresh_token'", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ")", "{", "$", "options", "[", "\"refresh_token\"", "]", "=", "base64_encode", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ";", "unset", "(", "$", "options", "[", "\"entity_id\"", "]", ")", ";", "}", "}", "$", "grant", "=", "$", "this", "->", "verifyGrant", "(", "$", "grant", ")", ";", "$", "params", "=", "[", "'client_id'", "=>", "$", "this", "->", "clientId", ",", "'client_secret'", "=>", "$", "this", "->", "clientSecret", ",", "'redirect_uri'", "=>", "$", "this", "->", "redirectUri", ",", "]", ";", "$", "params", "=", "$", "grant", "->", "prepareRequestParameters", "(", "$", "params", ",", "$", "options", ")", ";", "$", "request", "=", "$", "this", "->", "getAccessTokenRequest", "(", "$", "params", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "$", "request", ")", ";", "if", "(", "gettype", "(", "$", "response", ")", "==", "\"string\"", ")", "{", "throw", "new", "UnauthorizedException", "(", "\"Request error. Didn't get json response back.\"", ",", "$", "request", ")", ";", "}", "$", "prepared", "=", "$", "this", "->", "prepareAccessTokenResponse", "(", "$", "response", ")", ";", "$", "token", "=", "$", "this", "->", "createAccessToken", "(", "$", "prepared", ",", "$", "grant", ")", ";", "return", "$", "token", ";", "}" ]
Requests an access token using a specified grant and option set. @param mixed $grant @param array $options @return \MergadoClient\OAuth2\AccessToken
[ "Requests", "an", "access", "token", "using", "a", "specified", "grant", "and", "option", "set", "." ]
train
https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/OAuth2/MergadoProvider.php#L208-L241
ouropencode/dachi
src/Request.php
Request.getUri
public static function getUri($index, $regex = ".*") { if(self::$uri === array()) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); if(isset(self::$uri_variables[$index])) if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri_variables[$index])) return self::$uri_variables[$index]; if(isset(self::$uri[$index])) if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri[$index])) return self::$uri[$index]; throw new InvalidRequestURIException; }
php
public static function getUri($index, $regex = ".*") { if(self::$uri === array()) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); if(isset(self::$uri_variables[$index])) if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri_variables[$index])) return self::$uri_variables[$index]; if(isset(self::$uri[$index])) if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri[$index])) return self::$uri[$index]; throw new InvalidRequestURIException; }
[ "public", "static", "function", "getUri", "(", "$", "index", ",", "$", "regex", "=", "\".*\"", ")", "{", "if", "(", "self", "::", "$", "uri", "===", "array", "(", ")", ")", "self", "::", "$", "uri", "=", "explode", "(", "\"/\"", ",", "trim", "(", "$", "_GET", "[", "'dachi_uri'", "]", ",", "\" \\t\\n\\r\\0\\x0B/\"", ")", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "uri_variables", "[", "$", "index", "]", ")", ")", "if", "(", "$", "regex", "==", "\".*\"", "||", "preg_match", "(", "\"/^\"", ".", "$", "regex", ".", "\"$/i\"", ",", "self", "::", "$", "uri_variables", "[", "$", "index", "]", ")", ")", "return", "self", "::", "$", "uri_variables", "[", "$", "index", "]", ";", "if", "(", "isset", "(", "self", "::", "$", "uri", "[", "$", "index", "]", ")", ")", "if", "(", "$", "regex", "==", "\".*\"", "||", "preg_match", "(", "\"/^\"", ".", "$", "regex", ".", "\"$/i\"", ",", "self", "::", "$", "uri", "[", "$", "index", "]", ")", ")", "return", "self", "::", "$", "uri", "[", "$", "index", "]", ";", "throw", "new", "InvalidRequestURIException", ";", "}" ]
Get a section of the URI The URI is split by the '/' character. @param string $index The index to retrieve @param string $regex The regular expression pattern the index must conform too @throws InvalidRequestURIException The specified index was not found or did not conform to the regex. @return string
[ "Get", "a", "section", "of", "the", "URI" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L37-L51
ouropencode/dachi
src/Request.php
Request.getFullUri
public static function getFullUri() { if(!isset($_GET['dachi_uri'])) $_GET['dachi_uri'] = ""; if(self::$uri === array() && isset($_GET['dachi_uri'])) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); return self::$uri; }
php
public static function getFullUri() { if(!isset($_GET['dachi_uri'])) $_GET['dachi_uri'] = ""; if(self::$uri === array() && isset($_GET['dachi_uri'])) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); return self::$uri; }
[ "public", "static", "function", "getFullUri", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "_GET", "[", "'dachi_uri'", "]", ")", ")", "$", "_GET", "[", "'dachi_uri'", "]", "=", "\"\"", ";", "if", "(", "self", "::", "$", "uri", "===", "array", "(", ")", "&&", "isset", "(", "$", "_GET", "[", "'dachi_uri'", "]", ")", ")", "self", "::", "$", "uri", "=", "explode", "(", "\"/\"", ",", "trim", "(", "$", "_GET", "[", "'dachi_uri'", "]", ",", "\" \\t\\n\\r\\0\\x0B/\"", ")", ")", ";", "return", "self", "::", "$", "uri", ";", "}" ]
Get the whole URI The URI is split by the '/' character. @return array
[ "Get", "the", "whole", "URI" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L60-L68
ouropencode/dachi
src/Request.php
Request.setRequestVariables
public static function setRequestVariables($uri_variables, $api_mode = false) { if(self::$uri === array() && isset($_GET['dachi_uri'])) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); foreach($uri_variables as $var) self::$uri_variables[$var[1]] = self::$uri[$var[0]]; self::$api_mode = $api_mode; }
php
public static function setRequestVariables($uri_variables, $api_mode = false) { if(self::$uri === array() && isset($_GET['dachi_uri'])) self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/")); foreach($uri_variables as $var) self::$uri_variables[$var[1]] = self::$uri[$var[0]]; self::$api_mode = $api_mode; }
[ "public", "static", "function", "setRequestVariables", "(", "$", "uri_variables", ",", "$", "api_mode", "=", "false", ")", "{", "if", "(", "self", "::", "$", "uri", "===", "array", "(", ")", "&&", "isset", "(", "$", "_GET", "[", "'dachi_uri'", "]", ")", ")", "self", "::", "$", "uri", "=", "explode", "(", "\"/\"", ",", "trim", "(", "$", "_GET", "[", "'dachi_uri'", "]", ",", "\" \\t\\n\\r\\0\\x0B/\"", ")", ")", ";", "foreach", "(", "$", "uri_variables", "as", "$", "var", ")", "self", "::", "$", "uri_variables", "[", "$", "var", "[", "1", "]", "]", "=", "self", "::", "$", "uri", "[", "$", "var", "[", "0", "]", "]", ";", "self", "::", "$", "api_mode", "=", "$", "api_mode", ";", "}" ]
Set the variable mapping for URI componants. This is an internal function that allows the Router to assign the URI variables. @internal @see Router @param array $uri_variables Format: array(array(uri index, variable name)) @param bool $api_mode Is this request serving an API method.
[ "Set", "the", "variable", "mapping", "for", "URI", "componants", "." ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L80-L88
ouropencode/dachi
src/Request.php
Request.getArgument
public static function getArgument($key, $default = "default", $regex = ".*") { if(self::$arguments === array()) self::$arguments = array_merge($_GET, $_POST, $_FILES); if(isset(self::$arguments[$key])) { if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$arguments[$key])) return self::$arguments[$key]; throw new InvalidRequestArgumentException; } return $default; }
php
public static function getArgument($key, $default = "default", $regex = ".*") { if(self::$arguments === array()) self::$arguments = array_merge($_GET, $_POST, $_FILES); if(isset(self::$arguments[$key])) { if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$arguments[$key])) return self::$arguments[$key]; throw new InvalidRequestArgumentException; } return $default; }
[ "public", "static", "function", "getArgument", "(", "$", "key", ",", "$", "default", "=", "\"default\"", ",", "$", "regex", "=", "\".*\"", ")", "{", "if", "(", "self", "::", "$", "arguments", "===", "array", "(", ")", ")", "self", "::", "$", "arguments", "=", "array_merge", "(", "$", "_GET", ",", "$", "_POST", ",", "$", "_FILES", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "arguments", "[", "$", "key", "]", ")", ")", "{", "if", "(", "$", "regex", "==", "\".*\"", "||", "preg_match", "(", "\"/^\"", ".", "$", "regex", ".", "\"$/i\"", ",", "self", "::", "$", "arguments", "[", "$", "key", "]", ")", ")", "return", "self", "::", "$", "arguments", "[", "$", "key", "]", ";", "throw", "new", "InvalidRequestArgumentException", ";", "}", "return", "$", "default", ";", "}" ]
Get an argument passed to the page This is used for _GET, _POST and _FILES. @param string $key The key to retrieve @param string $default The default value to return if the key was not found @param string $regex The regular expression pattern the key must conform too @throws InvalidRequestArgumentException The specified key did not conform to the regex. @return string
[ "Get", "an", "argument", "passed", "to", "the", "page" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L127-L139
ouropencode/dachi
src/Request.php
Request.getAllArguments
public static function getAllArguments() { if(self::$arguments === array()) self::$arguments = array_merge($_GET, $_POST, $_FILES); return self::$arguments; }
php
public static function getAllArguments() { if(self::$arguments === array()) self::$arguments = array_merge($_GET, $_POST, $_FILES); return self::$arguments; }
[ "public", "static", "function", "getAllArguments", "(", ")", "{", "if", "(", "self", "::", "$", "arguments", "===", "array", "(", ")", ")", "self", "::", "$", "arguments", "=", "array_merge", "(", "$", "_GET", ",", "$", "_POST", ",", "$", "_FILES", ")", ";", "return", "self", "::", "$", "arguments", ";", "}" ]
Get all arguments passed to the page This is used for _GET, _POST and _FILES. @return string
[ "Get", "all", "arguments", "passed", "to", "the", "page" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L148-L153
ouropencode/dachi
src/Request.php
Request.setCookie
public static function setCookie($key, $value, $expire = -1, $path = "/", $domain = null) { if($expire == -1) $expire = time() + 2592000; // 30 days return setcookie($key, $value, $expire, $path, $domain); }
php
public static function setCookie($key, $value, $expire = -1, $path = "/", $domain = null) { if($expire == -1) $expire = time() + 2592000; // 30 days return setcookie($key, $value, $expire, $path, $domain); }
[ "public", "static", "function", "setCookie", "(", "$", "key", ",", "$", "value", ",", "$", "expire", "=", "-", "1", ",", "$", "path", "=", "\"/\"", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "$", "expire", "==", "-", "1", ")", "$", "expire", "=", "time", "(", ")", "+", "2592000", ";", "// 30 days", "return", "setcookie", "(", "$", "key", ",", "$", "value", ",", "$", "expire", ",", "$", "path", ",", "$", "domain", ")", ";", "}" ]
Set a value in the user's cookie @param string $key The key to set @param string $value The value to set @param integer $expire The time to expire (defaults to -1, -1 is 'now + 30 days') @param string $path The cookie path inside the domain (defaults to '/') @param string $domain The domain this cookie is assigned to (defaults to server default) @return bool
[ "Set", "a", "value", "in", "the", "user", "s", "cookie" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L203-L208
ouropencode/dachi
src/Request.php
Request.getData
public static function getData($key) { if(!isset(self::$output_data[$key])) return false; return self::$output_data[$key]; }
php
public static function getData($key) { if(!isset(self::$output_data[$key])) return false; return self::$output_data[$key]; }
[ "public", "static", "function", "getData", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "output_data", "[", "$", "key", "]", ")", ")", "return", "false", ";", "return", "self", "::", "$", "output_data", "[", "$", "key", "]", ";", "}" ]
Get an outgoing request data variable @param string $key The key to get @return mixed
[ "Get", "an", "outgoing", "request", "data", "variable" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L215-L220
ouropencode/dachi
src/Request.php
Request.isAjax
public static function isAjax() { if(Configuration::get("dachi.api-mode", false) == true) return true; return (self::getArgument("dachi-ui", "false") == "true" || self::getArgument("radon-ui-ajax", "false") == "true"); }
php
public static function isAjax() { if(Configuration::get("dachi.api-mode", false) == true) return true; return (self::getArgument("dachi-ui", "false") == "true" || self::getArgument("radon-ui-ajax", "false") == "true"); }
[ "public", "static", "function", "isAjax", "(", ")", "{", "if", "(", "Configuration", "::", "get", "(", "\"dachi.api-mode\"", ",", "false", ")", "==", "true", ")", "return", "true", ";", "return", "(", "self", "::", "getArgument", "(", "\"dachi-ui\"", ",", "\"false\"", ")", "==", "\"true\"", "||", "self", "::", "getArgument", "(", "\"radon-ui-ajax\"", ",", "\"false\"", ")", "==", "\"true\"", ")", ";", "}" ]
Check if this request is being served via ajax @return bool
[ "Check", "if", "this", "request", "is", "being", "served", "via", "ajax" ]
train
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L274-L279
openclerk/db
src/Migration.php
Migration.getAllParents
function getAllParents() { $result = array($this->getName() => $this); foreach ($this->getParents() as $parent) { $result += $parent->getAllParents(); } return $result; }
php
function getAllParents() { $result = array($this->getName() => $this); foreach ($this->getParents() as $parent) { $result += $parent->getAllParents(); } return $result; }
[ "function", "getAllParents", "(", ")", "{", "$", "result", "=", "array", "(", "$", "this", "->", "getName", "(", ")", "=>", "$", "this", ")", ";", "foreach", "(", "$", "this", "->", "getParents", "(", ")", "as", "$", "parent", ")", "{", "$", "result", "+=", "$", "parent", "->", "getAllParents", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get all our parent {@link Migration}s along with all of its parents migrations into one unique array.
[ "Get", "all", "our", "parent", "{" ]
train
https://github.com/openclerk/db/blob/923275ed6e9414d8952585b77331c28dbd032bac/src/Migration.php#L58-L64
openclerk/db
src/Migration.php
Migration.install
function install(Connection $db, Logger $log) { // bail if we've already applied if ($this->isApplied($db)) { $log->info("Skipping " . $this->getName() . ": already applied"); return; } // simply make sure all parent migrations are applied foreach ($this->getParents() as $migration) { $migration->install($db, $log); } // check we have a valid name if (strlen($this->getName()) == 0 || strlen($this->getName()) > 255) { throw new DbException("Invalid migration name '" . $this->getName() . "'"); } // and then install our own try { $log->info("Applying " . $this->getName()); if ($this->apply($db)) { $log->info("Applied migration " . $this->getName()); } else { $log->error("Could not apply migration '" . $this->getName() . "': " . $db->lastError()); throw new DbException("Could not apply migration " . $this->getName()); } } catch (DbException $e) { $log->error("Could not apply migration '" . $this->getName() . "': " . $e->getMessage()); throw new DbException("Could not apply migration " . $this->getName(), $e); } // save migration status $q = $db->prepare("INSERT INTO migrations SET name=?"); $q->execute(array($this->getName())); }
php
function install(Connection $db, Logger $log) { // bail if we've already applied if ($this->isApplied($db)) { $log->info("Skipping " . $this->getName() . ": already applied"); return; } // simply make sure all parent migrations are applied foreach ($this->getParents() as $migration) { $migration->install($db, $log); } // check we have a valid name if (strlen($this->getName()) == 0 || strlen($this->getName()) > 255) { throw new DbException("Invalid migration name '" . $this->getName() . "'"); } // and then install our own try { $log->info("Applying " . $this->getName()); if ($this->apply($db)) { $log->info("Applied migration " . $this->getName()); } else { $log->error("Could not apply migration '" . $this->getName() . "': " . $db->lastError()); throw new DbException("Could not apply migration " . $this->getName()); } } catch (DbException $e) { $log->error("Could not apply migration '" . $this->getName() . "': " . $e->getMessage()); throw new DbException("Could not apply migration " . $this->getName(), $e); } // save migration status $q = $db->prepare("INSERT INTO migrations SET name=?"); $q->execute(array($this->getName())); }
[ "function", "install", "(", "Connection", "$", "db", ",", "Logger", "$", "log", ")", "{", "// bail if we've already applied", "if", "(", "$", "this", "->", "isApplied", "(", "$", "db", ")", ")", "{", "$", "log", "->", "info", "(", "\"Skipping \"", ".", "$", "this", "->", "getName", "(", ")", ".", "\": already applied\"", ")", ";", "return", ";", "}", "// simply make sure all parent migrations are applied", "foreach", "(", "$", "this", "->", "getParents", "(", ")", "as", "$", "migration", ")", "{", "$", "migration", "->", "install", "(", "$", "db", ",", "$", "log", ")", ";", "}", "// check we have a valid name", "if", "(", "strlen", "(", "$", "this", "->", "getName", "(", ")", ")", "==", "0", "||", "strlen", "(", "$", "this", "->", "getName", "(", ")", ")", ">", "255", ")", "{", "throw", "new", "DbException", "(", "\"Invalid migration name '\"", ".", "$", "this", "->", "getName", "(", ")", ".", "\"'\"", ")", ";", "}", "// and then install our own", "try", "{", "$", "log", "->", "info", "(", "\"Applying \"", ".", "$", "this", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "this", "->", "apply", "(", "$", "db", ")", ")", "{", "$", "log", "->", "info", "(", "\"Applied migration \"", ".", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "else", "{", "$", "log", "->", "error", "(", "\"Could not apply migration '\"", ".", "$", "this", "->", "getName", "(", ")", ".", "\"': \"", ".", "$", "db", "->", "lastError", "(", ")", ")", ";", "throw", "new", "DbException", "(", "\"Could not apply migration \"", ".", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "}", "catch", "(", "DbException", "$", "e", ")", "{", "$", "log", "->", "error", "(", "\"Could not apply migration '\"", ".", "$", "this", "->", "getName", "(", ")", ".", "\"': \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "throw", "new", "DbException", "(", "\"Could not apply migration \"", ".", "$", "this", "->", "getName", "(", ")", ",", "$", "e", ")", ";", "}", "// save migration status", "$", "q", "=", "$", "db", "->", "prepare", "(", "\"INSERT INTO migrations SET name=?\"", ")", ";", "$", "q", "->", "execute", "(", "array", "(", "$", "this", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Install the current migration and any parent migrations that this migration depends on.
[ "Install", "the", "current", "migration", "and", "any", "parent", "migrations", "that", "this", "migration", "depends", "on", "." ]
train
https://github.com/openclerk/db/blob/923275ed6e9414d8952585b77331c28dbd032bac/src/Migration.php#L69-L103
openclerk/db
src/Migration.php
Migration.tableExists
function tableExists(Connection $db, $table) { $q = $db->prepare("SHOW TABLES LIKE ?"); $q->execute(array($table)); if ($q->fetch()) { return true; } else { return false; } }
php
function tableExists(Connection $db, $table) { $q = $db->prepare("SHOW TABLES LIKE ?"); $q->execute(array($table)); if ($q->fetch()) { return true; } else { return false; } }
[ "function", "tableExists", "(", "Connection", "$", "db", ",", "$", "table", ")", "{", "$", "q", "=", "$", "db", "->", "prepare", "(", "\"SHOW TABLES LIKE ?\"", ")", ";", "$", "q", "->", "execute", "(", "array", "(", "$", "table", ")", ")", ";", "if", "(", "$", "q", "->", "fetch", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Used e.g. in BaseMigration @return true if the given table exists
[ "Used", "e", ".", "g", ".", "in", "BaseMigration" ]
train
https://github.com/openclerk/db/blob/923275ed6e9414d8952585b77331c28dbd032bac/src/Migration.php#L135-L144
accompli/chrono
src/Adapter/SubversionAdapter.php
SubversionAdapter.getBranches
public function getBranches() { $branches = array(); $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->trunkPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $branch) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $branch, $matches) === 1 && $matches[2] === '.') { $branches[$matches[1]] = 'master'; } } } $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->branchesPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $branch) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $branch, $matches) === 1) { $branches[$matches[1]] = $matches[2]; } } } return $branches; }
php
public function getBranches() { $branches = array(); $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->trunkPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $branch) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $branch, $matches) === 1 && $matches[2] === '.') { $branches[$matches[1]] = 'master'; } } } $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->branchesPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $branch) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $branch, $matches) === 1) { $branches[$matches[1]] = $matches[2]; } } } return $branches; }
[ "public", "function", "getBranches", "(", ")", "{", "$", "branches", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "sprintf", "(", "'svn ls --non-interactive --verbose %s'", ",", "ProcessUtils", "::", "escapeArgument", "(", "$", "this", "->", "repositoryUrl", ".", "'/'", ".", "$", "this", "->", "trunkPath", ")", ")", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "foreach", "(", "$", "result", "->", "getOutputAsArray", "(", ")", "as", "$", "branch", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "self", "::", "BRANCHES_TAGS_REGEX", ",", "$", "branch", ",", "$", "matches", ")", "===", "1", "&&", "$", "matches", "[", "2", "]", "===", "'.'", ")", "{", "$", "branches", "[", "$", "matches", "[", "1", "]", "]", "=", "'master'", ";", "}", "}", "}", "$", "result", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "sprintf", "(", "'svn ls --non-interactive --verbose %s'", ",", "ProcessUtils", "::", "escapeArgument", "(", "$", "this", "->", "repositoryUrl", ".", "'/'", ".", "$", "this", "->", "branchesPath", ")", ")", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "foreach", "(", "$", "result", "->", "getOutputAsArray", "(", ")", "as", "$", "branch", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "self", "::", "BRANCHES_TAGS_REGEX", ",", "$", "branch", ",", "$", "matches", ")", "===", "1", ")", "{", "$", "branches", "[", "$", "matches", "[", "1", "]", "]", "=", "$", "matches", "[", "2", "]", ";", "}", "}", "}", "return", "$", "branches", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/SubversionAdapter.php#L67-L92
accompli/chrono
src/Adapter/SubversionAdapter.php
SubversionAdapter.getTags
public function getTags() { $tags = array(); $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->tagsPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $tag) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $tag, $matches) === 1) { $tags[$matches[1]] = $matches[2]; } } } return $tags; }
php
public function getTags() { $tags = array(); $result = $this->processExecutor->execute(sprintf('svn ls --non-interactive --verbose %s', ProcessUtils::escapeArgument($this->repositoryUrl.'/'.$this->tagsPath))); if ($result->isSuccessful()) { foreach ($result->getOutputAsArray() as $tag) { $matches = array(); if (preg_match(self::BRANCHES_TAGS_REGEX, $tag, $matches) === 1) { $tags[$matches[1]] = $matches[2]; } } } return $tags; }
[ "public", "function", "getTags", "(", ")", "{", "$", "tags", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "sprintf", "(", "'svn ls --non-interactive --verbose %s'", ",", "ProcessUtils", "::", "escapeArgument", "(", "$", "this", "->", "repositoryUrl", ".", "'/'", ".", "$", "this", "->", "tagsPath", ")", ")", ")", ";", "if", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "foreach", "(", "$", "result", "->", "getOutputAsArray", "(", ")", "as", "$", "tag", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", "self", "::", "BRANCHES_TAGS_REGEX", ",", "$", "tag", ",", "$", "matches", ")", "===", "1", ")", "{", "$", "tags", "[", "$", "matches", "[", "1", "]", "]", "=", "$", "matches", "[", "2", "]", ";", "}", "}", "}", "return", "$", "tags", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/SubversionAdapter.php#L97-L112
accompli/chrono
src/Adapter/SubversionAdapter.php
SubversionAdapter.checkout
public function checkout($version) { $checkoutSuccesful = false; $escapedRepositoryUrlWithVersionPath = $this->getRepositoryUrlWithVersionPath($version); if ($escapedRepositoryUrlWithVersionPath === false) { return false; } if ($this->processExecutor->isDirectory($this->repositoryDirectory) && $this->processExecutor->execute('svn info --non-interactive', $this->repositoryDirectory)->isSuccessful()) { $checkoutSuccesful = $this->processExecutor->execute(sprintf('svn switch --non-interactive %s', $escapedRepositoryUrlWithVersionPath), $this->repositoryDirectory)->isSuccessful(); } else { $escapedRepositoryDirectory = ProcessUtils::escapeArgument($this->repositoryDirectory); $checkoutSuccesful = $this->processExecutor->execute(sprintf('svn checkout --non-interactive %s %s', $escapedRepositoryUrlWithVersionPath, $escapedRepositoryDirectory))->isSuccessful(); } return $checkoutSuccesful; }
php
public function checkout($version) { $checkoutSuccesful = false; $escapedRepositoryUrlWithVersionPath = $this->getRepositoryUrlWithVersionPath($version); if ($escapedRepositoryUrlWithVersionPath === false) { return false; } if ($this->processExecutor->isDirectory($this->repositoryDirectory) && $this->processExecutor->execute('svn info --non-interactive', $this->repositoryDirectory)->isSuccessful()) { $checkoutSuccesful = $this->processExecutor->execute(sprintf('svn switch --non-interactive %s', $escapedRepositoryUrlWithVersionPath), $this->repositoryDirectory)->isSuccessful(); } else { $escapedRepositoryDirectory = ProcessUtils::escapeArgument($this->repositoryDirectory); $checkoutSuccesful = $this->processExecutor->execute(sprintf('svn checkout --non-interactive %s %s', $escapedRepositoryUrlWithVersionPath, $escapedRepositoryDirectory))->isSuccessful(); } return $checkoutSuccesful; }
[ "public", "function", "checkout", "(", "$", "version", ")", "{", "$", "checkoutSuccesful", "=", "false", ";", "$", "escapedRepositoryUrlWithVersionPath", "=", "$", "this", "->", "getRepositoryUrlWithVersionPath", "(", "$", "version", ")", ";", "if", "(", "$", "escapedRepositoryUrlWithVersionPath", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "processExecutor", "->", "isDirectory", "(", "$", "this", "->", "repositoryDirectory", ")", "&&", "$", "this", "->", "processExecutor", "->", "execute", "(", "'svn info --non-interactive'", ",", "$", "this", "->", "repositoryDirectory", ")", "->", "isSuccessful", "(", ")", ")", "{", "$", "checkoutSuccesful", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "sprintf", "(", "'svn switch --non-interactive %s'", ",", "$", "escapedRepositoryUrlWithVersionPath", ")", ",", "$", "this", "->", "repositoryDirectory", ")", "->", "isSuccessful", "(", ")", ";", "}", "else", "{", "$", "escapedRepositoryDirectory", "=", "ProcessUtils", "::", "escapeArgument", "(", "$", "this", "->", "repositoryDirectory", ")", ";", "$", "checkoutSuccesful", "=", "$", "this", "->", "processExecutor", "->", "execute", "(", "sprintf", "(", "'svn checkout --non-interactive %s %s'", ",", "$", "escapedRepositoryUrlWithVersionPath", ",", "$", "escapedRepositoryDirectory", ")", ")", "->", "isSuccessful", "(", ")", ";", "}", "return", "$", "checkoutSuccesful", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/SubversionAdapter.php#L117-L135
accompli/chrono
src/Adapter/SubversionAdapter.php
SubversionAdapter.getRepositoryUrlWithVersionPath
private function getRepositoryUrlWithVersionPath($version) { $repositoryUrl = $this->repositoryUrl; if (in_array($version, array('master', $this->trunkPath))) { $repositoryUrl .= '/'.$this->trunkPath; } elseif (in_array($version, $this->getBranches())) { $repositoryUrl .= '/'.$this->branchesPath.'/'.$version; } elseif (in_array($version, $this->getTags())) { $repositoryUrl .= '/'.$this->tagsPath.'/'.$version; } else { return false; } return ProcessUtils::escapeArgument($repositoryUrl); }
php
private function getRepositoryUrlWithVersionPath($version) { $repositoryUrl = $this->repositoryUrl; if (in_array($version, array('master', $this->trunkPath))) { $repositoryUrl .= '/'.$this->trunkPath; } elseif (in_array($version, $this->getBranches())) { $repositoryUrl .= '/'.$this->branchesPath.'/'.$version; } elseif (in_array($version, $this->getTags())) { $repositoryUrl .= '/'.$this->tagsPath.'/'.$version; } else { return false; } return ProcessUtils::escapeArgument($repositoryUrl); }
[ "private", "function", "getRepositoryUrlWithVersionPath", "(", "$", "version", ")", "{", "$", "repositoryUrl", "=", "$", "this", "->", "repositoryUrl", ";", "if", "(", "in_array", "(", "$", "version", ",", "array", "(", "'master'", ",", "$", "this", "->", "trunkPath", ")", ")", ")", "{", "$", "repositoryUrl", ".=", "'/'", ".", "$", "this", "->", "trunkPath", ";", "}", "elseif", "(", "in_array", "(", "$", "version", ",", "$", "this", "->", "getBranches", "(", ")", ")", ")", "{", "$", "repositoryUrl", ".=", "'/'", ".", "$", "this", "->", "branchesPath", ".", "'/'", ".", "$", "version", ";", "}", "elseif", "(", "in_array", "(", "$", "version", ",", "$", "this", "->", "getTags", "(", ")", ")", ")", "{", "$", "repositoryUrl", ".=", "'/'", ".", "$", "this", "->", "tagsPath", ".", "'/'", ".", "$", "version", ";", "}", "else", "{", "return", "false", ";", "}", "return", "ProcessUtils", "::", "escapeArgument", "(", "$", "repositoryUrl", ")", ";", "}" ]
Returns the escaped repository URL with version path. Returns false when the repository URL for a version cannot be found. @param string $version @return string|bool
[ "Returns", "the", "escaped", "repository", "URL", "with", "version", "path", ".", "Returns", "false", "when", "the", "repository", "URL", "for", "a", "version", "cannot", "be", "found", "." ]
train
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/SubversionAdapter.php#L145-L159
mothership-ec/composer
src/Composer/Package/Archiver/PharArchiver.php
PharArchiver.archive
public function archive($sources, $target, $format, array $excludes = array()) { $sources = realpath($sources); // Phar would otherwise load the file which we don't want if (file_exists($target)) { unlink($target); } try { $phar = new \PharData($target, null, null, static::$formats[$format]); $files = new ArchivableFilesFinder($sources, $excludes); $phar->buildFromIterator($files, $sources); return $target; } catch (\UnexpectedValueException $e) { $message = sprintf("Could not create archive '%s' from '%s': %s", $target, $sources, $e->getMessage() ); throw new \RuntimeException($message, $e->getCode(), $e); } }
php
public function archive($sources, $target, $format, array $excludes = array()) { $sources = realpath($sources); // Phar would otherwise load the file which we don't want if (file_exists($target)) { unlink($target); } try { $phar = new \PharData($target, null, null, static::$formats[$format]); $files = new ArchivableFilesFinder($sources, $excludes); $phar->buildFromIterator($files, $sources); return $target; } catch (\UnexpectedValueException $e) { $message = sprintf("Could not create archive '%s' from '%s': %s", $target, $sources, $e->getMessage() ); throw new \RuntimeException($message, $e->getCode(), $e); } }
[ "public", "function", "archive", "(", "$", "sources", ",", "$", "target", ",", "$", "format", ",", "array", "$", "excludes", "=", "array", "(", ")", ")", "{", "$", "sources", "=", "realpath", "(", "$", "sources", ")", ";", "// Phar would otherwise load the file which we don't want", "if", "(", "file_exists", "(", "$", "target", ")", ")", "{", "unlink", "(", "$", "target", ")", ";", "}", "try", "{", "$", "phar", "=", "new", "\\", "PharData", "(", "$", "target", ",", "null", ",", "null", ",", "static", "::", "$", "formats", "[", "$", "format", "]", ")", ";", "$", "files", "=", "new", "ArchivableFilesFinder", "(", "$", "sources", ",", "$", "excludes", ")", ";", "$", "phar", "->", "buildFromIterator", "(", "$", "files", ",", "$", "sources", ")", ";", "return", "$", "target", ";", "}", "catch", "(", "\\", "UnexpectedValueException", "$", "e", ")", "{", "$", "message", "=", "sprintf", "(", "\"Could not create archive '%s' from '%s': %s\"", ",", "$", "target", ",", "$", "sources", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "message", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Archiver/PharArchiver.php#L30-L54
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Commands/Version.php
VersionCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->setupEnvironment('site', $input, $output); $version = new \JVersion; if ($input->getOption('short')) { $result = $version->getShortVersion(); } elseif ($input->getOption('release')) { $result = $version->RELEASE; } else { $result = $version->getLongVersion(); } $output->writeln($result); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->setupEnvironment('site', $input, $output); $version = new \JVersion; if ($input->getOption('short')) { $result = $version->getShortVersion(); } elseif ($input->getOption('release')) { $result = $version->RELEASE; } else { $result = $version->getLongVersion(); } $output->writeln($result); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "setupEnvironment", "(", "'site'", ",", "$", "input", ",", "$", "output", ")", ";", "$", "version", "=", "new", "\\", "JVersion", ";", "if", "(", "$", "input", "->", "getOption", "(", "'short'", ")", ")", "{", "$", "result", "=", "$", "version", "->", "getShortVersion", "(", ")", ";", "}", "elseif", "(", "$", "input", "->", "getOption", "(", "'release'", ")", ")", "{", "$", "result", "=", "$", "version", "->", "RELEASE", ";", "}", "else", "{", "$", "result", "=", "$", "version", "->", "getLongVersion", "(", ")", ";", "}", "$", "output", "->", "writeln", "(", "$", "result", ")", ";", "}" ]
Execute the version command @param InputInterface $input An InputInterface instance @param OutputInterface $output An OutputInterface instance @return void
[ "Execute", "the", "version", "command" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Version.php#L90-L109
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.add_attachment
public function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = "base64", $charset='', $contentid='') { $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, "charset" => $charset, "contentid" => $contentid ); }
php
public function add_attachment($message, $name = "", $ctype = "application/octet-stream", $encode = "base64", $charset='', $contentid='') { $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, "charset" => $charset, "contentid" => $contentid ); }
[ "public", "function", "add_attachment", "(", "$", "message", ",", "$", "name", "=", "\"\"", ",", "$", "ctype", "=", "\"application/octet-stream\"", ",", "$", "encode", "=", "\"base64\"", ",", "$", "charset", "=", "''", ",", "$", "contentid", "=", "''", ")", "{", "$", "this", "->", "parts", "[", "]", "=", "array", "(", "\"ctype\"", "=>", "$", "ctype", ",", "\"message\"", "=>", "$", "message", ",", "\"encode\"", "=>", "$", "encode", ",", "\"name\"", "=>", "$", "name", ",", "\"charset\"", "=>", "$", "charset", ",", "\"contentid\"", "=>", "$", "contentid", ")", ";", "}" ]
void add_attachment(string message, [string name], [string ctype], [string encode], [string charset], [string content-id]) Add an attachment to the mail object NOTE: be sure to encode all content types other than base64 and quoted printable yourself
[ "void", "add_attachment", "(", "string", "message", "[", "string", "name", "]", "[", "string", "ctype", "]", "[", "string", "encode", "]", "[", "string", "charset", "]", "[", "string", "content", "-", "id", "]", ")", "Add", "an", "attachment", "to", "the", "mail", "object" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L114-L122
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.add_alternative_part
public function add_alternative_part($message, $name = "", $ctype = "plain/text", $encode = "8bit", $charset='', $contentid='') { $this->altparts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, "charset" => $charset, "contentid" => $contentid ); }
php
public function add_alternative_part($message, $name = "", $ctype = "plain/text", $encode = "8bit", $charset='', $contentid='') { $this->altparts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, "charset" => $charset, "contentid" => $contentid ); }
[ "public", "function", "add_alternative_part", "(", "$", "message", ",", "$", "name", "=", "\"\"", ",", "$", "ctype", "=", "\"plain/text\"", ",", "$", "encode", "=", "\"8bit\"", ",", "$", "charset", "=", "''", ",", "$", "contentid", "=", "''", ")", "{", "$", "this", "->", "altparts", "[", "]", "=", "array", "(", "\"ctype\"", "=>", "$", "ctype", ",", "\"message\"", "=>", "$", "message", ",", "\"encode\"", "=>", "$", "encode", ",", "\"name\"", "=>", "$", "name", ",", "\"charset\"", "=>", "$", "charset", ",", "\"contentid\"", "=>", "$", "contentid", ")", ";", "}" ]
void add_alternative_part(string message, [string name], [string ctype], [string encode], [string charset], [string content-id]) Add an alternative part to the mail object NOTE: be sure to encode all content types other than base64 and quoted-printable yourself
[ "void", "add_alternative_part", "(", "string", "message", "[", "string", "name", "]", "[", "string", "ctype", "]", "[", "string", "encode", "]", "[", "string", "charset", "]", "[", "string", "content", "-", "id", "]", ")", "Add", "an", "alternative", "part", "to", "the", "mail", "object" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L131-L140
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.build_message
private function build_message($part) { $message = $part[ "message"]; // #### only base64 encoding supported // #### other encodings you have to encode yourself if ($part[ "encode"] == "base64"){ $message = chunk_split(base64_encode($message)); }else if ($part[ "encode"] == "quoted-printable"){ $message = $this->encode_qp($message); } return "Content-Type: ".$part[ "ctype"]. ($part[ "charset"]? "; charset = \"".$part[ "charset"]. "\"" : ""). ($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : ""). (empty($part[ "encode"])? "" : "\nContent-Transfer-Encoding: ".$part[ "encode"] ). (empty($part[ "contentid"])? "" : "\nContent-ID: ".$part[ "contentid"] ). ((empty($part["contentid"])&&($part["name"]))? "\nContent-Disposition: attachment; filename=\"".$part["name"].'"' : '' ). "\n\n$message\n"; }
php
private function build_message($part) { $message = $part[ "message"]; // #### only base64 encoding supported // #### other encodings you have to encode yourself if ($part[ "encode"] == "base64"){ $message = chunk_split(base64_encode($message)); }else if ($part[ "encode"] == "quoted-printable"){ $message = $this->encode_qp($message); } return "Content-Type: ".$part[ "ctype"]. ($part[ "charset"]? "; charset = \"".$part[ "charset"]. "\"" : ""). ($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : ""). (empty($part[ "encode"])? "" : "\nContent-Transfer-Encoding: ".$part[ "encode"] ). (empty($part[ "contentid"])? "" : "\nContent-ID: ".$part[ "contentid"] ). ((empty($part["contentid"])&&($part["name"]))? "\nContent-Disposition: attachment; filename=\"".$part["name"].'"' : '' ). "\n\n$message\n"; }
[ "private", "function", "build_message", "(", "$", "part", ")", "{", "$", "message", "=", "$", "part", "[", "\"message\"", "]", ";", "// #### only base64 encoding supported", "// #### other encodings you have to encode yourself", "if", "(", "$", "part", "[", "\"encode\"", "]", "==", "\"base64\"", ")", "{", "$", "message", "=", "chunk_split", "(", "base64_encode", "(", "$", "message", ")", ")", ";", "}", "else", "if", "(", "$", "part", "[", "\"encode\"", "]", "==", "\"quoted-printable\"", ")", "{", "$", "message", "=", "$", "this", "->", "encode_qp", "(", "$", "message", ")", ";", "}", "return", "\"Content-Type: \"", ".", "$", "part", "[", "\"ctype\"", "]", ".", "(", "$", "part", "[", "\"charset\"", "]", "?", "\"; charset = \\\"\"", ".", "$", "part", "[", "\"charset\"", "]", ".", "\"\\\"\"", ":", "\"\"", ")", ".", "(", "$", "part", "[", "\"name\"", "]", "?", "\"; name = \\\"\"", ".", "$", "part", "[", "\"name\"", "]", ".", "\"\\\"\"", ":", "\"\"", ")", ".", "(", "empty", "(", "$", "part", "[", "\"encode\"", "]", ")", "?", "\"\"", ":", "\"\\nContent-Transfer-Encoding: \"", ".", "$", "part", "[", "\"encode\"", "]", ")", ".", "(", "empty", "(", "$", "part", "[", "\"contentid\"", "]", ")", "?", "\"\"", ":", "\"\\nContent-ID: \"", ".", "$", "part", "[", "\"contentid\"", "]", ")", ".", "(", "(", "empty", "(", "$", "part", "[", "\"contentid\"", "]", ")", "&&", "(", "$", "part", "[", "\"name\"", "]", ")", ")", "?", "\"\\nContent-Disposition: attachment; filename=\\\"\"", ".", "$", "part", "[", "\"name\"", "]", ".", "'\"'", ":", "''", ")", ".", "\"\\n\\n$message\\n\"", ";", "}" ]
void build_message(array part= Build message parts of an multipart mail NOTE: base64 encoding messages will be encoded automaticly my the class. all others will not.
[ "void", "build_message", "(", "array", "part", "=", "Build", "message", "parts", "of", "an", "multipart", "mail" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L149-L165
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.build_multipart
private function build_multipart() { $boundary = "b".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n"; if(count($this->altparts)>0){ $multipart .= "\n--$boundary\n".$this->build_alternative_multipart(); } for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n--$boundary\n".$this->build_message($this->parts[$i]); } return $multipart.= "\n--"."$boundary"."--"; }
php
private function build_multipart() { $boundary = "b".md5(uniqid(time())); $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n"; if(count($this->altparts)>0){ $multipart .= "\n--$boundary\n".$this->build_alternative_multipart(); } for($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n--$boundary\n".$this->build_message($this->parts[$i]); } return $multipart.= "\n--"."$boundary"."--"; }
[ "private", "function", "build_multipart", "(", ")", "{", "$", "boundary", "=", "\"b\"", ".", "md5", "(", "uniqid", "(", "time", "(", ")", ")", ")", ";", "$", "multipart", "=", "\"Content-Type: multipart/mixed; boundary = $boundary\\n\\nThis is a MIME encoded message.\\n\"", ";", "if", "(", "count", "(", "$", "this", "->", "altparts", ")", ">", "0", ")", "{", "$", "multipart", ".=", "\"\\n--$boundary\\n\"", ".", "$", "this", "->", "build_alternative_multipart", "(", ")", ";", "}", "for", "(", "$", "i", "=", "sizeof", "(", "$", "this", "->", "parts", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "multipart", ".=", "\"\\n--$boundary\\n\"", ".", "$", "this", "->", "build_message", "(", "$", "this", "->", "parts", "[", "$", "i", "]", ")", ";", "}", "return", "$", "multipart", ".=", "\"\\n--\"", ".", "\"$boundary\"", ".", "\"--\"", ";", "}" ]
string build_multipart() Build a multipart mail
[ "string", "build_multipart", "()", "Build", "a", "multipart", "mail" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L171-L185
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.build_alternative_multipart
private function build_alternative_multipart() { $boundary = "ba".md5(uniqid(time())); $multipart = "Content-Type: multipart/alternative; boundary = $boundary\n\n"; for($i = sizeof($this->altparts)-1; $i >= 0; $i--) { $multipart .= "\n--$boundary\n".$this->build_message($this->altparts[$i]); } return $multipart.= "\n--"."$boundary"."--\n"; }
php
private function build_alternative_multipart() { $boundary = "ba".md5(uniqid(time())); $multipart = "Content-Type: multipart/alternative; boundary = $boundary\n\n"; for($i = sizeof($this->altparts)-1; $i >= 0; $i--) { $multipart .= "\n--$boundary\n".$this->build_message($this->altparts[$i]); } return $multipart.= "\n--"."$boundary"."--\n"; }
[ "private", "function", "build_alternative_multipart", "(", ")", "{", "$", "boundary", "=", "\"ba\"", ".", "md5", "(", "uniqid", "(", "time", "(", ")", ")", ")", ";", "$", "multipart", "=", "\"Content-Type: multipart/alternative; boundary = $boundary\\n\\n\"", ";", "for", "(", "$", "i", "=", "sizeof", "(", "$", "this", "->", "altparts", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "multipart", ".=", "\"\\n--$boundary\\n\"", ".", "$", "this", "->", "build_message", "(", "$", "this", "->", "altparts", "[", "$", "i", "]", ")", ";", "}", "return", "$", "multipart", ".=", "\"\\n--\"", ".", "\"$boundary\"", ".", "\"--\\n\"", ";", "}" ]
string build_alternative_multipart() Build a build_alternative_multipart mail
[ "string", "build_alternative_multipart", "()", "Build", "a", "build_alternative_multipart", "mail" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L191-L201
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.buildRawMime
public function buildRawMime($addAllHeaders=true) { $mime = ""; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n"; if (!empty($this->headers)) $mime .= $this->headers. "\n"; if($addAllHeaders){ // add all headers, even the ones automatically added by the php mail function $mime .= "To: ".$this->to. "\n"; $subject = $this->subject; if ($this->subject_charset) { $subject=$this->encodeSubject($subject,$this->subject_charset); } $mime .= "Subject: ".$subject. "\n"; } if (!empty($this->body)){ $this->add_attachment($this->body, "", "text/plain"); } // lets build the simpliest message possible if (count($this->parts)==1 && count($this->altparts)==0) { // single part mail $mime .= $this->build_message($this->parts[0]); }elseif (count($this->parts)==0 && count($this->altparts)==1) { // single part mail $mime .= $this->build_message($this->altparts[0]); }elseif (count($this->parts)==0 && count($this->altparts)>0) { // multi part alternative mail (without attachments) $mime .= "MIME-Version: 1.0\n".$this->build_alternative_multipart(); }else{ // its a multipart mail with attachments $mime .= "MIME-Version: 1.0\n".$this->build_multipart(); } return $mime; }
php
public function buildRawMime($addAllHeaders=true) { $mime = ""; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n"; if (!empty($this->headers)) $mime .= $this->headers. "\n"; if($addAllHeaders){ // add all headers, even the ones automatically added by the php mail function $mime .= "To: ".$this->to. "\n"; $subject = $this->subject; if ($this->subject_charset) { $subject=$this->encodeSubject($subject,$this->subject_charset); } $mime .= "Subject: ".$subject. "\n"; } if (!empty($this->body)){ $this->add_attachment($this->body, "", "text/plain"); } // lets build the simpliest message possible if (count($this->parts)==1 && count($this->altparts)==0) { // single part mail $mime .= $this->build_message($this->parts[0]); }elseif (count($this->parts)==0 && count($this->altparts)==1) { // single part mail $mime .= $this->build_message($this->altparts[0]); }elseif (count($this->parts)==0 && count($this->altparts)>0) { // multi part alternative mail (without attachments) $mime .= "MIME-Version: 1.0\n".$this->build_alternative_multipart(); }else{ // its a multipart mail with attachments $mime .= "MIME-Version: 1.0\n".$this->build_multipart(); } return $mime; }
[ "public", "function", "buildRawMime", "(", "$", "addAllHeaders", "=", "true", ")", "{", "$", "mime", "=", "\"\"", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "from", ")", ")", "$", "mime", ".=", "\"From: \"", ".", "$", "this", "->", "from", ".", "\"\\n\"", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "headers", ")", ")", "$", "mime", ".=", "$", "this", "->", "headers", ".", "\"\\n\"", ";", "if", "(", "$", "addAllHeaders", ")", "{", "// add all headers, even the ones automatically added by the php mail function", "$", "mime", ".=", "\"To: \"", ".", "$", "this", "->", "to", ".", "\"\\n\"", ";", "$", "subject", "=", "$", "this", "->", "subject", ";", "if", "(", "$", "this", "->", "subject_charset", ")", "{", "$", "subject", "=", "$", "this", "->", "encodeSubject", "(", "$", "subject", ",", "$", "this", "->", "subject_charset", ")", ";", "}", "$", "mime", ".=", "\"Subject: \"", ".", "$", "subject", ".", "\"\\n\"", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "body", ")", ")", "{", "$", "this", "->", "add_attachment", "(", "$", "this", "->", "body", ",", "\"\"", ",", "\"text/plain\"", ")", ";", "}", "// lets build the simpliest message possible", "if", "(", "count", "(", "$", "this", "->", "parts", ")", "==", "1", "&&", "count", "(", "$", "this", "->", "altparts", ")", "==", "0", ")", "{", "// single part mail", "$", "mime", ".=", "$", "this", "->", "build_message", "(", "$", "this", "->", "parts", "[", "0", "]", ")", ";", "}", "elseif", "(", "count", "(", "$", "this", "->", "parts", ")", "==", "0", "&&", "count", "(", "$", "this", "->", "altparts", ")", "==", "1", ")", "{", "// single part mail", "$", "mime", ".=", "$", "this", "->", "build_message", "(", "$", "this", "->", "altparts", "[", "0", "]", ")", ";", "}", "elseif", "(", "count", "(", "$", "this", "->", "parts", ")", "==", "0", "&&", "count", "(", "$", "this", "->", "altparts", ")", ">", "0", ")", "{", "// multi part alternative mail (without attachments)", "$", "mime", ".=", "\"MIME-Version: 1.0\\n\"", ".", "$", "this", "->", "build_alternative_multipart", "(", ")", ";", "}", "else", "{", "// its a multipart mail with attachments", "$", "mime", ".=", "\"MIME-Version: 1.0\\n\"", ".", "$", "this", "->", "build_multipart", "(", ")", ";", "}", "return", "$", "mime", ";", "}" ]
buildRawMime() This method is used by send(), but can also be called directly if you want to send email by other means and need the raw mime message as a string. @param boolean $addAllHeaders @return string the raw mime mail
[ "buildRawMime", "()" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L213-L247
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.send
public function send() { $mime=$this->buildRawMime(false); // possibly convert the subject $subject = $this->subject; if ($this->subject_charset) { $subject=$this->encodeSubject($subject,$this->subject_charset); } // workaround on fix for PHP bug #68776 // we have to split the headers from the body list($header_str, $body_str) = explode("\n\n",$mime,2); if (!empty($this->from)) { $extra_param = "-f". self::extractMailAddress($this->from); return mail($this->to, $subject, $body_str, $header_str, $extra_param); } else { return mail($this->to, $subject, $body_str, $header_str); } }
php
public function send() { $mime=$this->buildRawMime(false); // possibly convert the subject $subject = $this->subject; if ($this->subject_charset) { $subject=$this->encodeSubject($subject,$this->subject_charset); } // workaround on fix for PHP bug #68776 // we have to split the headers from the body list($header_str, $body_str) = explode("\n\n",$mime,2); if (!empty($this->from)) { $extra_param = "-f". self::extractMailAddress($this->from); return mail($this->to, $subject, $body_str, $header_str, $extra_param); } else { return mail($this->to, $subject, $body_str, $header_str); } }
[ "public", "function", "send", "(", ")", "{", "$", "mime", "=", "$", "this", "->", "buildRawMime", "(", "false", ")", ";", "// possibly convert the subject", "$", "subject", "=", "$", "this", "->", "subject", ";", "if", "(", "$", "this", "->", "subject_charset", ")", "{", "$", "subject", "=", "$", "this", "->", "encodeSubject", "(", "$", "subject", ",", "$", "this", "->", "subject_charset", ")", ";", "}", "// workaround on fix for PHP bug #68776", "// we have to split the headers from the body", "list", "(", "$", "header_str", ",", "$", "body_str", ")", "=", "explode", "(", "\"\\n\\n\"", ",", "$", "mime", ",", "2", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "from", ")", ")", "{", "$", "extra_param", "=", "\"-f\"", ".", "self", "::", "extractMailAddress", "(", "$", "this", "->", "from", ")", ";", "return", "mail", "(", "$", "this", "->", "to", ",", "$", "subject", ",", "$", "body_str", ",", "$", "header_str", ",", "$", "extra_param", ")", ";", "}", "else", "{", "return", "mail", "(", "$", "this", "->", "to", ",", "$", "subject", ",", "$", "body_str", ",", "$", "header_str", ")", ";", "}", "}" ]
void send() Send the mail (last class-function to be called) NOTE: if ->body is set it will be base64 encoded do not use body in combination with other parts its just a lazy shortcut for simple mails
[ "void", "send", "()", "Send", "the", "mail", "(", "last", "class", "-", "function", "to", "be", "called", ")" ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L257-L276
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.fix_eol
private function fix_eol($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); if($this->LE != "\n"){ $str = str_replace("\n", $this->LE, $str); } return $str; }
php
private function fix_eol($str) { $str = str_replace("\r\n", "\n", $str); $str = str_replace("\r", "\n", $str); if($this->LE != "\n"){ $str = str_replace("\n", $this->LE, $str); } return $str; }
[ "private", "function", "fix_eol", "(", "$", "str", ")", "{", "$", "str", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "str", ")", ";", "$", "str", "=", "str_replace", "(", "\"\\r\"", ",", "\"\\n\"", ",", "$", "str", ")", ";", "if", "(", "$", "this", "->", "LE", "!=", "\"\\n\"", ")", "{", "$", "str", "=", "str_replace", "(", "\"\\n\"", ",", "$", "this", "->", "LE", ",", "$", "str", ")", ";", "}", "return", "$", "str", ";", "}" ]
Changes every end of line from CR or LF to $this->LE. Returns string. @private @returns string
[ "Changes", "every", "end", "of", "line", "from", "CR", "or", "LF", "to", "$this", "-", ">", "LE", ".", "Returns", "string", "." ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L303-L310
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.encode_qp
public function encode_qp ($str) { $encoded = $this->fix_eol($str); if (substr($encoded, -2) != $this->LE) $encoded .= $this->LE; // Replace every high ascii, control and = characters $encoded = preg_replace_callback("/([\001-\010\013\014\016-\037\075\177-\377])/", array($this,'qp_replace_high_ascii'), $encoded); // Replace every spaces and tabs when it's the last character on a line $encoded = preg_replace_callback("/([\011\040])".$this->LE."/", array($this,'qp_replace_end_whitespace'), $encoded); // Maximum line length of 76 characters before CRLF (74 + space + '=') $encoded = $this->word_wrap($encoded, 74, true); return $encoded; }
php
public function encode_qp ($str) { $encoded = $this->fix_eol($str); if (substr($encoded, -2) != $this->LE) $encoded .= $this->LE; // Replace every high ascii, control and = characters $encoded = preg_replace_callback("/([\001-\010\013\014\016-\037\075\177-\377])/", array($this,'qp_replace_high_ascii'), $encoded); // Replace every spaces and tabs when it's the last character on a line $encoded = preg_replace_callback("/([\011\040])".$this->LE."/", array($this,'qp_replace_end_whitespace'), $encoded); // Maximum line length of 76 characters before CRLF (74 + space + '=') $encoded = $this->word_wrap($encoded, 74, true); return $encoded; }
[ "public", "function", "encode_qp", "(", "$", "str", ")", "{", "$", "encoded", "=", "$", "this", "->", "fix_eol", "(", "$", "str", ")", ";", "if", "(", "substr", "(", "$", "encoded", ",", "-", "2", ")", "!=", "$", "this", "->", "LE", ")", "$", "encoded", ".=", "$", "this", "->", "LE", ";", "// Replace every high ascii, control and = characters", "$", "encoded", "=", "preg_replace_callback", "(", "\"/([\\001-\\010\\013\\014\\016-\\037\\075\\177-\\377])/\"", ",", "array", "(", "$", "this", ",", "'qp_replace_high_ascii'", ")", ",", "$", "encoded", ")", ";", "// Replace every spaces and tabs when it's the last character on a line", "$", "encoded", "=", "preg_replace_callback", "(", "\"/([\\011\\040])\"", ".", "$", "this", "->", "LE", ".", "\"/\"", ",", "array", "(", "$", "this", ",", "'qp_replace_end_whitespace'", ")", ",", "$", "encoded", ")", ";", "// Maximum line length of 76 characters before CRLF (74 + space + '=')", "$", "encoded", "=", "$", "this", "->", "word_wrap", "(", "$", "encoded", ",", "74", ",", "true", ")", ";", "return", "$", "encoded", ";", "}" ]
Encode string to quoted-printable. Returns a string. @returns string
[ "Encode", "string", "to", "quoted", "-", "printable", ".", "Returns", "a", "string", "." ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L341-L357
web2all/framework
src/Web2All/Email/MimeMail.class.php
Web2All_Email_MimeMail.encodeSubject
function encodeSubject($input, $charset = 'ISO-8859-1') { // set the internal encoding to the encoding of the given input // this way no conversion is done, because we only need the 'Q' encoding $old_enc=mb_internal_encoding(); mb_internal_encoding($charset); $output=mb_encode_mimeheader($input,$charset, 'Q', $this->LE); // and when ready, restore the internal encoding again mb_internal_encoding($old_enc); return $output; // below is a fallback mechanism which seems to work also /* preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches); foreach ($matches[1] as $value) { $replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" . strtoupper(dechex(ord("\\1")))', $value); $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); } return $input; */ }
php
function encodeSubject($input, $charset = 'ISO-8859-1') { // set the internal encoding to the encoding of the given input // this way no conversion is done, because we only need the 'Q' encoding $old_enc=mb_internal_encoding(); mb_internal_encoding($charset); $output=mb_encode_mimeheader($input,$charset, 'Q', $this->LE); // and when ready, restore the internal encoding again mb_internal_encoding($old_enc); return $output; // below is a fallback mechanism which seems to work also /* preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches); foreach ($matches[1] as $value) { $replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" . strtoupper(dechex(ord("\\1")))', $value); $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); } return $input; */ }
[ "function", "encodeSubject", "(", "$", "input", ",", "$", "charset", "=", "'ISO-8859-1'", ")", "{", "// set the internal encoding to the encoding of the given input", "// this way no conversion is done, because we only need the 'Q' encoding", "$", "old_enc", "=", "mb_internal_encoding", "(", ")", ";", "mb_internal_encoding", "(", "$", "charset", ")", ";", "$", "output", "=", "mb_encode_mimeheader", "(", "$", "input", ",", "$", "charset", ",", "'Q'", ",", "$", "this", "->", "LE", ")", ";", "// and when ready, restore the internal encoding again", "mb_internal_encoding", "(", "$", "old_enc", ")", ";", "return", "$", "output", ";", "// below is a fallback mechanism which seems to work also", "/*\n preg_match_all('/(\\\\w*[\\\\x80-\\\\xFF]+\\\\w*)/', $input, $matches);\n foreach ($matches[1] as $value) {\n $replacement = preg_replace('/([\\\\x80-\\\\xFF])/e', '\"=\" . strtoupper(dechex(ord(\"\\\\1\")))', $value);\n $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);\n }\n return $input;\n */", "}" ]
The method can be used to encode the subject which is in a non ascii encoding. encoding style: =?charset?Q?the encoded text?= @param string $input @param string $charset eg. UTF-8 or ISO-8859-1 @return string the encoded subject
[ "The", "method", "can", "be", "used", "to", "encode", "the", "subject", "which", "is", "in", "a", "non", "ascii", "encoding", "." ]
train
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L455-L474
42mate/towel
src/Towel/Cache/TowelMemcached.php
TowelMemcached.setOptions
public function setOptions($options) { // Adding hosts. if (!empty($options['hosts'])) { foreach ($options['hosts'] as $host => $port) { $this->addserver($host, $port, false); } } else { $this->addserver('127.0.0.1', '11211', false); } }
php
public function setOptions($options) { // Adding hosts. if (!empty($options['hosts'])) { foreach ($options['hosts'] as $host => $port) { $this->addserver($host, $port, false); } } else { $this->addserver('127.0.0.1', '11211', false); } }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "// Adding hosts.", "if", "(", "!", "empty", "(", "$", "options", "[", "'hosts'", "]", ")", ")", "{", "foreach", "(", "$", "options", "[", "'hosts'", "]", "as", "$", "host", "=>", "$", "port", ")", "{", "$", "this", "->", "addserver", "(", "$", "host", ",", "$", "port", ",", "false", ")", ";", "}", "}", "else", "{", "$", "this", "->", "addserver", "(", "'127.0.0.1'", ",", "'11211'", ",", "false", ")", ";", "}", "}" ]
Stablish Memcached options defined in config.php @param $options
[ "Stablish", "Memcached", "options", "defined", "in", "config", ".", "php" ]
train
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Cache/TowelMemcached.php#L11-L21
Innmind/neo4j-dbal
src/Query/Query.php
Query.cypher
public function cypher(): string { if ($this->cypher) { return $this->cypher; } $previous = $this->clauses->first(); $clauses = $this->clauses->drop(1); $cypher = $previous->identifier().' '.(string) $previous; foreach ($clauses as $clause) { if ($clause->identifier() === $previous->identifier()) { $cypher .= ', '; } else { $cypher .= ' '.$clause->identifier().' '; } $cypher .= (string) $clause; $previous = $clause; } $this->cypher = $cypher; return $cypher; }
php
public function cypher(): string { if ($this->cypher) { return $this->cypher; } $previous = $this->clauses->first(); $clauses = $this->clauses->drop(1); $cypher = $previous->identifier().' '.(string) $previous; foreach ($clauses as $clause) { if ($clause->identifier() === $previous->identifier()) { $cypher .= ', '; } else { $cypher .= ' '.$clause->identifier().' '; } $cypher .= (string) $clause; $previous = $clause; } $this->cypher = $cypher; return $cypher; }
[ "public", "function", "cypher", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "cypher", ")", "{", "return", "$", "this", "->", "cypher", ";", "}", "$", "previous", "=", "$", "this", "->", "clauses", "->", "first", "(", ")", ";", "$", "clauses", "=", "$", "this", "->", "clauses", "->", "drop", "(", "1", ")", ";", "$", "cypher", "=", "$", "previous", "->", "identifier", "(", ")", ".", "' '", ".", "(", "string", ")", "$", "previous", ";", "foreach", "(", "$", "clauses", "as", "$", "clause", ")", "{", "if", "(", "$", "clause", "->", "identifier", "(", ")", "===", "$", "previous", "->", "identifier", "(", ")", ")", "{", "$", "cypher", ".=", "', '", ";", "}", "else", "{", "$", "cypher", ".=", "' '", ".", "$", "clause", "->", "identifier", "(", ")", ".", "' '", ";", "}", "$", "cypher", ".=", "(", "string", ")", "$", "clause", ";", "$", "previous", "=", "$", "clause", ";", "}", "$", "this", "->", "cypher", "=", "$", "cypher", ";", "return", "$", "cypher", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L33-L57
Innmind/neo4j-dbal
src/Query/Query.php
Query.parameters
public function parameters(): MapInterface { if ($this->parameters) { return $this->parameters; } return $this->parameters = $this ->clauses ->filter(function(Clause $clause): bool { return $clause instanceof Clause\Parametrable; }) ->reduce( new Map('string', Parameter::class), function(Map $carry, Clause\Parametrable $clause): Map { return $carry->merge($clause->parameters()); } ); }
php
public function parameters(): MapInterface { if ($this->parameters) { return $this->parameters; } return $this->parameters = $this ->clauses ->filter(function(Clause $clause): bool { return $clause instanceof Clause\Parametrable; }) ->reduce( new Map('string', Parameter::class), function(Map $carry, Clause\Parametrable $clause): Map { return $carry->merge($clause->parameters()); } ); }
[ "public", "function", "parameters", "(", ")", ":", "MapInterface", "{", "if", "(", "$", "this", "->", "parameters", ")", "{", "return", "$", "this", "->", "parameters", ";", "}", "return", "$", "this", "->", "parameters", "=", "$", "this", "->", "clauses", "->", "filter", "(", "function", "(", "Clause", "$", "clause", ")", ":", "bool", "{", "return", "$", "clause", "instanceof", "Clause", "\\", "Parametrable", ";", "}", ")", "->", "reduce", "(", "new", "Map", "(", "'string'", ",", "Parameter", "::", "class", ")", ",", "function", "(", "Map", "$", "carry", ",", "Clause", "\\", "Parametrable", "$", "clause", ")", ":", "Map", "{", "return", "$", "carry", "->", "merge", "(", "$", "clause", "->", "parameters", "(", ")", ")", ";", "}", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L70-L87
Innmind/neo4j-dbal
src/Query/Query.php
Query.match
public function match(string $variable = null, array $labels = []): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\MatchClause( Clause\Expression\Path::startWithNode($variable, $labels) ) ); return $query; }
php
public function match(string $variable = null, array $labels = []): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\MatchClause( Clause\Expression\Path::startWithNode($variable, $labels) ) ); return $query; }
[ "public", "function", "match", "(", "string", "$", "variable", "=", "null", ",", "array", "$", "labels", "=", "[", "]", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "MatchClause", "(", "Clause", "\\", "Expression", "\\", "Path", "::", "startWithNode", "(", "$", "variable", ",", "$", "labels", ")", ")", ")", ";", "return", "$", "query", ";", "}" ]
Match the given node @param string $variable @param array $labels @return self
[ "Match", "the", "given", "node" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L105-L115
Innmind/neo4j-dbal
src/Query/Query.php
Query.maybeMatch
public function maybeMatch(string $variable = null, array $labels = []): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\OptionalMatchClause( Clause\Expression\Path::startWithNode($variable, $labels) ) ); return $query; }
php
public function maybeMatch(string $variable = null, array $labels = []): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\OptionalMatchClause( Clause\Expression\Path::startWithNode($variable, $labels) ) ); return $query; }
[ "public", "function", "maybeMatch", "(", "string", "$", "variable", "=", "null", ",", "array", "$", "labels", "=", "[", "]", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "OptionalMatchClause", "(", "Clause", "\\", "Expression", "\\", "Path", "::", "startWithNode", "(", "$", "variable", ",", "$", "labels", ")", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a OPTIONAL MATCh clause @param string $variable @param array $labels @return self
[ "Add", "a", "OPTIONAL", "MATCh", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L125-L135
Innmind/neo4j-dbal
src/Query/Query.php
Query.withParameter
public function withParameter(string $key, $parameter): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\Parametrable) { throw new NonParametrableClause; } $clause = $clause->withParameter($key, $parameter); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function withParameter(string $key, $parameter): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\Parametrable) { throw new NonParametrableClause; } $clause = $clause->withParameter($key, $parameter); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "withParameter", "(", "string", "$", "key", ",", "$", "parameter", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "Parametrable", ")", "{", "throw", "new", "NonParametrableClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "withParameter", "(", "$", "key", ",", "$", "parameter", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Attach the given parameter to the last clause @param string $key @param mixed $parameter @throws NonParametrableClause @return self
[ "Attach", "the", "given", "parameter", "to", "the", "last", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L167-L183
Innmind/neo4j-dbal
src/Query/Query.php
Query.withProperties
public function withProperties(array $properties): self { $query = $this; foreach ($properties as $property => $cypher) { $query = $query->withProperty($property, $cypher); } return $query; }
php
public function withProperties(array $properties): self { $query = $this; foreach ($properties as $property => $cypher) { $query = $query->withProperty($property, $cypher); } return $query; }
[ "public", "function", "withProperties", "(", "array", "$", "properties", ")", ":", "self", "{", "$", "query", "=", "$", "this", ";", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "cypher", ")", "{", "$", "query", "=", "$", "query", "->", "withProperty", "(", "$", "property", ",", "$", "cypher", ")", ";", "}", "return", "$", "query", ";", "}" ]
Specify a set of properties to be matched @param array $properties @throws NonPathAwareClause @return self
[ "Specify", "a", "set", "of", "properties", "to", "be", "matched" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L194-L203
Innmind/neo4j-dbal
src/Query/Query.php
Query.withProperty
public function withProperty(string $property, string $cypher): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withProperty($property, $cypher); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function withProperty(string $property, string $cypher): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withProperty($property, $cypher); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "withProperty", "(", "string", "$", "property", ",", "string", "$", "cypher", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "withProperty", "(", "$", "property", ",", "$", "cypher", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Specify a property to be matched @param string $property @param string $cypher @throws NonPathAwareClause @return self
[ "Specify", "a", "property", "to", "be", "matched" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L215-L231
Innmind/neo4j-dbal
src/Query/Query.php
Query.linkedTo
public function linkedTo(string $variable = null, array $labels = []): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->linkedTo($variable, $labels); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function linkedTo(string $variable = null, array $labels = []): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->linkedTo($variable, $labels); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "linkedTo", "(", "string", "$", "variable", "=", "null", ",", "array", "$", "labels", "=", "[", "]", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "linkedTo", "(", "$", "variable", ",", "$", "labels", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Match the node linked to the previous declared node match @param string $variable @param array $labels @throws NonPathAwareClause @return self
[ "Match", "the", "node", "linked", "to", "the", "previous", "declared", "node", "match" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L243-L259
Innmind/neo4j-dbal
src/Query/Query.php
Query.through
public function through( string $type, string $variable = null, string $direction = 'BOTH' ): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->through($variable, $type, $direction); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function through( string $type, string $variable = null, string $direction = 'BOTH' ): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->through($variable, $type, $direction); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "through", "(", "string", "$", "type", ",", "string", "$", "variable", "=", "null", ",", "string", "$", "direction", "=", "'BOTH'", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "through", "(", "$", "variable", ",", "$", "type", ",", "$", "direction", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Specify the type of relationship for the last match clause @param string $type @param string $variable @param string $direction @throws NonPathAwareClause @return self
[ "Specify", "the", "type", "of", "relationship", "for", "the", "last", "match", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L272-L291
Innmind/neo4j-dbal
src/Query/Query.php
Query.withADistanceOf
public function withADistanceOf(int $distance): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withADistanceOf($distance); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function withADistanceOf(int $distance): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withADistanceOf($distance); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "withADistanceOf", "(", "int", "$", "distance", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "withADistanceOf", "(", "$", "distance", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Define the deepness of the relationship @param int $distance @throws LogicException If no relationship in the path @return self
[ "Define", "the", "deepness", "of", "the", "relationship" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L302-L318
Innmind/neo4j-dbal
src/Query/Query.php
Query.withADistanceBetween
public function withADistanceBetween(int $min, int $max): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withADistanceBetween($min, $max); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function withADistanceBetween(int $min, int $max): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withADistanceBetween($min, $max); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "withADistanceBetween", "(", "int", "$", "min", ",", "int", "$", "max", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "withADistanceBetween", "(", "$", "min", ",", "$", "max", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Define the deepness range of the relationship @param int $min @param int $max @throws LogicException If no relationship in the path @return self
[ "Define", "the", "deepness", "range", "of", "the", "relationship" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L330-L346
Innmind/neo4j-dbal
src/Query/Query.php
Query.withAnyDistance
public function withAnyDistance(): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withAnyDistance(); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
php
public function withAnyDistance(): self { $clause = $this->clauses->last(); if (!$clause instanceof Clause\PathAware) { throw new NonPathAwareClause; } $clause = $clause->withAnyDistance(); $query = new self; $query->clauses = $this ->clauses ->dropEnd(1) ->add($clause); return $query; }
[ "public", "function", "withAnyDistance", "(", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "PathAware", ")", "{", "throw", "new", "NonPathAwareClause", ";", "}", "$", "clause", "=", "$", "clause", "->", "withAnyDistance", "(", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "dropEnd", "(", "1", ")", "->", "add", "(", "$", "clause", ")", ";", "return", "$", "query", ";", "}" ]
Define any deepness of the relationship @param int $distance @throws LogicException If no relationship in the path @return self
[ "Define", "any", "deepness", "of", "the", "relationship" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L411-L427
Innmind/neo4j-dbal
src/Query/Query.php
Query.with
public function with(string ...$variables): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\WithClause(...$variables) ); return $query; }
php
public function with(string ...$variables): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\WithClause(...$variables) ); return $query; }
[ "public", "function", "with", "(", "string", "...", "$", "variables", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "WithClause", "(", "...", "$", "variables", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a WITH clause @param string[] $variables @return self
[ "Add", "a", "WITH", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L436-L444
Innmind/neo4j-dbal
src/Query/Query.php
Query.where
public function where(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\WhereClause($cypher) ); return $query; }
php
public function where(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\WhereClause($cypher) ); return $query; }
[ "public", "function", "where", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "WhereClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a WHERE clause @param string $cypher @return self
[ "Add", "a", "WHERE", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L453-L461
Innmind/neo4j-dbal
src/Query/Query.php
Query.set
public function set(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\SetClause($cypher) ); return $query; }
php
public function set(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\SetClause($cypher) ); return $query; }
[ "public", "function", "set", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "SetClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a SET clause @param string $cypher @return self
[ "Add", "a", "SET", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L470-L478
Innmind/neo4j-dbal
src/Query/Query.php
Query.using
public function using(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UsingClause($cypher) ); return $query; }
php
public function using(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UsingClause($cypher) ); return $query; }
[ "public", "function", "using", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "UsingClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a USING clause @param string $cypher @return self
[ "Add", "a", "USING", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L487-L495
Innmind/neo4j-dbal
src/Query/Query.php
Query.unwind
public function unwind(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UnwindClause($cypher) ); return $query; }
php
public function unwind(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UnwindClause($cypher) ); return $query; }
[ "public", "function", "unwind", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "UnwindClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a UNWIND clause @param string $cypher @return self
[ "Add", "a", "UNWIND", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L504-L512
Innmind/neo4j-dbal
src/Query/Query.php
Query.union
public function union(): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UnionClause ); return $query; }
php
public function union(): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\UnionClause ); return $query; }
[ "public", "function", "union", "(", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "UnionClause", ")", ";", "return", "$", "query", ";", "}" ]
Add a UNION clause @return self
[ "Add", "a", "UNION", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L519-L527
Innmind/neo4j-dbal
src/Query/Query.php
Query.skip
public function skip(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\SkipClause($cypher) ); return $query; }
php
public function skip(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\SkipClause($cypher) ); return $query; }
[ "public", "function", "skip", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "SkipClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a SKIP clause @see http://neo4j.com/docs/stable/query-skip.html#skip-skip-first-from-expression @param string $cypher Of type string as it may contain operations @return self
[ "Add", "a", "SKIP", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L537-L545
Innmind/neo4j-dbal
src/Query/Query.php
Query.return
public function return(string ...$variables): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\ReturnClause(...$variables) ); return $query; }
php
public function return(string ...$variables): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\ReturnClause(...$variables) ); return $query; }
[ "public", "function", "return", "(", "string", "...", "$", "variables", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "ReturnClause", "(", "...", "$", "variables", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a RETURN clause @param string[] $variables @return self
[ "Add", "a", "RETURN", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L554-L562
Innmind/neo4j-dbal
src/Query/Query.php
Query.remove
public function remove(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\RemoveClause($cypher) ); return $query; }
php
public function remove(string $cypher): self { $query = new self; $query->clauses = $this->clauses->add( new Clause\RemoveClause($cypher) ); return $query; }
[ "public", "function", "remove", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "RemoveClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a REMOVE clause @param string $cypher @return self
[ "Add", "a", "REMOVE", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L571-L579
Innmind/neo4j-dbal
src/Query/Query.php
Query.orderBy
public function orderBy( string $cypher, string $direction = 'ASC' ): self { $direction = \strtolower($direction); $query = new self; $query->clauses = $this->clauses->add( Clause\OrderByClause::$direction($cypher) ); return $query; }
php
public function orderBy( string $cypher, string $direction = 'ASC' ): self { $direction = \strtolower($direction); $query = new self; $query->clauses = $this->clauses->add( Clause\OrderByClause::$direction($cypher) ); return $query; }
[ "public", "function", "orderBy", "(", "string", "$", "cypher", ",", "string", "$", "direction", "=", "'ASC'", ")", ":", "self", "{", "$", "direction", "=", "\\", "strtolower", "(", "$", "direction", ")", ";", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "Clause", "\\", "OrderByClause", "::", "$", "direction", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a ORDER BY clause @param string $cypher @param string $direction @return self
[ "Add", "a", "ORDER", "BY", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L589-L601
Innmind/neo4j-dbal
src/Query/Query.php
Query.onMatch
public function onMatch(string $cypher): self { $clause = $this->clauses->last(); if ( !$clause instanceof Clause\MergeClause && !$clause instanceof Clause\OnCreateClause ) { throw new NonMergeClause; } $query = new self; $query->clauses = $this->clauses->add( new Clause\OnMatchClause($cypher) ); return $query; }
php
public function onMatch(string $cypher): self { $clause = $this->clauses->last(); if ( !$clause instanceof Clause\MergeClause && !$clause instanceof Clause\OnCreateClause ) { throw new NonMergeClause; } $query = new self; $query->clauses = $this->clauses->add( new Clause\OnMatchClause($cypher) ); return $query; }
[ "public", "function", "onMatch", "(", "string", "$", "cypher", ")", ":", "self", "{", "$", "clause", "=", "$", "this", "->", "clauses", "->", "last", "(", ")", ";", "if", "(", "!", "$", "clause", "instanceof", "Clause", "\\", "MergeClause", "&&", "!", "$", "clause", "instanceof", "Clause", "\\", "OnCreateClause", ")", "{", "throw", "new", "NonMergeClause", ";", "}", "$", "query", "=", "new", "self", ";", "$", "query", "->", "clauses", "=", "$", "this", "->", "clauses", "->", "add", "(", "new", "Clause", "\\", "OnMatchClause", "(", "$", "cypher", ")", ")", ";", "return", "$", "query", ";", "}" ]
Add a ON MATCH clause @param string $cypher @throws NonMergeClause @return self
[ "Add", "a", "ON", "MATCH", "clause" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L612-L629