repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Tecnocreaciones/ToolsBundle | Model/Paginator/Paginator.php | Paginator.getLinks | protected function getLinks($route,array $parameters = array()){
$links = array();
if($route != null){
$baseParams = $_GET;
unset($baseParams["page"]);
$parameters = array_merge($parameters,$baseParams);
$links['first']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => 1)));
$links['self']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getCurrentPage())));
$links['last']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNbPages())));
if($this->hasPreviousPage()){
$links['previous']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getPreviousPage())));
}
if($this->hasNextPage()){
$links['next']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNextPage())));
}
}
return $links;
} | php | protected function getLinks($route,array $parameters = array()){
$links = array();
if($route != null){
$baseParams = $_GET;
unset($baseParams["page"]);
$parameters = array_merge($parameters,$baseParams);
$links['first']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => 1)));
$links['self']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getCurrentPage())));
$links['last']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNbPages())));
if($this->hasPreviousPage()){
$links['previous']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getPreviousPage())));
}
if($this->hasNextPage()){
$links['next']['href'] = $this->generateUrl($route, array_merge($parameters, array('page' => $this->getNextPage())));
}
}
return $links;
} | [
"protected",
"function",
"getLinks",
"(",
"$",
"route",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"links",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"route",
"!=",
"null",
")",
"{",
"$",
"baseParams",
"=",
"$",
"_... | Genera los links de navegacion entre una y otra pagina
@param type $route
@param array $parameters
@return type | [
"Genera",
"los",
"links",
"de",
"navegacion",
"entre",
"una",
"y",
"otra",
"pagina"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L191-L208 | train |
Tecnocreaciones/ToolsBundle | Model/Paginator/Paginator.php | Paginator.setRequest | function setRequest(\Symfony\Component\HttpFoundation\Request $request) {
$this->request = $request;
if(self::FORMAT_ARRAY_DATA_TABLES == $this->defaultFormat){
//Ejemplo start(20) / length(10) = 2
$start = (int)$request->get("start",0);//Elemento inicio
$length = (int)$request->get("length",10);//Cantidad de elementos por pagina
$this->draw = $request->get("draw", $this->draw) + 1;//No cache
if($start > 0){
$page = (int)($start / $length);
$page = $page + 1;
}else{
$page = 1;
}
if(!is_int($length)){
$length = 10;
}
if(!is_int($page)){
$page = 1;
}
$this->setMaxPerPage($length);
$this->setCurrentPage($page);
}else if(self::FORMAT_ARRAY_STANDARD == $this->defaultFormat){
$page = (int)$request->get("page",1);//Elemento inicio
$maxPerPage = (int)$request->get("maxPerPage",10);//Elemento inicio
$this->setMaxPerPage($maxPerPage);
$totalPages = $this->getNbPages();
if($page > $this->getNbPages()){
$page = $totalPages;
}
$this->setCurrentPage($page);
}
} | php | function setRequest(\Symfony\Component\HttpFoundation\Request $request) {
$this->request = $request;
if(self::FORMAT_ARRAY_DATA_TABLES == $this->defaultFormat){
//Ejemplo start(20) / length(10) = 2
$start = (int)$request->get("start",0);//Elemento inicio
$length = (int)$request->get("length",10);//Cantidad de elementos por pagina
$this->draw = $request->get("draw", $this->draw) + 1;//No cache
if($start > 0){
$page = (int)($start / $length);
$page = $page + 1;
}else{
$page = 1;
}
if(!is_int($length)){
$length = 10;
}
if(!is_int($page)){
$page = 1;
}
$this->setMaxPerPage($length);
$this->setCurrentPage($page);
}else if(self::FORMAT_ARRAY_STANDARD == $this->defaultFormat){
$page = (int)$request->get("page",1);//Elemento inicio
$maxPerPage = (int)$request->get("maxPerPage",10);//Elemento inicio
$this->setMaxPerPage($maxPerPage);
$totalPages = $this->getNbPages();
if($page > $this->getNbPages()){
$page = $totalPages;
}
$this->setCurrentPage($page);
}
} | [
"function",
"setRequest",
"(",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"if",
"(",
"self",
"::",
"FORMAT_ARRAY_DATA_TABLES",
"==",
"$",
"t... | Establece el request actual para calculos en los formaters
@param \Symfony\Component\HttpFoundation\Request $request | [
"Establece",
"el",
"request",
"actual",
"para",
"calculos",
"en",
"los",
"formaters"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Model/Paginator/Paginator.php#L214-L247 | train |
manusreload/GLFramework | src/Filesystem.php | Filesystem.allocate | public static function allocate($filename = null, $extension = ".rnd", $folder = null)
{
if ($filename === null) {
$filename = sha1(time() . "_" . microtime(true));
}
if ($folder) {
$ffolder = new Filesystem($folder);
if (!$ffolder->exists()) {
$ffolder->mkdir();
}
}
$file = new Filesystem($folder . '/' . $filename . $extension);
//$this->getStorage() . "/{$filename}{$extension}";
return $file;
} | php | public static function allocate($filename = null, $extension = ".rnd", $folder = null)
{
if ($filename === null) {
$filename = sha1(time() . "_" . microtime(true));
}
if ($folder) {
$ffolder = new Filesystem($folder);
if (!$ffolder->exists()) {
$ffolder->mkdir();
}
}
$file = new Filesystem($folder . '/' . $filename . $extension);
//$this->getStorage() . "/{$filename}{$extension}";
return $file;
} | [
"public",
"static",
"function",
"allocate",
"(",
"$",
"filename",
"=",
"null",
",",
"$",
"extension",
"=",
"\".rnd\"",
",",
"$",
"folder",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"filename",
"===",
"null",
")",
"{",
"$",
"filename",
"=",
"sha1",
"(",
... | Solicita un nuevo archivo con ese nombre y extension, si no se indica un nombre, se genera
uno de forma aleatoria.
@param null $filename
@param string $extension
@param null $folder
@return Filesystem | [
"Solicita",
"un",
"nuevo",
"archivo",
"con",
"ese",
"nombre",
"y",
"extension",
"si",
"no",
"se",
"indica",
"un",
"nombre",
"se",
"genera",
"uno",
"de",
"forma",
"aleatoria",
"."
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Filesystem.php#L64-L78 | train |
manusreload/GLFramework | src/Filesystem.php | Filesystem.getFilesystemFolder | public function getFilesystemFolder()
{
$config = Bootstrap::getSingleton()->getConfig();
if (isset($config['app']['filesystem'])) {
return Bootstrap::getSingleton()->getDirectory() . '/' . $config['app']['filesystem'];
}
return Bootstrap::getSingleton()->getDirectory() . '/filesystem';
} | php | public function getFilesystemFolder()
{
$config = Bootstrap::getSingleton()->getConfig();
if (isset($config['app']['filesystem'])) {
return Bootstrap::getSingleton()->getDirectory() . '/' . $config['app']['filesystem'];
}
return Bootstrap::getSingleton()->getDirectory() . '/filesystem';
} | [
"public",
"function",
"getFilesystemFolder",
"(",
")",
"{",
"$",
"config",
"=",
"Bootstrap",
"::",
"getSingleton",
"(",
")",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'app'",
"]",
"[",
"'filesystem'",
"]",
")",
")"... | Obtiene la ruta al directorio donde se almacenan los archivos
@return string | [
"Obtiene",
"la",
"ruta",
"al",
"directorio",
"donde",
"se",
"almacenan",
"los",
"archivos"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Filesystem.php#L85-L92 | train |
manusreload/GLFramework | src/Filesystem.php | Filesystem.url | public function url($expires = null)
{
$this->setPublic($expires);
return get_protocol() . $_SERVER['HTTP_HOST'] . '/_raw/' . $this->file;
} | php | public function url($expires = null)
{
$this->setPublic($expires);
return get_protocol() . $_SERVER['HTTP_HOST'] . '/_raw/' . $this->file;
} | [
"public",
"function",
"url",
"(",
"$",
"expires",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPublic",
"(",
"$",
"expires",
")",
";",
"return",
"get_protocol",
"(",
")",
".",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
".",
"'/_raw/'",
".",
"$",
"this... | Obtiene una url accesible por el navegador
@param null $expires
@return string | [
"Obtiene",
"una",
"url",
"accesible",
"por",
"el",
"navegador"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Filesystem.php#L145-L149 | train |
JBZoo/PimpleDumper | src/PimpleDumper.php | PimpleDumper._writePHPStorm | protected function _writePHPStorm($map, $className)
{
$fileName = $this->_root . DIRECTORY_SEPARATOR . self::FILE_PHPSTORM;
if (is_dir($fileName)) {
$fileName .= DIRECTORY_SEPARATOR . 'pimple.meta.php';
}
$list = array();
foreach ($map as $data) {
if ($data['type'] === 'class') {
$list[] = " '{$data['name']}' instanceof {$data['value']},";
}
}
$tmpl = array(
'<?php',
'/**',
' * ProcessWire PhpStorm Meta',
' *',
' * This file is not a CODE, it makes no sense and won\'t run or validate',
' * Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions.',
' * ',
' * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata',
' */',
'',
'namespace PHPSTORM_META {',
'',
' $STATIC_METHOD_TYPES = [',
' new \\' . $className . ' => [',
' \'\' == \'@\',',
implode("\n", $list),
' ],',
' ];',
'',
'}',
'',
);
$content = implode("\n", $tmpl);
$this->_updateFile($fileName, $content);
return $fileName;
} | php | protected function _writePHPStorm($map, $className)
{
$fileName = $this->_root . DIRECTORY_SEPARATOR . self::FILE_PHPSTORM;
if (is_dir($fileName)) {
$fileName .= DIRECTORY_SEPARATOR . 'pimple.meta.php';
}
$list = array();
foreach ($map as $data) {
if ($data['type'] === 'class') {
$list[] = " '{$data['name']}' instanceof {$data['value']},";
}
}
$tmpl = array(
'<?php',
'/**',
' * ProcessWire PhpStorm Meta',
' *',
' * This file is not a CODE, it makes no sense and won\'t run or validate',
' * Its AST serves PhpStorm IDE as DATA source to make advanced type inference decisions.',
' * ',
' * @see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata',
' */',
'',
'namespace PHPSTORM_META {',
'',
' $STATIC_METHOD_TYPES = [',
' new \\' . $className . ' => [',
' \'\' == \'@\',',
implode("\n", $list),
' ],',
' ];',
'',
'}',
'',
);
$content = implode("\n", $tmpl);
$this->_updateFile($fileName, $content);
return $fileName;
} | [
"protected",
"function",
"_writePHPStorm",
"(",
"$",
"map",
",",
"$",
"className",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"_root",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"FILE_PHPSTORM",
";",
"if",
"(",
"is_dir",
"(",
"$",
"fileName",
... | Dump mapping to phpstorm meta file
@param array $map
@param string $className
@return string | [
"Dump",
"mapping",
"to",
"phpstorm",
"meta",
"file"
] | 4fd449dbe751b77066b2b101954185bd76f8dae7 | https://github.com/JBZoo/PimpleDumper/blob/4fd449dbe751b77066b2b101954185bd76f8dae7/src/PimpleDumper.php#L303-L347 | train |
JBZoo/PimpleDumper | src/PimpleDumper.php | PimpleDumper._updateFile | protected function _updateFile($fileName, $content)
{
$oldContent = null;
if (file_exists($fileName)) {
$oldContent = file_get_contents($fileName);
}
if ($content !== $oldContent) {
file_put_contents($fileName, $content);
}
return $fileName;
} | php | protected function _updateFile($fileName, $content)
{
$oldContent = null;
if (file_exists($fileName)) {
$oldContent = file_get_contents($fileName);
}
if ($content !== $oldContent) {
file_put_contents($fileName, $content);
}
return $fileName;
} | [
"protected",
"function",
"_updateFile",
"(",
"$",
"fileName",
",",
"$",
"content",
")",
"{",
"$",
"oldContent",
"=",
"null",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"oldContent",
"=",
"file_get_contents",
"(",
"$",
"fileN... | Update file
Prevent file lastModified time change
@param string $fileName
@param string $content
@return mixed | [
"Update",
"file",
"Prevent",
"file",
"lastModified",
"time",
"change"
] | 4fd449dbe751b77066b2b101954185bd76f8dae7 | https://github.com/JBZoo/PimpleDumper/blob/4fd449dbe751b77066b2b101954185bd76f8dae7/src/PimpleDumper.php#L357-L369 | train |
jer-lim/Telegram-Bot-Core | src/ForwardableHandler.php | ForwardableHandler.forwardMessage | public function forwardMessage($toChatId, bool $disableNotification = false): void
{
$m = $this->bot->forwardMessage();
$m->setChatId($toChatId);
$m->setFromChatId($this->message->getChat()->getId());
$m->setMessageId($this->message->getMessageId());
$m->setDisableNotification($disableNotification);
$m->send();
} | php | public function forwardMessage($toChatId, bool $disableNotification = false): void
{
$m = $this->bot->forwardMessage();
$m->setChatId($toChatId);
$m->setFromChatId($this->message->getChat()->getId());
$m->setMessageId($this->message->getMessageId());
$m->setDisableNotification($disableNotification);
$m->send();
} | [
"public",
"function",
"forwardMessage",
"(",
"$",
"toChatId",
",",
"bool",
"$",
"disableNotification",
"=",
"false",
")",
":",
"void",
"{",
"$",
"m",
"=",
"$",
"this",
"->",
"bot",
"->",
"forwardMessage",
"(",
")",
";",
"$",
"m",
"->",
"setChatId",
"("... | Forward the message that triggered this command.
@param int|string $toChatId Chat ID to forward to.
@param bool|boolean $disableNotification Disable notification for this message. | [
"Forward",
"the",
"message",
"that",
"triggered",
"this",
"command",
"."
] | 49a184aef0922d1b70ade91204738fe40a1ea5ae | https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/ForwardableHandler.php#L17-L26 | train |
krystal-framework/krystal.framework | src/Krystal/Text/Storage/JsonStorage.php | JsonStorage.load | public function load()
{
// Initial state, is always empty array
$data = array();
// Alter $data in case it exists and its valid
if ($this->storageAdapter->has($this->key)) {
$target = $this->serializer->unserialize($this->storageAdapter->get($this->key));
// If $target is null, then data either is damaged or doesn't exist, otherwise it's okay
if ($target !== null) {
$data = $target;
}
}
return $data;
} | php | public function load()
{
// Initial state, is always empty array
$data = array();
// Alter $data in case it exists and its valid
if ($this->storageAdapter->has($this->key)) {
$target = $this->serializer->unserialize($this->storageAdapter->get($this->key));
// If $target is null, then data either is damaged or doesn't exist, otherwise it's okay
if ($target !== null) {
$data = $target;
}
}
return $data;
} | [
"public",
"function",
"load",
"(",
")",
"{",
"// Initial state, is always empty array",
"$",
"data",
"=",
"array",
"(",
")",
";",
"// Alter $data in case it exists and its valid",
"if",
"(",
"$",
"this",
"->",
"storageAdapter",
"->",
"has",
"(",
"$",
"this",
"->",... | Loads data from a storage
@return array Returns loaded data | [
"Loads",
"data",
"from",
"a",
"storage"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Storage/JsonStorage.php#L71-L87 | train |
krystal-framework/krystal.framework | src/Krystal/Text/Storage/JsonStorage.php | JsonStorage.save | public function save(array $data)
{
// This is what we're going to store
$seriaziledData = $this->serializer->serialize($data);
$this->storageAdapter->set($this->key, $seriaziledData, $this->ttl);
return true;
} | php | public function save(array $data)
{
// This is what we're going to store
$seriaziledData = $this->serializer->serialize($data);
$this->storageAdapter->set($this->key, $seriaziledData, $this->ttl);
return true;
} | [
"public",
"function",
"save",
"(",
"array",
"$",
"data",
")",
"{",
"// This is what we're going to store",
"$",
"seriaziledData",
"=",
"$",
"this",
"->",
"serializer",
"->",
"serialize",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"storageAdapter",
"->",
... | Saves data into a storage
@param array $data Data to be saved
@return void | [
"Saves",
"data",
"into",
"a",
"storage"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Storage/JsonStorage.php#L95-L102 | train |
krystal-framework/krystal.framework | src/Krystal/Text/Storage/JsonStorage.php | JsonStorage.clear | public function clear()
{
if ($this->storageAdapter->has($this->key)) {
$this->storageAdapter->remove($this->key);
}
} | php | public function clear()
{
if ($this->storageAdapter->has($this->key)) {
$this->storageAdapter->remove($this->key);
}
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"storageAdapter",
"->",
"has",
"(",
"$",
"this",
"->",
"key",
")",
")",
"{",
"$",
"this",
"->",
"storageAdapter",
"->",
"remove",
"(",
"$",
"this",
"->",
"key",
")",
";",
... | Clears data from a storage
@return void | [
"Clears",
"data",
"from",
"a",
"storage"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Storage/JsonStorage.php#L109-L114 | train |
krystal-framework/krystal.framework | src/Krystal/Ftp/FtpFactory.php | FtpFactory.build | public static function build($host, $username = null, $password = null, $timeout = 90, $port = 21, $ssl = false)
{
$connector = new Connector($host, $timeout, $port, $ssl);
if (!$connector->connect()) {
throw new RuntimeException('Cannot connect to remote FTP server');
}
if ($username !== null && $password !== null) {
if (!$connector->login($username, $password)) {
throw new LogicException('Invalid combination of username and password provided');
}
}
return new FtpManager($connector);
} | php | public static function build($host, $username = null, $password = null, $timeout = 90, $port = 21, $ssl = false)
{
$connector = new Connector($host, $timeout, $port, $ssl);
if (!$connector->connect()) {
throw new RuntimeException('Cannot connect to remote FTP server');
}
if ($username !== null && $password !== null) {
if (!$connector->login($username, $password)) {
throw new LogicException('Invalid combination of username and password provided');
}
}
return new FtpManager($connector);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"host",
",",
"$",
"username",
"=",
"null",
",",
"$",
"password",
"=",
"null",
",",
"$",
"timeout",
"=",
"90",
",",
"$",
"port",
"=",
"21",
",",
"$",
"ssl",
"=",
"false",
")",
"{",
"$",
"connector... | Builds FTP Manager
@param string $host
@param string $username
@param string $password
@param integer $timeout Timeout to wait for connection success in seconds
@param integer $port FTP port
@param boolean $ssl Whether to connect via secure layer
@throws \RuntimeException If cannot connect to the remote host
@throws \LogicException If Invalid combination of username and password provided
@return \Krystal\Ftp\FtpManager | [
"Builds",
"FTP",
"Manager"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Ftp/FtpFactory.php#L32-L47 | train |
fxpio/fxp-bootstrap | Block/Type/TableType.php | TableType.isColumn | protected function isColumn(ResolvedBlockTypeInterface $type)
{
if ('table_column' === $type->getBlockPrefix()) {
return true;
}
if (null !== $type->getParent()) {
return $this->isColumn($type->getParent());
}
return false;
} | php | protected function isColumn(ResolvedBlockTypeInterface $type)
{
if ('table_column' === $type->getBlockPrefix()) {
return true;
}
if (null !== $type->getParent()) {
return $this->isColumn($type->getParent());
}
return false;
} | [
"protected",
"function",
"isColumn",
"(",
"ResolvedBlockTypeInterface",
"$",
"type",
")",
"{",
"if",
"(",
"'table_column'",
"===",
"$",
"type",
"->",
"getBlockPrefix",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"type",
... | Check if the child is a column.
@param ResolvedBlockTypeInterface $type
@return bool | [
"Check",
"if",
"the",
"child",
"is",
"a",
"column",
"."
] | 4ff1408018c71d18b6951b1f8d7c5ad0b684eadb | https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/Type/TableType.php#L231-L242 | train |
Tecnocreaciones/ToolsBundle | Service/SecurityHandler.php | SecurityHandler.checkSecurity | public function checkSecurity($rol,$parameters = null) {
if($rol === null){
throw $this->createAccessDeniedHttpException($this->trans($this->genericMessage));
}
$roles = $rol;
if(!is_array($rol)){
$roles = array($rol);
}
$valid = $this->getSecurityContext()->isGranted($roles,$parameters);
foreach ($roles as $rol) {
if(!$valid){
throw $this->createAccessDeniedHttpException($this->buildMessage($rol));
}
$methodValidMap = $this->getMethodValidMap();
if(isset($methodValidMap[$rol])){
$method = $methodValidMap[$rol];
$valid = call_user_func_array(array($this,$method),array($rol,$parameters));
}
}
} | php | public function checkSecurity($rol,$parameters = null) {
if($rol === null){
throw $this->createAccessDeniedHttpException($this->trans($this->genericMessage));
}
$roles = $rol;
if(!is_array($rol)){
$roles = array($rol);
}
$valid = $this->getSecurityContext()->isGranted($roles,$parameters);
foreach ($roles as $rol) {
if(!$valid){
throw $this->createAccessDeniedHttpException($this->buildMessage($rol));
}
$methodValidMap = $this->getMethodValidMap();
if(isset($methodValidMap[$rol])){
$method = $methodValidMap[$rol];
$valid = call_user_func_array(array($this,$method),array($rol,$parameters));
}
}
} | [
"public",
"function",
"checkSecurity",
"(",
"$",
"rol",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"rol",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedHttpException",
"(",
"$",
"this",
"->",
"trans",
"(",
... | Evalua que el usuario tenga acceso a la seccion especifica, ademas se valida con un segundo metodo
@param type $rol
@param type $parameters
@throws type | [
"Evalua",
"que",
"el",
"usuario",
"tenga",
"acceso",
"a",
"la",
"seccion",
"especifica",
"ademas",
"se",
"valida",
"con",
"un",
"segundo",
"metodo"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SecurityHandler.php#L41-L60 | train |
Tecnocreaciones/ToolsBundle | Service/SecurityHandler.php | SecurityHandler.buildMessage | private function buildMessage($rol,$prefix = '403')
{
return $this->trans(sprintf('%s.%s.%s', $this->prefixMessage,$prefix,strtolower($rol)));
} | php | private function buildMessage($rol,$prefix = '403')
{
return $this->trans(sprintf('%s.%s.%s', $this->prefixMessage,$prefix,strtolower($rol)));
} | [
"private",
"function",
"buildMessage",
"(",
"$",
"rol",
",",
"$",
"prefix",
"=",
"'403'",
")",
"{",
"return",
"$",
"this",
"->",
"trans",
"(",
"sprintf",
"(",
"'%s.%s.%s'",
",",
"$",
"this",
"->",
"prefixMessage",
",",
"$",
"prefix",
",",
"strtolower",
... | Genera el mensaje de error
@param type $rol
@param type $prefix
@return type | [
"Genera",
"el",
"mensaje",
"de",
"error"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SecurityHandler.php#L68-L71 | train |
Tecnocreaciones/ToolsBundle | Service/SecurityHandler.php | SecurityHandler.setFlash | protected function setFlash($type,$message,$parameters = array(),$domain = 'flashes')
{
return $this->container->get('session')->getBag('flashes')->add($type,$message);
} | php | protected function setFlash($type,$message,$parameters = array(),$domain = 'flashes')
{
return $this->container->get('session')->getBag('flashes')->add($type,$message);
} | [
"protected",
"function",
"setFlash",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"domain",
"=",
"'flashes'",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'session'",
")",
... | Envia un mensaje flash
@param array $type success|error
@param type $message
@param type $parameters
@param type $domain
@return type | [
"Envia",
"un",
"mensaje",
"flash"
] | 8edc159b91ea41d7a880d2ca0860352d7b05370f | https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Service/SecurityHandler.php#L105-L108 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/AbstractImageManagerFactory.php | AbstractImageManagerFactory.build | final public function build()
{
return new ImageManager($this->getPath(), $this->getRootDir(), $this->getRootUrl(), $this->getConfig());
} | php | final public function build()
{
return new ImageManager($this->getPath(), $this->getRootDir(), $this->getRootUrl(), $this->getConfig());
} | [
"final",
"public",
"function",
"build",
"(",
")",
"{",
"return",
"new",
"ImageManager",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"getRootDir",
"(",
")",
",",
"$",
"this",
"->",
"getRootUrl",
"(",
")",
",",
"$",
"this",
"... | Builds image manager's instance
@return \Krystal\Image\Tool\ImageManager | [
"Builds",
"image",
"manager",
"s",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/AbstractImageManagerFactory.php#L85-L88 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Style/DiggStyle.php | DiggStyle.getPageNumbers | public function getPageNumbers(array $pages, $current)
{
$result = array();
$amount = count($pages);
$start = 3;
if ($amount > $start) {
// this specifies the range of pages we want to show in the middle
$min = max($current - 2, 2);
$max = min($current + 2, $amount - 1);
// we always show the first page
$result[] = 1;
// we're more than one space away from the beginning, so we need a separator
if ($min > 2) {
$result[] = '...';
}
// generate the middle numbers
for ($i = $min; $i < $max + 1; $i++) {
$result[] = $i;
}
// we're more than one space away from the end, so we need a separator
if ($max < $amount - 1) {
$result[] = '...';
}
// we always show the last page, which is the same as amount
$result[] = $amount;
return $result;
} else {
// It's not worth using a style adapter, because amount of pages is less than 3
return range(1, $start);
}
} | php | public function getPageNumbers(array $pages, $current)
{
$result = array();
$amount = count($pages);
$start = 3;
if ($amount > $start) {
// this specifies the range of pages we want to show in the middle
$min = max($current - 2, 2);
$max = min($current + 2, $amount - 1);
// we always show the first page
$result[] = 1;
// we're more than one space away from the beginning, so we need a separator
if ($min > 2) {
$result[] = '...';
}
// generate the middle numbers
for ($i = $min; $i < $max + 1; $i++) {
$result[] = $i;
}
// we're more than one space away from the end, so we need a separator
if ($max < $amount - 1) {
$result[] = '...';
}
// we always show the last page, which is the same as amount
$result[] = $amount;
return $result;
} else {
// It's not worth using a style adapter, because amount of pages is less than 3
return range(1, $start);
}
} | [
"public",
"function",
"getPageNumbers",
"(",
"array",
"$",
"pages",
",",
"$",
"current",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"amount",
"=",
"count",
"(",
"$",
"pages",
")",
";",
"$",
"start",
"=",
"3",
";",
"if",
"(",
"$",
... | Returns filtered array via this style adapter
@param array $page Array of page numbers
@param integer $current Current page number
@return array | [
"Returns",
"filtered",
"array",
"via",
"this",
"style",
"adapter"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Style/DiggStyle.php#L23-L63 | train |
krystal-framework/krystal.framework | src/Krystal/Application/FrontController/ControllerFactory.php | ControllerFactory.build | public function build($controller, $action, array $options)
{
$class = Ns::normalize($controller);
// PSR-0 Autoloader will do its own job by default when calling class_exists() function
if (class_exists($class)) {
// Target module which is going to be instantiated
$module = Ns::extractVendorNs($controller);
$controller = new $class($this->serviceLocator, $module, $options);
if (method_exists($controller, 'initialize')) {
$controller->initialize($action);
if ($controller->isHalted()) {
throw new DomainException('Controller halted its execution due to route options mismatch');
}
return $controller;
} else {
throw new RuntimeException('A base controller must be inherited');
}
} else {
// A name does not match PSR-0
trigger_error(sprintf(
'Controller does not exist : "%s" or it does not match PSR-0', $class), E_USER_ERROR
);
}
} | php | public function build($controller, $action, array $options)
{
$class = Ns::normalize($controller);
// PSR-0 Autoloader will do its own job by default when calling class_exists() function
if (class_exists($class)) {
// Target module which is going to be instantiated
$module = Ns::extractVendorNs($controller);
$controller = new $class($this->serviceLocator, $module, $options);
if (method_exists($controller, 'initialize')) {
$controller->initialize($action);
if ($controller->isHalted()) {
throw new DomainException('Controller halted its execution due to route options mismatch');
}
return $controller;
} else {
throw new RuntimeException('A base controller must be inherited');
}
} else {
// A name does not match PSR-0
trigger_error(sprintf(
'Controller does not exist : "%s" or it does not match PSR-0', $class), E_USER_ERROR
);
}
} | [
"public",
"function",
"build",
"(",
"$",
"controller",
",",
"$",
"action",
",",
"array",
"$",
"options",
")",
"{",
"$",
"class",
"=",
"Ns",
"::",
"normalize",
"(",
"$",
"controller",
")",
";",
"// PSR-0 Autoloader will do its own job by default when calling class_... | Builds a controller instance
@param string $controller PSR-0 Compliant path
@param string $action Method to be invoked on controller
@param array $options Route options passed to corresponding controller
@return \Krystal\Application\Controller\AbstractController | [
"Builds",
"a",
"controller",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/FrontController/ControllerFactory.php#L46-L76 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Routing/RoutesManager.php | RoutesManager.getRoutesFromIndex | private function getRoutesFromIndex (&$routes, &$routesIndex, &$requestMethod, &$requestPathParts, $requestPathIndex = 0) {
if (!empty($requestPathParts[$requestPathIndex])) {
$requestPathPart = $requestPathParts[$requestPathIndex];
if (array_key_exists($requestPathPart, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[$requestPathPart], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
if (array_key_exists(self::ROUTE_PARAMETER_WILDCARD, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[self::ROUTE_PARAMETER_WILDCARD], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
}
else if (array_key_exists(self::ROUTE_ACTIONS_KEY, $routesIndex)) {
$testRoutes = &$routesIndex[self::ROUTE_ACTIONS_KEY];
if (array_key_exists($requestMethod, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[$requestMethod], $requestMethod,$requestPathParts);
}
if (array_key_exists(self::ROUTE_GENERIC_METHOD, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[self::ROUTE_GENERIC_METHOD], $requestMethod, $requestPathParts);
}
}
if (array_key_exists(self::ROUTE_GENERIC_ACTIONS_KEY, $routesIndex)) {
$testRoutes = &$routesIndex[self::ROUTE_GENERIC_ACTIONS_KEY];
if (array_key_exists($requestMethod, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[$requestMethod], $requestMethod, $requestPathParts);
}
if (array_key_exists(self::ROUTE_GENERIC_METHOD, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[self::ROUTE_GENERIC_METHOD], $requestMethod, $requestPathParts);
}
}
} | php | private function getRoutesFromIndex (&$routes, &$routesIndex, &$requestMethod, &$requestPathParts, $requestPathIndex = 0) {
if (!empty($requestPathParts[$requestPathIndex])) {
$requestPathPart = $requestPathParts[$requestPathIndex];
if (array_key_exists($requestPathPart, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[$requestPathPart], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
if (array_key_exists(self::ROUTE_PARAMETER_WILDCARD, $routesIndex)) {
$this->getRoutesFromIndex($routes,$routesIndex[self::ROUTE_PARAMETER_WILDCARD], $requestMethod, $requestPathParts, $requestPathIndex + 1);
}
}
else if (array_key_exists(self::ROUTE_ACTIONS_KEY, $routesIndex)) {
$testRoutes = &$routesIndex[self::ROUTE_ACTIONS_KEY];
if (array_key_exists($requestMethod, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[$requestMethod], $requestMethod,$requestPathParts);
}
if (array_key_exists(self::ROUTE_GENERIC_METHOD, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[self::ROUTE_GENERIC_METHOD], $requestMethod, $requestPathParts);
}
}
if (array_key_exists(self::ROUTE_GENERIC_ACTIONS_KEY, $routesIndex)) {
$testRoutes = &$routesIndex[self::ROUTE_GENERIC_ACTIONS_KEY];
if (array_key_exists($requestMethod, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[$requestMethod], $requestMethod, $requestPathParts);
}
if (array_key_exists(self::ROUTE_GENERIC_METHOD, $testRoutes)) {
$this->getRoutesFromIndexActions($routes,$testRoutes[self::ROUTE_GENERIC_METHOD], $requestMethod, $requestPathParts);
}
}
} | [
"private",
"function",
"getRoutesFromIndex",
"(",
"&",
"$",
"routes",
",",
"&",
"$",
"routesIndex",
",",
"&",
"$",
"requestMethod",
",",
"&",
"$",
"requestPathParts",
",",
"$",
"requestPathIndex",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
... | Obtiene una ruta desde un indice de rutas
@param $routes
@param $routesIndex
@param $requestMethod
@param $requestPathParts
@param int $requestPathIndex | [
"Obtiene",
"una",
"ruta",
"desde",
"un",
"indice",
"de",
"rutas"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Routing/RoutesManager.php#L72-L101 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Routing/RoutesManager.php | RoutesManager.getRoutesFromIndexActions | private function getRoutesFromIndexActions (&$routes, array &$routeActions, &$requestMethod, array &$requestPathParts) {
foreach ($routeActions as $routeData) {
$routePath = $routeData[0];
$routeAction = $routeData[1];
$routeParameters = [];
if (strpos($routePath, self::ROUTE_PARAMETER_PREFIX) !== false || strpos($routePath, self::ROUTE_GENERIC_PATH) !== false) {
$routePathParts = explode(self::ROUTE_PATH_SEPARATOR, trim($routePath, self::ROUTE_PATH_SEPARATOR));;
for ($i = 0; $i < sizeof($routePathParts); $i++) {
$routePathPart = $routePathParts[$i];
if ($routePathPart == self::ROUTE_GENERIC_PATH) {
$path = array_slice($requestPathParts, $i);
$routeParameters[self::ROUTE_PATH_PARAMETER_NAME] = $path;
break;
}
else if ($routePathPart[0] == self::ROUTE_PARAMETER_PREFIX) {
$parameterName = substr($routePathPart, 1);
$parameterValue = $requestPathParts[$i];
$routeParameters[$parameterName] = $parameterValue;
}
}
}
if ($routeAction instanceof RouteGenerator) {
$route = $routeAction->generateRoute($requestMethod, isset($path)?$path : $requestPathParts);
if ($route) {
$routes[] = $route;
}
}
else {
$routes[] = new Route($routeAction, $routeParameters);
}
}
} | php | private function getRoutesFromIndexActions (&$routes, array &$routeActions, &$requestMethod, array &$requestPathParts) {
foreach ($routeActions as $routeData) {
$routePath = $routeData[0];
$routeAction = $routeData[1];
$routeParameters = [];
if (strpos($routePath, self::ROUTE_PARAMETER_PREFIX) !== false || strpos($routePath, self::ROUTE_GENERIC_PATH) !== false) {
$routePathParts = explode(self::ROUTE_PATH_SEPARATOR, trim($routePath, self::ROUTE_PATH_SEPARATOR));;
for ($i = 0; $i < sizeof($routePathParts); $i++) {
$routePathPart = $routePathParts[$i];
if ($routePathPart == self::ROUTE_GENERIC_PATH) {
$path = array_slice($requestPathParts, $i);
$routeParameters[self::ROUTE_PATH_PARAMETER_NAME] = $path;
break;
}
else if ($routePathPart[0] == self::ROUTE_PARAMETER_PREFIX) {
$parameterName = substr($routePathPart, 1);
$parameterValue = $requestPathParts[$i];
$routeParameters[$parameterName] = $parameterValue;
}
}
}
if ($routeAction instanceof RouteGenerator) {
$route = $routeAction->generateRoute($requestMethod, isset($path)?$path : $requestPathParts);
if ($route) {
$routes[] = $route;
}
}
else {
$routes[] = new Route($routeAction, $routeParameters);
}
}
} | [
"private",
"function",
"getRoutesFromIndexActions",
"(",
"&",
"$",
"routes",
",",
"array",
"&",
"$",
"routeActions",
",",
"&",
"$",
"requestMethod",
",",
"array",
"&",
"$",
"requestPathParts",
")",
"{",
"foreach",
"(",
"$",
"routeActions",
"as",
"$",
"routeD... | Obtiene rutas desde las acciones del metodo
@param $routes
@param array $routeActions
@param $requestMethod
@param array $requestPathParts | [
"Obtiene",
"rutas",
"desde",
"las",
"acciones",
"del",
"metodo"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Routing/RoutesManager.php#L110-L141 | train |
fxpio/fxp-form-extensions | Doctrine/Form/Loader/DynamicDoctrineChoiceLoader.php | DynamicDoctrineChoiceLoader.getRealValues | protected function getRealValues(array $values, $value = null)
{
$value = $this->getCallableValue($value);
foreach ($values as &$val) {
if (\is_object($val) && \is_callable($value)) {
$val = \call_user_func($value, $val);
}
}
return $values;
} | php | protected function getRealValues(array $values, $value = null)
{
$value = $this->getCallableValue($value);
foreach ($values as &$val) {
if (\is_object($val) && \is_callable($value)) {
$val = \call_user_func($value, $val);
}
}
return $values;
} | [
"protected",
"function",
"getRealValues",
"(",
"array",
"$",
"values",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getCallableValue",
"(",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"&",
"$",
"va... | Get the choice names of values.
@param array $values The selected values
@param null|callable $value The callable which generates the values
from choices
@return array | [
"Get",
"the",
"choice",
"names",
"of",
"values",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Doctrine/Form/Loader/DynamicDoctrineChoiceLoader.php#L181-L192 | train |
bobfridley/laravel-google-tasks | src/GoogleTasks.php | GoogleTasks.listTasklists | public function listTasklists(
array $queryParameters = []
): array {
$parameters = [
'maxResults' => 100,
];
$parameters = array_merge($parameters, $queryParameters);
return $this
->taskService
->tasklists
->listTasklists($parameters)
->getItems();
} | php | public function listTasklists(
array $queryParameters = []
): array {
$parameters = [
'maxResults' => 100,
];
$parameters = array_merge($parameters, $queryParameters);
return $this
->taskService
->tasklists
->listTasklists($parameters)
->getItems();
} | [
"public",
"function",
"listTasklists",
"(",
"array",
"$",
"queryParameters",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'maxResults'",
"=>",
"100",
",",
"]",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",... | Get all task lists
@param string $maxResults Maximum number of task lists returned on one page. Optional. The default is 100.
@param string $pageToken Token specifying the result page to return. Optional.
@param string $fields Which fields to include in a partial response.
@link https://developers.google.com/google-apps/tasks/v1/reference/tasklists/list
@return array | [
"Get",
"all",
"task",
"lists"
] | 0dc080278cc768d400e58adc51a8984d5b646f4f | https://github.com/bobfridley/laravel-google-tasks/blob/0dc080278cc768d400e58adc51a8984d5b646f4f/src/GoogleTasks.php#L64-L78 | train |
bobfridley/laravel-google-tasks | src/GoogleTasks.php | GoogleTasks.listTasks | public function listTasks(
string $taskListId,
Carbon $dueMin = null,
array $queryParameters = []
): array {
$parameters = [
'showCompleted' => false,
'showDeleted' => true,
'showHidden' => true,
];
if (is_null($dueMin)) {
$dueMin = Carbon::now()->startOfDay();
}
$parameters['dueMin'] = $dueMin->format(DateTime::RFC3339);
$parameters = array_merge($parameters, $queryParameters);
return $this
->taskService
->tasks
->listTasks($taskListId, $parameters)
->getItems();
} | php | public function listTasks(
string $taskListId,
Carbon $dueMin = null,
array $queryParameters = []
): array {
$parameters = [
'showCompleted' => false,
'showDeleted' => true,
'showHidden' => true,
];
if (is_null($dueMin)) {
$dueMin = Carbon::now()->startOfDay();
}
$parameters['dueMin'] = $dueMin->format(DateTime::RFC3339);
$parameters = array_merge($parameters, $queryParameters);
return $this
->taskService
->tasks
->listTasks($taskListId, $parameters)
->getItems();
} | [
"public",
"function",
"listTasks",
"(",
"string",
"$",
"taskListId",
",",
"Carbon",
"$",
"dueMin",
"=",
"null",
",",
"array",
"$",
"queryParameters",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"parameters",
"=",
"[",
"'showCompleted'",
"=>",
"false",
",... | Get task from specified list
@param string $taskListId Task list identifier.
@param \Carbon\Carbon|null $completedMax Upper bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional.
@param \Carbon\Carbon|null $completedMin Lower bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional.
@param \Carbon\Carbon|null $dueMax Upper bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional.
@param \Carbon\Carbon|null $dueMin Lower bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional.
@param string $maxResults Maximum number of task lists returned on one page. Optional. The default is 100.
@param string $pageToken Token specifying the result page to return. Optional.
@param boolean $showCompleted Flag indicating whether completed tasks are returned in the result. Optional. The default is True.
@param boolean $showDeleted Flag indicating whether deleted tasks are returned in the result. Optional. The default is False.
@param boolean $showHidden Flag indicating whether hidden tasks are returned in the result. Optional. The default is False.
@param \Carbon\Carbon|null $updatedMin Lower bound for a task's last modification time (as a RFC 3339 timestamp) to filter by. Optional.
@param string $fields Selector specifying which fields to include in a partial response.
@link https://developers.google.com/google-apps/tasks/v1/reference/tasks/list
@return array | [
"Get",
"task",
"from",
"specified",
"list"
] | 0dc080278cc768d400e58adc51a8984d5b646f4f | https://github.com/bobfridley/laravel-google-tasks/blob/0dc080278cc768d400e58adc51a8984d5b646f4f/src/GoogleTasks.php#L100-L124 | train |
bobfridley/laravel-google-tasks | src/GoogleTasks.php | GoogleTasks.getTask | public function getTask(string $taskId): Google_Service_Tasks
{
return $this->service->tasks->get($this->tasklist, $taskId);
} | php | public function getTask(string $taskId): Google_Service_Tasks
{
return $this->service->tasks->get($this->tasklist, $taskId);
} | [
"public",
"function",
"getTask",
"(",
"string",
"$",
"taskId",
")",
":",
"Google_Service_Tasks",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"tasks",
"->",
"get",
"(",
"$",
"this",
"->",
"tasklist",
",",
"$",
"taskId",
")",
";",
"}"
] | Get a single task.
@param string $taskId
@link https://developers.google.com/google-apps/tasks/v1/reference/tasks/get
@return \Google_Service_Tasks | [
"Get",
"a",
"single",
"task",
"."
] | 0dc080278cc768d400e58adc51a8984d5b646f4f | https://github.com/bobfridley/laravel-google-tasks/blob/0dc080278cc768d400e58adc51a8984d5b646f4f/src/GoogleTasks.php#L135-L138 | train |
bobfridley/laravel-google-tasks | src/GoogleTasks.php | GoogleTasks.insertTask | public function insertTask($task): Google_Service_Tasks
{
if ($task instanceof Tasks) {
$task = $task->googleTasks;
}
return $this->service->tasks->insert($this->tasklist, $task);
} | php | public function insertTask($task): Google_Service_Tasks
{
if ($task instanceof Tasks) {
$task = $task->googleTasks;
}
return $this->service->tasks->insert($this->tasklist, $task);
} | [
"public",
"function",
"insertTask",
"(",
"$",
"task",
")",
":",
"Google_Service_Tasks",
"{",
"if",
"(",
"$",
"task",
"instanceof",
"Tasks",
")",
"{",
"$",
"task",
"=",
"$",
"task",
"->",
"googleTasks",
";",
"}",
"return",
"$",
"this",
"->",
"service",
... | Insert a task.
@param \BobFridley\GoogleTasks\Tasks|Google_Service_Tasks $task
@link https://developers.google.com/google-apps/tasks/v1/reference/tasks/insert
@return \Google_Service_Tasks | [
"Insert",
"a",
"task",
"."
] | 0dc080278cc768d400e58adc51a8984d5b646f4f | https://github.com/bobfridley/laravel-google-tasks/blob/0dc080278cc768d400e58adc51a8984d5b646f4f/src/GoogleTasks.php#L149-L156 | train |
bobfridley/laravel-google-tasks | src/GoogleTasks.php | GoogleTasks.deleteTask | public function deleteTask($taskId)
{
if ($taskId instanceof Tasks) {
$taskId = $taskId->id;
}
$this->service->tasks->delete($this->tasklist, $taskId);
} | php | public function deleteTask($taskId)
{
if ($taskId instanceof Tasks) {
$taskId = $taskId->id;
}
$this->service->tasks->delete($this->tasklist, $taskId);
} | [
"public",
"function",
"deleteTask",
"(",
"$",
"taskId",
")",
"{",
"if",
"(",
"$",
"taskId",
"instanceof",
"Tasks",
")",
"{",
"$",
"taskId",
"=",
"$",
"taskId",
"->",
"id",
";",
"}",
"$",
"this",
"->",
"service",
"->",
"tasks",
"->",
"delete",
"(",
... | Delete a task
@param string|\BobFridley\GoogleTasks\Tasks $taskId
@link https://developers.google.com/google-apps/tasks/v1/reference/tasks/delete | [
"Delete",
"a",
"task"
] | 0dc080278cc768d400e58adc51a8984d5b646f4f | https://github.com/bobfridley/laravel-google-tasks/blob/0dc080278cc768d400e58adc51a8984d5b646f4f/src/GoogleTasks.php#L183-L190 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/Input.php | Input.getFiles | public function getFiles($name = null)
{
if ($name !== null) {
if (!array_key_exists($name, $this->files)) {
throw new RuntimeException(sprintf(
'Attempted to access non-existing field %s', $name
));
}
return $this->hydrateAll($this->files[$name]);
} else {
return $this->hydrateAll($this->files);
}
} | php | public function getFiles($name = null)
{
if ($name !== null) {
if (!array_key_exists($name, $this->files)) {
throw new RuntimeException(sprintf(
'Attempted to access non-existing field %s', $name
));
}
return $this->hydrateAll($this->files[$name]);
} else {
return $this->hydrateAll($this->files);
}
} | [
"public",
"function",
"getFiles",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"files",
")",
")",
"{",
"throw",
"new",
"Run... | Return all files. Optionally filtered by named input
@param string $name Name filter
@throws \RuntimeException if $name isn't valid field
@return object | [
"Return",
"all",
"files",
".",
"Optionally",
"filtered",
"by",
"named",
"input"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/Input.php#L70-L83 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/Input.php | Input.hydrateAll | private function hydrateAll(array $files)
{
foreach ($files as $name => $file) {
// Recursive protection
if (!is_array($file)) {
continue;
}
foreach ($file as $key => $value) {
if (is_array($value)) {
// Recursive call
$files[$name] = call_user_func(array($this, __FUNCTION__), $files[$name]);
} else {
$files[$name] = $this->hydrate($file);
}
}
}
return $files;
} | php | private function hydrateAll(array $files)
{
foreach ($files as $name => $file) {
// Recursive protection
if (!is_array($file)) {
continue;
}
foreach ($file as $key => $value) {
if (is_array($value)) {
// Recursive call
$files[$name] = call_user_func(array($this, __FUNCTION__), $files[$name]);
} else {
$files[$name] = $this->hydrate($file);
}
}
}
return $files;
} | [
"private",
"function",
"hydrateAll",
"(",
"array",
"$",
"files",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"name",
"=>",
"$",
"file",
")",
"{",
"// Recursive protection",
"if",
"(",
"!",
"is_array",
"(",
"$",
"file",
")",
")",
"{",
"continue",... | Recursively hydrate array entires skipping empty files
@param array $files Remapped array
@return array | [
"Recursively",
"hydrate",
"array",
"entires",
"skipping",
"empty",
"files"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/Input.php#L91-L110 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/Input.php | Input.hydrate | private function hydrate(array $file)
{
$entity = new FileEntity();
$entity->setType($file['type'])
->setName($file['name'])
->setTmpName($file['tmp_name'])
->setSize($file['size'])
->setError($file['error']);
return $entity;
} | php | private function hydrate(array $file)
{
$entity = new FileEntity();
$entity->setType($file['type'])
->setName($file['name'])
->setTmpName($file['tmp_name'])
->setSize($file['size'])
->setError($file['error']);
return $entity;
} | [
"private",
"function",
"hydrate",
"(",
"array",
"$",
"file",
")",
"{",
"$",
"entity",
"=",
"new",
"FileEntity",
"(",
")",
";",
"$",
"entity",
"->",
"setType",
"(",
"$",
"file",
"[",
"'type'",
"]",
")",
"->",
"setName",
"(",
"$",
"file",
"[",
"'name... | Hydrates a single file
@param array $file
@return mixed | [
"Hydrates",
"a",
"single",
"file"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/Input.php#L118-L128 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/Input.php | Input.removeBrokenFiles | private function removeBrokenFiles(array $files)
{
// Recursive logic to replace broken arrays with empty ones (which to be removed later)
if (isset($files['error'])) {
return $files['error'] == 4 ? array() : $files;
}
foreach ($files as $key => $value) {
// Recursive call
$files[$key] = call_user_func(array($this, __FUNCTION__), $value);
}
// Now remove empty arrays
return array_filter($files);
} | php | private function removeBrokenFiles(array $files)
{
// Recursive logic to replace broken arrays with empty ones (which to be removed later)
if (isset($files['error'])) {
return $files['error'] == 4 ? array() : $files;
}
foreach ($files as $key => $value) {
// Recursive call
$files[$key] = call_user_func(array($this, __FUNCTION__), $value);
}
// Now remove empty arrays
return array_filter($files);
} | [
"private",
"function",
"removeBrokenFiles",
"(",
"array",
"$",
"files",
")",
"{",
"// Recursive logic to replace broken arrays with empty ones (which to be removed later)",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"'error'",
"]",
")",
")",
"{",
"return",
"$",
"file... | Remove broken ones from target array
A broken file is empty one
@param array $files Remapped files array
@return array | [
"Remove",
"broken",
"ones",
"from",
"target",
"array",
"A",
"broken",
"file",
"is",
"empty",
"one"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/Input.php#L137-L151 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Routing/Routes.php | Routes.handleRequestNotFound | private static function handleRequestNotFound () {
$response = get_response();
$response->clear();
$response->statusCode(Response::HTTP_NOT_FOUND);
$notFoundRoutes = self::$notFoundRoutes->getRoutes();
if (!empty($notFoundRoutes)) {
foreach ($notFoundRoutes as $notFoundRoute) {
$routeResult = self::executeAction($notFoundRoute->getAction(), array_merge($_REQUEST, $notFoundRoute->getParameters()));
if (isset($routeResult)) {
$response->content($routeResult);
}
}
$response->send();
}
else {
handle_error_code(Response::HTTP_NOT_FOUND);
}
} | php | private static function handleRequestNotFound () {
$response = get_response();
$response->clear();
$response->statusCode(Response::HTTP_NOT_FOUND);
$notFoundRoutes = self::$notFoundRoutes->getRoutes();
if (!empty($notFoundRoutes)) {
foreach ($notFoundRoutes as $notFoundRoute) {
$routeResult = self::executeAction($notFoundRoute->getAction(), array_merge($_REQUEST, $notFoundRoute->getParameters()));
if (isset($routeResult)) {
$response->content($routeResult);
}
}
$response->send();
}
else {
handle_error_code(Response::HTTP_NOT_FOUND);
}
} | [
"private",
"static",
"function",
"handleRequestNotFound",
"(",
")",
"{",
"$",
"response",
"=",
"get_response",
"(",
")",
";",
"$",
"response",
"->",
"clear",
"(",
")",
";",
"$",
"response",
"->",
"statusCode",
"(",
"Response",
"::",
"HTTP_NOT_FOUND",
")",
... | Procesa una ruta no encontrada
@throws Exception | [
"Procesa",
"una",
"ruta",
"no",
"encontrada"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Routing/Routes.php#L237-L254 | train |
krystal-framework/krystal.framework | src/Krystal/Application/KernelFactory.php | KernelFactory.build | public static function build(array $config)
{
$input = new Input();
$input->setQuery($_GET)
->setPost($_POST)
->setCookie($_COOKIE)
->setFiles($_FILES)
->setServer($_SERVER)
->setEnv($_ENV)
->setRequest($_REQUEST);
return new Kernel($input, $config);
} | php | public static function build(array $config)
{
$input = new Input();
$input->setQuery($_GET)
->setPost($_POST)
->setCookie($_COOKIE)
->setFiles($_FILES)
->setServer($_SERVER)
->setEnv($_ENV)
->setRequest($_REQUEST);
return new Kernel($input, $config);
} | [
"public",
"static",
"function",
"build",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"input",
"=",
"new",
"Input",
"(",
")",
";",
"$",
"input",
"->",
"setQuery",
"(",
"$",
"_GET",
")",
"->",
"setPost",
"(",
"$",
"_POST",
")",
"->",
"setCookie",
"("... | Builds prepared application instance
@param array $config
@return \Krystal\Application\Kernel | [
"Builds",
"prepared",
"application",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/KernelFactory.php#L24-L36 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/Upload/Plugin/ThumbFactory.php | ThumbFactory.build | public function build($dir, $quality, array $options = array())
{
// Alter default quality on demand
if (isset($options['quality'])) {
$quality = $options['quality'];
}
return new Thumb($dir, $options['dimensions'], $quality);
} | php | public function build($dir, $quality, array $options = array())
{
// Alter default quality on demand
if (isset($options['quality'])) {
$quality = $options['quality'];
}
return new Thumb($dir, $options['dimensions'], $quality);
} | [
"public",
"function",
"build",
"(",
"$",
"dir",
",",
"$",
"quality",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// Alter default quality on demand",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'quality'",
"]",
")",
")",
"{",
"$... | Builds thumb uploader
@param string $dir Target directory
@param integer $quality Desired quality for thumbs
@param array $options
@return \Krystal\Image\Tool\Upload\Plugin\ThumbFactory | [
"Builds",
"thumb",
"uploader"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/Upload/Plugin/ThumbFactory.php#L24-L32 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.store | public function store($module, $name, $value)
{
$this->initializeOnDemand();
if (!$this->has($module, $name)) {
if ($this->configMapper->insert($module, $name, $value)) {
$this->arrayConfig->add($module, $name, $value);
return true;
}
} else {
if ($this->configMapper->update($module, $name, $value)) {
$this->arrayConfig->update($module, $name, $value);
return true;
}
}
// By default
return false;
} | php | public function store($module, $name, $value)
{
$this->initializeOnDemand();
if (!$this->has($module, $name)) {
if ($this->configMapper->insert($module, $name, $value)) {
$this->arrayConfig->add($module, $name, $value);
return true;
}
} else {
if ($this->configMapper->update($module, $name, $value)) {
$this->arrayConfig->update($module, $name, $value);
return true;
}
}
// By default
return false;
} | [
"public",
"function",
"store",
"(",
"$",
"module",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"module",
",",
"$",
"name",
")",
")",
... | Stores configuration's entry
@param string $module
@param string $name
@param string $value
@return boolean | [
"Stores",
"configuration",
"s",
"entry"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L73-L92 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.storeModule | public function storeModule($module, array $vars)
{
foreach ($vars as $key => $value) {
if (!$this->store($module, $key, $value)) {
return false;
}
}
return true;
} | php | public function storeModule($module, array $vars)
{
foreach ($vars as $key => $value) {
if (!$this->store($module, $key, $value)) {
return false;
}
}
return true;
} | [
"public",
"function",
"storeModule",
"(",
"$",
"module",
",",
"array",
"$",
"vars",
")",
"{",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"store",
"(",
"$",
"module",
",",
"$",
... | Stores a collection for a module
@param string $module
@param array $vars
@return boolean | [
"Stores",
"a",
"collection",
"for",
"a",
"module"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L101-L110 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.get | public function get($module, $name, $default = false)
{
$this->initializeOnDemand();
return $this->arrayConfig->get($module, $name, $default);
} | php | public function get($module, $name, $default = false)
{
$this->initializeOnDemand();
return $this->arrayConfig->get($module, $name, $default);
} | [
"public",
"function",
"get",
"(",
"$",
"module",
",",
"$",
"name",
",",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"return",
"$",
"this",
"->",
"arrayConfig",
"->",
"get",
"(",
"$",
"module",
",",
... | Returns configuration entry from the cache
@param string $module
@param string $name
@param mixed $default
@return mixed | [
"Returns",
"configuration",
"entry",
"from",
"the",
"cache"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L132-L136 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.has | public function has($module, $name)
{
$this->initializeOnDemand();
return $this->arrayConfig->has($module, $name);
} | php | public function has($module, $name)
{
$this->initializeOnDemand();
return $this->arrayConfig->has($module, $name);
} | [
"public",
"function",
"has",
"(",
"$",
"module",
",",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"return",
"$",
"this",
"->",
"arrayConfig",
"->",
"has",
"(",
"$",
"module",
",",
"$",
"name",
")",
";",
"}"
] | Checks configuration's entry exists in a module
@param string $module
@param string $name
@return boolean | [
"Checks",
"configuration",
"s",
"entry",
"exists",
"in",
"a",
"module"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L145-L149 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.removeAll | public function removeAll()
{
$this->initializeOnDemand();
if ($this->configMapper->truncate()) {
$this->arrayConfig->clear();
return true;
} else {
return false;
}
} | php | public function removeAll()
{
$this->initializeOnDemand();
if ($this->configMapper->truncate()) {
$this->arrayConfig->clear();
return true;
} else {
return false;
}
} | [
"public",
"function",
"removeAll",
"(",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"configMapper",
"->",
"truncate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"arrayConfig",
"->",
"clear",
"(",
")",
"... | Removes all configuration
@return boolean | [
"Removes",
"all",
"configuration"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L174-L185 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.remove | public function remove($module, $name)
{
$this->initializeOnDemand();
if ($this->exists($module, $name) && $this->configMapper->delete($module, $name)) {
$this->arrayConfig->remove($module, $name);
return true;
} else {
return false;
}
} | php | public function remove($module, $name)
{
$this->initializeOnDemand();
if ($this->exists($module, $name) && $this->configMapper->delete($module, $name)) {
$this->arrayConfig->remove($module, $name);
return true;
} else {
return false;
}
} | [
"public",
"function",
"remove",
"(",
"$",
"module",
",",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"module",
",",
"$",
"name",
")",
"&&",
"$",
"this",
"->",
"c... | Removes a configuration's name and value by associated module
@param string $module
@param string $name
@return boolean | [
"Removes",
"a",
"configuration",
"s",
"name",
"and",
"value",
"by",
"associated",
"module"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L194-L205 | train |
krystal-framework/krystal.framework | src/Krystal/Config/Sql/SqlConfigService.php | SqlConfigService.removeAllByModule | public function removeAllByModule($module)
{
$this->initializeOnDemand();
if ($this->arrayConfig->hasModule($module) && $this->configMapper->deleteAllByModule($module)) {
$this->arrayConfig->removeAllByModule($module);
return true;
} else {
return false;
}
} | php | public function removeAllByModule($module)
{
$this->initializeOnDemand();
if ($this->arrayConfig->hasModule($module) && $this->configMapper->deleteAllByModule($module)) {
$this->arrayConfig->removeAllByModule($module);
return true;
} else {
return false;
}
} | [
"public",
"function",
"removeAllByModule",
"(",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"initializeOnDemand",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"arrayConfig",
"->",
"hasModule",
"(",
"$",
"module",
")",
"&&",
"$",
"this",
"->",
"configMapp... | Removes all configuration data by associated module
@param string $module
@return boolean | [
"Removes",
"all",
"configuration",
"data",
"by",
"associated",
"module"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/Sql/SqlConfigService.php#L213-L223 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.isDirtyFile | private function isDirtyFile($path, $git)
{
if (!\is_file($path)) {
return false;
}
$status = (array) $git->status()->short()->getIndexStatus();
$relPath = (string) \substr($path, (\strlen($git->getRepositoryPath()) + 1));
if (isset($status[$relPath]) && $status[$relPath]) {
return true;
}
return false;
} | php | private function isDirtyFile($path, $git)
{
if (!\is_file($path)) {
return false;
}
$status = (array) $git->status()->short()->getIndexStatus();
$relPath = (string) \substr($path, (\strlen($git->getRepositoryPath()) + 1));
if (isset($status[$relPath]) && $status[$relPath]) {
return true;
}
return false;
} | [
"private",
"function",
"isDirtyFile",
"(",
"$",
"path",
",",
"$",
"git",
")",
"{",
"if",
"(",
"!",
"\\",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"status",
"=",
"(",
"array",
")",
"$",
"git",
"->",
"status",
... | Check if the current file path is a file and if so, if it has staged modifications.
@param string $path A path obtained via a prior call to AuthorExtractor::getFilePaths().
@param GitRepository $git The repository to extract all files from.
@return bool | [
"Check",
"if",
"the",
"current",
"file",
"path",
"is",
"a",
"file",
"and",
"if",
"so",
"if",
"it",
"has",
"staged",
"modifications",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L105-L119 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.getAuthorListFrom | private function getAuthorListFrom()
{
$filePath = $this->getFilePathCollection($this->currentPath);
$authors = [];
foreach ((array) $filePath['commits'] as $commit) {
if ($this->isMergeCommit($commit)
|| isset($authors[\md5($commit['name'])])
) {
continue;
}
$authors[\md5($commit['name'])] = $commit;
}
if (isset($filePath['pathHistory'])) {
foreach ((array) $filePath['pathHistory'] as $pathHistory) {
foreach ((array) $pathHistory['commits'] as $commitHistory) {
if ($this->isMergeCommit($commitHistory)
|| isset($authors[\md5($commitHistory['name'])])
) {
continue;
}
$authors[\md5($commitHistory['name'])] = $commitHistory;
}
}
}
return $authors;
} | php | private function getAuthorListFrom()
{
$filePath = $this->getFilePathCollection($this->currentPath);
$authors = [];
foreach ((array) $filePath['commits'] as $commit) {
if ($this->isMergeCommit($commit)
|| isset($authors[\md5($commit['name'])])
) {
continue;
}
$authors[\md5($commit['name'])] = $commit;
}
if (isset($filePath['pathHistory'])) {
foreach ((array) $filePath['pathHistory'] as $pathHistory) {
foreach ((array) $pathHistory['commits'] as $commitHistory) {
if ($this->isMergeCommit($commitHistory)
|| isset($authors[\md5($commitHistory['name'])])
) {
continue;
}
$authors[\md5($commitHistory['name'])] = $commitHistory;
}
}
}
return $authors;
} | [
"private",
"function",
"getAuthorListFrom",
"(",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePathCollection",
"(",
"$",
"this",
"->",
"currentPath",
")",
";",
"$",
"authors",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"f... | Retrieve the author list from the given path via calling git.
@return array | [
"Retrieve",
"the",
"author",
"list",
"from",
"the",
"given",
"path",
"via",
"calling",
"git",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L126-L156 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.collectFilesWithCommits | public function collectFilesWithCommits(GitRepository $git)
{
// git show --format="%H" --quiet
$lastCommitId = $git->show()->format('%H')->execute('--quiet');
$cacheId = \md5(__FUNCTION__ . $lastCommitId);
if ($this->cachePool->has($cacheId)) {
$fromCache = $this->cachePool->get($cacheId);
$this->commitCollection = $fromCache['commitCollection'];
$this->filePathMapping = $fromCache['filePathMapping'];
$this->filePathCollection = $fromCache['filePathCollection'];
return;
}
$commitCollection = [];
$filePathMapping = [];
$filePathCollection = [];
$this->prepareCommitCollection(
$git,
$this->fetchAllCommits($git, $lastCommitId),
$commitCollection,
$filePathMapping,
$filePathCollection
);
$this->cachePool->set(
$cacheId,
[
'commitCollection' => $commitCollection,
'filePathMapping' => $filePathMapping,
'filePathCollection' => $filePathCollection
]
);
$this->commitCollection = $commitCollection;
$this->filePathMapping = $filePathMapping;
$this->filePathCollection = $filePathCollection;
} | php | public function collectFilesWithCommits(GitRepository $git)
{
// git show --format="%H" --quiet
$lastCommitId = $git->show()->format('%H')->execute('--quiet');
$cacheId = \md5(__FUNCTION__ . $lastCommitId);
if ($this->cachePool->has($cacheId)) {
$fromCache = $this->cachePool->get($cacheId);
$this->commitCollection = $fromCache['commitCollection'];
$this->filePathMapping = $fromCache['filePathMapping'];
$this->filePathCollection = $fromCache['filePathCollection'];
return;
}
$commitCollection = [];
$filePathMapping = [];
$filePathCollection = [];
$this->prepareCommitCollection(
$git,
$this->fetchAllCommits($git, $lastCommitId),
$commitCollection,
$filePathMapping,
$filePathCollection
);
$this->cachePool->set(
$cacheId,
[
'commitCollection' => $commitCollection,
'filePathMapping' => $filePathMapping,
'filePathCollection' => $filePathCollection
]
);
$this->commitCollection = $commitCollection;
$this->filePathMapping = $filePathMapping;
$this->filePathCollection = $filePathCollection;
} | [
"public",
"function",
"collectFilesWithCommits",
"(",
"GitRepository",
"$",
"git",
")",
"{",
"// git show --format=\"%H\" --quiet",
"$",
"lastCommitId",
"=",
"$",
"git",
"->",
"show",
"(",
")",
"->",
"format",
"(",
"'%H'",
")",
"->",
"execute",
"(",
"'--quiet'",... | Collect all files with their commits.
@param GitRepository $git The git repository.
@return void | [
"Collect",
"all",
"files",
"with",
"their",
"commits",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L196-L236 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.prepareCommitCollection | private function prepareCommitCollection(
GitRepository $git,
array $logList,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($logList as $log) {
$currentCacheId = \md5(__FUNCTION__ . $log['commit']);
if ($this->cachePool->has($currentCacheId)) {
$fromCurrentCache = $this->cachePool->get($currentCacheId);
$commitCollection = \array_merge($filePathMapping, $fromCurrentCache['commitCollection']);
$filePathMapping = \array_merge($filePathMapping, $fromCurrentCache['filePathMapping']);
$filePathCollection = \array_merge($filePathCollection, $fromCurrentCache['filePathCollection']);
break;
}
$matches = $this->matchFileInformation($this->fetchNameStatusFromCommit($log['commit'], $git));
if (!\count($matches)) {
continue;
}
$changeCollection = [];
foreach ($matches as $match) {
$changeCollection[] = \array_filter(\array_filter($match), 'is_string', ARRAY_FILTER_USE_KEY);
}
$this->prepareChangeCollection(
$log,
$changeCollection,
$commitCollection,
$filePathMapping,
$filePathCollection
);
}
} | php | private function prepareCommitCollection(
GitRepository $git,
array $logList,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($logList as $log) {
$currentCacheId = \md5(__FUNCTION__ . $log['commit']);
if ($this->cachePool->has($currentCacheId)) {
$fromCurrentCache = $this->cachePool->get($currentCacheId);
$commitCollection = \array_merge($filePathMapping, $fromCurrentCache['commitCollection']);
$filePathMapping = \array_merge($filePathMapping, $fromCurrentCache['filePathMapping']);
$filePathCollection = \array_merge($filePathCollection, $fromCurrentCache['filePathCollection']);
break;
}
$matches = $this->matchFileInformation($this->fetchNameStatusFromCommit($log['commit'], $git));
if (!\count($matches)) {
continue;
}
$changeCollection = [];
foreach ($matches as $match) {
$changeCollection[] = \array_filter(\array_filter($match), 'is_string', ARRAY_FILTER_USE_KEY);
}
$this->prepareChangeCollection(
$log,
$changeCollection,
$commitCollection,
$filePathMapping,
$filePathCollection
);
}
} | [
"private",
"function",
"prepareCommitCollection",
"(",
"GitRepository",
"$",
"git",
",",
"array",
"$",
"logList",
",",
"array",
"&",
"$",
"commitCollection",
",",
"array",
"&",
"$",
"filePathMapping",
",",
"array",
"&",
"$",
"filePathCollection",
")",
"{",
"fo... | Prepare the collection of commits from the git log.
@param GitRepository $git The git repository.
@param array $logList The collection of commits from the git log.
@param array $commitCollection The commit collection.
@param array $filePathMapping The file path mapping.
@param array $filePathCollection The file path collection.
@return void | [
"Prepare",
"the",
"collection",
"of",
"commits",
"from",
"the",
"git",
"log",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L269-L306 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.prepareChangeCollection | private function prepareChangeCollection(
array $commit,
array $changeCollection,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($changeCollection as $change) {
if (!isset($commit['containedPath'])) {
$commit['containedPath'] = [];
}
if (!isset($commit['information'])) {
$commit['information'] = [];
}
if (isset($change['criteria'])) {
$changeToHash = \md5($change['to']);
$changeFromHash = \md5($change['from']);
$commit['containedPath'][$changeToHash] = $change['to'];
$commit['information'][$changeToHash] = $change;
$filePathMapping[$changeToHash] = $change['to'];
$filePathMapping[$changeFromHash] = $change['from'];
$filePathCollection[$changeToHash]['commits'][$commit['commit']] = $commit;
$filePathCollection[$changeFromHash]['commits'][$commit['commit']] = $commit;
$commitCollection[$commit['commit']] = $commit;
continue;
}
$fileHash = \md5($change['file']);
$commit['containedPath'][$fileHash] = $change['file'];
$commit['information'][$fileHash] = $change;
$filePathMapping[$fileHash] = $change['file'];
$filePathCollection[$fileHash]['commits'][$commit['commit']] = $commit;
$commitCollection[$commit['commit']] = $commit;
}
} | php | private function prepareChangeCollection(
array $commit,
array $changeCollection,
array &$commitCollection,
array &$filePathMapping,
array &$filePathCollection
) {
foreach ($changeCollection as $change) {
if (!isset($commit['containedPath'])) {
$commit['containedPath'] = [];
}
if (!isset($commit['information'])) {
$commit['information'] = [];
}
if (isset($change['criteria'])) {
$changeToHash = \md5($change['to']);
$changeFromHash = \md5($change['from']);
$commit['containedPath'][$changeToHash] = $change['to'];
$commit['information'][$changeToHash] = $change;
$filePathMapping[$changeToHash] = $change['to'];
$filePathMapping[$changeFromHash] = $change['from'];
$filePathCollection[$changeToHash]['commits'][$commit['commit']] = $commit;
$filePathCollection[$changeFromHash]['commits'][$commit['commit']] = $commit;
$commitCollection[$commit['commit']] = $commit;
continue;
}
$fileHash = \md5($change['file']);
$commit['containedPath'][$fileHash] = $change['file'];
$commit['information'][$fileHash] = $change;
$filePathMapping[$fileHash] = $change['file'];
$filePathCollection[$fileHash]['commits'][$commit['commit']] = $commit;
$commitCollection[$commit['commit']] = $commit;
}
} | [
"private",
"function",
"prepareChangeCollection",
"(",
"array",
"$",
"commit",
",",
"array",
"$",
"changeCollection",
",",
"array",
"&",
"$",
"commitCollection",
",",
"array",
"&",
"$",
"filePathMapping",
",",
"array",
"&",
"$",
"filePathCollection",
")",
"{",
... | Prepare the collection for commit, file path mapping and the file path.
@param array $commit The commit information.
@param array $changeCollection The change collection.
@param array $commitCollection The commit collection.
@param array $filePathMapping The file path mapping.
@param array $filePathCollection The file path collection.
@return void | [
"Prepare",
"the",
"collection",
"for",
"commit",
"file",
"path",
"mapping",
"and",
"the",
"file",
"path",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L319-L364 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.getFilePathCollection | private function getFilePathCollection($path)
{
$key = \array_flip($this->filePathMapping)[$path];
return $this->filePathCollection[$key];
} | php | private function getFilePathCollection($path)
{
$key = \array_flip($this->filePathMapping)[$path];
return $this->filePathCollection[$key];
} | [
"private",
"function",
"getFilePathCollection",
"(",
"$",
"path",
")",
"{",
"$",
"key",
"=",
"\\",
"array_flip",
"(",
"$",
"this",
"->",
"filePathMapping",
")",
"[",
"$",
"path",
"]",
";",
"return",
"$",
"this",
"->",
"filePathCollection",
"[",
"$",
"key... | Get the data to the file path collection.
@param string $path The file path.
@return array | [
"Get",
"the",
"data",
"to",
"the",
"file",
"path",
"collection",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L373-L378 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.setFilePathCollection | private function setFilePathCollection($path, array $data)
{
$key = \array_flip($this->filePathMapping)[$path];
$this->filePathCollection[$key] = $data;
} | php | private function setFilePathCollection($path, array $data)
{
$key = \array_flip($this->filePathMapping)[$path];
$this->filePathCollection[$key] = $data;
} | [
"private",
"function",
"setFilePathCollection",
"(",
"$",
"path",
",",
"array",
"$",
"data",
")",
"{",
"$",
"key",
"=",
"\\",
"array_flip",
"(",
"$",
"this",
"->",
"filePathMapping",
")",
"[",
"$",
"path",
"]",
";",
"$",
"this",
"->",
"filePathCollection... | Set the data to the file path collection.
@param string $path The file path.
@param array $data The file path data.
@return void | [
"Set",
"the",
"data",
"to",
"the",
"file",
"path",
"collection",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L388-L393 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.countMergeCommits | private function countMergeCommits(array $commitList)
{
$count = 0;
foreach ($commitList as $filePathCommit) {
if (!$this->isMergeCommit($filePathCommit)) {
continue;
}
$count++;
}
return $count;
} | php | private function countMergeCommits(array $commitList)
{
$count = 0;
foreach ($commitList as $filePathCommit) {
if (!$this->isMergeCommit($filePathCommit)) {
continue;
}
$count++;
}
return $count;
} | [
"private",
"function",
"countMergeCommits",
"(",
"array",
"$",
"commitList",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"commitList",
"as",
"$",
"filePathCommit",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMergeCommit",
"(",
"$",
... | Count merge commits from the commit list.
@param array $commitList The list of commits.
@return int | [
"Count",
"merge",
"commits",
"from",
"the",
"commit",
"list",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L402-L414 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.buildFileHistory | private function buildFileHistory(GitRepository $git)
{
$filePath = $this->getFilePathCollection($this->currentPath);
// If the commit history only merges,
// then use the last merge commit for find the renaming file for follow the history.
if (\count((array) $filePath['commits']) === $this->countMergeCommits($filePath['commits'])) {
$commit = $filePath['commits'][\array_reverse(\array_keys($filePath['commits']))[0]];
if ($this->isMergeCommit($commit)) {
$parents = \explode(' ', $commit['parent']);
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'diff',
$commit['commit'],
$parents[1],
'--diff-filter=R',
'--name-status',
'--format=',
'-M'
];
// git diff currentCommit rightCommit --diff-filter=R --name-status --format='' -M
$matches = $this->matchFileInformation($this->runCustomGit($arguments, $git));
foreach ($matches as $match) {
if (!\in_array($this->currentPath, $match)) {
continue;
}
$this->currentPath = $match['to'];
$filePath = $this->getFilePathCollection($this->currentPath);
break;
}
}
}
$fileHistory = $this->fetchFileHistory($this->currentPath, $git);
if (!\count($fileHistory)) {
return;
}
foreach ($fileHistory as $pathHistory) {
$filePath['pathHistory'][\md5($pathHistory)] = $this->getFilePathCollection($pathHistory);
}
$this->setFilePathCollection($this->currentPath, $filePath);
} | php | private function buildFileHistory(GitRepository $git)
{
$filePath = $this->getFilePathCollection($this->currentPath);
// If the commit history only merges,
// then use the last merge commit for find the renaming file for follow the history.
if (\count((array) $filePath['commits']) === $this->countMergeCommits($filePath['commits'])) {
$commit = $filePath['commits'][\array_reverse(\array_keys($filePath['commits']))[0]];
if ($this->isMergeCommit($commit)) {
$parents = \explode(' ', $commit['parent']);
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'diff',
$commit['commit'],
$parents[1],
'--diff-filter=R',
'--name-status',
'--format=',
'-M'
];
// git diff currentCommit rightCommit --diff-filter=R --name-status --format='' -M
$matches = $this->matchFileInformation($this->runCustomGit($arguments, $git));
foreach ($matches as $match) {
if (!\in_array($this->currentPath, $match)) {
continue;
}
$this->currentPath = $match['to'];
$filePath = $this->getFilePathCollection($this->currentPath);
break;
}
}
}
$fileHistory = $this->fetchFileHistory($this->currentPath, $git);
if (!\count($fileHistory)) {
return;
}
foreach ($fileHistory as $pathHistory) {
$filePath['pathHistory'][\md5($pathHistory)] = $this->getFilePathCollection($pathHistory);
}
$this->setFilePathCollection($this->currentPath, $filePath);
} | [
"private",
"function",
"buildFileHistory",
"(",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePathCollection",
"(",
"$",
"this",
"->",
"currentPath",
")",
";",
"// If the commit history only merges,",
"// then use the last mer... | Build the file history.
@param GitRepository $git The git repository.
@return void | [
"Build",
"the",
"file",
"history",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L423-L469 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.getFileContent | private function getFileContent($search, GitRepository $git)
{
$cacheId = \md5(__FUNCTION__ . $search);
if (!$this->cachePool->has($cacheId)) {
$fileContent = $git->show()->execute($search);
$this->cachePool->set($cacheId, $fileContent);
return $fileContent;
}
return $this->cachePool->get($cacheId);
} | php | private function getFileContent($search, GitRepository $git)
{
$cacheId = \md5(__FUNCTION__ . $search);
if (!$this->cachePool->has($cacheId)) {
$fileContent = $git->show()->execute($search);
$this->cachePool->set($cacheId, $fileContent);
return $fileContent;
}
return $this->cachePool->get($cacheId);
} | [
"private",
"function",
"getFileContent",
"(",
"$",
"search",
",",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"cacheId",
"=",
"\\",
"md5",
"(",
"__FUNCTION__",
".",
"$",
"search",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cachePool",
"->",
"has",
... | Get the file content.
@param string $search The search key (COMMIT:FILE_PATH).
@param GitRepository $git The git repository.
@return string | [
"Get",
"the",
"file",
"content",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L479-L491 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.fetchNameStatusFromCommit | private function fetchNameStatusFromCommit($commitId, GitRepository $git)
{
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'show',
$commitId,
'-M',
'--name-status',
'--format='
];
// git show $commitId -M --name-status --format=''
return $this->runCustomGit($arguments, $git);
} | php | private function fetchNameStatusFromCommit($commitId, GitRepository $git)
{
$arguments = [
$git->getConfig()->getGitExecutablePath(),
'show',
$commitId,
'-M',
'--name-status',
'--format='
];
// git show $commitId -M --name-status --format=''
return $this->runCustomGit($arguments, $git);
} | [
"private",
"function",
"fetchNameStatusFromCommit",
"(",
"$",
"commitId",
",",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"arguments",
"=",
"[",
"$",
"git",
"->",
"getConfig",
"(",
")",
"->",
"getGitExecutablePath",
"(",
")",
",",
"'show'",
",",
"$",
"com... | Fetch the file names with status from the commit.
@param string $commitId The commit identifier.
@param GitRepository $git The git repository.
@return string | [
"Fetch",
"the",
"file",
"names",
"with",
"status",
"from",
"the",
"commit",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L501-L514 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.fetchCurrentCommit | private function fetchCurrentCommit(GitRepository $git)
{
return \json_decode(
\sprintf(
'[%s]',
// git show --format=$this->logFormat() --quiet
$git->show()->format($this->logFormat())->execute('--quiet')
),
true
);
} | php | private function fetchCurrentCommit(GitRepository $git)
{
return \json_decode(
\sprintf(
'[%s]',
// git show --format=$this->logFormat() --quiet
$git->show()->format($this->logFormat())->execute('--quiet')
),
true
);
} | [
"private",
"function",
"fetchCurrentCommit",
"(",
"GitRepository",
"$",
"git",
")",
"{",
"return",
"\\",
"json_decode",
"(",
"\\",
"sprintf",
"(",
"'[%s]'",
",",
"// git show --format=$this->logFormat() --quiet",
"$",
"git",
"->",
"show",
"(",
")",
"->",
"format",... | Fetch the current commit.
@param GitRepository $git The git repository.
@return array | [
"Fetch",
"the",
"current",
"commit",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L523-L533 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.fetchAllCommits | private function fetchAllCommits(GitRepository $git)
{
$currentCommit = $this->fetchCurrentCommit($git);
$cacheId = \md5(__FUNCTION__ . \serialize($currentCommit));
if (!$this->cachePool->has($cacheId)) {
$logList = \json_decode(
\sprintf(
'[%s]',
\trim(
// git log --simplify-merges --format=$this->logFormat()
$git->log()->simplifyMerges()->format($this->logFormat() . ',')->execute(),
','
)
),
true
);
$this->cachePool->set($cacheId, $logList);
return $logList;
}
return $this->cachePool->get($cacheId);
} | php | private function fetchAllCommits(GitRepository $git)
{
$currentCommit = $this->fetchCurrentCommit($git);
$cacheId = \md5(__FUNCTION__ . \serialize($currentCommit));
if (!$this->cachePool->has($cacheId)) {
$logList = \json_decode(
\sprintf(
'[%s]',
\trim(
// git log --simplify-merges --format=$this->logFormat()
$git->log()->simplifyMerges()->format($this->logFormat() . ',')->execute(),
','
)
),
true
);
$this->cachePool->set($cacheId, $logList);
return $logList;
}
return $this->cachePool->get($cacheId);
} | [
"private",
"function",
"fetchAllCommits",
"(",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"currentCommit",
"=",
"$",
"this",
"->",
"fetchCurrentCommit",
"(",
"$",
"git",
")",
";",
"$",
"cacheId",
"=",
"\\",
"md5",
"(",
"__FUNCTION__",
".",
"\\",
"serializ... | Fetch the git log with simplify merges.
@param GitRepository $git The git repository.
@return array | [
"Fetch",
"the",
"git",
"log",
"with",
"simplify",
"merges",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L542-L567 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.fetchFileHistory | private function fetchFileHistory($path, GitRepository $git)
{
$fileHistory = [];
foreach ($this->fetchCommitCollectionByPath($path, $git) as $logItem) {
// If the renaming/copy to not found in the file history, then continue the loop.
if (\count($fileHistory) && !\in_array($logItem['to'], $fileHistory)) {
continue;
}
// If the file history empty (also by the start for the detection) and the to path not exactly the same
// with the same path, then continue the loop.
if (($logItem['to'] !== $path) && !\count($fileHistory)) {
continue;
}
$this->executeFollowDetection($logItem, $fileHistory, $git);
}
return $fileHistory;
} | php | private function fetchFileHistory($path, GitRepository $git)
{
$fileHistory = [];
foreach ($this->fetchCommitCollectionByPath($path, $git) as $logItem) {
// If the renaming/copy to not found in the file history, then continue the loop.
if (\count($fileHistory) && !\in_array($logItem['to'], $fileHistory)) {
continue;
}
// If the file history empty (also by the start for the detection) and the to path not exactly the same
// with the same path, then continue the loop.
if (($logItem['to'] !== $path) && !\count($fileHistory)) {
continue;
}
$this->executeFollowDetection($logItem, $fileHistory, $git);
}
return $fileHistory;
} | [
"private",
"function",
"fetchFileHistory",
"(",
"$",
"path",
",",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"fileHistory",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"fetchCommitCollectionByPath",
"(",
"$",
"path",
",",
"$",
"git",
")",
"as... | Fetch the history for the file.
@param string $path The file path.
@param GitRepository $git The git repository.
@return array | [
"Fetch",
"the",
"history",
"for",
"the",
"file",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L577-L596 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.fetchCommitCollectionByPath | private function fetchCommitCollectionByPath($path, GitRepository $git)
{
// git log --follow --name-status --format='%H' -- $path
$log = $git->log()->follow()->revisionRange('--name-status')->revisionRange('--format=%H')->execute($path);
\preg_match_all(
"/^(?'commit'.*)\n+(?'criteria'[RC])(?'index'[\d]{3})\t(?'from'.+)\t(?'to'.+)\n/m",
$log,
$matches,
PREG_SET_ORDER
);
if (!\count($matches)) {
return [];
}
$logCollection = [];
foreach ((array) $matches as $match) {
$logCollection[] = \array_filter($match, 'is_string', ARRAY_FILTER_USE_KEY);
}
return $logCollection;
} | php | private function fetchCommitCollectionByPath($path, GitRepository $git)
{
// git log --follow --name-status --format='%H' -- $path
$log = $git->log()->follow()->revisionRange('--name-status')->revisionRange('--format=%H')->execute($path);
\preg_match_all(
"/^(?'commit'.*)\n+(?'criteria'[RC])(?'index'[\d]{3})\t(?'from'.+)\t(?'to'.+)\n/m",
$log,
$matches,
PREG_SET_ORDER
);
if (!\count($matches)) {
return [];
}
$logCollection = [];
foreach ((array) $matches as $match) {
$logCollection[] = \array_filter($match, 'is_string', ARRAY_FILTER_USE_KEY);
}
return $logCollection;
} | [
"private",
"function",
"fetchCommitCollectionByPath",
"(",
"$",
"path",
",",
"GitRepository",
"$",
"git",
")",
"{",
"// git log --follow --name-status --format='%H' -- $path",
"$",
"log",
"=",
"$",
"git",
"->",
"log",
"(",
")",
"->",
"follow",
"(",
")",
"->",
"r... | Fetch the commit collection by the file path.
@param string $path The file path.
@param GitRepository $git The git repository.
@return array | [
"Fetch",
"the",
"commit",
"collection",
"by",
"the",
"file",
"path",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L606-L627 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.executeFollowDetection | private function executeFollowDetection(array $logItem, array &$fileHistory, GitRepository $git)
{
$currentCommit = $this->commitCollection[$logItem['commit']];
if (($logItem['index'] <= 70) && \in_array($logItem['criteria'], ['R', 'C'])) {
if (isset($currentCommit['information'][\md5($logItem['to'])])) {
$pathInformation = $currentCommit['information'][\md5($logItem['to'])];
if (isset($pathInformation['status']) && ($pathInformation['status'] === 'A')) {
return;
}
}
}
$this->renamingDetection($logItem, $currentCommit, $fileHistory, $git);
$this->copyDetection($logItem, $fileHistory, $git);
} | php | private function executeFollowDetection(array $logItem, array &$fileHistory, GitRepository $git)
{
$currentCommit = $this->commitCollection[$logItem['commit']];
if (($logItem['index'] <= 70) && \in_array($logItem['criteria'], ['R', 'C'])) {
if (isset($currentCommit['information'][\md5($logItem['to'])])) {
$pathInformation = $currentCommit['information'][\md5($logItem['to'])];
if (isset($pathInformation['status']) && ($pathInformation['status'] === 'A')) {
return;
}
}
}
$this->renamingDetection($logItem, $currentCommit, $fileHistory, $git);
$this->copyDetection($logItem, $fileHistory, $git);
} | [
"private",
"function",
"executeFollowDetection",
"(",
"array",
"$",
"logItem",
",",
"array",
"&",
"$",
"fileHistory",
",",
"GitRepository",
"$",
"git",
")",
"{",
"$",
"currentCommit",
"=",
"$",
"this",
"->",
"commitCollection",
"[",
"$",
"logItem",
"[",
"'co... | Execute the file follow detection.
@param array $logItem The git log item.
@param array $fileHistory The file history.
@param GitRepository $git The git repository.
@return void | [
"Execute",
"the",
"file",
"follow",
"detection",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L638-L654 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.renamingDetection | private function renamingDetection(array $logItem, array $currentCommit, array &$fileHistory, GitRepository $git)
{
if ($logItem['criteria'] !== 'R') {
return;
}
if ((int) $logItem['index'] >= 75) {
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
return;
}
$fromFileContent = $this->getFileContent($currentCommit['parent'] . ':' . $logItem['from'], $git);
$toFileContent = $this->getFileContent($logItem['commit'] . ':' . $logItem['to'], $git);
$tempFrom =
$this->createTempFile($logItem['commit'] . ':' . $logItem['from'], $fromFileContent);
$tempTo = $this->createTempFile($logItem['commit'] . ':' . $logItem['to'], $toFileContent);
$detector = new Detector(new DefaultStrategy());
$result = $detector->copyPasteDetection([$tempFrom, $tempTo], 2, 7);
if (!$result->count()) {
return;
}
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
} | php | private function renamingDetection(array $logItem, array $currentCommit, array &$fileHistory, GitRepository $git)
{
if ($logItem['criteria'] !== 'R') {
return;
}
if ((int) $logItem['index'] >= 75) {
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
return;
}
$fromFileContent = $this->getFileContent($currentCommit['parent'] . ':' . $logItem['from'], $git);
$toFileContent = $this->getFileContent($logItem['commit'] . ':' . $logItem['to'], $git);
$tempFrom =
$this->createTempFile($logItem['commit'] . ':' . $logItem['from'], $fromFileContent);
$tempTo = $this->createTempFile($logItem['commit'] . ':' . $logItem['to'], $toFileContent);
$detector = new Detector(new DefaultStrategy());
$result = $detector->copyPasteDetection([$tempFrom, $tempTo], 2, 7);
if (!$result->count()) {
return;
}
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
} | [
"private",
"function",
"renamingDetection",
"(",
"array",
"$",
"logItem",
",",
"array",
"$",
"currentCommit",
",",
"array",
"&",
"$",
"fileHistory",
",",
"GitRepository",
"$",
"git",
")",
"{",
"if",
"(",
"$",
"logItem",
"[",
"'criteria'",
"]",
"!==",
"'R'"... | Detected file follow by the renaming criteria.
@param array $logItem The git log item.
@param array $currentCommit The current commit information.
@param array $fileHistory The file history.
@param GitRepository $git The git repository.
@return void | [
"Detected",
"file",
"follow",
"by",
"the",
"renaming",
"criteria",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L666-L692 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.copyDetection | private function copyDetection(array $logItem, array &$fileHistory, GitRepository $git)
{
if ($logItem['criteria'] !== 'C') {
return;
}
$fromLastCommit = $this->commitCollection[$logItem['commit']]['parent'];
$fromFileContent = $this->getFileContent($fromLastCommit . ':' . $logItem['from'], $git);
$fromFileContentLength = \strlen($fromFileContent);
$toFileContent = $this->getFileContent($logItem['commit'] . ':' . $logItem['to'], $git);
$toFileContentLength = \strlen($toFileContent);
if ($fromFileContentLength === $toFileContentLength) {
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
return;
}
$tempFrom =
$this->createTempFile($logItem['commit'] . ':' . $logItem['from'], $fromFileContent);
$tempTo = $this->createTempFile($logItem['commit'] . ':' . $logItem['to'], $toFileContent);
$detector = new Detector(new DefaultStrategy());
$result = $detector->copyPasteDetection([$tempFrom, $tempTo], 5, 35);
if (!$result->count()) {
return;
}
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
} | php | private function copyDetection(array $logItem, array &$fileHistory, GitRepository $git)
{
if ($logItem['criteria'] !== 'C') {
return;
}
$fromLastCommit = $this->commitCollection[$logItem['commit']]['parent'];
$fromFileContent = $this->getFileContent($fromLastCommit . ':' . $logItem['from'], $git);
$fromFileContentLength = \strlen($fromFileContent);
$toFileContent = $this->getFileContent($logItem['commit'] . ':' . $logItem['to'], $git);
$toFileContentLength = \strlen($toFileContent);
if ($fromFileContentLength === $toFileContentLength) {
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
return;
}
$tempFrom =
$this->createTempFile($logItem['commit'] . ':' . $logItem['from'], $fromFileContent);
$tempTo = $this->createTempFile($logItem['commit'] . ':' . $logItem['to'], $toFileContent);
$detector = new Detector(new DefaultStrategy());
$result = $detector->copyPasteDetection([$tempFrom, $tempTo], 5, 35);
if (!$result->count()) {
return;
}
$fileHistory[\md5($logItem['from'])] = $logItem['from'];
} | [
"private",
"function",
"copyDetection",
"(",
"array",
"$",
"logItem",
",",
"array",
"&",
"$",
"fileHistory",
",",
"GitRepository",
"$",
"git",
")",
"{",
"if",
"(",
"$",
"logItem",
"[",
"'criteria'",
"]",
"!==",
"'C'",
")",
"{",
"return",
";",
"}",
"$",... | Detected file follow by the copy criteria.
@param array $logItem The git log item.
@param array $fileHistory The file history.
@param GitRepository $git The git repository.
@return void | [
"Detected",
"file",
"follow",
"by",
"the",
"copy",
"criteria",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L703-L734 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.createTempFile | private function createTempFile($name, $content)
{
$tempDir = \sys_get_temp_dir();
$fileName = \md5($name);
$filePath = $tempDir . DIRECTORY_SEPARATOR . 'phpcq-author-validation' . DIRECTORY_SEPARATOR . $fileName;
if (\file_exists($filePath)) {
return $filePath;
}
if (!\file_exists(\dirname($filePath)) && !\mkdir($concurrentDirectory = \dirname($filePath))
&& !is_dir(
$concurrentDirectory
)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
$file = \fopen($filePath, 'wb');
\fwrite($file, $content);
return $filePath;
} | php | private function createTempFile($name, $content)
{
$tempDir = \sys_get_temp_dir();
$fileName = \md5($name);
$filePath = $tempDir . DIRECTORY_SEPARATOR . 'phpcq-author-validation' . DIRECTORY_SEPARATOR . $fileName;
if (\file_exists($filePath)) {
return $filePath;
}
if (!\file_exists(\dirname($filePath)) && !\mkdir($concurrentDirectory = \dirname($filePath))
&& !is_dir(
$concurrentDirectory
)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
$file = \fopen($filePath, 'wb');
\fwrite($file, $content);
return $filePath;
} | [
"private",
"function",
"createTempFile",
"(",
"$",
"name",
",",
"$",
"content",
")",
"{",
"$",
"tempDir",
"=",
"\\",
"sys_get_temp_dir",
"(",
")",
";",
"$",
"fileName",
"=",
"\\",
"md5",
"(",
"$",
"name",
")",
";",
"$",
"filePath",
"=",
"$",
"tempDir... | Create a temporary file.
@param string $name The file name.
@param string $content The file content.
@return string
@throws \RuntimeException Throws an exception if the directory not created for the file. | [
"Create",
"a",
"temporary",
"file",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L746-L768 | train |
phpcq/author-validation | src/AuthorExtractor/GitAuthorExtractor.php | GitAuthorExtractor.removeTempDirectory | private function removeTempDirectory()
{
$tempDir = \sys_get_temp_dir();
$directoryPath = $tempDir . DIRECTORY_SEPARATOR . 'phpcq-author-validation';
if (!\file_exists($directoryPath)) {
return;
}
$directory = \opendir($directoryPath);
while (($file = \readdir($directory)) !== false) {
if (\in_array($file, ['.', '..'])) {
continue;
}
\unlink($directoryPath . DIRECTORY_SEPARATOR . $file);
}
\rmdir($directoryPath);
} | php | private function removeTempDirectory()
{
$tempDir = \sys_get_temp_dir();
$directoryPath = $tempDir . DIRECTORY_SEPARATOR . 'phpcq-author-validation';
if (!\file_exists($directoryPath)) {
return;
}
$directory = \opendir($directoryPath);
while (($file = \readdir($directory)) !== false) {
if (\in_array($file, ['.', '..'])) {
continue;
}
\unlink($directoryPath . DIRECTORY_SEPARATOR . $file);
}
\rmdir($directoryPath);
} | [
"private",
"function",
"removeTempDirectory",
"(",
")",
"{",
"$",
"tempDir",
"=",
"\\",
"sys_get_temp_dir",
"(",
")",
";",
"$",
"directoryPath",
"=",
"$",
"tempDir",
".",
"DIRECTORY_SEPARATOR",
".",
"'phpcq-author-validation'",
";",
"if",
"(",
"!",
"\\",
"file... | Remove the temporary directory.
@return void | [
"Remove",
"the",
"temporary",
"directory",
"."
] | 1e22f6133dcadea486a7961274f4e611b5ef4c0c | https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitAuthorExtractor.php#L775-L795 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.save | public function save()
{
$this->load();
// Do the work in case we have only changed hash
if ($this->isChanged()) {
@chmod($this->path, 0777);
return file_put_contents($this->path, $this->fileType->render($this->config));
} else {
return true;
}
} | php | public function save()
{
$this->load();
// Do the work in case we have only changed hash
if ($this->isChanged()) {
@chmod($this->path, 0777);
return file_put_contents($this->path, $this->fileType->render($this->config));
} else {
return true;
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"// Do the work in case we have only changed hash",
"if",
"(",
"$",
"this",
"->",
"isChanged",
"(",
")",
")",
"{",
"@",
"chmod",
"(",
"$",
"this",
"->",
"path",
",",
... | Saves the content to the disk
@param array $array
@return boolean Depending on success | [
"Saves",
"the",
"content",
"to",
"the",
"disk"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L106-L116 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.store | public function store($key, $value)
{
$this->load();
$this->config[$key] = $value;
return true;
} | php | public function store($key, $value)
{
$this->load();
$this->config[$key] = $value;
return true;
} | [
"public",
"function",
"store",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"true",
";",
"}"
] | Writes configuration pair
@param string $key
@param string $value
@return boolean | [
"Writes",
"configuration",
"pair"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L125-L131 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.storeMany | public function storeMany(array $pair)
{
foreach ($pair as $key => $value) {
$this->set($key, $value);
}
return true;
} | php | public function storeMany(array $pair)
{
foreach ($pair as $key => $value) {
$this->set($key, $value);
}
return true;
} | [
"public",
"function",
"storeMany",
"(",
"array",
"$",
"pair",
")",
"{",
"foreach",
"(",
"$",
"pair",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"true",
... | Sets a collection
@param array $pair
@return boolean | [
"Sets",
"a",
"collection"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L139-L146 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.get | public function get($key, $default = false)
{
$this->load();
if ($this->has($key)) {
return $this->config[$key];
} else {
return $default;
}
} | php | public function get($key, $default = false)
{
$this->load();
if ($this->has($key)) {
return $this->config[$key];
} else {
return $default;
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"... | Reads a value by a given key
@param string $key
@param mixed $default Default value to be returned in $key doesn't exist
@return mixed | [
"Reads",
"a",
"value",
"by",
"a",
"given",
"key"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L184-L193 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.remove | public function remove($key)
{
$this->load();
if ($this->exists($key)) {
unset($this->config[$key]);
return true;
} else {
throw new RuntimeException(sprintf('Attempted to read non-existing key "%s"', $key));
}
} | php | public function remove($key)
{
$this->load();
if ($this->exists($key)) {
unset($this->config[$key]);
return true;
} else {
throw new RuntimeException(sprintf('Attempted to read non-existing key "%s"', $key));
}
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"load",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
")",... | Deletes configuration value by its associated key
@param string $key
@throws \RuntimeException if attempted to remove by non-existing key
@return boolean | [
"Deletes",
"configuration",
"value",
"by",
"its",
"associated",
"key"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L202-L212 | train |
krystal-framework/krystal.framework | src/Krystal/Config/File/FileConfigService.php | FileConfigService.load | private function load()
{
if ($this->loaded === false) {
if ($this->autoCreate === true) {
if (!is_file($this->path)) {
$this->touch();
}
}
$array = $this->fileType->fetch($this->path);
if (is_array($array)) {
// Keep initial array hash
$this->hash = $this->serializer->buildHash($array);
$this->config = $array;
$this->loaded = true;
return true;
} else {
throw new LogicException(sprintf(
'Required file should return an array and only, not "%s"', gettype($array)
));
}
}
return true;
} | php | private function load()
{
if ($this->loaded === false) {
if ($this->autoCreate === true) {
if (!is_file($this->path)) {
$this->touch();
}
}
$array = $this->fileType->fetch($this->path);
if (is_array($array)) {
// Keep initial array hash
$this->hash = $this->serializer->buildHash($array);
$this->config = $array;
$this->loaded = true;
return true;
} else {
throw new LogicException(sprintf(
'Required file should return an array and only, not "%s"', gettype($array)
));
}
}
return true;
} | [
"private",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loaded",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"autoCreate",
"===",
"true",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"path",
")",
... | Loads configuration into memory on demand
@throws \LogicException If included file doesn't return an array
@return boolean Depending on success | [
"Loads",
"configuration",
"into",
"memory",
"on",
"demand"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Config/File/FileConfigService.php#L233-L259 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/ServiceLocator.php | ServiceLocator.get | public function get($service)
{
if ($this->has($service)) {
return $this->container[$service];
} else {
throw new RuntimeException(sprintf(
'Attempted to grab non-existing service "%s"', $service
));
}
} | php | public function get($service)
{
if ($this->has($service)) {
return $this->container[$service];
} else {
throw new RuntimeException(sprintf(
'Attempted to grab non-existing service "%s"', $service
));
}
} | [
"public",
"function",
"get",
"(",
"$",
"service",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"service",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"[",
"$",
"service",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Runti... | Returns service's instance by its name
@param string $service Service name
@throws \RuntimeException if attempted to return non-existing service
@return object | [
"Returns",
"service",
"s",
"instance",
"by",
"its",
"name"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/ServiceLocator.php#L56-L65 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/ServiceLocator.php | ServiceLocator.registerArray | public function registerArray(array $instances)
{
foreach ($instances as $name => $instance) {
$this->register($name, $instance);
}
return $this;
} | php | public function registerArray(array $instances)
{
foreach ($instances as $name => $instance) {
$this->register($name, $instance);
}
return $this;
} | [
"public",
"function",
"registerArray",
"(",
"array",
"$",
"instances",
")",
"{",
"foreach",
"(",
"$",
"instances",
"as",
"$",
"name",
"=>",
"$",
"instance",
")",
"{",
"$",
"this",
"->",
"register",
"(",
"$",
"name",
",",
"$",
"instance",
")",
";",
"}... | Registers a collection of service instances
@param array $instances
@return \Krystal\InstanceManager\ServiceLocator | [
"Registers",
"a",
"collection",
"of",
"service",
"instances"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/ServiceLocator.php#L73-L80 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/ServiceLocator.php | ServiceLocator.register | public function register($name, $instance)
{
if (!is_string($name)) {
throw new InvalidArgumentException(sprintf(
'Argument #1 $name must be a string, received "%s"', gettype($name)
));
}
$this->container[$name] = $instance;
return $this;
} | php | public function register($name, $instance)
{
if (!is_string($name)) {
throw new InvalidArgumentException(sprintf(
'Argument #1 $name must be a string, received "%s"', gettype($name)
));
}
$this->container[$name] = $instance;
return $this;
} | [
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"instance",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Argument #1 $name must be a string, received \"%s... | Registers a new service
@param string $name
@param object $instance
@throws \InvalidArgumentException if service name isn't string
@return \Krystal\InstanceManager\ServiceLocator | [
"Registers",
"a",
"new",
"service"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/ServiceLocator.php#L90-L100 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/ServiceLocator.php | ServiceLocator.has | public function has($service)
{
if (!is_string($service)) {
throw new InvalidArgumentException(sprintf(
'Service name must be a string, received "%s"', gettype($service)
));
}
return isset($this->container[$service]);
} | php | public function has($service)
{
if (!is_string($service)) {
throw new InvalidArgumentException(sprintf(
'Service name must be a string, received "%s"', gettype($service)
));
}
return isset($this->container[$service]);
} | [
"public",
"function",
"has",
"(",
"$",
"service",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"service",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Service name must be a string, received \"%s\"'",
",",
"gettype",
"(",... | Check whether service has been registered
@param string $service
@throws \InvalidArgumentException if service's name wasn't a string
@return boolean | [
"Check",
"whether",
"service",
"has",
"been",
"registered"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/ServiceLocator.php#L109-L118 | train |
krystal-framework/krystal.framework | src/Krystal/InstanceManager/ServiceLocator.php | ServiceLocator.remove | public function remove($service)
{
if ($this->has($service)) {
unset($this->container[$service]);
return true;
} else {
trigger_error(sprintf(
'Attempted to un-register non-existing service "%s"', $service
));
return false;
}
} | php | public function remove($service)
{
if ($this->has($service)) {
unset($this->container[$service]);
return true;
} else {
trigger_error(sprintf(
'Attempted to un-register non-existing service "%s"', $service
));
return false;
}
} | [
"public",
"function",
"remove",
"(",
"$",
"service",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"service",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"service",
"]",
")",
";",
"return",
"true",
";",
"}",
... | Removes a registered service
@param string $service
@throws \InvalidArgumentException if $service_name wasn't string
@return boolean Depending on success | [
"Removes",
"a",
"registered",
"service"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/InstanceManager/ServiceLocator.php#L127-L139 | train |
inc2734/mimizuku-core | src/App/Contract/Helper/Template_Tag.php | Template_Tag.get_pure_post_content | public static function get_pure_post_content() {
$post = get_post();
if ( ! $post || ! isset( $post->post_content ) ) {
return;
}
if ( post_password_required( $post ) ) {
return;
}
$extended = get_extended( $post->post_content );
$content = $extended['main'];
return $content;
} | php | public static function get_pure_post_content() {
$post = get_post();
if ( ! $post || ! isset( $post->post_content ) ) {
return;
}
if ( post_password_required( $post ) ) {
return;
}
$extended = get_extended( $post->post_content );
$content = $extended['main'];
return $content;
} | [
"public",
"static",
"function",
"get_pure_post_content",
"(",
")",
"{",
"$",
"post",
"=",
"get_post",
"(",
")",
";",
"if",
"(",
"!",
"$",
"post",
"||",
"!",
"isset",
"(",
"$",
"post",
"->",
"post_content",
")",
")",
"{",
"return",
";",
"}",
"if",
"... | Return pure post content
@return string | [
"Return",
"pure",
"post",
"content"
] | d192a01f4a730e53bced3dfcd0ef29fbecc80330 | https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Template_Tag.php#L36-L50 | train |
inc2734/mimizuku-core | src/App/Contract/Helper/Template_Tag.php | Template_Tag.pure_trim_excerpt | public static function pure_trim_excerpt() {
$raw_excerpt = '';
$text = static::get_pure_post_content();
$text = strip_shortcodes( $text );
$text = str_replace( ']]>', ']]>', $text );
$excerpt_length = apply_filters( 'excerpt_length', 55 );
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
} | php | public static function pure_trim_excerpt() {
$raw_excerpt = '';
$text = static::get_pure_post_content();
$text = strip_shortcodes( $text );
$text = str_replace( ']]>', ']]>', $text );
$excerpt_length = apply_filters( 'excerpt_length', 55 );
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
} | [
"public",
"static",
"function",
"pure_trim_excerpt",
"(",
")",
"{",
"$",
"raw_excerpt",
"=",
"''",
";",
"$",
"text",
"=",
"static",
"::",
"get_pure_post_content",
"(",
")",
";",
"$",
"text",
"=",
"strip_shortcodes",
"(",
"$",
"text",
")",
";",
"$",
"text... | Return pure trim excerpt
@link https://developer.wordpress.org/reference/functions/wp_trim_excerpt/
@return string | [
"Return",
"pure",
"trim",
"excerpt"
] | d192a01f4a730e53bced3dfcd0ef29fbecc80330 | https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Template_Tag.php#L59-L72 | train |
inc2734/mimizuku-core | src/App/Contract/Helper/Template_Tag.php | Template_Tag.get_page_templates | public static function get_page_templates() {
static $wrappers = [];
if ( $wrappers ) {
return $wrappers;
}
$page_templates = new Model\Page_Templates();
$wrappers = $page_templates->get();
return $wrappers;
} | php | public static function get_page_templates() {
static $wrappers = [];
if ( $wrappers ) {
return $wrappers;
}
$page_templates = new Model\Page_Templates();
$wrappers = $page_templates->get();
return $wrappers;
} | [
"public",
"static",
"function",
"get_page_templates",
"(",
")",
"{",
"static",
"$",
"wrappers",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"wrappers",
")",
"{",
"return",
"$",
"wrappers",
";",
"}",
"$",
"page_templates",
"=",
"new",
"Model",
"\\",
"Page_Templat... | Returns array of page templates for layout selector in customizer
@return array
@var string Template slug e.g. right-sidebar
@var string Template name e.g. Right Sidebar | [
"Returns",
"array",
"of",
"page",
"templates",
"for",
"layout",
"selector",
"in",
"customizer"
] | d192a01f4a730e53bced3dfcd0ef29fbecc80330 | https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Template_Tag.php#L175-L184 | train |
manusreload/GLFramework | src/ModelResult.php | ModelResult.last | public function last()
{
if ($this->count()) {
$models = $this->getModels();
return $models[$this->count() - 1];
}
return null;
} | php | public function last()
{
if ($this->count()) {
$models = $this->getModels();
return $models[$this->count() - 1];
}
return null;
} | [
"public",
"function",
"last",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"getModels",
"(",
")",
";",
"return",
"$",
"models",
"[",
"$",
"this",
"->",
"count",
"(",
")",
"-",
... | Obtiene el ultimo modelo de la lista
@return Model|null | [
"Obtiene",
"el",
"ultimo",
"modelo",
"de",
"la",
"lista"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/ModelResult.php#L143-L150 | train |
manusreload/GLFramework | src/ModelResult.php | ModelResult.json | public function json($fields = array(), $recursive = true)
{
$list = array();
foreach ($this->getModels() as $model) {
$list[] = $model->json($fields, $recursive);
}
return $list;
} | php | public function json($fields = array(), $recursive = true)
{
$list = array();
foreach ($this->getModels() as $model) {
$list[] = $model->json($fields, $recursive);
}
return $list;
} | [
"public",
"function",
"json",
"(",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getModels",
"(",
")",
"as",
"$",
"model",
")",
... | Genera una array lista para usar con json_encode
@param array $fields
@param bool $recursive
@return array | [
"Genera",
"una",
"array",
"lista",
"para",
"usar",
"con",
"json_encode"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/ModelResult.php#L159-L166 | train |
manusreload/GLFramework | src/ModelResult.php | ModelResult.order | public function order($field, $desc = false)
{
if(count($this->models) > 0) {
$instance = $this->reflection->newInstance();
$string = $instance->isString($field);
usort($this->models, function ($a, $b) use ($field, $string) {
if($string) {
return strcmp($a[$field], $b[$field]);
}
return $a[$field] - $b[$field];
});
if ($desc) {
$this->models = array_reverse($this->models);
}
}
return $this;
} | php | public function order($field, $desc = false)
{
if(count($this->models) > 0) {
$instance = $this->reflection->newInstance();
$string = $instance->isString($field);
usort($this->models, function ($a, $b) use ($field, $string) {
if($string) {
return strcmp($a[$field], $b[$field]);
}
return $a[$field] - $b[$field];
});
if ($desc) {
$this->models = array_reverse($this->models);
}
}
return $this;
} | [
"public",
"function",
"order",
"(",
"$",
"field",
",",
"$",
"desc",
"=",
"false",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"models",
")",
">",
"0",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"reflection",
"->",
"newInstance",
... | Ordena de menor a mayor en funcion del campo indicado
@param $field
@param bool $desc
@return $this | [
"Ordena",
"de",
"menor",
"a",
"mayor",
"en",
"funcion",
"del",
"campo",
"indicado"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/ModelResult.php#L194-L210 | train |
bookboon/api-php | src/Entity/Question.php | Question.send | public static function send(
Bookboon $bookboon,
array $variables = [],
string $rootSegmentId = ''
) : BookboonResponse {
$url = $rootSegmentId == '' ? '/questions' : '/questions/' . $rootSegmentId;
$bResponse = $bookboon->rawRequest($url, $variables, ClientInterface::HTTP_POST);
return $bResponse;
} | php | public static function send(
Bookboon $bookboon,
array $variables = [],
string $rootSegmentId = ''
) : BookboonResponse {
$url = $rootSegmentId == '' ? '/questions' : '/questions/' . $rootSegmentId;
$bResponse = $bookboon->rawRequest($url, $variables, ClientInterface::HTTP_POST);
return $bResponse;
} | [
"public",
"static",
"function",
"send",
"(",
"Bookboon",
"$",
"bookboon",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
",",
"string",
"$",
"rootSegmentId",
"=",
"''",
")",
":",
"BookboonResponse",
"{",
"$",
"url",
"=",
"$",
"rootSegmentId",
"==",
"''",... | Post Questions.
@param Bookboon $bookboon
@param array $variables
@param string $rootSegmentId
@return BookboonResponse
@throws \Bookboon\Api\Exception\UsageException | [
"Post",
"Questions",
"."
] | dc386b94dd21589606335a5d16a5300c226ecc21 | https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Entity/Question.php#L44-L52 | train |
bookboon/api-php | src/Entity/Book.php | Book.getThumbnail | public function getThumbnail(int $size = 210, bool $ssl = false)
{
$thumbs = [];
foreach ($this->safeGet('thumbnail') as $thumb) {
$thumbs[$thumb['width']] = $thumb['_link'];
}
$sizes = array_keys($thumbs);
while (true) {
$thumbSize = array_shift($sizes);
if ((int) $size <= (int) $thumbSize || count($sizes) === 0) {
return $thumbs[$thumbSize];
}
}
} | php | public function getThumbnail(int $size = 210, bool $ssl = false)
{
$thumbs = [];
foreach ($this->safeGet('thumbnail') as $thumb) {
$thumbs[$thumb['width']] = $thumb['_link'];
}
$sizes = array_keys($thumbs);
while (true) {
$thumbSize = array_shift($sizes);
if ((int) $size <= (int) $thumbSize || count($sizes) === 0) {
return $thumbs[$thumbSize];
}
}
} | [
"public",
"function",
"getThumbnail",
"(",
"int",
"$",
"size",
"=",
"210",
",",
"bool",
"$",
"ssl",
"=",
"false",
")",
"{",
"$",
"thumbs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"safeGet",
"(",
"'thumbnail'",
")",
"as",
"$",
"thumb"... | Returns closes thumbnail size to input, default 210px.
@param int $size appromimate size
@param bool $ssl Whether or not to return https:// url for thumbnail
@return string url for thumbnail | [
"Returns",
"closes",
"thumbnail",
"size",
"to",
"input",
"default",
"210px",
"."
] | dc386b94dd21589606335a5d16a5300c226ecc21 | https://github.com/bookboon/api-php/blob/dc386b94dd21589606335a5d16a5300c226ecc21/src/Entity/Book.php#L295-L309 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/HttpResponse.php | HttpResponse.authenticate | public function authenticate($login, $password)
{
if (!isset($this->server['PHP_AUTH_USER'])) {
$this->forbid();
return false;
} else {
if (($this->server['PHP_AUTH_USER'] == $login) && ($this->server['PHP_AUTH_PW'] == $password)) {
return true;
} else {
$this->forbid();
return false;
}
}
} | php | public function authenticate($login, $password)
{
if (!isset($this->server['PHP_AUTH_USER'])) {
$this->forbid();
return false;
} else {
if (($this->server['PHP_AUTH_USER'] == $login) && ($this->server['PHP_AUTH_PW'] == $password)) {
return true;
} else {
$this->forbid();
return false;
}
}
} | [
"public",
"function",
"authenticate",
"(",
"$",
"login",
",",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"'PHP_AUTH_USER'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"forbid",
"(",
")",
";",
"return",
"f... | Performs HTTP-digest authentication
@param string $login
@param string $password
@return boolean | [
"Performs",
"HTTP",
"-",
"digest",
"authentication"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/HttpResponse.php#L116-L129 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/HttpResponse.php | HttpResponse.setStatusCode | public function setStatusCode($code)
{
$this->headerBag->setStatusCode($code);
$this->statusCode = $code;
return $this;
} | php | public function setStatusCode($code)
{
$this->headerBag->setStatusCode($code);
$this->statusCode = $code;
return $this;
} | [
"public",
"function",
"setStatusCode",
"(",
"$",
"code",
")",
"{",
"$",
"this",
"->",
"headerBag",
"->",
"setStatusCode",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"statusCode",
"=",
"$",
"code",
";",
"return",
"$",
"this",
";",
"}"
] | Prepared and appends HTTP status message to the queue by associated code
@param integer $code
@return \Krystal\Http\Response\HttpResponse | [
"Prepared",
"and",
"appends",
"HTTP",
"status",
"message",
"to",
"the",
"queue",
"by",
"associated",
"code"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/HttpResponse.php#L192-L198 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/HttpResponse.php | HttpResponse.enableCache | public function enableCache($timestamp, $ttl)
{
// HttpCache alters HeaderBag's state internally
$handler = new HttpCache($this->headerBag);
$handler->configure($timestamp, $ttl);
return $this;
} | php | public function enableCache($timestamp, $ttl)
{
// HttpCache alters HeaderBag's state internally
$handler = new HttpCache($this->headerBag);
$handler->configure($timestamp, $ttl);
return $this;
} | [
"public",
"function",
"enableCache",
"(",
"$",
"timestamp",
",",
"$",
"ttl",
")",
"{",
"// HttpCache alters HeaderBag's state internally",
"$",
"handler",
"=",
"new",
"HttpCache",
"(",
"$",
"this",
"->",
"headerBag",
")",
";",
"$",
"handler",
"->",
"configure",
... | Enables internal HTTP cache mechanism
@param integer $timestamp Last modified timestamp
@param integer $ttl Time to live in seconds
@return \Krystal\Http\Response\HttpResponse | [
"Enables",
"internal",
"HTTP",
"cache",
"mechanism"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/HttpResponse.php#L253-L260 | train |
krystal-framework/krystal.framework | src/Krystal/Http/Response/HttpResponse.php | HttpResponse.setContentType | public function setContentType($type)
{
$this->headerBag->appendPair('Content-Type', sprintf('%s;charset=%s', $type, $this->charset));
return $this;
} | php | public function setContentType($type)
{
$this->headerBag->appendPair('Content-Type', sprintf('%s;charset=%s', $type, $this->charset));
return $this;
} | [
"public",
"function",
"setContentType",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"headerBag",
"->",
"appendPair",
"(",
"'Content-Type'",
",",
"sprintf",
"(",
"'%s;charset=%s'",
",",
"$",
"type",
",",
"$",
"this",
"->",
"charset",
")",
")",
";",
"re... | Generates and appends to the queue "Content-Type" header
@param string $type Content type
@return \Krystal\Http\Response\HttpResponse | [
"Generates",
"and",
"appends",
"to",
"the",
"queue",
"Content",
"-",
"Type",
"header"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Response/HttpResponse.php#L281-L285 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleCoind.php | TurtleCoind.getBlockTemplate | public function getBlockTemplate(int $reserveSize, string $address):JsonResponse
{
$params = [
'reserve_size' => $reserveSize,
'wallet_address' => $address,
];
return $this->rpcPost('getblocktemplate', $params);
} | php | public function getBlockTemplate(int $reserveSize, string $address):JsonResponse
{
$params = [
'reserve_size' => $reserveSize,
'wallet_address' => $address,
];
return $this->rpcPost('getblocktemplate', $params);
} | [
"public",
"function",
"getBlockTemplate",
"(",
"int",
"$",
"reserveSize",
",",
"string",
"$",
"address",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"'reserve_size'",
"=>",
"$",
"reserveSize",
",",
"'wallet_address'",
"=>",
"$",
"address",
",",
"... | Returns block template with an empty "hole" for nonce.
@param int $reserveSize Size of the reserve to be specified. Required.
@param string $address Valid TurtleCoin wallet address. Required.
@return JsonResponse | [
"Returns",
"block",
"template",
"with",
"an",
"empty",
"hole",
"for",
"nonce",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleCoind.php#L50-L58 | train |
Firesphere/silverstripe-newsmodule | code/extras/ExtraShorctodeParser.php | ExtraShortcodeParser.TweetHandler | public static function TweetHandler($arguments)
{
if (!isset($arguments['id'])) {
return null;
}
if (substr($arguments['id'], 0, 4) === 'http') {
list($unneeded, $id) = explode('/status/', $arguments['id']);
} else {
$id = $arguments['id'];
}
$data = json_decode(file_get_contents('https://api.twitter.com/1/statuses/oembed.json?id=' . $id . '&omit_script=true&lang=en'), 1);
return $data['html'];
} | php | public static function TweetHandler($arguments)
{
if (!isset($arguments['id'])) {
return null;
}
if (substr($arguments['id'], 0, 4) === 'http') {
list($unneeded, $id) = explode('/status/', $arguments['id']);
} else {
$id = $arguments['id'];
}
$data = json_decode(file_get_contents('https://api.twitter.com/1/statuses/oembed.json?id=' . $id . '&omit_script=true&lang=en'), 1);
return $data['html'];
} | [
"public",
"static",
"function",
"TweetHandler",
"(",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"arguments",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"arguments",
"[",
"'id'",
"... | The following three functions are global once enabled!
@param array $arguments from Content.
@return String block with the parsed code. | [
"The",
"following",
"three",
"functions",
"are",
"global",
"once",
"enabled!"
] | 98c501bf940878ed9c044124409b85a3e3c4265c | https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/extras/ExtraShorctodeParser.php#L19-L32 | train |
stefk/JVal | src/Uri.php | Uri.isSamePrimaryResource | public function isSamePrimaryResource(Uri $uri)
{
if (!$this->isAbsolute() || !$uri->isAbsolute()) {
throw new \LogicException('Cannot compare URIs: both must be absolute');
}
return $this->primaryIdentifier === $uri->getPrimaryResourceIdentifier();
} | php | public function isSamePrimaryResource(Uri $uri)
{
if (!$this->isAbsolute() || !$uri->isAbsolute()) {
throw new \LogicException('Cannot compare URIs: both must be absolute');
}
return $this->primaryIdentifier === $uri->getPrimaryResourceIdentifier();
} | [
"public",
"function",
"isSamePrimaryResource",
"(",
"Uri",
"$",
"uri",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isAbsolute",
"(",
")",
"||",
"!",
"$",
"uri",
"->",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'... | Returns whether two URIs share the same primary resource identifier,
i.e. whether they point to the same document.
@param Uri $uri
@return bool | [
"Returns",
"whether",
"two",
"URIs",
"share",
"the",
"same",
"primary",
"resource",
"identifier",
"i",
".",
"e",
".",
"whether",
"they",
"point",
"to",
"the",
"same",
"document",
"."
] | 1c26dd2c16e5273d1c0565ff6c9dc51e6316c564 | https://github.com/stefk/JVal/blob/1c26dd2c16e5273d1c0565ff6c9dc51e6316c564/src/Uri.php#L179-L186 | train |
fxpio/fxp-form-extensions | Form/Extension/CollectionSelect2TypeExtension.php | CollectionSelect2TypeExtension.normalizeOptions | protected function normalizeOptions(array $options, array $value)
{
return $options['select2']['enabled']
? array_merge($value, [
'error_bubbling' => false,
'multiple' => false,
'select2' => array_merge($options['select2'], [
'tags' => $options['allow_add'],
]),
])
: $value;
} | php | protected function normalizeOptions(array $options, array $value)
{
return $options['select2']['enabled']
? array_merge($value, [
'error_bubbling' => false,
'multiple' => false,
'select2' => array_merge($options['select2'], [
'tags' => $options['allow_add'],
]),
])
: $value;
} | [
"protected",
"function",
"normalizeOptions",
"(",
"array",
"$",
"options",
",",
"array",
"$",
"value",
")",
"{",
"return",
"$",
"options",
"[",
"'select2'",
"]",
"[",
"'enabled'",
"]",
"?",
"array_merge",
"(",
"$",
"value",
",",
"[",
"'error_bubbling'",
"=... | Normalise the options for selector.
@param array $options The form options
@param array $value The options of form type
@return array The normalized options for selector | [
"Normalise",
"the",
"options",
"for",
"selector",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/Extension/CollectionSelect2TypeExtension.php#L142-L153 | train |
krystal-framework/krystal.framework | src/Krystal/Http/FileTransfer/FileEntity.php | FileEntity.getUniqueName | public function getUniqueName()
{
$key = 'uniq';
// Lazy initialization
if (!isset($this->container[$key])) {
$extension = $this->getExtension();
// If extension avaiable, use it
if ($extension) {
$name = sprintf('%s.%s', uniqid(), $extension);
} else {
// Otherwise just filename without extension
$name = uniqid();
}
$this->container[$key] = $name;
}
return $this->container[$key];
} | php | public function getUniqueName()
{
$key = 'uniq';
// Lazy initialization
if (!isset($this->container[$key])) {
$extension = $this->getExtension();
// If extension avaiable, use it
if ($extension) {
$name = sprintf('%s.%s', uniqid(), $extension);
} else {
// Otherwise just filename without extension
$name = uniqid();
}
$this->container[$key] = $name;
}
return $this->container[$key];
} | [
"public",
"function",
"getUniqueName",
"(",
")",
"{",
"$",
"key",
"=",
"'uniq'",
";",
"// Lazy initialization",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->... | Returns unique name for uploaded file
@return string | [
"Returns",
"unique",
"name",
"for",
"uploaded",
"file"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/FileTransfer/FileEntity.php#L86-L106 | train |
Firesphere/silverstripe-newsmodule | code/extensions/SlideshowCMSExtension.php | SlideshowCMSExtension.updateCMSFields | public function updateCMSFields(FieldList $fields)
{
$owner = $this->owner;
$fields->removeByName(array('News', 'NewsID', 'SortOrder'));
$fields->addFieldsToTab(
'Root.Main', array(
TextField::create('Title', $owner->fieldLabel('Title')),
HtmlEditorField::create('Description', $owner->fieldLabel('Description')),
UploadField::create('Image', $owner->fieldLabel('Image')),
)
);
} | php | public function updateCMSFields(FieldList $fields)
{
$owner = $this->owner;
$fields->removeByName(array('News', 'NewsID', 'SortOrder'));
$fields->addFieldsToTab(
'Root.Main', array(
TextField::create('Title', $owner->fieldLabel('Title')),
HtmlEditorField::create('Description', $owner->fieldLabel('Description')),
UploadField::create('Image', $owner->fieldLabel('Image')),
)
);
} | [
"public",
"function",
"updateCMSFields",
"(",
"FieldList",
"$",
"fields",
")",
"{",
"$",
"owner",
"=",
"$",
"this",
"->",
"owner",
";",
"$",
"fields",
"->",
"removeByName",
"(",
"array",
"(",
"'News'",
",",
"'NewsID'",
",",
"'SortOrder'",
")",
")",
";",
... | Setup the CMSFields
@param FieldList $fields | [
"Setup",
"the",
"CMSFields"
] | 98c501bf940878ed9c044124409b85a3e3c4265c | https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/extensions/SlideshowCMSExtension.php#L20-L31 | train |
jarnix/nofussframework | Nf/Front/Request/Http.php | Http.setPutFromRequest | public function setPutFromRequest()
{
if ($this->_put === null) {
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
$this->_put = file_get_contents("php://input");
}
} else {
$this->_put = '';
}
} | php | public function setPutFromRequest()
{
if ($this->_put === null) {
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
$this->_put = file_get_contents("php://input");
}
} else {
$this->_put = '';
}
} | [
"public",
"function",
"setPutFromRequest",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_put",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'PUT'",
")",
"{",
"$",
"this",
"->",
"_put",
"=",
"file_get_content... | get the string sent as put | [
"get",
"the",
"string",
"sent",
"as",
"put"
] | 2177ebefd408bd9545ac64345b47cde1ff3cdccb | https://github.com/jarnix/nofussframework/blob/2177ebefd408bd9545ac64345b47cde1ff3cdccb/Nf/Front/Request/Http.php#L110-L119 | train |
jarnix/nofussframework | Nf/Front/Request/Http.php | Http.redirectForTrailingSlash | public function redirectForTrailingSlash()
{
$config = \Nf\Registry::get('config');
$redirectionUrl = false;
$requestParams = '';
$requestPage = '/' . $this->_uri;
// we don't redirect for the home page...
if ($requestPage != '/' && mb_strpos($requestPage, '/?') !== 0) {
// the url without the params is :
if (mb_strpos($requestPage, '?') !== false) {
$requestParams = mb_substr($requestPage, mb_strpos($requestPage, '?'), mb_strlen($requestPage) - mb_strpos($requestPage, '?'));
$requestPage = mb_substr($requestPage, 0, mb_strpos($requestPage, '?'));
}
if (isset($config->trailingSlash->needed) && $config->trailingSlash->needed == true) {
if (mb_substr($requestPage, - 1, 1) != '/') {
$redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . $requestPage . '/' . $requestParams;
}
} else {
if (mb_substr($requestPage, - 1, 1) == '/') {
$redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . rtrim($requestPage, '/') . $requestParams;
}
}
if ($redirectionUrl !== false) {
$response = new \Nf\Front\Response\Http();
$response->redirect($redirectionUrl, 301);
$response->sendHeaders();
return true;
}
}
return false;
} | php | public function redirectForTrailingSlash()
{
$config = \Nf\Registry::get('config');
$redirectionUrl = false;
$requestParams = '';
$requestPage = '/' . $this->_uri;
// we don't redirect for the home page...
if ($requestPage != '/' && mb_strpos($requestPage, '/?') !== 0) {
// the url without the params is :
if (mb_strpos($requestPage, '?') !== false) {
$requestParams = mb_substr($requestPage, mb_strpos($requestPage, '?'), mb_strlen($requestPage) - mb_strpos($requestPage, '?'));
$requestPage = mb_substr($requestPage, 0, mb_strpos($requestPage, '?'));
}
if (isset($config->trailingSlash->needed) && $config->trailingSlash->needed == true) {
if (mb_substr($requestPage, - 1, 1) != '/') {
$redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . $requestPage . '/' . $requestParams;
}
} else {
if (mb_substr($requestPage, - 1, 1) == '/') {
$redirectionUrl = 'http://' . $_SERVER['HTTP_HOST'] . rtrim($requestPage, '/') . $requestParams;
}
}
if ($redirectionUrl !== false) {
$response = new \Nf\Front\Response\Http();
$response->redirect($redirectionUrl, 301);
$response->sendHeaders();
return true;
}
}
return false;
} | [
"public",
"function",
"redirectForTrailingSlash",
"(",
")",
"{",
"$",
"config",
"=",
"\\",
"Nf",
"\\",
"Registry",
"::",
"get",
"(",
"'config'",
")",
";",
"$",
"redirectionUrl",
"=",
"false",
";",
"$",
"requestParams",
"=",
"''",
";",
"$",
"requestPage",
... | handle the redirection according to the trailing slash configuration | [
"handle",
"the",
"redirection",
"according",
"to",
"the",
"trailing",
"slash",
"configuration"
] | 2177ebefd408bd9545ac64345b47cde1ff3cdccb | https://github.com/jarnix/nofussframework/blob/2177ebefd408bd9545ac64345b47cde1ff3cdccb/Nf/Front/Request/Http.php#L157-L191 | train |
wpfulcrum/extender | src/Extender/WP/ParentChild.php | ParentChild.isChildPost | public static function isChildPost($postOrPostId = null)
{
$post = self::getPost($postOrPostId);
if (empty($post)) {
return false;
}
return $post->post_parent > 0;
} | php | public static function isChildPost($postOrPostId = null)
{
$post = self::getPost($postOrPostId);
if (empty($post)) {
return false;
}
return $post->post_parent > 0;
} | [
"public",
"static",
"function",
"isChildPost",
"(",
"$",
"postOrPostId",
"=",
"null",
")",
"{",
"$",
"post",
"=",
"self",
"::",
"getPost",
"(",
"$",
"postOrPostId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"post",
")",
")",
"{",
"return",
"false",
";"... | Checks if the given post is a child.
@since 3.1.3
@param int|WP_Post|null $postOrPostId Post Instance or Post ID to check
@return boolean | [
"Checks",
"if",
"the",
"given",
"post",
"is",
"a",
"child",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/WP/ParentChild.php#L16-L24 | train |
wpfulcrum/extender | src/Extender/WP/ParentChild.php | ParentChild.getNextParentPost | public static function getNextParentPost($inSameTerm = false, $excludedTerms = '', $taxonomy = 'category')
{
add_filter('get_next_post_where', [__CLASS__, 'addParentPostToAdjacentSql']);
return get_adjacent_post($inSameTerm, $excludedTerms, false, $taxonomy);
} | php | public static function getNextParentPost($inSameTerm = false, $excludedTerms = '', $taxonomy = 'category')
{
add_filter('get_next_post_where', [__CLASS__, 'addParentPostToAdjacentSql']);
return get_adjacent_post($inSameTerm, $excludedTerms, false, $taxonomy);
} | [
"public",
"static",
"function",
"getNextParentPost",
"(",
"$",
"inSameTerm",
"=",
"false",
",",
"$",
"excludedTerms",
"=",
"''",
",",
"$",
"taxonomy",
"=",
"'category'",
")",
"{",
"add_filter",
"(",
"'get_next_post_where'",
",",
"[",
"__CLASS__",
",",
"'addPar... | Get the next adjacent parent post.
This function extends the SQL WHERE query of the WordPress get_adjacent_post()
function. It registers a callback to the `get_next_post_where` event filter,
which then adds a new WHERE parameter.
@uses get_next_post()
@uses `get_next_post_where` filter
@uses fulcrum_add_parent_post_to_adjacent_sql()
@since 3.1.3
@param bool $inSameTerm Optional. Whether post should be in a same taxonomy term. Default false.
@param array|string $excludedTerms Optional. Array or comma-separated list of excluded term IDs. Default empty.
@param string $taxonomy Optional. Taxonomy, if $inSameTerm is true. Default 'category'.
@return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no
corresponding post exists. | [
"Get",
"the",
"next",
"adjacent",
"parent",
"post",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/WP/ParentChild.php#L104-L109 | train |
wpfulcrum/extender | src/Extender/WP/ParentChild.php | ParentChild.getPreviousParentPost | public static function getPreviousParentPost($inSameTerm = false, $excludedTerms = '', $taxonomy = 'category')
{
add_filter('get_previous_post_where', [__CLASS__, 'addParentPostToAdjacentSql']);
return get_adjacent_post($inSameTerm, $excludedTerms, true, $taxonomy);
} | php | public static function getPreviousParentPost($inSameTerm = false, $excludedTerms = '', $taxonomy = 'category')
{
add_filter('get_previous_post_where', [__CLASS__, 'addParentPostToAdjacentSql']);
return get_adjacent_post($inSameTerm, $excludedTerms, true, $taxonomy);
} | [
"public",
"static",
"function",
"getPreviousParentPost",
"(",
"$",
"inSameTerm",
"=",
"false",
",",
"$",
"excludedTerms",
"=",
"''",
",",
"$",
"taxonomy",
"=",
"'category'",
")",
"{",
"add_filter",
"(",
"'get_previous_post_where'",
",",
"[",
"__CLASS__",
",",
... | Get the previous adjacent parent post.
This function extends the SQL WHERE query of the WordPress get_adjacent_post()
function. It registers a callback to the `get_previous_post_where` event filter,
which then adds a new WHERE parameter.
@uses get_previous_post()
@uses `get_previous_post_where` filter
@uses fulcrum_add_parent_post_to_adjacent_sql()
@since 3.1.3
@param bool $inSameTerm Optional. Whether post should be in a same taxonomy term. Default false.
@param array|string $excludedTerms Optional. Array or comma-separated list of excluded term IDs. Default empty.
@param string $taxonomy Optional. Taxonomy, if $inSameTerm is true. Default 'category'.
@return null|string|WP_Post Post object if successful. Null if global $post is not set. Empty string if no
corresponding post exists. | [
"Get",
"the",
"previous",
"adjacent",
"parent",
"post",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/WP/ParentChild.php#L131-L136 | train |
wpfulcrum/extender | src/Extender/WP/ParentChild.php | ParentChild.extractPostId | public static function extractPostId($postOrPostId = null)
{
if (is_object($postOrPostId)) {
return property_exists($postOrPostId, 'ID')
? (int) $postOrPostId->ID
: null;
}
if ($postOrPostId > 0) {
return (int) $postOrPostId;
}
return get_the_ID();
} | php | public static function extractPostId($postOrPostId = null)
{
if (is_object($postOrPostId)) {
return property_exists($postOrPostId, 'ID')
? (int) $postOrPostId->ID
: null;
}
if ($postOrPostId > 0) {
return (int) $postOrPostId;
}
return get_the_ID();
} | [
"public",
"static",
"function",
"extractPostId",
"(",
"$",
"postOrPostId",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"postOrPostId",
")",
")",
"{",
"return",
"property_exists",
"(",
"$",
"postOrPostId",
",",
"'ID'",
")",
"?",
"(",
"int",
"... | Get the post ID from the given post or post ID.
If none is passed in, then it grabs the current ID.
@since 3.1.3
@param WP_Post|int|null $postOrPostId Given post or post ID
@return int|null | [
"Get",
"the",
"post",
"ID",
"from",
"the",
"given",
"post",
"or",
"post",
"ID",
".",
"If",
"none",
"is",
"passed",
"in",
"then",
"it",
"grabs",
"the",
"current",
"ID",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/WP/ParentChild.php#L148-L161 | train |
Droeftoeter/pokapi | src/Pokapi/Request/Position.php | Position.createRandomized | public function createRandomized($minDistance = -0.005, $maxDistance = 0.005)
{
$newCoordinates = Geo::calculateNewCoordinates($this->latitude, $this->longitude, Random::randomFloat($minDistance, $maxDistance), rand(0,360));
$newAltitude = $this->altitude + round(Random::randomFloat(-2, 2), 2);
$newAccuracy = mt_rand(3, 10);
return new self($newCoordinates[0], $newCoordinates[1], $newAltitude, $newAccuracy);
} | php | public function createRandomized($minDistance = -0.005, $maxDistance = 0.005)
{
$newCoordinates = Geo::calculateNewCoordinates($this->latitude, $this->longitude, Random::randomFloat($minDistance, $maxDistance), rand(0,360));
$newAltitude = $this->altitude + round(Random::randomFloat(-2, 2), 2);
$newAccuracy = mt_rand(3, 10);
return new self($newCoordinates[0], $newCoordinates[1], $newAltitude, $newAccuracy);
} | [
"public",
"function",
"createRandomized",
"(",
"$",
"minDistance",
"=",
"-",
"0.005",
",",
"$",
"maxDistance",
"=",
"0.005",
")",
"{",
"$",
"newCoordinates",
"=",
"Geo",
"::",
"calculateNewCoordinates",
"(",
"$",
"this",
"->",
"latitude",
",",
"$",
"this",
... | Creates a randomized version of this approximate position
@param float $minDistance
@param float $maxDistance
@return Position | [
"Creates",
"a",
"randomized",
"version",
"of",
"this",
"approximate",
"position"
] | 3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3 | https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Request/Position.php#L100-L106 | train |
fxpio/fxp-form-extensions | Form/Helper/AjaxChoiceListHelper.php | AjaxChoiceListHelper.extractChoiceLoader | protected static function extractChoiceLoader($form)
{
$form = static::getForm($form);
$choiceLoader = $form->getAttribute('choice_loader', $form->getOption('choice_loader'));
return $choiceLoader;
} | php | protected static function extractChoiceLoader($form)
{
$form = static::getForm($form);
$choiceLoader = $form->getAttribute('choice_loader', $form->getOption('choice_loader'));
return $choiceLoader;
} | [
"protected",
"static",
"function",
"extractChoiceLoader",
"(",
"$",
"form",
")",
"{",
"$",
"form",
"=",
"static",
"::",
"getForm",
"(",
"$",
"form",
")",
";",
"$",
"choiceLoader",
"=",
"$",
"form",
"->",
"getAttribute",
"(",
"'choice_loader'",
",",
"$",
... | Extracts the ajax choice loader.
@param FormBuilderInterface|FormInterface $form
@return AjaxChoiceLoaderInterface
@throws InvalidArgumentException When the choice list is not an instance of AjaxChoiceListInterface | [
"Extracts",
"the",
"ajax",
"choice",
"loader",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/Helper/AjaxChoiceListHelper.php#L117-L123 | train |
fxpio/fxp-form-extensions | Form/Helper/AjaxChoiceListHelper.php | AjaxChoiceListHelper.extractAjaxFormatter | protected static function extractAjaxFormatter($form)
{
$form = static::getForm($form);
$formatter = $form->getAttribute('select2', $form->getOption('select2'));
$formatter = $formatter['ajax_formatter'];
if (!$formatter instanceof AjaxChoiceListFormatterInterface) {
throw new UnexpectedTypeException($formatter, 'Fxp\Component\FormExtensions\Form\ChoiceList\Formatter\AjaxChoiceListFormatterInterface');
}
return $formatter;
} | php | protected static function extractAjaxFormatter($form)
{
$form = static::getForm($form);
$formatter = $form->getAttribute('select2', $form->getOption('select2'));
$formatter = $formatter['ajax_formatter'];
if (!$formatter instanceof AjaxChoiceListFormatterInterface) {
throw new UnexpectedTypeException($formatter, 'Fxp\Component\FormExtensions\Form\ChoiceList\Formatter\AjaxChoiceListFormatterInterface');
}
return $formatter;
} | [
"protected",
"static",
"function",
"extractAjaxFormatter",
"(",
"$",
"form",
")",
"{",
"$",
"form",
"=",
"static",
"::",
"getForm",
"(",
"$",
"form",
")",
";",
"$",
"formatter",
"=",
"$",
"form",
"->",
"getAttribute",
"(",
"'select2'",
",",
"$",
"form",
... | Extracts the ajax formatter.
@param FormBuilderInterface|FormInterface $form
@return AjaxChoiceListFormatterInterface
@throws InvalidArgumentException When the ajax_formatter is not an instance of AjaxChoiceListFormatterInterface | [
"Extracts",
"the",
"ajax",
"formatter",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/Helper/AjaxChoiceListHelper.php#L134-L145 | train |
solspace/craft3-commons | src/Helpers/StringHelper.php | StringHelper.camelize | public static function camelize($string, $delimiter = ' '): string
{
$stringParts = explode($delimiter, $string);
$camelized = array_map('ucwords', $stringParts);
return implode($delimiter, $camelized);
} | php | public static function camelize($string, $delimiter = ' '): string
{
$stringParts = explode($delimiter, $string);
$camelized = array_map('ucwords', $stringParts);
return implode($delimiter, $camelized);
} | [
"public",
"static",
"function",
"camelize",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"' '",
")",
":",
"string",
"{",
"$",
"stringParts",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"string",
")",
";",
"$",
"camelized",
"=",
"array_map",
"("... | Turns every first letter in every word in the string into a camel cased letter
@param string $string
@param string $delimiter
@return string | [
"Turns",
"every",
"first",
"letter",
"in",
"every",
"word",
"in",
"the",
"string",
"into",
"a",
"camel",
"cased",
"letter"
] | 2de20a76e83efe3ed615a2a102dfef18e2295420 | https://github.com/solspace/craft3-commons/blob/2de20a76e83efe3ed615a2a102dfef18e2295420/src/Helpers/StringHelper.php#L76-L82 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.