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
Features/BaseDataContext.php
BaseDataContext.setKernel
public function setKernel(KernelInterface $kernel) { $this->kernel = $kernel; $this->container = $kernel->getContainer(); }
php
public function setKernel(KernelInterface $kernel) { $this->kernel = $kernel; $this->container = $kernel->getContainer(); }
[ "public", "function", "setKernel", "(", "KernelInterface", "$", "kernel", ")", "{", "$", "this", "->", "kernel", "=", "$", "kernel", ";", "$", "this", "->", "container", "=", "$", "kernel", "->", "getContainer", "(", ")", ";", "}" ]
Sets Kernel instance. @param KernelInterface $kernel
[ "Sets", "Kernel", "instance", "." ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L109-L112
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.createClient
public function createClient() { $this->client = $this->getKernel()->getContainer()->get('test.client'); $client = $this->client; return $client; }
php
public function createClient() { $this->client = $this->getKernel()->getContainer()->get('test.client'); $client = $this->client; return $client; }
[ "public", "function", "createClient", "(", ")", "{", "$", "this", "->", "client", "=", "$", "this", "->", "getKernel", "(", ")", "->", "getContainer", "(", ")", "->", "get", "(", "'test.client'", ")", ";", "$", "client", "=", "$", "this", "->", "clie...
Crea un cliente para hacer peticiones @return \Symfony\Component\BrowserKit\Client
[ "Crea", "un", "cliente", "para", "hacer", "peticiones" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L129-L133
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.parseScenarioParameters
public function parseScenarioParameters(array &$parameters, $checkExp = false) { foreach ($parameters as $key => $value) { if ($this->isScenarioParameter($value, $checkExp)) { $parameters[$key] = $this->getScenarioParameter($value); } } return $parameters; }
php
public function parseScenarioParameters(array &$parameters, $checkExp = false) { foreach ($parameters as $key => $value) { if ($this->isScenarioParameter($value, $checkExp)) { $parameters[$key] = $this->getScenarioParameter($value); } } return $parameters; }
[ "public", "function", "parseScenarioParameters", "(", "array", "&", "$", "parameters", ",", "$", "checkExp", "=", "false", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isSce...
Busca los parametros dentro de un array por su indice y le hace el parse a su valor final. @param array $parameters @param type $checkExp
[ "Busca", "los", "parametros", "dentro", "de", "un", "array", "por", "su", "indice", "y", "le", "hace", "el", "parse", "a", "su", "valor", "final", "." ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L187-L194
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.isScenarioParameter
public function isScenarioParameter($value, $checkExp = false) { if ($this->scenarioParameters === null) { $this->initParameters(); } $result = isset($this->scenarioParameters[$value]); if (!$result) { if (substr($value, 0, 1) === "%" && substr($value, strlen($value) - 1, 1) === "%") { $result = true; } } if (!$result && $checkExp === true) { foreach ($this->scenarioParameters as $key => $v) { if (preg_match("/" . $key . "/", $value)) { $result = true; break; } } } return $result; }
php
public function isScenarioParameter($value, $checkExp = false) { if ($this->scenarioParameters === null) { $this->initParameters(); } $result = isset($this->scenarioParameters[$value]); if (!$result) { if (substr($value, 0, 1) === "%" && substr($value, strlen($value) - 1, 1) === "%") { $result = true; } } if (!$result && $checkExp === true) { foreach ($this->scenarioParameters as $key => $v) { if (preg_match("/" . $key . "/", $value)) { $result = true; break; } } } return $result; }
[ "public", "function", "isScenarioParameter", "(", "$", "value", ",", "$", "checkExp", "=", "false", ")", "{", "if", "(", "$", "this", "->", "scenarioParameters", "===", "null", ")", "{", "$", "this", "->", "initParameters", "(", ")", ";", "}", "$", "re...
Verifica si el texto es un parametro @param type $value @return boolean
[ "Verifica", "si", "el", "texto", "es", "un", "parametro" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L201-L220
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.getScenarioParameter
public function getScenarioParameter($key, $checkExp = false) { $parameters = $this->getScenarioParameters(); // var_dump(array_keys($parameters)); $user = null; if ($this->currentUser) { $user = $this->find($this->userClass, $this->currentUser->getId()); } $value = null; if (empty($key)) { xdebug_print_function_stack(); throw new Exception("The scenario parameter can not be empty."); } if (isset($parameters[$key])) { if (is_callable($parameters[$key])) { $value = call_user_func_array($parameters[$key], [$user, $this]); } else { $value = $parameters[$key]; } } else { $found = false; if ($checkExp === true) { foreach ($parameters as $k => $v) { if (preg_match("/" . $k . "/", $key)) { $value = str_replace($k, $this->getScenarioParameter($k), $key); $found = true; break; } } } if (!$found) { throw new Exception(sprintf("The scenario parameter '%s' is not defined", $key)); } } return $value; }
php
public function getScenarioParameter($key, $checkExp = false) { $parameters = $this->getScenarioParameters(); // var_dump(array_keys($parameters)); $user = null; if ($this->currentUser) { $user = $this->find($this->userClass, $this->currentUser->getId()); } $value = null; if (empty($key)) { xdebug_print_function_stack(); throw new Exception("The scenario parameter can not be empty."); } if (isset($parameters[$key])) { if (is_callable($parameters[$key])) { $value = call_user_func_array($parameters[$key], [$user, $this]); } else { $value = $parameters[$key]; } } else { $found = false; if ($checkExp === true) { foreach ($parameters as $k => $v) { if (preg_match("/" . $k . "/", $key)) { $value = str_replace($k, $this->getScenarioParameter($k), $key); $found = true; break; } } } if (!$found) { throw new Exception(sprintf("The scenario parameter '%s' is not defined", $key)); } } return $value; }
[ "public", "function", "getScenarioParameter", "(", "$", "key", ",", "$", "checkExp", "=", "false", ")", "{", "$", "parameters", "=", "$", "this", "->", "getScenarioParameters", "(", ")", ";", "// var_dump(array_keys($parameters));", "$", "user", "=", "null", "...
Obtiene el valor de un parametro en el escenario @param type $key @return type @throws Exception
[ "Obtiene", "el", "valor", "de", "un", "parametro", "en", "el", "escenario" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L228-L262
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.iSetConfigurationKeyWithValue
public function iSetConfigurationKeyWithValue($wrapperName, $key, $value) { if ($value === "false") { $value = false; } else if ($value === "true") { $value = true; } $configurationManager = $this->container->get($this->container->getParameter("tecnocreaciones_tools.configuration_manager.name")); $wrapper = $configurationManager->getWrapper($wrapperName); $success = false; if ($this->accessor->isWritable($wrapper, $key) === true) { $success = $this->accessor->setValue($wrapper, $key, $value); } else { $success = $configurationManager->set($key, $value, $wrapperName, null, true); } if ($success === false) { throw new Exception(sprintf("The value of '%s' can not be update with value '%s'.", $key, $value)); } $configurationManager->flush(true); if ($this->accessor->isReadable($wrapper, $key)) { $newValue = $this->accessor->getValue($wrapper, $key); } else { $newValue = $configurationManager->get($key, $wrapperName, null); } if ($value != $newValue) { throw new Exception(sprintf("Failed to update '%s' key '%s' with '%s' configuration.", $wrapperName, $key, $value)); } }
php
public function iSetConfigurationKeyWithValue($wrapperName, $key, $value) { if ($value === "false") { $value = false; } else if ($value === "true") { $value = true; } $configurationManager = $this->container->get($this->container->getParameter("tecnocreaciones_tools.configuration_manager.name")); $wrapper = $configurationManager->getWrapper($wrapperName); $success = false; if ($this->accessor->isWritable($wrapper, $key) === true) { $success = $this->accessor->setValue($wrapper, $key, $value); } else { $success = $configurationManager->set($key, $value, $wrapperName, null, true); } if ($success === false) { throw new Exception(sprintf("The value of '%s' can not be update with value '%s'.", $key, $value)); } $configurationManager->flush(true); if ($this->accessor->isReadable($wrapper, $key)) { $newValue = $this->accessor->getValue($wrapper, $key); } else { $newValue = $configurationManager->get($key, $wrapperName, null); } if ($value != $newValue) { throw new Exception(sprintf("Failed to update '%s' key '%s' with '%s' configuration.", $wrapperName, $key, $value)); } }
[ "public", "function", "iSetConfigurationKeyWithValue", "(", "$", "wrapperName", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "\"false\"", ")", "{", "$", "value", "=", "false", ";", "}", "else", "if", "(", "$", "value", ...
Actualiza la configuracion del sistema @example Given I set configuration 'WRAPPER_EPR_SALES' key "ENABLE_DIGITAL_INVOICING" with value "1" @Given I set configuration :wrapperName key :key with value :value
[ "Actualiza", "la", "configuracion", "del", "sistema" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L354-L382
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.aClearEntityTable
public function aClearEntityTable($className, $andWhere = null) { $doctrine = $this->getDoctrine(); $em = $doctrine->getManager(); if ($em->getFilters()->isEnabled('softdeleteable')) { $em->getFilters()->disable('softdeleteable'); } if ($className === \Pandco\Bundle\AppBundle\Entity\User\DigitalAccount\TimeWithdraw::class) { $query = $em->createQuery("UPDATE " . \Pandco\Bundle\AppBundle\Entity\App\User\DigitalAccount\DigitalAccountConfig::class . " dac SET dac.timeWithdraw = null"); $query->execute(); } $query = $em->createQuery("DELETE FROM " . $className . " " . $andWhere); $query->execute(); $em->flush(); $em->clear(); }
php
public function aClearEntityTable($className, $andWhere = null) { $doctrine = $this->getDoctrine(); $em = $doctrine->getManager(); if ($em->getFilters()->isEnabled('softdeleteable')) { $em->getFilters()->disable('softdeleteable'); } if ($className === \Pandco\Bundle\AppBundle\Entity\User\DigitalAccount\TimeWithdraw::class) { $query = $em->createQuery("UPDATE " . \Pandco\Bundle\AppBundle\Entity\App\User\DigitalAccount\DigitalAccountConfig::class . " dac SET dac.timeWithdraw = null"); $query->execute(); } $query = $em->createQuery("DELETE FROM " . $className . " " . $andWhere); $query->execute(); $em->flush(); $em->clear(); }
[ "public", "function", "aClearEntityTable", "(", "$", "className", ",", "$", "andWhere", "=", "null", ")", "{", "$", "doctrine", "=", "$", "this", "->", "getDoctrine", "(", ")", ";", "$", "em", "=", "$", "doctrine", "->", "getManager", "(", ")", ";", ...
Limia una tabla de la base de datos @example Given a clear entity "Pandco\Bundle\AppBundle\Entity\EPR\Sales\SalesInvoice" table @Given a clear entity :className table @Given a clear entity :className table and where :where
[ "Limia", "una", "tabla", "de", "la", "base", "de", "datos" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L390-L404
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.theQuantityOfElementInEntityIs
public function theQuantityOfElementInEntityIs($className, $expresion) { $doctrine = $this->getDoctrine(); $em = $doctrine->getManager(); $query = $em->createQuery('SELECT COUNT(u.id) FROM ' . $className . ' u'); $count = $query->getSingleScalarResult(); $expAmount = explode(" ", $expresion); $amount2 = \Pandco\Bundle\AppBundle\Service\Util\CurrencyUtil::fotmatToNumber($expAmount[1]); if (version_compare($count, $amount2, $expAmount[0]) === false) { throw new Exception(sprintf("Expected '%s' but there quantity is '%s'.", $expresion, $count)); } }
php
public function theQuantityOfElementInEntityIs($className, $expresion) { $doctrine = $this->getDoctrine(); $em = $doctrine->getManager(); $query = $em->createQuery('SELECT COUNT(u.id) FROM ' . $className . ' u'); $count = $query->getSingleScalarResult(); $expAmount = explode(" ", $expresion); $amount2 = \Pandco\Bundle\AppBundle\Service\Util\CurrencyUtil::fotmatToNumber($expAmount[1]); if (version_compare($count, $amount2, $expAmount[0]) === false) { throw new Exception(sprintf("Expected '%s' but there quantity is '%s'.", $expresion, $count)); } }
[ "public", "function", "theQuantityOfElementInEntityIs", "(", "$", "className", ",", "$", "expresion", ")", "{", "$", "doctrine", "=", "$", "this", "->", "getDoctrine", "(", ")", ";", "$", "em", "=", "$", "doctrine", "->", "getManager", "(", ")", ";", "$"...
Cuenta la cantidad de elementos de una tabla @example And the quantity of element in entity "Pandco\Bundle\AppBundle\Entity\Core\Email\EmailQueue" is "= 2" @example And the quantity of element in entity "Pandco\Bundle\AppBundle\Entity\Core\Email\EmailQueue" is "> 0" @Given the quantity of element in entity :className is :expresion
[ "Cuenta", "la", "cantidad", "de", "elementos", "de", "una", "tabla" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L433-L443
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.findOneElement
public function findOneElement($class, UserInterface $user = null) { $em = $this->getDoctrine()->getManager(); $alias = "o"; $qb = $em->createQueryBuilder() ->select($alias) ->from($class, $alias); if ($user !== null) { $qb ->andWhere("o.user = :user") ->setParameter("user", $user) ; } $qb->orderBy("o.createdAt", "DESC"); $entity = $qb->setMaxResults(1)->getQuery()->getOneOrNullResult(); return $entity; }
php
public function findOneElement($class, UserInterface $user = null) { $em = $this->getDoctrine()->getManager(); $alias = "o"; $qb = $em->createQueryBuilder() ->select($alias) ->from($class, $alias); if ($user !== null) { $qb ->andWhere("o.user = :user") ->setParameter("user", $user) ; } $qb->orderBy("o.createdAt", "DESC"); $entity = $qb->setMaxResults(1)->getQuery()->getOneOrNullResult(); return $entity; }
[ "public", "function", "findOneElement", "(", "$", "class", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "alias", "=", "\"o\"", ";", "$", ...
Devuelve el primer elemento que encuentr de la base de datos @param type $class @return type
[ "Devuelve", "el", "primer", "elemento", "que", "encuentr", "de", "la", "base", "de", "datos" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L450-L465
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.arrayReplaceRecursiveValue
private function arrayReplaceRecursiveValue(&$array, $parameters) { foreach ($array as $key => $value) { // create new key in $array, if it is empty or not an array if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) { $array[$key] = array(); } // overwrite the value in the base array if (is_array($value)) { $value = $this->arrayReplaceRecursiveValue($array[$key], $parameters); } else { $value = $this->parseParameter($value, $parameters); } $array[$key] = $value; } return $array; }
php
private function arrayReplaceRecursiveValue(&$array, $parameters) { foreach ($array as $key => $value) { // create new key in $array, if it is empty or not an array if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) { $array[$key] = array(); } // overwrite the value in the base array if (is_array($value)) { $value = $this->arrayReplaceRecursiveValue($array[$key], $parameters); } else { $value = $this->parseParameter($value, $parameters); } $array[$key] = $value; } return $array; }
[ "private", "function", "arrayReplaceRecursiveValue", "(", "&", "$", "array", ",", "$", "parameters", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "// create new key in $array, if it is empty or not an array", "if", "(", ...
Reemplaza recursivamente los parametros en un array @param type $array @param type $parameters @return type
[ "Reemplaza", "recursivamente", "los", "parametros", "en", "un", "array" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L490-L506
train
Tecnocreaciones/ToolsBundle
Features/BaseDataContext.php
BaseDataContext.aExecuteCommandTo
public function aExecuteCommandTo($command) { $this->restartKernel(); $kernel = $this->getKernel(); $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel); $application->setAutoExit(false); $exploded = explode(" ", $command); $commandsParams = [ ]; foreach ($exploded as $value) { if (!isset($commandsParams["command"])) { $commandsParams["command"] = $value; } else { $e2 = explode("=", $value); // var_dump($e2); if (count($e2) == 1) { $commandsParams[] = $e2[0]; } else if (count($e2) == 2) { $commandsParams[$e2[0]] = $e2[1]; } } } foreach ($commandsParams as $key => $value) { $commandsParams[$key] = $value; } $input = new \Symfony\Component\Console\Input\ArrayInput($commandsParams); if ($output === null) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); } $application->run($input, $output); // $content = $output->fetch(); }
php
public function aExecuteCommandTo($command) { $this->restartKernel(); $kernel = $this->getKernel(); $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel); $application->setAutoExit(false); $exploded = explode(" ", $command); $commandsParams = [ ]; foreach ($exploded as $value) { if (!isset($commandsParams["command"])) { $commandsParams["command"] = $value; } else { $e2 = explode("=", $value); // var_dump($e2); if (count($e2) == 1) { $commandsParams[] = $e2[0]; } else if (count($e2) == 2) { $commandsParams[$e2[0]] = $e2[1]; } } } foreach ($commandsParams as $key => $value) { $commandsParams[$key] = $value; } $input = new \Symfony\Component\Console\Input\ArrayInput($commandsParams); if ($output === null) { $output = new \Symfony\Component\Console\Output\ConsoleOutput(); } $application->run($input, $output); // $content = $output->fetch(); }
[ "public", "function", "aExecuteCommandTo", "(", "$", "command", ")", "{", "$", "this", "->", "restartKernel", "(", ")", ";", "$", "kernel", "=", "$", "this", "->", "getKernel", "(", ")", ";", "$", "application", "=", "new", "\\", "Symfony", "\\", "Bund...
Executa un comando @Given a execute command to :command
[ "Executa", "un", "comando" ]
8edc159b91ea41d7a880d2ca0860352d7b05370f
https://github.com/Tecnocreaciones/ToolsBundle/blob/8edc159b91ea41d7a880d2ca0860352d7b05370f/Features/BaseDataContext.php#L553-L586
train
Larium/larium_creditcard
src/CreditCard/CreditCardDetector.php
CreditCardDetector.detect
public function detect($number) { foreach (self::$cardPatterns as $name => $pattern) { if (preg_match($pattern, $number)) { return $name; } } return false; }
php
public function detect($number) { foreach (self::$cardPatterns as $name => $pattern) { if (preg_match($pattern, $number)) { return $name; } } return false; }
[ "public", "function", "detect", "(", "$", "number", ")", "{", "foreach", "(", "self", "::", "$", "cardPatterns", "as", "$", "name", "=>", "$", "pattern", ")", "{", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "number", ")", ")", "{", "re...
Detect card brand from card number @param string $number The card number to detect. @return mixed|false Card name on success or false if not.
[ "Detect", "card", "brand", "from", "card", "number" ]
ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d
https://github.com/Larium/larium_creditcard/blob/ea1957bbe28e2448498abe7bb5a5b6ff0020bb2d/src/CreditCard/CreditCardDetector.php#L32-L41
train
krystal-framework/krystal.framework
src/Krystal/Cache/FileEngine/CacheFile.php
CacheFile.load
public function load() { // Check for existence only once and save the result $exists = is_file($this->file); if ($this->autoCreate == false && !$exists) { throw new RuntimeException('File does not exist'); } else if ($this->autoCreate == true && !$exists) { // Create new empty file touch($this->file); $this->loaded = true; // There's no need to fetch content from the empty file return array(); } $content = file_get_contents($this->file); $content = $this->serializer->unserialize($content); if (!$content) { $content = array(); } $this->content = $content; $this->loaded = true; }
php
public function load() { // Check for existence only once and save the result $exists = is_file($this->file); if ($this->autoCreate == false && !$exists) { throw new RuntimeException('File does not exist'); } else if ($this->autoCreate == true && !$exists) { // Create new empty file touch($this->file); $this->loaded = true; // There's no need to fetch content from the empty file return array(); } $content = file_get_contents($this->file); $content = $this->serializer->unserialize($content); if (!$content) { $content = array(); } $this->content = $content; $this->loaded = true; }
[ "public", "function", "load", "(", ")", "{", "// Check for existence only once and save the result", "$", "exists", "=", "is_file", "(", "$", "this", "->", "file", ")", ";", "if", "(", "$", "this", "->", "autoCreate", "==", "false", "&&", "!", "$", "exists",...
Loads content from a file @throws \RuntimeException When $autoCreate set to false and file doesn't exist @return array
[ "Loads", "content", "from", "a", "file" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/FileEngine/CacheFile.php#L90-L115
train
krystal-framework/krystal.framework
src/Krystal/Cache/FileEngine/CacheFile.php
CacheFile.save
public function save(array $data) { return (bool) file_put_contents($this->file, $this->serializer->serialize($data)); }
php
public function save(array $data) { return (bool) file_put_contents($this->file, $this->serializer->serialize($data)); }
[ "public", "function", "save", "(", "array", "$", "data", ")", "{", "return", "(", "bool", ")", "file_put_contents", "(", "$", "this", "->", "file", ",", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "data", ")", ")", ";", "}" ]
Writes data to the file @param array $data @return boolean
[ "Writes", "data", "to", "the", "file" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/FileEngine/CacheFile.php#L123-L126
train
stevebauman/WinPerm
src/Scanner.php
Scanner.getAccounts
public function getAccounts() { if ($output = $this->execute('icacls', $this->path)) { // The first element will always include the path, we'll // remove it before passing the output to the parser. $output[0] = str_replace($this->path, '', $output[0]); // The last element will always contain the success / failure message. array_pop($output); // We'll also remove blank lines from the output array. $output = array_filter($output); // Finally, we'll pass the output to the parser. return $this->newParser($output)->parse(); } return false; }
php
public function getAccounts() { if ($output = $this->execute('icacls', $this->path)) { // The first element will always include the path, we'll // remove it before passing the output to the parser. $output[0] = str_replace($this->path, '', $output[0]); // The last element will always contain the success / failure message. array_pop($output); // We'll also remove blank lines from the output array. $output = array_filter($output); // Finally, we'll pass the output to the parser. return $this->newParser($output)->parse(); } return false; }
[ "public", "function", "getAccounts", "(", ")", "{", "if", "(", "$", "output", "=", "$", "this", "->", "execute", "(", "'icacls'", ",", "$", "this", "->", "path", ")", ")", "{", "// The first element will always include the path, we'll", "// remove it before passin...
Returns an array of accounts with their permissions on the current directory. Returns false on failure. @return array|bool
[ "Returns", "an", "array", "of", "accounts", "with", "their", "permissions", "on", "the", "current", "directory", "." ]
1a31be477cbe21e6bd8ee9f0c09330a7b2c649e9
https://github.com/stevebauman/WinPerm/blob/1a31be477cbe21e6bd8ee9f0c09330a7b2c649e9/src/Scanner.php#L53-L71
train
stevebauman/WinPerm
src/Scanner.php
Scanner.getId
public function getId() { if ($output = $this->execute('fsutil file queryfileid', $this->path)) { if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) { return $matches[0]; } } }
php
public function getId() { if ($output = $this->execute('fsutil file queryfileid', $this->path)) { if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) { return $matches[0]; } } }
[ "public", "function", "getId", "(", ")", "{", "if", "(", "$", "output", "=", "$", "this", "->", "execute", "(", "'fsutil file queryfileid'", ",", "$", "this", "->", "path", ")", ")", "{", "if", "(", "(", "bool", ")", "preg_match", "(", "'/(\\d{1}[x].*)...
Returns the current paths unique ID. @return string|null
[ "Returns", "the", "current", "paths", "unique", "ID", "." ]
1a31be477cbe21e6bd8ee9f0c09330a7b2c649e9
https://github.com/stevebauman/WinPerm/blob/1a31be477cbe21e6bd8ee9f0c09330a7b2c649e9/src/Scanner.php#L78-L85
train
Droeftoeter/pokapi
src/Pokapi/Utility/Geo.php
Geo.calculateNewCoordinates
public static function calculateNewCoordinates(float $initialLatitude, float $initialLongitude, float $distance, int $bearing) { $bearing = deg2rad($bearing); $latitude = deg2rad($initialLatitude); $longitude = deg2rad($initialLongitude); $earth = self::EARTH_RADIUS_METERS / 1000; $newLatitude = asin( sin($latitude) * cos($distance/$earth) + cos($latitude) * sin($distance/$earth) * cos($bearing) ); $newLongitude = $longitude + atan2( sin($bearing) * sin($distance/$earth) * cos($latitude), cos($distance/$earth)-sin($latitude)*sin($newLatitude) ); return [rad2deg($newLatitude), rad2deg($newLongitude)]; }
php
public static function calculateNewCoordinates(float $initialLatitude, float $initialLongitude, float $distance, int $bearing) { $bearing = deg2rad($bearing); $latitude = deg2rad($initialLatitude); $longitude = deg2rad($initialLongitude); $earth = self::EARTH_RADIUS_METERS / 1000; $newLatitude = asin( sin($latitude) * cos($distance/$earth) + cos($latitude) * sin($distance/$earth) * cos($bearing) ); $newLongitude = $longitude + atan2( sin($bearing) * sin($distance/$earth) * cos($latitude), cos($distance/$earth)-sin($latitude)*sin($newLatitude) ); return [rad2deg($newLatitude), rad2deg($newLongitude)]; }
[ "public", "static", "function", "calculateNewCoordinates", "(", "float", "$", "initialLatitude", ",", "float", "$", "initialLongitude", ",", "float", "$", "distance", ",", "int", "$", "bearing", ")", "{", "$", "bearing", "=", "deg2rad", "(", "$", "bearing", ...
Calculate new coordinates based on distance and bearing @param float $initialLatitude @param float $initialLongitude @param float $distance @param int $bearing @return array
[ "Calculate", "new", "coordinates", "based", "on", "distance", "and", "bearing" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Utility/Geo.php#L30-L48
train
Droeftoeter/pokapi
src/Pokapi/Utility/Geo.php
Geo.calculateDistance
public static function calculateDistance(float $sourceLatitude, float $sourceLongitude, float $targetLatitude, float $targetLongitude) : float { $radSourceLat = deg2rad($sourceLatitude); $radSourceLon = deg2rad($sourceLongitude); $radTargetLat = deg2rad($targetLatitude); $radTargetLon = deg2rad($targetLongitude); $latitudeDelta = $radTargetLat - $radSourceLat; $longitudeDelta = $radTargetLon - $radSourceLon; $angle = 2 * asin( sqrt( pow(sin($latitudeDelta / 2), 2) + cos($radSourceLat) * cos($radTargetLat) * pow(sin($longitudeDelta / 2), 2) ) ); return $angle * Geo::EARTH_RADIUS_METERS; }
php
public static function calculateDistance(float $sourceLatitude, float $sourceLongitude, float $targetLatitude, float $targetLongitude) : float { $radSourceLat = deg2rad($sourceLatitude); $radSourceLon = deg2rad($sourceLongitude); $radTargetLat = deg2rad($targetLatitude); $radTargetLon = deg2rad($targetLongitude); $latitudeDelta = $radTargetLat - $radSourceLat; $longitudeDelta = $radTargetLon - $radSourceLon; $angle = 2 * asin( sqrt( pow(sin($latitudeDelta / 2), 2) + cos($radSourceLat) * cos($radTargetLat) * pow(sin($longitudeDelta / 2), 2) ) ); return $angle * Geo::EARTH_RADIUS_METERS; }
[ "public", "static", "function", "calculateDistance", "(", "float", "$", "sourceLatitude", ",", "float", "$", "sourceLongitude", ",", "float", "$", "targetLatitude", ",", "float", "$", "targetLongitude", ")", ":", "float", "{", "$", "radSourceLat", "=", "deg2rad"...
Calculate distance in meters between two points @param float $sourceLatitude @param float $sourceLongitude @param float $targetLatitude @param float $targetLongitude @return float
[ "Calculate", "distance", "in", "meters", "between", "two", "points" ]
3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3
https://github.com/Droeftoeter/pokapi/blob/3fe0f0c1bd4dc09c5d439eb96294440a75b5e0f3/src/Pokapi/Utility/Geo.php#L140-L158
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Checkbox.php
Checkbox.createHiddenNode
private function createHiddenNode(array $attrs) { $attrs = array( 'type' => 'hidden', 'name' => $attrs['name'], 'value' => '0' ); $node = new NodeElement(); $node->openTag('input') ->addAttributes($attrs) ->finalize(true); return $node; }
php
private function createHiddenNode(array $attrs) { $attrs = array( 'type' => 'hidden', 'name' => $attrs['name'], 'value' => '0' ); $node = new NodeElement(); $node->openTag('input') ->addAttributes($attrs) ->finalize(true); return $node; }
[ "private", "function", "createHiddenNode", "(", "array", "$", "attrs", ")", "{", "$", "attrs", "=", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "$", "attrs", "[", "'name'", "]", ",", "'value'", "=>", "'0'", ")", ";", "$", "node", "...
Creates hidden node @param array $attrs @return \Krystal\Form\NodeElement
[ "Creates", "hidden", "node" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Checkbox.php#L51-L65
train
krystal-framework/krystal.framework
src/Krystal/Form/Element/Checkbox.php
Checkbox.createCheckboxNode
private function createCheckboxNode(array $attrs) { $defaults = array( 'type' => 'checkbox', 'value' => '1' ); $attrs = array_merge($defaults, $attrs); $node = new NodeElement(); $node->openTag('input') ->addAttributes($attrs); // Check if active if ($this->active == $defaults['value'] || $this->active === true) { $node->addProperty('checked'); } $node->finalize(true); return $node; }
php
private function createCheckboxNode(array $attrs) { $defaults = array( 'type' => 'checkbox', 'value' => '1' ); $attrs = array_merge($defaults, $attrs); $node = new NodeElement(); $node->openTag('input') ->addAttributes($attrs); // Check if active if ($this->active == $defaults['value'] || $this->active === true) { $node->addProperty('checked'); } $node->finalize(true); return $node; }
[ "private", "function", "createCheckboxNode", "(", "array", "$", "attrs", ")", "{", "$", "defaults", "=", "array", "(", "'type'", "=>", "'checkbox'", ",", "'value'", "=>", "'1'", ")", ";", "$", "attrs", "=", "array_merge", "(", "$", "defaults", ",", "$", ...
Creates checkbox node @param array $attrs @return \Krystal\Form\NodeElement
[ "Creates", "checkbox", "node" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Form/Element/Checkbox.php#L73-L94
train
spiral/odm
source/Spiral/ODM/Accessors/AbstractArray.php
AbstractArray.has
public function has($needle, bool $strict = true): bool { foreach ($this->values as $value) { if ($strict && $value === $needle) { return true; } if ($strict && $value == $needle) { return true; } } return false; }
php
public function has($needle, bool $strict = true): bool { foreach ($this->values as $value) { if ($strict && $value === $needle) { return true; } if ($strict && $value == $needle) { return true; } } return false; }
[ "public", "function", "has", "(", "$", "needle", ",", "bool", "$", "strict", "=", "true", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "values", "as", "$", "value", ")", "{", "if", "(", "$", "strict", "&&", "$", "value", "===", "$", ...
Check if value presented in array. @param mixed $needle @param bool $strict @return bool
[ "Check", "if", "value", "presented", "in", "array", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Accessors/AbstractArray.php#L63-L76
train
spiral/odm
source/Spiral/ODM/Accessors/AbstractArray.php
AbstractArray.addValues
protected function addValues($values) { if (!is_array($values) && !$values instanceof \Traversable) { //Unable to process values return; } foreach ($values as $value) { //Passing every value thought the filter $value = $this->filterValue($value); if (!is_null($value)) { $this->values[] = $value; } } }
php
protected function addValues($values) { if (!is_array($values) && !$values instanceof \Traversable) { //Unable to process values return; } foreach ($values as $value) { //Passing every value thought the filter $value = $this->filterValue($value); if (!is_null($value)) { $this->values[] = $value; } } }
[ "protected", "function", "addValues", "(", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", "&&", "!", "$", "values", "instanceof", "\\", "Traversable", ")", "{", "//Unable to process values", "return", ";", "}", "foreach", "("...
Add values matched with filter. @param mixed $values
[ "Add", "values", "matched", "with", "filter", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Accessors/AbstractArray.php#L259-L273
train
inc2734/mimizuku-core
src/App/Contract/Helper/Assets.php
Assets.generate_script_dependencies
public static function generate_script_dependencies( $maybe_dependencies ) { $dependencies = []; foreach ( $maybe_dependencies as $dependency ) { if ( ! wp_script_is( $dependency, 'enqueued' ) && ! wp_script_is( $dependency, 'registered' ) ) { continue; } $dependencies[] = $dependency; } return $dependencies; }
php
public static function generate_script_dependencies( $maybe_dependencies ) { $dependencies = []; foreach ( $maybe_dependencies as $dependency ) { if ( ! wp_script_is( $dependency, 'enqueued' ) && ! wp_script_is( $dependency, 'registered' ) ) { continue; } $dependencies[] = $dependency; } return $dependencies; }
[ "public", "static", "function", "generate_script_dependencies", "(", "$", "maybe_dependencies", ")", "{", "$", "dependencies", "=", "[", "]", ";", "foreach", "(", "$", "maybe_dependencies", "as", "$", "dependency", ")", "{", "if", "(", "!", "wp_script_is", "("...
Generate script dependencies @param array $maybe_dependencies @return array
[ "Generate", "script", "dependencies" ]
d192a01f4a730e53bced3dfcd0ef29fbecc80330
https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Assets.php#L46-L55
train
inc2734/mimizuku-core
src/App/Contract/Helper/Assets.php
Assets.generate_style_dependencies
public static function generate_style_dependencies( $maybe_dependencies ) { $dependencies = []; foreach ( $maybe_dependencies as $dependency ) { if ( ! wp_style_is( $dependency, 'enqueued' ) && ! wp_style_is( $dependency, 'registered' ) ) { continue; } $dependencies[] = $dependency; } return $dependencies; }
php
public static function generate_style_dependencies( $maybe_dependencies ) { $dependencies = []; foreach ( $maybe_dependencies as $dependency ) { if ( ! wp_style_is( $dependency, 'enqueued' ) && ! wp_style_is( $dependency, 'registered' ) ) { continue; } $dependencies[] = $dependency; } return $dependencies; }
[ "public", "static", "function", "generate_style_dependencies", "(", "$", "maybe_dependencies", ")", "{", "$", "dependencies", "=", "[", "]", ";", "foreach", "(", "$", "maybe_dependencies", "as", "$", "dependency", ")", "{", "if", "(", "!", "wp_style_is", "(", ...
Generate style dependencies @param array $maybe_dependencies @return array
[ "Generate", "style", "dependencies" ]
d192a01f4a730e53bced3dfcd0ef29fbecc80330
https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Assets.php#L63-L72
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/MapperFactory.php
MapperFactory.createArgs
private function createArgs() { $args = array($this->db); if (is_object($this->paginator)) { array_push($args, $this->paginator); } array_push($args, $this->prefix); return $args; }
php
private function createArgs() { $args = array($this->db); if (is_object($this->paginator)) { array_push($args, $this->paginator); } array_push($args, $this->prefix); return $args; }
[ "private", "function", "createArgs", "(", ")", "{", "$", "args", "=", "array", "(", "$", "this", "->", "db", ")", ";", "if", "(", "is_object", "(", "$", "this", "->", "paginator", ")", ")", "{", "array_push", "(", "$", "args", ",", "$", "this", "...
Return arguments for a mapper @return array
[ "Return", "arguments", "for", "a", "mapper" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/MapperFactory.php#L64-L74
train
jarnix/nofussframework
Nf/LabelManager.php
LabelManager.loadLabels
public function loadLabels($locale, $force = false) { if (!$this->labelsLoaded || $force) { if (file_exists(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini')) { $this->labels=parse_ini_file(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini', true); $this->labelsLoaded=true; } else { throw new \Exception('Cannot load labels for this locale (' . $locale . ')'); } } }
php
public function loadLabels($locale, $force = false) { if (!$this->labelsLoaded || $force) { if (file_exists(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini')) { $this->labels=parse_ini_file(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini', true); $this->labelsLoaded=true; } else { throw new \Exception('Cannot load labels for this locale (' . $locale . ')'); } } }
[ "public", "function", "loadLabels", "(", "$", "locale", ",", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "labelsLoaded", "||", "$", "force", ")", "{", "if", "(", "file_exists", "(", "\\", "Nf", "\\", "Registry", "::", "...
load the labels
[ "load", "the", "labels" ]
2177ebefd408bd9545ac64345b47cde1ff3cdccb
https://github.com/jarnix/nofussframework/blob/2177ebefd408bd9545ac64345b47cde1ff3cdccb/Nf/LabelManager.php#L14-L24
train
hostnet/dead
src/common/YmlCommandLine.php
YmlCommandLine.fromYamlString
public static function fromYamlString($yml, $config_yml = null) { $parser = new sfYamlParser(); $yml_tree = $parser->parse($yml); if ($config_yml) { $yml_config_tree = $parser->parse($config_yml); self::mergeDefaultsIntoYml($yml_tree, $yml_config_tree); } $cmd = self::ymlToCmd($yml_tree); $cmd = self::ymlParseOptions($yml_tree, $cmd); $cmd = self::ymlParseArguments($yml_tree, $cmd); $cmd = self::ymlParseCommands($yml_tree, $cmd); return $cmd; }
php
public static function fromYamlString($yml, $config_yml = null) { $parser = new sfYamlParser(); $yml_tree = $parser->parse($yml); if ($config_yml) { $yml_config_tree = $parser->parse($config_yml); self::mergeDefaultsIntoYml($yml_tree, $yml_config_tree); } $cmd = self::ymlToCmd($yml_tree); $cmd = self::ymlParseOptions($yml_tree, $cmd); $cmd = self::ymlParseArguments($yml_tree, $cmd); $cmd = self::ymlParseCommands($yml_tree, $cmd); return $cmd; }
[ "public", "static", "function", "fromYamlString", "(", "$", "yml", ",", "$", "config_yml", "=", "null", ")", "{", "$", "parser", "=", "new", "sfYamlParser", "(", ")", ";", "$", "yml_tree", "=", "$", "parser", "->", "parse", "(", "$", "yml", ")", ";",...
Read Console_CommandLine_Command from yml strings, one with all arguments and one with configuration options to overwrite default values set in the first one. @param string $yml @param string $config_yml @return Console_CommandLine_Command @throws Exception
[ "Read", "Console_CommandLine_Command", "from", "yml", "strings", "one", "with", "all", "arguments", "and", "one", "with", "configuration", "options", "to", "overwrite", "default", "values", "set", "in", "the", "first", "one", "." ]
29cdfeb4feb019405dbd0cbcd34bfa3105c07880
https://github.com/hostnet/dead/blob/29cdfeb4feb019405dbd0cbcd34bfa3105c07880/src/common/YmlCommandLine.php#L41-L58
train
krystal-framework/krystal.framework
src/Krystal/Application/Route/RouteNotation.php
RouteNotation.toArgs
public function toArgs($notation) { $target = $this->toClassPath($notation); return explode(self::ROUTE_SYNTAX_SEPARATOR, $target); }
php
public function toArgs($notation) { $target = $this->toClassPath($notation); return explode(self::ROUTE_SYNTAX_SEPARATOR, $target); }
[ "public", "function", "toArgs", "(", "$", "notation", ")", "{", "$", "target", "=", "$", "this", "->", "toClassPath", "(", "$", "notation", ")", ";", "return", "explode", "(", "self", "::", "ROUTE_SYNTAX_SEPARATOR", ",", "$", "target", ")", ";", "}" ]
Converts short controller action into parameters that can be passed to call_user_func_array @param string $notation @return array
[ "Converts", "short", "controller", "action", "into", "parameters", "that", "can", "be", "passed", "to", "call_user_func_array" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Route/RouteNotation.php#L26-L30
train
krystal-framework/krystal.framework
src/Krystal/Application/Route/RouteNotation.php
RouteNotation.toCompliant
public function toCompliant($notation) { $chunks = explode(self::ROUTE_SYNTAX_SEPARATOR, $notation); // Save the action into a variable $action = $chunks[1]; // Break what we have according to separators now $parts = explode(':', $chunks[0]); // Take a module and save it now $module = array_shift($parts); // It's time to build PSR-0 compliant path $path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts)); return array($path => $action); }
php
public function toCompliant($notation) { $chunks = explode(self::ROUTE_SYNTAX_SEPARATOR, $notation); // Save the action into a variable $action = $chunks[1]; // Break what we have according to separators now $parts = explode(':', $chunks[0]); // Take a module and save it now $module = array_shift($parts); // It's time to build PSR-0 compliant path $path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts)); return array($path => $action); }
[ "public", "function", "toCompliant", "(", "$", "notation", ")", "{", "$", "chunks", "=", "explode", "(", "self", "::", "ROUTE_SYNTAX_SEPARATOR", ",", "$", "notation", ")", ";", "// Save the action into a variable", "$", "action", "=", "$", "chunks", "[", "1", ...
Converts route notation syntax back to PSR-0 compliant @param string $notation @return array
[ "Converts", "route", "notation", "syntax", "back", "to", "PSR", "-", "0", "compliant" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Route/RouteNotation.php#L38-L52
train
krystal-framework/krystal.framework
src/Krystal/Application/Route/RouteNotation.php
RouteNotation.toClassPath
public function toClassPath($class) { $parts = explode(self::ROUTE_SYNTAX_DELIMITER, $class); $module = $parts[0]; unset($parts[0]); $path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts)); return $path; }
php
public function toClassPath($class) { $parts = explode(self::ROUTE_SYNTAX_DELIMITER, $class); $module = $parts[0]; unset($parts[0]); $path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts)); return $path; }
[ "public", "function", "toClassPath", "(", "$", "class", ")", "{", "$", "parts", "=", "explode", "(", "self", "::", "ROUTE_SYNTAX_DELIMITER", ",", "$", "class", ")", ";", "$", "module", "=", "$", "parts", "[", "0", "]", ";", "unset", "(", "$", "parts"...
Converts notated syntax to compliant @param string $class @return string
[ "Converts", "notated", "syntax", "to", "compliant" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Route/RouteNotation.php#L60-L70
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.hashPassword
public function hashPassword($password) { if ($this->mode == self::MODE_BCRYPT) { return $this->hashModeBcrypt($password); } elseif ($this->mode == self::MODE_PBKDF2) { return $this->hashModePbkdf2($password); } $this->error = 'You have to set the mode...'; $this->cwsDebug->error($this->error); }
php
public function hashPassword($password) { if ($this->mode == self::MODE_BCRYPT) { return $this->hashModeBcrypt($password); } elseif ($this->mode == self::MODE_PBKDF2) { return $this->hashModePbkdf2($password); } $this->error = 'You have to set the mode...'; $this->cwsDebug->error($this->error); }
[ "public", "function", "hashPassword", "(", "$", "password", ")", "{", "if", "(", "$", "this", "->", "mode", "==", "self", "::", "MODE_BCRYPT", ")", "{", "return", "$", "this", "->", "hashModeBcrypt", "(", "$", "password", ")", ";", "}", "elseif", "(", ...
Create a password hash. @param string $password : The password @return string|null
[ "Create", "a", "password", "hash", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L87-L97
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.hashModePbkdf2
private function hashModePbkdf2($password) { $this->cwsDebug->titleH2('Create password hash using PBKDF2'); $this->cwsDebug->labelValue('Password', $password); $salt = $this->random(self::PBKDF2_RANDOM_BYTES); $this->cwsDebug->labelValue('Salt', $salt); $algorithm = $this->encode(self::PBKDF2_ALGORITHM); $this->cwsDebug->labelValue('Algorithm', self::PBKDF2_ALGORITHM); $ite = rand(self::PBKDF2_MIN_ITE, self::PBKDF2_MAX_ITE); $this->cwsDebug->labelValue('Iterations', $ite); $ite = $this->encode(rand(self::PBKDF2_MIN_ITE, self::PBKDF2_MAX_ITE)); $params = $algorithm.self::PBKDF2_SEPARATOR; $params .= $ite.self::PBKDF2_SEPARATOR; $params .= $salt.self::PBKDF2_SEPARATOR; $hash = $this->getPbkdf2($algorithm, $password, $salt, $ite, self::PBKDF2_HASH_BYTES, true); $this->cwsDebug->labelValue('Hash', $hash); $this->cwsDebug->labelValue('Length', strlen($hash)); $finalHash = $params.base64_encode($hash); $this->cwsDebug->dump('Encoded hash (length : '.strlen($finalHash).')', $finalHash); if (strlen($finalHash) == self::PBKDF2_LENGTH) { return $finalHash; } $this->error = 'Cannot generate the PBKDF2 password hash...'; $this->cwsDebug->error($this->error); }
php
private function hashModePbkdf2($password) { $this->cwsDebug->titleH2('Create password hash using PBKDF2'); $this->cwsDebug->labelValue('Password', $password); $salt = $this->random(self::PBKDF2_RANDOM_BYTES); $this->cwsDebug->labelValue('Salt', $salt); $algorithm = $this->encode(self::PBKDF2_ALGORITHM); $this->cwsDebug->labelValue('Algorithm', self::PBKDF2_ALGORITHM); $ite = rand(self::PBKDF2_MIN_ITE, self::PBKDF2_MAX_ITE); $this->cwsDebug->labelValue('Iterations', $ite); $ite = $this->encode(rand(self::PBKDF2_MIN_ITE, self::PBKDF2_MAX_ITE)); $params = $algorithm.self::PBKDF2_SEPARATOR; $params .= $ite.self::PBKDF2_SEPARATOR; $params .= $salt.self::PBKDF2_SEPARATOR; $hash = $this->getPbkdf2($algorithm, $password, $salt, $ite, self::PBKDF2_HASH_BYTES, true); $this->cwsDebug->labelValue('Hash', $hash); $this->cwsDebug->labelValue('Length', strlen($hash)); $finalHash = $params.base64_encode($hash); $this->cwsDebug->dump('Encoded hash (length : '.strlen($finalHash).')', $finalHash); if (strlen($finalHash) == self::PBKDF2_LENGTH) { return $finalHash; } $this->error = 'Cannot generate the PBKDF2 password hash...'; $this->cwsDebug->error($this->error); }
[ "private", "function", "hashModePbkdf2", "(", "$", "password", ")", "{", "$", "this", "->", "cwsDebug", "->", "titleH2", "(", "'Create password hash using PBKDF2'", ")", ";", "$", "this", "->", "cwsDebug", "->", "labelValue", "(", "'Password'", ",", "$", "pass...
Create a password hash using PBKDF2 mode. @param string $password @return string|null
[ "Create", "a", "password", "hash", "using", "PBKDF2", "mode", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L136-L168
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.checkPassword
public function checkPassword($password, $hash) { if ($this->mode == self::MODE_BCRYPT) { return $this->checkModeBcrypt($password, $hash); } elseif ($this->mode == self::MODE_PBKDF2) { return $this->checkModePbkdf2($password, $hash); } $this->error = 'You have to set the mode...'; $this->cwsDebug->error($this->error); return false; }
php
public function checkPassword($password, $hash) { if ($this->mode == self::MODE_BCRYPT) { return $this->checkModeBcrypt($password, $hash); } elseif ($this->mode == self::MODE_PBKDF2) { return $this->checkModePbkdf2($password, $hash); } $this->error = 'You have to set the mode...'; $this->cwsDebug->error($this->error); return false; }
[ "public", "function", "checkPassword", "(", "$", "password", ",", "$", "hash", ")", "{", "if", "(", "$", "this", "->", "mode", "==", "self", "::", "MODE_BCRYPT", ")", "{", "return", "$", "this", "->", "checkModeBcrypt", "(", "$", "password", ",", "$", ...
Check a hash with the password given. @param string $password : The password @param string $hash : The stored password hash @return bool
[ "Check", "a", "hash", "with", "the", "password", "given", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L178-L190
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.checkModeBcrypt
private function checkModeBcrypt($password, $hash) { $this->cwsDebug->titleH2('Check password hash in BCRYPT mode'); $this->cwsDebug->labelValue('Password', $password); $this->cwsDebug->labelValue('Hash', $hash); $checkHash = crypt($password, $hash); $this->cwsDebug->labelValue('Check hash', $checkHash); $result = $this->slowEquals($hash, $checkHash); $this->cwsDebug->labelValue('Valid?', ($result ? 'YES!' : 'NO...')); return $result; }
php
private function checkModeBcrypt($password, $hash) { $this->cwsDebug->titleH2('Check password hash in BCRYPT mode'); $this->cwsDebug->labelValue('Password', $password); $this->cwsDebug->labelValue('Hash', $hash); $checkHash = crypt($password, $hash); $this->cwsDebug->labelValue('Check hash', $checkHash); $result = $this->slowEquals($hash, $checkHash); $this->cwsDebug->labelValue('Valid?', ($result ? 'YES!' : 'NO...')); return $result; }
[ "private", "function", "checkModeBcrypt", "(", "$", "password", ",", "$", "hash", ")", "{", "$", "this", "->", "cwsDebug", "->", "titleH2", "(", "'Check password hash in BCRYPT mode'", ")", ";", "$", "this", "->", "cwsDebug", "->", "labelValue", "(", "'Passwor...
Check a hash with the password given using BCRYPT mode. @param string $password @param string $hash @return bool
[ "Check", "a", "hash", "with", "the", "password", "given", "using", "BCRYPT", "mode", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L200-L213
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.checkModePbkdf2
private function checkModePbkdf2($password, $hash) { $this->cwsDebug->titleH2('Check password hash in PBKDF2 mode'); $this->cwsDebug->labelValue('Password', $password); $this->cwsDebug->dump('Hash', $hash); $params = explode(self::PBKDF2_SEPARATOR, $hash); if (count($params) < self::PBKDF2_SECTIONS) { return false; } $algorithm = $params[self::PBKDF2_ALGORITHM_INDEX]; $salt = $params[self::PBKDF2_SALT_INDEX]; $ite = $params[self::PBKDF2_ITE_INDEX]; $hash = base64_decode($params[self::PBKDF2_HASH_INDEX]); $this->cwsDebug->labelValue('Decoded hash', $hash); $checkHash = $this->getPbkdf2($algorithm, $password, $salt, $ite, strlen($hash), true); $this->cwsDebug->labelValue('Check hash', $checkHash); $result = $this->slowEquals($hash, $checkHash); $this->cwsDebug->labelValue('Valid?', ($result ? 'YES!' : 'NO...')); return $result; }
php
private function checkModePbkdf2($password, $hash) { $this->cwsDebug->titleH2('Check password hash in PBKDF2 mode'); $this->cwsDebug->labelValue('Password', $password); $this->cwsDebug->dump('Hash', $hash); $params = explode(self::PBKDF2_SEPARATOR, $hash); if (count($params) < self::PBKDF2_SECTIONS) { return false; } $algorithm = $params[self::PBKDF2_ALGORITHM_INDEX]; $salt = $params[self::PBKDF2_SALT_INDEX]; $ite = $params[self::PBKDF2_ITE_INDEX]; $hash = base64_decode($params[self::PBKDF2_HASH_INDEX]); $this->cwsDebug->labelValue('Decoded hash', $hash); $checkHash = $this->getPbkdf2($algorithm, $password, $salt, $ite, strlen($hash), true); $this->cwsDebug->labelValue('Check hash', $checkHash); $result = $this->slowEquals($hash, $checkHash); $this->cwsDebug->labelValue('Valid?', ($result ? 'YES!' : 'NO...')); return $result; }
[ "private", "function", "checkModePbkdf2", "(", "$", "password", ",", "$", "hash", ")", "{", "$", "this", "->", "cwsDebug", "->", "titleH2", "(", "'Check password hash in PBKDF2 mode'", ")", ";", "$", "this", "->", "cwsDebug", "->", "labelValue", "(", "'Passwor...
Check a hash with the password given using PBKDF2 mode. @param string $password @param string $hash @return bool
[ "Check", "a", "hash", "with", "the", "password", "given", "using", "PBKDF2", "mode", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L223-L247
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.encrypt
public function encrypt($data) { $this->cwsDebug->titleH2('Encrypt data'); if (empty($this->encryptionKey)) { $this->error = 'You have to set the encryption key...'; $this->cwsDebug->error($this->error); return; } if (empty($data)) { $this->error = 'Data empty...'; $this->cwsDebug->error($this->error); return; } $this->cwsDebug->labelValue('Encryption key', $this->encryptionKey); $this->cwsDebug->dump('Data', $data); $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CFB, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = mcrypt_create_iv($ivsize, MCRYPT_DEV_URANDOM); $key = $this->validateKey($this->encryptionKey, mcrypt_enc_get_key_size($td)); mcrypt_generic_init($td, $key, $iv); $encryptedData = mcrypt_generic($td, $this->encode($data)); mcrypt_generic_deinit($td); $result = $iv.$encryptedData; $this->cwsDebug->dump('Encrypted data', $result); return $result; }
php
public function encrypt($data) { $this->cwsDebug->titleH2('Encrypt data'); if (empty($this->encryptionKey)) { $this->error = 'You have to set the encryption key...'; $this->cwsDebug->error($this->error); return; } if (empty($data)) { $this->error = 'Data empty...'; $this->cwsDebug->error($this->error); return; } $this->cwsDebug->labelValue('Encryption key', $this->encryptionKey); $this->cwsDebug->dump('Data', $data); $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CFB, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = mcrypt_create_iv($ivsize, MCRYPT_DEV_URANDOM); $key = $this->validateKey($this->encryptionKey, mcrypt_enc_get_key_size($td)); mcrypt_generic_init($td, $key, $iv); $encryptedData = mcrypt_generic($td, $this->encode($data)); mcrypt_generic_deinit($td); $result = $iv.$encryptedData; $this->cwsDebug->dump('Encrypted data', $result); return $result; }
[ "public", "function", "encrypt", "(", "$", "data", ")", "{", "$", "this", "->", "cwsDebug", "->", "titleH2", "(", "'Encrypt data'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "encryptionKey", ")", ")", "{", "$", "this", "->", "error", "=",...
Generate a symectric encryption string with the blowfish algorithm and an encryption key in CFB mode. Please be advised that you should not use this method for truly sensitive data. @param string $data : The data to encrypt @return string|null : The encrypted string
[ "Generate", "a", "symectric", "encryption", "string", "with", "the", "blowfish", "algorithm", "and", "an", "encryption", "key", "in", "CFB", "mode", ".", "Please", "be", "advised", "that", "you", "should", "not", "use", "this", "method", "for", "truly", "sen...
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L258-L294
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.decrypt
public function decrypt($data) { $this->cwsDebug->titleH2('Decrypt data'); if (empty($this->encryptionKey)) { $this->error = 'You have to set the encryption key...'; $this->cwsDebug->error($this->error); return; } if (empty($data)) { $this->error = 'Data empty...'; $this->cwsDebug->error($this->error); return; } $this->cwsDebug->labelValue('Encryption key', $this->encryptionKey); $this->cwsDebug->dump('Encrypted data', strval($data)); $result = null; $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CFB, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = substr($data, 0, $ivsize); $key = $this->validateKey($this->encryptionKey, mcrypt_enc_get_key_size($td)); if ($iv) { $data = substr($data, $ivsize); mcrypt_generic_init($td, $key, $iv); $decryptData = mdecrypt_generic($td, $data); $result = $this->decode($decryptData); } $this->cwsDebug->dump('Data', $result); return $result; }
php
public function decrypt($data) { $this->cwsDebug->titleH2('Decrypt data'); if (empty($this->encryptionKey)) { $this->error = 'You have to set the encryption key...'; $this->cwsDebug->error($this->error); return; } if (empty($data)) { $this->error = 'Data empty...'; $this->cwsDebug->error($this->error); return; } $this->cwsDebug->labelValue('Encryption key', $this->encryptionKey); $this->cwsDebug->dump('Encrypted data', strval($data)); $result = null; $td = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CFB, ''); $ivsize = mcrypt_enc_get_iv_size($td); $iv = substr($data, 0, $ivsize); $key = $this->validateKey($this->encryptionKey, mcrypt_enc_get_key_size($td)); if ($iv) { $data = substr($data, $ivsize); mcrypt_generic_init($td, $key, $iv); $decryptData = mdecrypt_generic($td, $data); $result = $this->decode($decryptData); } $this->cwsDebug->dump('Data', $result); return $result; }
[ "public", "function", "decrypt", "(", "$", "data", ")", "{", "$", "this", "->", "cwsDebug", "->", "titleH2", "(", "'Decrypt data'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "encryptionKey", ")", ")", "{", "$", "this", "->", "error", "=",...
Return the decrypted string generated from the encrypt method. @param string $data : The encrypted string @return null|string : The decrypted string
[ "Return", "the", "decrypted", "string", "generated", "from", "the", "encrypt", "method", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L303-L341
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.encode
private function encode($data) { $rdm = $this->random(); $data = base64_encode($data); $startIndex = rand(1, strlen($rdm)); $params = base64_encode($startIndex).self::ENC_SEPARATOR; $params .= base64_encode(strlen($data)).self::ENC_SEPARATOR; return $params.substr_replace($rdm, $data, $startIndex, 0); }
php
private function encode($data) { $rdm = $this->random(); $data = base64_encode($data); $startIndex = rand(1, strlen($rdm)); $params = base64_encode($startIndex).self::ENC_SEPARATOR; $params .= base64_encode(strlen($data)).self::ENC_SEPARATOR; return $params.substr_replace($rdm, $data, $startIndex, 0); }
[ "private", "function", "encode", "(", "$", "data", ")", "{", "$", "rdm", "=", "$", "this", "->", "random", "(", ")", ";", "$", "data", "=", "base64_encode", "(", "$", "data", ")", ";", "$", "startIndex", "=", "rand", "(", "1", ",", "strlen", "(",...
Encode data inside a random string. @param string $data : the data to encode @return string : the encoded data
[ "Encode", "data", "inside", "a", "random", "string", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L519-L528
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.decode
private function decode($encData) { $params = explode(self::ENC_SEPARATOR, $encData); if (count($params) < self::ENC_SECTIONS) { return false; } $startIndex = intval(base64_decode($params[self::ENC_STARTINDEX_INDEX])); $dataLength = intval(base64_decode($params[self::ENC_DATALENGTH_INDEX])); if (empty($startIndex) || empty($dataLength)) { return false; } $data = $params[self::ENC_DATA_INDEX]; return base64_decode(substr($data, $startIndex, $dataLength)); }
php
private function decode($encData) { $params = explode(self::ENC_SEPARATOR, $encData); if (count($params) < self::ENC_SECTIONS) { return false; } $startIndex = intval(base64_decode($params[self::ENC_STARTINDEX_INDEX])); $dataLength = intval(base64_decode($params[self::ENC_DATALENGTH_INDEX])); if (empty($startIndex) || empty($dataLength)) { return false; } $data = $params[self::ENC_DATA_INDEX]; return base64_decode(substr($data, $startIndex, $dataLength)); }
[ "private", "function", "decode", "(", "$", "encData", ")", "{", "$", "params", "=", "explode", "(", "self", "::", "ENC_SEPARATOR", ",", "$", "encData", ")", ";", "if", "(", "count", "(", "$", "params", ")", "<", "self", "::", "ENC_SECTIONS", ")", "{"...
Decode and extract data from encoded one. @param string $encData : the encoded data @return string : The decoded data
[ "Decode", "and", "extract", "data", "from", "encoded", "one", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L537-L554
train
crazy-max/CwsCrypto
lib/Cws/CwsCrypto.php
CwsCrypto.validateKey
private static function validateKey($key, $size) { $length = strlen($key); if ($length < $size) { $key = str_pad($key, $size, $key); } elseif ($length > $size) { $key = substr($key, 0, $size); } return $key; }
php
private static function validateKey($key, $size) { $length = strlen($key); if ($length < $size) { $key = str_pad($key, $size, $key); } elseif ($length > $size) { $key = substr($key, 0, $size); } return $key; }
[ "private", "static", "function", "validateKey", "(", "$", "key", ",", "$", "size", ")", "{", "$", "length", "=", "strlen", "(", "$", "key", ")", ";", "if", "(", "$", "length", "<", "$", "size", ")", "{", "$", "key", "=", "str_pad", "(", "$", "k...
Validate a key relative to maximum supported keysize of the opened mode. @param string $key : The key to validate @param int $size : The size of the key (check with mcrypt_enc_get_key_size) @return string $key : The validated key
[ "Validate", "a", "key", "relative", "to", "maximum", "supported", "keysize", "of", "the", "opened", "mode", "." ]
0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426
https://github.com/crazy-max/CwsCrypto/blob/0ab16f1bb4d3b16b1fb6de2be2aee084c3cf1426/lib/Cws/CwsCrypto.php#L564-L575
train
krystal-framework/krystal.framework
src/Krystal/Authentication/AuthManager.php
AuthManager.getData
public function getData($key, $default = false) { if ($this->sessionBag->has($key)){ return $this->sessionBag->get($key); } else { return $default; } }
php
public function getData($key, $default = false) { if ($this->sessionBag->has($key)){ return $this->sessionBag->get($key); } else { return $default; } }
[ "public", "function", "getData", "(", "$", "key", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "this", "->", "sessionBag", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "sessionBag", "->", "get", "(", "...
Returns session data @param string $key @param mixed $default Default value to be returned in case requested key doesn't exist @return mixed
[ "Returns", "session", "data" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Authentication/AuthManager.php#L146-L153
train
krystal-framework/krystal.framework
src/Krystal/Authentication/AuthManager.php
AuthManager.loggenIn
private function loggenIn() { if (!$this->has()) { if (!($this->authService instanceof UserAuthServiceInterface)) { // Not logged in return false; } // Now try to find only in cookies, if found prepare a bag if ($this->reAuth->isStored() && (!$this->has())) { $userBag = $this->reAuth->getUserBag(); } // If session namespace is filled up and at the same time data stored in cookies if (($this->has() && $this->reAuth->isStored()) || $this->has()) { $data = $this->sessionBag->get(self::AUTH_NAMESPACE); $userBag = new UserBag(); $userBag->setLogin($data['login']) ->setPasswordHash($data['passwordHash']); } // If $userBag wasn't created so far, that means user isn't logged at all if (!isset($userBag)) { return false; } // Now let's invoke our defined match visitor $authResult = $this->authService->authenticate($userBag->getLogin(), $userBag->getPasswordHash(), false, false); if ($authResult == true) { // Remember success, in order not to query on each request $this->login($userBag->getLogin(), $userBag->getPasswordHash()); return true; } return false; } else { return true; } }
php
private function loggenIn() { if (!$this->has()) { if (!($this->authService instanceof UserAuthServiceInterface)) { // Not logged in return false; } // Now try to find only in cookies, if found prepare a bag if ($this->reAuth->isStored() && (!$this->has())) { $userBag = $this->reAuth->getUserBag(); } // If session namespace is filled up and at the same time data stored in cookies if (($this->has() && $this->reAuth->isStored()) || $this->has()) { $data = $this->sessionBag->get(self::AUTH_NAMESPACE); $userBag = new UserBag(); $userBag->setLogin($data['login']) ->setPasswordHash($data['passwordHash']); } // If $userBag wasn't created so far, that means user isn't logged at all if (!isset($userBag)) { return false; } // Now let's invoke our defined match visitor $authResult = $this->authService->authenticate($userBag->getLogin(), $userBag->getPasswordHash(), false, false); if ($authResult == true) { // Remember success, in order not to query on each request $this->login($userBag->getLogin(), $userBag->getPasswordHash()); return true; } return false; } else { return true; } }
[ "private", "function", "loggenIn", "(", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", ")", ")", "{", "if", "(", "!", "(", "$", "this", "->", "authService", "instanceof", "UserAuthServiceInterface", ")", ")", "{", "// Not logged in", "return", ...
Checks whether user is logged in @return boolean
[ "Checks", "whether", "user", "is", "logged", "in" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Authentication/AuthManager.php#L170-L211
train
krystal-framework/krystal.framework
src/Krystal/Authentication/AuthManager.php
AuthManager.login
public function login($login, $passwordHash, $remember = false) { if ((bool) $remember == true) { // Write to client's cookies $this->reAuth->store($login, $passwordHash); } // Store it $this->sessionBag->set(self::AUTH_NAMESPACE, array( 'login' => $login, 'passwordHash' => $passwordHash )); }
php
public function login($login, $passwordHash, $remember = false) { if ((bool) $remember == true) { // Write to client's cookies $this->reAuth->store($login, $passwordHash); } // Store it $this->sessionBag->set(self::AUTH_NAMESPACE, array( 'login' => $login, 'passwordHash' => $passwordHash )); }
[ "public", "function", "login", "(", "$", "login", ",", "$", "passwordHash", ",", "$", "remember", "=", "false", ")", "{", "if", "(", "(", "bool", ")", "$", "remember", "==", "true", ")", "{", "// Write to client's cookies", "$", "this", "->", "reAuth", ...
Logins a user @param string $login @param string $passwordHash @param boolean Whether to enable "remember me" functionality @return void
[ "Logins", "a", "user" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Authentication/AuthManager.php#L232-L244
train
krystal-framework/krystal.framework
src/Krystal/Authentication/AuthManager.php
AuthManager.logout
public function logout() { if ($this->has()) { $this->sessionBag->remove(self::AUTH_NAMESPACE); } if ($this->reAuth->isStored()) { $this->reAuth->clear(); } }
php
public function logout() { if ($this->has()) { $this->sessionBag->remove(self::AUTH_NAMESPACE); } if ($this->reAuth->isStored()) { $this->reAuth->clear(); } }
[ "public", "function", "logout", "(", ")", "{", "if", "(", "$", "this", "->", "has", "(", ")", ")", "{", "$", "this", "->", "sessionBag", "->", "remove", "(", "self", "::", "AUTH_NAMESPACE", ")", ";", "}", "if", "(", "$", "this", "->", "reAuth", "...
Erases all credentials @return void
[ "Erases", "all", "credentials" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Authentication/AuthManager.php#L267-L276
train
luismanuelamengual/NeoPHP
src/NeoPHP/Controllers/ControllersRouteGenerator.php
ControllersRouteGenerator.generateRoute
public function generateRoute($method, array $path) : ?Route { $pathPartsSize = sizeof($path); //Obtención del nombre de la clase de controlador $controllerClassName = $this->namespace; if ($pathPartsSize > 1) { for ($i = 0; $i < $pathPartsSize - 1; $i++) { if (!empty($controllerClassName)) { $controllerClassName .= '\\'; } $requestPathPart = $path[$i]; $requestPathPart = str_replace(' ', '', ucwords(str_replace('_', ' ', $requestPathPart))); $controllerClassName .= $requestPathPart; } } else { if (!empty($controllerClassName)) { $controllerClassName .= '\\'; } $controllerClassName .= 'Main'; } $controllerClassName .= get_property('routes.controllers_suffix', 'Controller'); $route = null; if (class_exists($controllerClassName)) { //Obtención del nombre de la metodo del controlador $controllerAction = (empty($path) || empty($path[$pathPartsSize - 1])) ? 'index' : $path[$pathPartsSize - 1]; $controllerAction = str_replace(' ', '', ucwords(str_replace('_', ' ', $controllerAction))); $controllerAction .= get_property('routes.actions_suffix', 'Action'); $controllerAction[0] = strtolower($controllerAction[0]); //Obtención del nombre de la acción $action = $controllerClassName . '@' . $controllerAction; $route = new Route($action); } return $route; }
php
public function generateRoute($method, array $path) : ?Route { $pathPartsSize = sizeof($path); //Obtención del nombre de la clase de controlador $controllerClassName = $this->namespace; if ($pathPartsSize > 1) { for ($i = 0; $i < $pathPartsSize - 1; $i++) { if (!empty($controllerClassName)) { $controllerClassName .= '\\'; } $requestPathPart = $path[$i]; $requestPathPart = str_replace(' ', '', ucwords(str_replace('_', ' ', $requestPathPart))); $controllerClassName .= $requestPathPart; } } else { if (!empty($controllerClassName)) { $controllerClassName .= '\\'; } $controllerClassName .= 'Main'; } $controllerClassName .= get_property('routes.controllers_suffix', 'Controller'); $route = null; if (class_exists($controllerClassName)) { //Obtención del nombre de la metodo del controlador $controllerAction = (empty($path) || empty($path[$pathPartsSize - 1])) ? 'index' : $path[$pathPartsSize - 1]; $controllerAction = str_replace(' ', '', ucwords(str_replace('_', ' ', $controllerAction))); $controllerAction .= get_property('routes.actions_suffix', 'Action'); $controllerAction[0] = strtolower($controllerAction[0]); //Obtención del nombre de la acción $action = $controllerClassName . '@' . $controllerAction; $route = new Route($action); } return $route; }
[ "public", "function", "generateRoute", "(", "$", "method", ",", "array", "$", "path", ")", ":", "?", "Route", "{", "$", "pathPartsSize", "=", "sizeof", "(", "$", "path", ")", ";", "//Obtención del nombre de la clase de controlador", "$", "controllerClassName", "...
Generates a route for accessing controllers @param string $method @param array $path @return mixed|null|string
[ "Generates", "a", "route", "for", "accessing", "controllers" ]
da7c5831974b37dd4b0b170d9aa64e61404d819b
https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Controllers/ControllersRouteGenerator.php#L30-L67
train
fxpio/fxp-form-extensions
Form/Extension/Select2Util.php
Select2Util.convertToDynamicLoader
public static function convertToDynamicLoader(ChoiceListFactoryInterface $choiceListFactory, Options $options, $value) { if ($value instanceof DynamicChoiceLoaderInterface) { return $value; } if (!\is_array($options['choices'])) { throw new InvalidConfigurationException('The "choice_loader" option must be an instance of DynamicChoiceLoaderInterface or the "choices" option must be an array'); } if ($options['select2']['ajax']) { return new AjaxChoiceLoader(self::getChoices($options, $value), $choiceListFactory); } return new DynamicChoiceLoader(self::getChoices($options, $value), $choiceListFactory); }
php
public static function convertToDynamicLoader(ChoiceListFactoryInterface $choiceListFactory, Options $options, $value) { if ($value instanceof DynamicChoiceLoaderInterface) { return $value; } if (!\is_array($options['choices'])) { throw new InvalidConfigurationException('The "choice_loader" option must be an instance of DynamicChoiceLoaderInterface or the "choices" option must be an array'); } if ($options['select2']['ajax']) { return new AjaxChoiceLoader(self::getChoices($options, $value), $choiceListFactory); } return new DynamicChoiceLoader(self::getChoices($options, $value), $choiceListFactory); }
[ "public", "static", "function", "convertToDynamicLoader", "(", "ChoiceListFactoryInterface", "$", "choiceListFactory", ",", "Options", "$", "options", ",", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "DynamicChoiceLoaderInterface", ")", "{", "retu...
Convert the array to the ajax choice loader. @param ChoiceListFactoryInterface $choiceListFactory The choice list factory @param Options $options The options @param DynamicChoiceLoaderInterface|AjaxChoiceLoaderInterface|null $value The value of choice loader normalizer @return DynamicChoiceLoaderInterface|AjaxChoiceLoaderInterface The dynamic choice loader
[ "Convert", "the", "array", "to", "the", "ajax", "choice", "loader", "." ]
ef09edf557b109187d38248b0976df31e5583b5b
https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/Extension/Select2Util.php#L37-L54
train
Firesphere/silverstripe-newsmodule
code/reports/CommentReport.php
CommentReport.parameterFields
public function parameterFields() { $return = FieldList::create( $title = TextField::create( 'Title', _t('CommentReport.NEWSSEARCHTITLE', 'Search newsitem') ), $count = DropdownField::create( 'Comment', _t('CommentReport.COUNTFILTER', 'Comment count filter'), array( '' => _t('CommentReport.ANY', 'All'), 'SPAMCOUNT' => _t('CommentReport.SPAMCOUNT', 'One or more spam comments'), 'HIDDENCOUNT' => _t('CommentReport.HIDDENCOUNT', 'One or more hidden comments'), ) ) ); return $return; }
php
public function parameterFields() { $return = FieldList::create( $title = TextField::create( 'Title', _t('CommentReport.NEWSSEARCHTITLE', 'Search newsitem') ), $count = DropdownField::create( 'Comment', _t('CommentReport.COUNTFILTER', 'Comment count filter'), array( '' => _t('CommentReport.ANY', 'All'), 'SPAMCOUNT' => _t('CommentReport.SPAMCOUNT', 'One or more spam comments'), 'HIDDENCOUNT' => _t('CommentReport.HIDDENCOUNT', 'One or more hidden comments'), ) ) ); return $return; }
[ "public", "function", "parameterFields", "(", ")", "{", "$", "return", "=", "FieldList", "::", "create", "(", "$", "title", "=", "TextField", "::", "create", "(", "'Title'", ",", "_t", "(", "'CommentReport.NEWSSEARCHTITLE'", ",", "'Search newsitem'", ")", ")",...
Setup the searchform. @return \FieldList FieldList instance with the searchfields.
[ "Setup", "the", "searchform", "." ]
98c501bf940878ed9c044124409b85a3e3c4265c
https://github.com/Firesphere/silverstripe-newsmodule/blob/98c501bf940878ed9c044124409b85a3e3c4265c/code/reports/CommentReport.php#L104-L119
train
inc2734/mimizuku-core
src/App/Contract/Helper/Query.php
Query.get_related_posts_query
public static function get_related_posts_query( $post_id ) { $_post = get_post( $post_id ); if ( ! isset( $_post->ID ) ) { return; } $tax_query = []; $taxonomies = get_object_taxonomies( get_post_type( $post_id ), 'object' ); foreach ( $taxonomies as $taxonomy ) { if ( false === $taxonomy->public || false === $taxonomy->show_ui ) { continue; } $term_ids = wp_get_object_terms( $post_id, $taxonomy->name, [ 'fields' => 'ids' ] ); if ( ! $term_ids ) { continue; } $tax_query[] = [ 'taxonomy' => $taxonomy->name, 'field' => 'term_id', 'terms' => $term_ids, 'operator' => 'IN', ]; } $related_posts_args = [ 'post_type' => get_post_type( $post_id ), 'posts_per_page' => 4, 'orderby' => 'rand', 'post__not_in' => [ $post_id ], 'tax_query' => array_merge( [ 'relation' => 'AND', ], $tax_query ), ]; $related_posts_args = apply_filters( 'mimizuku_related_posts_args', $related_posts_args ); return new \WP_Query( array_merge( $related_posts_args, [ 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'suppress_filters' => true, ] ) ); }
php
public static function get_related_posts_query( $post_id ) { $_post = get_post( $post_id ); if ( ! isset( $_post->ID ) ) { return; } $tax_query = []; $taxonomies = get_object_taxonomies( get_post_type( $post_id ), 'object' ); foreach ( $taxonomies as $taxonomy ) { if ( false === $taxonomy->public || false === $taxonomy->show_ui ) { continue; } $term_ids = wp_get_object_terms( $post_id, $taxonomy->name, [ 'fields' => 'ids' ] ); if ( ! $term_ids ) { continue; } $tax_query[] = [ 'taxonomy' => $taxonomy->name, 'field' => 'term_id', 'terms' => $term_ids, 'operator' => 'IN', ]; } $related_posts_args = [ 'post_type' => get_post_type( $post_id ), 'posts_per_page' => 4, 'orderby' => 'rand', 'post__not_in' => [ $post_id ], 'tax_query' => array_merge( [ 'relation' => 'AND', ], $tax_query ), ]; $related_posts_args = apply_filters( 'mimizuku_related_posts_args', $related_posts_args ); return new \WP_Query( array_merge( $related_posts_args, [ 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'suppress_filters' => true, ] ) ); }
[ "public", "static", "function", "get_related_posts_query", "(", "$", "post_id", ")", "{", "$", "_post", "=", "get_post", "(", "$", "post_id", ")", ";", "if", "(", "!", "isset", "(", "$", "_post", "->", "ID", ")", ")", "{", "return", ";", "}", "$", ...
Return related posts @param int $post_id @return array
[ "Return", "related", "posts" ]
d192a01f4a730e53bced3dfcd0ef29fbecc80330
https://github.com/inc2734/mimizuku-core/blob/d192a01f4a730e53bced3dfcd0ef29fbecc80330/src/App/Contract/Helper/Query.php#L38-L91
train
krystal-framework/krystal.framework
src/Krystal/Security/CsrfProtector.php
CsrfProtector.prepare
public function prepare() { if (!$this->sessionBag->has(self::CSRF_TKN_NAME)) { $this->sessionBag->set(self::CSRF_TKN_NAME, $this->generateToken()); $this->sessionBag->set(self::CSRF_TKN_TIME, time()); } $this->prepared = true; }
php
public function prepare() { if (!$this->sessionBag->has(self::CSRF_TKN_NAME)) { $this->sessionBag->set(self::CSRF_TKN_NAME, $this->generateToken()); $this->sessionBag->set(self::CSRF_TKN_TIME, time()); } $this->prepared = true; }
[ "public", "function", "prepare", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sessionBag", "->", "has", "(", "self", "::", "CSRF_TKN_NAME", ")", ")", "{", "$", "this", "->", "sessionBag", "->", "set", "(", "self", "::", "CSRF_TKN_NAME", ",", "$...
Prepares to run @return void
[ "Prepares", "to", "run" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/CsrfProtector.php#L61-L69
train
krystal-framework/krystal.framework
src/Krystal/Security/CsrfProtector.php
CsrfProtector.isExpired
public function isExpired() { $this->validatePrepared(); if (!$this->sessionBag->has(self::CSRF_TKN_TIME)) { return true; } else { $age = time() - $this->sessionBag->get(self::CSRF_TKN_TIME); return $age >= $this->ttl; } }
php
public function isExpired() { $this->validatePrepared(); if (!$this->sessionBag->has(self::CSRF_TKN_TIME)) { return true; } else { $age = time() - $this->sessionBag->get(self::CSRF_TKN_TIME); return $age >= $this->ttl; } }
[ "public", "function", "isExpired", "(", ")", "{", "$", "this", "->", "validatePrepared", "(", ")", ";", "if", "(", "!", "$", "this", "->", "sessionBag", "->", "has", "(", "self", "::", "CSRF_TKN_TIME", ")", ")", "{", "return", "true", ";", "}", "else...
Checks whether token is expired @return boolean
[ "Checks", "whether", "token", "is", "expired" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/CsrfProtector.php#L87-L97
train
krystal-framework/krystal.framework
src/Krystal/Security/CsrfProtector.php
CsrfProtector.isValid
public function isValid($token) { $this->validatePrepared(); return $this->sessionBag->has(self::CSRF_TKN_NAME) && $this->sessionBag->has(self::CSRF_TKN_TIME) && $this->sessionBag->get(self::CSRF_TKN_NAME) === $token; }
php
public function isValid($token) { $this->validatePrepared(); return $this->sessionBag->has(self::CSRF_TKN_NAME) && $this->sessionBag->has(self::CSRF_TKN_TIME) && $this->sessionBag->get(self::CSRF_TKN_NAME) === $token; }
[ "public", "function", "isValid", "(", "$", "token", ")", "{", "$", "this", "->", "validatePrepared", "(", ")", ";", "return", "$", "this", "->", "sessionBag", "->", "has", "(", "self", "::", "CSRF_TKN_NAME", ")", "&&", "$", "this", "->", "sessionBag", ...
Check whether coming token is valid @param string $token Target token to be validated @return boolean
[ "Check", "whether", "coming", "token", "is", "valid" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/CsrfProtector.php#L105-L112
train
cuevae/collection-json-php
src/Template.php
Template.getQuery
public function getQuery() { $properties = array( 'data' => $this, ); $wrapper = new \stdClass(); $collection = new \StdClass(); foreach ($properties as $name => $value) { if (is_array( $value )) { foreach ($value as &$val) { if (is_object( $val )) { $val = $val->output(); } } } if (is_object( $value ) && !$value instanceof \StdClass) { $value = $value->output(); } $collection->$name = $value; } $wrapper->template = $collection; return json_encode($wrapper); }
php
public function getQuery() { $properties = array( 'data' => $this, ); $wrapper = new \stdClass(); $collection = new \StdClass(); foreach ($properties as $name => $value) { if (is_array( $value )) { foreach ($value as &$val) { if (is_object( $val )) { $val = $val->output(); } } } if (is_object( $value ) && !$value instanceof \StdClass) { $value = $value->output(); } $collection->$name = $value; } $wrapper->template = $collection; return json_encode($wrapper); }
[ "public", "function", "getQuery", "(", ")", "{", "$", "properties", "=", "array", "(", "'data'", "=>", "$", "this", ",", ")", ";", "$", "wrapper", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "collection", "=", "new", "\\", "StdClass", "(", ")...
Get the query json @return string
[ "Get", "the", "query", "json" ]
d2d67eed0a4a8fb4e136d7cb9d7fa91937ee67b4
https://github.com/cuevae/collection-json-php/blob/d2d67eed0a4a8fb4e136d7cb9d7fa91937ee67b4/src/Template.php#L57-L79
train
cuevae/collection-json-php
src/Template.php
Template.importItem
public function importItem(Item $item) { foreach ($this->data as $templateData) { foreach ($item->getData() as $itemData) { if ($itemData->getName() === $templateData->getName()) { $templateData->setName($itemData->getName()); $templateData->setValue($itemData->getValue()); $templateData->setPrompt($itemData->getPrompt()); } } } return $this; }
php
public function importItem(Item $item) { foreach ($this->data as $templateData) { foreach ($item->getData() as $itemData) { if ($itemData->getName() === $templateData->getName()) { $templateData->setName($itemData->getName()); $templateData->setValue($itemData->getValue()); $templateData->setPrompt($itemData->getPrompt()); } } } return $this; }
[ "public", "function", "importItem", "(", "Item", "$", "item", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "templateData", ")", "{", "foreach", "(", "$", "item", "->", "getData", "(", ")", "as", "$", "itemData", ")", "{", "if", "...
Import Item object into template @return Template
[ "Import", "Item", "object", "into", "template" ]
d2d67eed0a4a8fb4e136d7cb9d7fa91937ee67b4
https://github.com/cuevae/collection-json-php/blob/d2d67eed0a4a8fb4e136d7cb9d7fa91937ee67b4/src/Template.php#L112-L125
train
krystal-framework/krystal.framework
src/Krystal/Text/Math.php
Math.roundCollection
public static function roundCollection(array $data, $precision = 2) { $output = array(); foreach ($data as $key => $value){ $output[$key] = round($value, $precision); } return $output; }
php
public static function roundCollection(array $data, $precision = 2) { $output = array(); foreach ($data as $key => $value){ $output[$key] = round($value, $precision); } return $output; }
[ "public", "static", "function", "roundCollection", "(", "array", "$", "data", ",", "$", "precision", "=", "2", ")", "{", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", ...
Rounds a collection @param array $data @param integer $precision @return array
[ "Rounds", "a", "collection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Math.php#L50-L59
train
krystal-framework/krystal.framework
src/Krystal/Text/Math.php
Math.average
public static function average($values) { $sum = array_sum($values); $count = count($values); // Avoid useless calculations if ($count == 0) { return 0; } return $sum / $count; }
php
public static function average($values) { $sum = array_sum($values); $count = count($values); // Avoid useless calculations if ($count == 0) { return 0; } return $sum / $count; }
[ "public", "static", "function", "average", "(", "$", "values", ")", "{", "$", "sum", "=", "array_sum", "(", "$", "values", ")", ";", "$", "count", "=", "count", "(", "$", "values", ")", ";", "// Avoid useless calculations", "if", "(", "$", "count", "==...
Finds the average @param array $values @return float
[ "Finds", "the", "average" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Math.php#L67-L78
train
krystal-framework/krystal.framework
src/Krystal/Text/Math.php
Math.percentage
public static function percentage($total, $actual, $round = 1) { // Avoid useless calculations if ($total == 0 || $actual == 0) { return 0; } $value = 100 * $actual / $total; if (is_integer($round)) { $value = round($value, $round); } return $value; }
php
public static function percentage($total, $actual, $round = 1) { // Avoid useless calculations if ($total == 0 || $actual == 0) { return 0; } $value = 100 * $actual / $total; if (is_integer($round)) { $value = round($value, $round); } return $value; }
[ "public", "static", "function", "percentage", "(", "$", "total", ",", "$", "actual", ",", "$", "round", "=", "1", ")", "{", "// Avoid useless calculations", "if", "(", "$", "total", "==", "0", "||", "$", "actual", "==", "0", ")", "{", "return", "0", ...
Counts a percentage @param float|integer $total @param float|integer $actual @param integer $round @return mixed
[ "Counts", "a", "percentage" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Text/Math.php#L113-L127
train
engageinteractive/laravel-config-provider
src/ConfigProvider.php
ConfigProvider.get
public function get($key = null, $default = null) { if (is_null($key)) { return Config::get($this->configKey()); } return Config::get($this->configKey() . '.' . $key, $default); }
php
public function get($key = null, $default = null) { if (is_null($key)) { return Config::get($this->configKey()); } return Config::get($this->configKey() . '.' . $key, $default); }
[ "public", "function", "get", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "Config", "::", "get", "(", "$", "this", "->", "configKey", "(", ")", ")", ";...
Retreives config values using the config key property as a prefix to all keys given. @param string $key used after the configKey @param mixed $default fallback used if not set @return mixed
[ "Retreives", "config", "values", "using", "the", "config", "key", "property", "as", "a", "prefix", "to", "all", "keys", "given", "." ]
06db7b633e22350acc97d570cd8bc7b71055bd3e
https://github.com/engageinteractive/laravel-config-provider/blob/06db7b633e22350acc97d570cd8bc7b71055bd3e/src/ConfigProvider.php#L37-L44
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.episode
public function episode($tvdbId, $season, $episode, $fullPath = 0) { $uri = 'episode'; $uriData = [ 'tvdbid' => $tvdbId, 'season' => $season, 'episode' => $episode, 'full_path' => $fullPath ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function episode($tvdbId, $season, $episode, $fullPath = 0) { $uri = 'episode'; $uriData = [ 'tvdbid' => $tvdbId, 'season' => $season, 'episode' => $episode, 'full_path' => $fullPath ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "episode", "(", "$", "tvdbId", ",", "$", "season", ",", "$", "episode", ",", "$", "fullPath", "=", "0", ")", "{", "$", "uri", "=", "'episode'", ";", "$", "uriData", "=", "[", "'tvdbid'", "=>", "$", "tvdbId", ",", "'season'", "...
Displays the information of a specific episode matching the corresponding tvdbid, season and episode number. @param int $tvdbId tvdbid unique show id @param int $season season number @param int $episode episode number @param int $fullPath 0: file name only 1: full path @return string @throws InvalidException
[ "Displays", "the", "information", "of", "a", "specific", "episode", "matching", "the", "corresponding", "tvdbid", "season", "and", "episode", "number", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L33-L56
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.episodeSetStatus
public function episodeSetStatus($tvdbId, $season, $status, $episode = null, $force = 0) { $uri = 'episode.setstatus'; $uriData = [ 'tvdbid' => $tvdbId, 'season' => $season, 'status' => $status, 'force' => $force ]; if ( $episode ) { $uriData['episode'] = $episode; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function episodeSetStatus($tvdbId, $season, $status, $episode = null, $force = 0) { $uri = 'episode.setstatus'; $uriData = [ 'tvdbid' => $tvdbId, 'season' => $season, 'status' => $status, 'force' => $force ]; if ( $episode ) { $uriData['episode'] = $episode; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "episodeSetStatus", "(", "$", "tvdbId", ",", "$", "season", ",", "$", "status", ",", "$", "episode", "=", "null", ",", "$", "force", "=", "0", ")", "{", "$", "uri", "=", "'episode.setstatus'", ";", "$", "uriData", "=", "[", "'tv...
Set the status of an epsiode or season. @param int $tvdbId tvdbid unique show id @param int $season season number @param string $status wanted, skipped, archived, ignored @param int|null $episode episode number --- if an episode is not provided, then the whole seasons' status will be set. @param int $force 0: not existing episodes 1: include existing episodes (can replace downloaded episodes) @return string @throws InvalidException
[ "Set", "the", "status", "of", "an", "epsiode", "or", "season", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L103-L127
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.future
public function future($sort = 'date', $type = 'missed|today|soon|later', $paused = null) { $uri = 'future'; $uriData = [ 'sort' => $sort, 'type' => $type ]; if ( $paused ) { $uriData['paused'] = $paused; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function future($sort = 'date', $type = 'missed|today|soon|later', $paused = null) { $uri = 'future'; $uriData = [ 'sort' => $sort, 'type' => $type ]; if ( $paused ) { $uriData['paused'] = $paused; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "future", "(", "$", "sort", "=", "'date'", ",", "$", "type", "=", "'missed|today|soon|later'", ",", "$", "paused", "=", "null", ")", "{", "$", "uri", "=", "'future'", ";", "$", "uriData", "=", "[", "'sort'", "=>", "$", "sort", "...
Display the upcoming episodes for the shows currently added in the users' database. @param string $sort date, network, name @param string $type missed, today, soon, later - multiple types can be passed when delimited by | --- missed - show's date is older than today --- today - show's date is today --- soon - show's date greater than today but less than a week --- later - show's date greater than a week @param int|null $paused 0: do not show paused 1: show paused --- if not set then the user's default setting in SickRage is used @return string @throws InvalidException
[ "Display", "the", "upcoming", "episodes", "for", "the", "shows", "currently", "added", "in", "the", "users", "database", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L171-L193
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.logs
public function logs($minLevel = 'error') { $uri = 'history.trim'; $uriData = [ 'min_level' => $minLevel ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function logs($minLevel = 'error') { $uri = 'history.trim'; $uriData = [ 'min_level' => $minLevel ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "logs", "(", "$", "minLevel", "=", "'error'", ")", "{", "$", "uri", "=", "'history.trim'", ";", "$", "uriData", "=", "[", "'min_level'", "=>", "$", "minLevel", "]", ";", "try", "{", "$", "response", "=", "$", "this", "->", "_req...
View SickRage's log. @param string $minLevel debug, info, warning, error @return string @throws InvalidException
[ "View", "SickRage", "s", "log", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L285-L305
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.showAddExisting
public function showAddExisting($tvdbId, $location, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'show.addexisting'; $uriData = [ 'tvdbid' => $tvdbId, 'location' => $location ]; if ( $flattenFolders ) { $uriData['flatten_folders'] = $flattenFolders; } if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function showAddExisting($tvdbId, $location, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'show.addexisting'; $uriData = [ 'tvdbid' => $tvdbId, 'location' => $location ]; if ( $flattenFolders ) { $uriData['flatten_folders'] = $flattenFolders; } if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "showAddExisting", "(", "$", "tvdbId", ",", "$", "location", ",", "$", "flattenFolders", "=", "null", ",", "$", "initial", "=", "null", ",", "$", "archive", "=", "null", ")", "{", "$", "uri", "=", "'show.addexisting'", ";", "$", "...
Add a show to SickRage using an existing folder. @param int $tvdbId tvdbid unique show id @param string $location path to existing show folder @param int|null $flattenFolders --- 0: use season folders if part of rename string --- 1: do not use season folders --- if not provided then the config setting (default) is used @param string|null $initial multiple types can be passed when delimited by | --- sdtv, sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray, unknown --- if not provided then the config setting (default) is used @param string|null $archive multiple types can be passed when delimited by | --- sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray --- if not provided then the config setting (default) is used @return string @throws InvalidException
[ "Add", "a", "show", "to", "SickRage", "using", "an", "existing", "folder", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L354-L379
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.showSeasons
public function showSeasons($tvdbId, $season = null) { $uri = 'show.seasons'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( is_numeric($season) ) { $uriData['season'] = $season; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function showSeasons($tvdbId, $season = null) { $uri = 'show.seasons'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( is_numeric($season) ) { $uriData['season'] = $season; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "showSeasons", "(", "$", "tvdbId", ",", "$", "season", "=", "null", ")", "{", "$", "uri", "=", "'show.seasons'", ";", "$", "uriData", "=", "[", "'tvdbid'", "=>", "$", "tvdbId", "]", ";", "if", "(", "is_numeric", "(", "$", "seaso...
Display a listing of episodes for all or a given season. @param int $tvdbId tvdbid unique show id @param int|null $season season number @return string @throws InvalidException
[ "Display", "a", "listing", "of", "episodes", "for", "all", "or", "a", "given", "season", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L680-L701
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.showSetQuality
public function showSetQuality($tvdbId, $initial = null, $archive = null) { $uri = 'show.setquality'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function showSetQuality($tvdbId, $initial = null, $archive = null) { $uri = 'show.setquality'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "showSetQuality", "(", "$", "tvdbId", ",", "$", "initial", "=", "null", ",", "$", "archive", "=", "null", ")", "{", "$", "uri", "=", "'show.setquality'", ";", "$", "uriData", "=", "[", "'tvdbid'", "=>", "$", "tvdbId", "]", ";", ...
Set desired quality of a show in SickRage. @param int $tvdbId tvdbid unique show id @param string|null $initial multiple types can be passed when delimited by | --- sdtv, sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray, unknown @param string|null $archive multiple types can be passed when delimited by | --- sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray @return string @throws InvalidException
[ "Set", "desired", "quality", "of", "a", "show", "in", "SickRage", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L714-L736
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.sbCheckScheduler
public function sbCheckScheduler() { $uri = 'sb.checkscheduler'; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => [] ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function sbCheckScheduler() { $uri = 'sb.checkscheduler'; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => [] ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "sbCheckScheduler", "(", ")", "{", "$", "uri", "=", "'sb.checkscheduler'", ";", "try", "{", "$", "response", "=", "$", "this", "->", "_request", "(", "[", "'uri'", "=>", "$", "uri", ",", "'type'", "=>", "'get'", ",", "'data'", "=>...
Query the SickBeard scheduler. @return string @throws InvalidException
[ "Query", "the", "SickBeard", "scheduler", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L922-L939
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.sbPauseBacklog
public function sbPauseBacklog($pause = 0) { $uri = 'sb.pausebacklog'; $uriData = [ 'pause' => $pause ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function sbPauseBacklog($pause = 0) { $uri = 'sb.pausebacklog'; $uriData = [ 'pause' => $pause ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "sbPauseBacklog", "(", "$", "pause", "=", "0", ")", "{", "$", "uri", "=", "'sb.pausebacklog'", ";", "$", "uriData", "=", "[", "'pause'", "=>", "$", "pause", "]", ";", "try", "{", "$", "response", "=", "$", "this", "->", "_reques...
Pause the backlog search. @param int $pause --- 0: unpause the backlog --- 1: pause the backlog @return string @throws InvalidException
[ "Pause", "the", "backlog", "search", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L1079-L1099
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.sbSearchTvdb
public function sbSearchTvdb($name = null, $tvdbId = null, $lang = 'en') { $uri = 'sb.searchtvdb'; $uriData = [ 'lang' => $lang ]; if ( $name ) { $uriData['name'] = $name; } if ( $tvdbId ) { $uriData['tvdbid'] = $tvdbId; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function sbSearchTvdb($name = null, $tvdbId = null, $lang = 'en') { $uri = 'sb.searchtvdb'; $uriData = [ 'lang' => $lang ]; if ( $name ) { $uriData['name'] = $name; } if ( $tvdbId ) { $uriData['tvdbid'] = $tvdbId; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "sbSearchTvdb", "(", "$", "name", "=", "null", ",", "$", "tvdbId", "=", "null", ",", "$", "lang", "=", "'en'", ")", "{", "$", "uri", "=", "'sb.searchtvdb'", ";", "$", "uriData", "=", "[", "'lang'", "=>", "$", "lang", "]", ";",...
Search TVDB for a show with a given string or tvdbid. @param string|null $name show name @param int|null $tvdbId tvdbid unique show id @param string $lang two letter tvdb language, en = english --- en, zh, hr, cs, da, nl, fi, fr, de, el, he, hu, it, ja, ko, no, pl, pt, ru, sl, es, sv, tr @return string @throws InvalidException
[ "Search", "TVDB", "for", "a", "show", "with", "a", "given", "string", "or", "tvdbid", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L1161-L1183
train
Kryptonit3/SickRage
src/SickRage.php
SickRage.sbSetDefaults
public function sbSetDefaults($futureShowPaused = null, $status = null, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'sb.setdefaults'; $uriData = []; if ( $futureShowPaused ) { $uriData['future_show_paused'] = $futureShowPaused; } if ( $status ) { $uriData['status'] = $status; } if ( $flattenFolders ) { $uriData['flatten_folders'] = $flattenFolders; } if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
php
public function sbSetDefaults($futureShowPaused = null, $status = null, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'sb.setdefaults'; $uriData = []; if ( $futureShowPaused ) { $uriData['future_show_paused'] = $futureShowPaused; } if ( $status ) { $uriData['status'] = $status; } if ( $flattenFolders ) { $uriData['flatten_folders'] = $flattenFolders; } if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => $uriData ] ); } catch (\Exception $e) { throw new InvalidException($e->getMessage()); } return $response->getBody()->getContents(); }
[ "public", "function", "sbSetDefaults", "(", "$", "futureShowPaused", "=", "null", ",", "$", "status", "=", "null", ",", "$", "flattenFolders", "=", "null", ",", "$", "initial", "=", "null", ",", "$", "archive", "=", "null", ")", "{", "$", "uri", "=", ...
Set default settings for SickRage. @param int|null $futureShowPaused --- 0: exclude paused shows on coming ep --- 1: include paused shows on coming ep @param string|null $status wanted, skipped, archived, ignored @param int|null $flattenFolders --- 0: use season folders if part of rename string --- 1: do not use season folders @param string|null $initial multiple types can be passed when delimited by | --- sdtv, sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray, unknown @param string|null $archive multiple types can be passed when delimited by | --- sddvd, hdtv, rawhdtv, fullhdtv, hdwebdl, fullhdwebdl, hdbluray, fullhdbluray @return string @throws InvalidException
[ "Set", "default", "settings", "for", "SickRage", "." ]
441a293b5c219c3cdd1ebebd2bcf4518598f84aa
https://github.com/Kryptonit3/SickRage/blob/441a293b5c219c3cdd1ebebd2bcf4518598f84aa/src/SickRage.php#L1202-L1226
train
krystal-framework/krystal.framework
src/Krystal/Session/SessionValidator.php
SessionValidator.isValid
public function isValid(SessionBagInterface $sessionBag) { return $sessionBag->get(self::PARAM_REMOTE_ADDR) === $this->hash($this->getRemoteAddr()) && $sessionBag->get(self::PARAM_USER_AGENT) === $this->hash($this->getUserAgent()); }
php
public function isValid(SessionBagInterface $sessionBag) { return $sessionBag->get(self::PARAM_REMOTE_ADDR) === $this->hash($this->getRemoteAddr()) && $sessionBag->get(self::PARAM_USER_AGENT) === $this->hash($this->getUserAgent()); }
[ "public", "function", "isValid", "(", "SessionBagInterface", "$", "sessionBag", ")", "{", "return", "$", "sessionBag", "->", "get", "(", "self", "::", "PARAM_REMOTE_ADDR", ")", "===", "$", "this", "->", "hash", "(", "$", "this", "->", "getRemoteAddr", "(", ...
Checks whether current session is valid @param \Krystal\Session\SessionBagInterface $sessionBag @return boolean
[ "Checks", "whether", "current", "session", "is", "valid" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Session/SessionValidator.php#L43-L47
train
krystal-framework/krystal.framework
src/Krystal/Session/SessionValidator.php
SessionValidator.write
public function write(SessionBagInterface $sessionBag) { if ($this->hasRequiredParams()) { // Writes hashes, not values themselves $sessionBag->set(self::PARAM_REMOTE_ADDR, $this->hash($this->getRemoteAddr())); $sessionBag->set(self::PARAM_USER_AGENT, $this->hash($this->getUserAgent())); } }
php
public function write(SessionBagInterface $sessionBag) { if ($this->hasRequiredParams()) { // Writes hashes, not values themselves $sessionBag->set(self::PARAM_REMOTE_ADDR, $this->hash($this->getRemoteAddr())); $sessionBag->set(self::PARAM_USER_AGENT, $this->hash($this->getUserAgent())); } }
[ "public", "function", "write", "(", "SessionBagInterface", "$", "sessionBag", ")", "{", "if", "(", "$", "this", "->", "hasRequiredParams", "(", ")", ")", "{", "// Writes hashes, not values themselves", "$", "sessionBag", "->", "set", "(", "self", "::", "PARAM_RE...
Writes validation data to the session @param \Krystal\Session\SessionBagInterface $sessionBag @return void
[ "Writes", "validation", "data", "to", "the", "session" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Session/SessionValidator.php#L55-L63
train
krystal-framework/krystal.framework
src/Krystal/Session/SessionValidator.php
SessionValidator.hasRequiredParams
private function hasRequiredParams() { return array_key_exists(self::PARAM_REMOTE_ADDR, $this->container) && array_key_exists(self::PARAM_USER_AGENT, $this->container); }
php
private function hasRequiredParams() { return array_key_exists(self::PARAM_REMOTE_ADDR, $this->container) && array_key_exists(self::PARAM_USER_AGENT, $this->container); }
[ "private", "function", "hasRequiredParams", "(", ")", "{", "return", "array_key_exists", "(", "self", "::", "PARAM_REMOTE_ADDR", ",", "$", "this", "->", "container", ")", "&&", "array_key_exists", "(", "self", "::", "PARAM_USER_AGENT", ",", "$", "this", "->", ...
Checks whether container data has required keys @return boolean
[ "Checks", "whether", "container", "data", "has", "required", "keys" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Session/SessionValidator.php#L101-L104
train
fxpio/fxp-bootstrap
Block/Type/ColumnType.php
ColumnType.convertToArray
protected function convertToArray($value) { if (\is_string($value)) { $value = [$value]; } elseif (null === $value) { $value = []; } return $value; }
php
protected function convertToArray($value) { if (\is_string($value)) { $value = [$value]; } elseif (null === $value) { $value = []; } return $value; }
[ "protected", "function", "convertToArray", "(", "$", "value", ")", "{", "if", "(", "\\", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "elseif", "(", "null", "===", "$", "value", ")", "{", "$"...
Convert value to array. @param array|string|null $value @return array
[ "Convert", "value", "to", "array", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/Type/ColumnType.php#L121-L130
train
fxpio/fxp-bootstrap
Block/Type/ColumnType.php
ColumnType.getParams
protected function getParams($type, $value) { if (false === strpos($value, '-')) { throw new InvalidConfigurationException(sprintf('The "%s" option must be configured with "{prefix}-{size}"', $type)); } list($prefix, $size) = explode('-', $value); if (!\in_array($prefix, $this->validPrefix)) { throw new InvalidConfigurationException(sprintf('The "%s" prefix option does not exist. Known options are: "'.implode('", "', $this->validPrefix).'"', $type)); } if (!(int) $size) { throw new InvalidConfigurationException(sprintf('The "%s" size option must be an integer', $type)); } return [$prefix, $size]; }
php
protected function getParams($type, $value) { if (false === strpos($value, '-')) { throw new InvalidConfigurationException(sprintf('The "%s" option must be configured with "{prefix}-{size}"', $type)); } list($prefix, $size) = explode('-', $value); if (!\in_array($prefix, $this->validPrefix)) { throw new InvalidConfigurationException(sprintf('The "%s" prefix option does not exist. Known options are: "'.implode('", "', $this->validPrefix).'"', $type)); } if (!(int) $size) { throw new InvalidConfigurationException(sprintf('The "%s" size option must be an integer', $type)); } return [$prefix, $size]; }
[ "protected", "function", "getParams", "(", "$", "type", ",", "$", "value", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "value", ",", "'-'", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'The \"%s\" optio...
Get the option params. @param string $type The option type @param string $value The option value @throws InvalidConfigurationException @return array The prefix and size
[ "Get", "the", "option", "params", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/Type/ColumnType.php#L142-L159
train
manusreload/GLFramework
src/Controller.php
Controller.quit
public function quit($redirection = null) { if (!$this->response->getAjax()) { if ($redirection) { $this->redirection($redirection); } $this->shareMessages(); if (!GL_TESTING) { Bootstrap::dispatch($this->response); exit; } } return true; }
php
public function quit($redirection = null) { if (!$this->response->getAjax()) { if ($redirection) { $this->redirection($redirection); } $this->shareMessages(); if (!GL_TESTING) { Bootstrap::dispatch($this->response); exit; } } return true; }
[ "public", "function", "quit", "(", "$", "redirection", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "response", "->", "getAjax", "(", ")", ")", "{", "if", "(", "$", "redirection", ")", "{", "$", "this", "->", "redirection", "(", "$", ...
Redirige y despacha la respuesta @param null $redirection @return bool
[ "Redirige", "y", "despacha", "la", "respuesta" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Controller.php#L231-L244
train
manusreload/GLFramework
src/Controller.php
Controller.addMessage
public function addMessage($message, $type = 'success') { Events::dispatch('onMessageDisplay', array('message' => $message, 'type' => $type)); $this->messages[] = array('message' => $message, 'type' => $type); }
php
public function addMessage($message, $type = 'success') { Events::dispatch('onMessageDisplay', array('message' => $message, 'type' => $type)); $this->messages[] = array('message' => $message, 'type' => $type); }
[ "public", "function", "addMessage", "(", "$", "message", ",", "$", "type", "=", "'success'", ")", "{", "Events", "::", "dispatch", "(", "'onMessageDisplay'", ",", "array", "(", "'message'", "=>", "$", "message", ",", "'type'", "=>", "$", "type", ")", ")"...
Muestra un mesaje en pantalla, con el estilo indicado @param $message @param string $type
[ "Muestra", "un", "mesaje", "en", "pantalla", "con", "el", "estilo", "indicado" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Controller.php#L269-L273
train
manusreload/GLFramework
src/Controller.php
Controller.getLink
public function getLink($controller, $params = array(), $fullPath = false) { if ($controller instanceof Controller) { $controller = get_class($controller); } $controller = (string)$controller; if(substr($controller, 0, 1) === "\\") { $controller = substr($controller, 1); } try { $url = Bootstrap::getSingleton()->getManager()->getRouter()->generate($controller, $params); if ($fullPath) { $protocol = 'http'; if (strpos($_SERVER['SCRIPT_URI'], 'https') !== false) { $protocol = 'https'; } return $protocol . '://' . $_SERVER['HTTP_HOST'] . $url; } return $url; } catch (\Exception $ex) { } return ""; }
php
public function getLink($controller, $params = array(), $fullPath = false) { if ($controller instanceof Controller) { $controller = get_class($controller); } $controller = (string)$controller; if(substr($controller, 0, 1) === "\\") { $controller = substr($controller, 1); } try { $url = Bootstrap::getSingleton()->getManager()->getRouter()->generate($controller, $params); if ($fullPath) { $protocol = 'http'; if (strpos($_SERVER['SCRIPT_URI'], 'https') !== false) { $protocol = 'https'; } return $protocol . '://' . $_SERVER['HTTP_HOST'] . $url; } return $url; } catch (\Exception $ex) { } return ""; }
[ "public", "function", "getLink", "(", "$", "controller", ",", "$", "params", "=", "array", "(", ")", ",", "$", "fullPath", "=", "false", ")", "{", "if", "(", "$", "controller", "instanceof", "Controller", ")", "{", "$", "controller", "=", "get_class", ...
Genera un enlace al controlador indicado, puede ser un objeto un un string @param string|Controller $controller @param array $params @param bool $fullPath @return string @throws \Exception
[ "Genera", "un", "enlace", "al", "controlador", "indicado", "puede", "ser", "un", "objeto", "un", "un", "string" ]
6867bdf22482cff4e92adbba6849818860228104
https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Controller.php#L307-L331
train
krystal-framework/krystal.framework
src/Krystal/Cache/WinCache.php
WinCache.remove
public function remove($key) { if ($this->has($key)) { return wincache_ucache_delete($key); } else { throw new RuntimeException(sprintf( 'Attempted to delete non-existing key "%s"', $key )); } }
php
public function remove($key) { if ($this->has($key)) { return wincache_ucache_delete($key); } else { throw new RuntimeException(sprintf( 'Attempted to delete non-existing key "%s"', $key )); } }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "wincache_ucache_delete", "(", "$", "key", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", ...
Deletes data associated with a key @param string $key @throws \RuntimeException if attempted to delete non-existing key @return boolean Depending on success
[ "Deletes", "data", "associated", "with", "a", "key" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/WinCache.php#L166-L175
train
krystal-framework/krystal.framework
src/Krystal/Cache/WinCache.php
WinCache.getInfo
public function getInfo() { return array( 'ucache_meminfo' => wincache_ucache_meminfo(), 'ucache_info' => wincache_ucache_info(), 'session_cache_info' => wincache_scache_info(), 'session_cache_meminfo' => wincache_scache_meminfo(), 'rp_meminfo' => wincache_rplist_meminfo(), 'rp_fileinfo' => wincache_rplist_fileinfo(), 'opcode_fileinfo' => wincache_ocache_fileinfo(), 'opcode_meminfo' => wincache_ocache_meminfo(), 'filecache_meminfo' => wincache_fcache_fileinfo(), 'filecache_fileinfo' => wincache_fcache_meminfo() ); }
php
public function getInfo() { return array( 'ucache_meminfo' => wincache_ucache_meminfo(), 'ucache_info' => wincache_ucache_info(), 'session_cache_info' => wincache_scache_info(), 'session_cache_meminfo' => wincache_scache_meminfo(), 'rp_meminfo' => wincache_rplist_meminfo(), 'rp_fileinfo' => wincache_rplist_fileinfo(), 'opcode_fileinfo' => wincache_ocache_fileinfo(), 'opcode_meminfo' => wincache_ocache_meminfo(), 'filecache_meminfo' => wincache_fcache_fileinfo(), 'filecache_fileinfo' => wincache_fcache_meminfo() ); }
[ "public", "function", "getInfo", "(", ")", "{", "return", "array", "(", "'ucache_meminfo'", "=>", "wincache_ucache_meminfo", "(", ")", ",", "'ucache_info'", "=>", "wincache_ucache_info", "(", ")", ",", "'session_cache_info'", "=>", "wincache_scache_info", "(", ")", ...
Retrieves information about user cache memory usage @return array
[ "Retrieves", "information", "about", "user", "cache", "memory", "usage" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/WinCache.php#L182-L196
train
krystal-framework/krystal.framework
src/Krystal/Validate/Input/Constraint/MinLength.php
MinLength.isValid
public function isValid($target) { if (mb_strlen($target, $this->charset) < $this->length) { $this->violate(sprintf($this->message, $this->length)); return false; } else { return true; } }
php
public function isValid($target) { if (mb_strlen($target, $this->charset) < $this->length) { $this->violate(sprintf($this->message, $this->length)); return false; } else { return true; } }
[ "public", "function", "isValid", "(", "$", "target", ")", "{", "if", "(", "mb_strlen", "(", "$", "target", ",", "$", "this", "->", "charset", ")", "<", "$", "this", "->", "length", ")", "{", "$", "this", "->", "violate", "(", "sprintf", "(", "$", ...
Checks whether target is valid @param string $target @return boolean True if string is blank, False otherwise
[ "Checks", "whether", "target", "is", "valid" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Validate/Input/Constraint/MinLength.php#L45-L53
train
krystal-framework/krystal.framework
src/Krystal/Application/FrontController/Dispatcher.php
Dispatcher.call
public function call($class, $action, array $params = array(), array $options = array()) { $controller = $this->controllerFactory->build($class, $action, $options); if (method_exists($controller, $action)) { return call_user_func_array(array($controller, $action), $params); } else { throw new LogicException(sprintf( 'A %s controller must implement %s() method, because it has been defined in the map', $class, $action )); } }
php
public function call($class, $action, array $params = array(), array $options = array()) { $controller = $this->controllerFactory->build($class, $action, $options); if (method_exists($controller, $action)) { return call_user_func_array(array($controller, $action), $params); } else { throw new LogicException(sprintf( 'A %s controller must implement %s() method, because it has been defined in the map', $class, $action )); } }
[ "public", "function", "call", "(", "$", "class", ",", "$", "action", ",", "array", "$", "params", "=", "array", "(", ")", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "controller", "=", "$", "this", "->", "controllerFactory", ...
Calls a controller providing a service locator as its dependency This uses PSR-0 compliant class name, $actions as its method name And an array of $params to supply into method's action @param string $class PSR-0 compliant class name @param string $action A class method to be invoked @param array $params Parameters to be passed into a method @param array $options Route options @throws \DomainException if controller's execution is halted @throws \LogicException if controller hasn't expected action to execute @return string
[ "Calls", "a", "controller", "providing", "a", "service", "locator", "as", "its", "dependency" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/FrontController/Dispatcher.php#L73-L84
train
krystal-framework/krystal.framework
src/Krystal/Application/FrontController/Dispatcher.php
Dispatcher.forward
public function forward($notation, array $args = array()) { $data = $this->mapManager->toCompliant($notation); $controller = array_keys($data); $controller = $controller[0]; $action = array_values($data); $action = $action[0]; return $this->call($controller, $action, $args); }
php
public function forward($notation, array $args = array()) { $data = $this->mapManager->toCompliant($notation); $controller = array_keys($data); $controller = $controller[0]; $action = array_values($data); $action = $action[0]; return $this->call($controller, $action, $args); }
[ "public", "function", "forward", "(", "$", "notation", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "$", "data", "=", "$", "this", "->", "mapManager", "->", "toCompliant", "(", "$", "notation", ")", ";", "$", "controller", "=", "array...
Forwards to another controller from notation @param string $notation (Controller@action syntax) @param array $args Arguments to be passed to that controller's action @return string
[ "Forwards", "to", "another", "controller", "from", "notation" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/FrontController/Dispatcher.php#L103-L114
train
krystal-framework/krystal.framework
src/Krystal/Application/FrontController/Dispatcher.php
Dispatcher.render
public function render($matchedURITemplate, array $params = array()) { // For current URI template $options = $this->mapManager->getDataByUriTemplate($matchedURITemplate); $class = $this->mapManager->getControllerByURITemplate($matchedURITemplate); $action = $this->mapManager->getActionByURITemplate($matchedURITemplate); return $this->call($class, $action, $params, $options); }
php
public function render($matchedURITemplate, array $params = array()) { // For current URI template $options = $this->mapManager->getDataByUriTemplate($matchedURITemplate); $class = $this->mapManager->getControllerByURITemplate($matchedURITemplate); $action = $this->mapManager->getActionByURITemplate($matchedURITemplate); return $this->call($class, $action, $params, $options); }
[ "public", "function", "render", "(", "$", "matchedURITemplate", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "// For current URI template", "$", "options", "=", "$", "this", "->", "mapManager", "->", "getDataByUriTemplate", "(", "$", "matched...
Dispatches a controller according to the request @param string $matchedURITemplate @param array $params URI arguments URI place-holders @return string The returned value of the controller action method
[ "Dispatches", "a", "controller", "according", "to", "the", "request" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/FrontController/Dispatcher.php#L123-L132
train
krystal-framework/krystal.framework
src/Krystal/Image/Tool/Upload/Plugin/OriginalSizeFactory.php
OriginalSizeFactory.build
public function build($dir, $quality, array $options = array()) { // Also, it would make sense to value user-provided prefix against regular [A-Z0-9] pattern if (!isset($options['prefix'])) { $options['prefix'] = 'original'; } // By default, we don't want to limit dimensions $maxWidth = 0; $maxHeight = 0; // If we have maximal dimensions limit, in configuration if (isset($options['max_width']) && isset($options['max_height'])) { $maxWidth = $options['max_width']; $maxHeight = $options['max_height']; } return new OriginalSize($dir, $options['prefix'], $quality, $maxWidth, $maxHeight); }
php
public function build($dir, $quality, array $options = array()) { // Also, it would make sense to value user-provided prefix against regular [A-Z0-9] pattern if (!isset($options['prefix'])) { $options['prefix'] = 'original'; } // By default, we don't want to limit dimensions $maxWidth = 0; $maxHeight = 0; // If we have maximal dimensions limit, in configuration if (isset($options['max_width']) && isset($options['max_height'])) { $maxWidth = $options['max_width']; $maxHeight = $options['max_height']; } return new OriginalSize($dir, $options['prefix'], $quality, $maxWidth, $maxHeight); }
[ "public", "function", "build", "(", "$", "dir", ",", "$", "quality", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// Also, it would make sense to value user-provided prefix against regular [A-Z0-9] pattern", "if", "(", "!", "isset", "(", "$", "...
Builds original size uploader @param integer $quality Desired quality @param array $options Options @return \Krystal\Image\Tool\Upload\Plugin\OriginalSize
[ "Builds", "original", "size", "uploader" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/Upload/Plugin/OriginalSizeFactory.php#L23-L42
train
austinheap/php-security-txt
src/Directives/Contact.php
Contact.setContacts
public function setContacts(array $contacts): SecurityTxt { if (!$this->validContacts($contacts, true)) { throw new Exception('Contacts array must contain well-formed e-mails and/or URLs.'); } $this->contacts = $contacts; return $this; }
php
public function setContacts(array $contacts): SecurityTxt { if (!$this->validContacts($contacts, true)) { throw new Exception('Contacts array must contain well-formed e-mails and/or URLs.'); } $this->contacts = $contacts; return $this; }
[ "public", "function", "setContacts", "(", "array", "$", "contacts", ")", ":", "SecurityTxt", "{", "if", "(", "!", "$", "this", "->", "validContacts", "(", "$", "contacts", ",", "true", ")", ")", "{", "throw", "new", "Exception", "(", "'Contacts array must ...
Set the contacts. @param array $contacts @return SecurityTxt
[ "Set", "the", "contacts", "." ]
01c4f32858b2a0d020fe0232467f0900833c0ff3
https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Contact.php#L42-L51
train
austinheap/php-security-txt
src/Directives/Contact.php
Contact.validContact
public function validContact(string $contact): bool { return filter_var($contact, FILTER_VALIDATE_EMAIL) !== false || filter_var($contact, FILTER_VALIDATE_URL) !== false; }
php
public function validContact(string $contact): bool { return filter_var($contact, FILTER_VALIDATE_EMAIL) !== false || filter_var($contact, FILTER_VALIDATE_URL) !== false; }
[ "public", "function", "validContact", "(", "string", "$", "contact", ")", ":", "bool", "{", "return", "filter_var", "(", "$", "contact", ",", "FILTER_VALIDATE_EMAIL", ")", "!==", "false", "||", "filter_var", "(", "$", "contact", ",", "FILTER_VALIDATE_URL", ")"...
Validates a contact. @param string $contact @string string $contact @return bool
[ "Validates", "a", "contact", "." ]
01c4f32858b2a0d020fe0232467f0900833c0ff3
https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Contact.php#L103-L107
train
austinheap/php-security-txt
src/Directives/Contact.php
Contact.validContacts
public function validContacts(array $contacts, bool $use_keys = false): bool { if ($use_keys) { $contacts = array_keys($contacts); } foreach ($contacts as $contact) { if (!$this->validContact($contact)) { return false; } } return true; }
php
public function validContacts(array $contacts, bool $use_keys = false): bool { if ($use_keys) { $contacts = array_keys($contacts); } foreach ($contacts as $contact) { if (!$this->validContact($contact)) { return false; } } return true; }
[ "public", "function", "validContacts", "(", "array", "$", "contacts", ",", "bool", "$", "use_keys", "=", "false", ")", ":", "bool", "{", "if", "(", "$", "use_keys", ")", "{", "$", "contacts", "=", "array_keys", "(", "$", "contacts", ")", ";", "}", "f...
Validates an array of contacts. @param array $contacts @param bool $use_keys @return bool
[ "Validates", "an", "array", "of", "contacts", "." ]
01c4f32858b2a0d020fe0232467f0900833c0ff3
https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Contact.php#L117-L130
train
austinheap/php-security-txt
src/Directives/Contact.php
Contact.hasContacts
public function hasContacts(array $contacts): bool { foreach ($contacts as $contact) { if (!$this->hasContact($contact)) { return false; } } return true; }
php
public function hasContacts(array $contacts): bool { foreach ($contacts as $contact) { if (!$this->hasContact($contact)) { return false; } } return true; }
[ "public", "function", "hasContacts", "(", "array", "$", "contacts", ")", ":", "bool", "{", "foreach", "(", "$", "contacts", "as", "$", "contact", ")", "{", "if", "(", "!", "$", "this", "->", "hasContact", "(", "$", "contact", ")", ")", "{", "return",...
Determines if an array of contacts exists. @param array $contacts @return bool
[ "Determines", "if", "an", "array", "of", "contacts", "exists", "." ]
01c4f32858b2a0d020fe0232467f0900833c0ff3
https://github.com/austinheap/php-security-txt/blob/01c4f32858b2a0d020fe0232467f0900833c0ff3/src/Directives/Contact.php#L185-L194
train
krystal-framework/krystal.framework
src/Krystal/Security/Filter.php
Filter.filterAttribute
public static function filterAttribute($value) { // Check whether current string has already been encoded $isEncoded = TextUtils::strModified($value, function($target){ return self::escape($target); }); // Decode if previous encoded or escaped if ($isEncoded) { $value = self::charsDecode($value); } // Convert special characters to make safe use of them $value = self::specialChars($value); return $value; }
php
public static function filterAttribute($value) { // Check whether current string has already been encoded $isEncoded = TextUtils::strModified($value, function($target){ return self::escape($target); }); // Decode if previous encoded or escaped if ($isEncoded) { $value = self::charsDecode($value); } // Convert special characters to make safe use of them $value = self::specialChars($value); return $value; }
[ "public", "static", "function", "filterAttribute", "(", "$", "value", ")", "{", "// Check whether current string has already been encoded", "$", "isEncoded", "=", "TextUtils", "::", "strModified", "(", "$", "value", ",", "function", "(", "$", "target", ")", "{", "...
Filters attribute value @param string $value Attribute value @return string
[ "Filters", "attribute", "value" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/Filter.php#L63-L79
train
krystal-framework/krystal.framework
src/Krystal/Security/Filter.php
Filter.stripTags
public static function stripTags($text, array $allowed = array()) { // Based on [fernando at zauber dot es]'s solution $allowed = array_map('strtolower', $allowed); return preg_replace_callback('/<\/?([^>\s]+)[^>]*>/i', function ($matches) use (&$allowed) { return in_array(strtolower($matches[1]), $allowed) ? $matches[0] : ''; }, $text); }
php
public static function stripTags($text, array $allowed = array()) { // Based on [fernando at zauber dot es]'s solution $allowed = array_map('strtolower', $allowed); return preg_replace_callback('/<\/?([^>\s]+)[^>]*>/i', function ($matches) use (&$allowed) { return in_array(strtolower($matches[1]), $allowed) ? $matches[0] : ''; }, $text); }
[ "public", "static", "function", "stripTags", "(", "$", "text", ",", "array", "$", "allowed", "=", "array", "(", ")", ")", "{", "// Based on [fernando at zauber dot es]'s solution", "$", "allowed", "=", "array_map", "(", "'strtolower'", ",", "$", "allowed", ")", ...
Strip the tags, even malformed ones @param string $text Target HTML string @param array $allowed An array of allowed tags @return string
[ "Strip", "the", "tags", "even", "malformed", "ones" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Security/Filter.php#L133-L141
train
Bludata/base
src/Doctrine/ORM/Repositories/BaseRepository.php
BaseRepository.remove
public function remove($target, $abort = true) { $entity = $this->find($target); if ($abort) { $this->isUsedByEntitys($entity); } $this->em()->remove($entity); return $entity; }
php
public function remove($target, $abort = true) { $entity = $this->find($target); if ($abort) { $this->isUsedByEntitys($entity); } $this->em()->remove($entity); return $entity; }
[ "public", "function", "remove", "(", "$", "target", ",", "$", "abort", "=", "true", ")", "{", "$", "entity", "=", "$", "this", "->", "find", "(", "$", "target", ")", ";", "if", "(", "$", "abort", ")", "{", "$", "this", "->", "isUsedByEntitys", "(...
Marcar um registro como deletado. @param object | int $target @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException Se $target não for encontrado @return Bludata\Doctrine\Common\Interfaces\BaseEntityInterface
[ "Marcar", "um", "registro", "como", "deletado", "." ]
c6936581a36defa04881d9c8f199aaed319ad1d0
https://github.com/Bludata/base/blob/c6936581a36defa04881d9c8f199aaed319ad1d0/src/Doctrine/ORM/Repositories/BaseRepository.php#L155-L164
train
droath/project-x
src/CommandBuilder.php
CommandBuilder.formattedCommand
protected function formattedCommand($command) { $structure = [ $this->getEnvVariable(), $this->executable, $this->getOptions(), $command ]; return implode(' ', array_filter($structure)); }
php
protected function formattedCommand($command) { $structure = [ $this->getEnvVariable(), $this->executable, $this->getOptions(), $command ]; return implode(' ', array_filter($structure)); }
[ "protected", "function", "formattedCommand", "(", "$", "command", ")", "{", "$", "structure", "=", "[", "$", "this", "->", "getEnvVariable", "(", ")", ",", "$", "this", "->", "executable", ",", "$", "this", "->", "getOptions", "(", ")", ",", "$", "comm...
Formatted command. @param $command @return string
[ "Formatted", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/CommandBuilder.php#L158-L168
train
krystal-framework/krystal.framework
src/Krystal/Filesystem/MimeTypeGuesser.php
MimeTypeGuesser.getTypeByExtension
public function getTypeByExtension($extension) { if ($this->isValidExtension($extension)) { // We get back flipped copy $list = $this->getList(true); return $list[$extension]; } else { // For all unknown extensions, the default Mime-Type is used return 'application/octet-stream'; } }
php
public function getTypeByExtension($extension) { if ($this->isValidExtension($extension)) { // We get back flipped copy $list = $this->getList(true); return $list[$extension]; } else { // For all unknown extensions, the default Mime-Type is used return 'application/octet-stream'; } }
[ "public", "function", "getTypeByExtension", "(", "$", "extension", ")", "{", "if", "(", "$", "this", "->", "isValidExtension", "(", "$", "extension", ")", ")", "{", "// We get back flipped copy", "$", "list", "=", "$", "this", "->", "getList", "(", "true", ...
Finds associated type by its extension @param string $extension @return string
[ "Finds", "associated", "type", "by", "its", "extension" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Filesystem/MimeTypeGuesser.php#L445-L458
train
krystal-framework/krystal.framework
src/Krystal/Filesystem/MimeTypeGuesser.php
MimeTypeGuesser.getExtensionByType
public function getExtensionByType($type) { if ($this->isValidType($type)) { return $this->mime[$type]; } else { throw new RuntimeException(sprintf('Invalid type "%s" supplied', $type)); } }
php
public function getExtensionByType($type) { if ($this->isValidType($type)) { return $this->mime[$type]; } else { throw new RuntimeException(sprintf('Invalid type "%s" supplied', $type)); } }
[ "public", "function", "getExtensionByType", "(", "$", "type", ")", "{", "if", "(", "$", "this", "->", "isValidType", "(", "$", "type", ")", ")", "{", "return", "$", "this", "->", "mime", "[", "$", "type", "]", ";", "}", "else", "{", "throw", "new",...
Finds associated extension by its type @param string $type @throws \RuntimeException if unknown type supplied @return string
[ "Finds", "associated", "extension", "by", "its", "type" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Filesystem/MimeTypeGuesser.php#L467-L474
train
krystal-framework/krystal.framework
src/Krystal/Filesystem/MimeTypeGuesser.php
MimeTypeGuesser.getList
public function getList($flip = false) { if ($flip !== false) { return array_flip($this->mime); } else { return $this->mime; } }
php
public function getList($flip = false) { if ($flip !== false) { return array_flip($this->mime); } else { return $this->mime; } }
[ "public", "function", "getList", "(", "$", "flip", "=", "false", ")", "{", "if", "(", "$", "flip", "!==", "false", ")", "{", "return", "array_flip", "(", "$", "this", "->", "mime", ")", ";", "}", "else", "{", "return", "$", "this", "->", "mime", ...
Returns full list @param boolean $flip Whether to flip the returning array or not @return array
[ "Returns", "full", "list" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Filesystem/MimeTypeGuesser.php#L482-L489
train
krystal-framework/krystal.framework
src/Krystal/Filesystem/MimeTypeGuesser.php
MimeTypeGuesser.append
public function append(array $pair) { foreach ($pair as $key => $value) { $this->mime[$key] = $value; } }
php
public function append(array $pair) { foreach ($pair as $key => $value) { $this->mime[$key] = $value; } }
[ "public", "function", "append", "(", "array", "$", "pair", ")", "{", "foreach", "(", "$", "pair", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "mime", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Appends pair to the end of the stack @param array $pair @return void
[ "Appends", "pair", "to", "the", "end", "of", "the", "stack" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Filesystem/MimeTypeGuesser.php#L539-L544
train
Torann/localization-helpers
src/Commands/ExportCommand.php
ExportCommand.getGroupArgument
protected function getGroupArgument() { $groups = explode(',', preg_replace('/\s+/', '', $this->argument('group'))); return array_map(function ($group) { return preg_replace('/\\.[^.\\s]{3,4}$/', '', $group); }, $groups); }
php
protected function getGroupArgument() { $groups = explode(',', preg_replace('/\s+/', '', $this->argument('group'))); return array_map(function ($group) { return preg_replace('/\\.[^.\\s]{3,4}$/', '', $group); }, $groups); }
[ "protected", "function", "getGroupArgument", "(", ")", "{", "$", "groups", "=", "explode", "(", "','", ",", "preg_replace", "(", "'/\\s+/'", ",", "''", ",", "$", "this", "->", "argument", "(", "'group'", ")", ")", ")", ";", "return", "array_map", "(", ...
Get group argument. @return array
[ "Get", "group", "argument", "." ]
cf307ad328a6b5f7c54bce5d0d3867d4d623505f
https://github.com/Torann/localization-helpers/blob/cf307ad328a6b5f7c54bce5d0d3867d4d623505f/src/Commands/ExportCommand.php#L121-L128
train
PayBreak/paybreak-sdk-php
src/Gateways/ApplicationGateway.php
ApplicationGateway.addMerchantPayment
public function addMerchantPayment($application, \DateTime $effectiveDate, $amount, $token) { return $this->postDocument( '/v4/applications/' . $application . '/merchant-payments', [ 'amount' => $amount, 'effective_date' => $effectiveDate->format('Y-m-d'), ], $token, 'Add Merchant Payment' ); }
php
public function addMerchantPayment($application, \DateTime $effectiveDate, $amount, $token) { return $this->postDocument( '/v4/applications/' . $application . '/merchant-payments', [ 'amount' => $amount, 'effective_date' => $effectiveDate->format('Y-m-d'), ], $token, 'Add Merchant Payment' ); }
[ "public", "function", "addMerchantPayment", "(", "$", "application", ",", "\\", "DateTime", "$", "effectiveDate", ",", "$", "amount", ",", "$", "token", ")", "{", "return", "$", "this", "->", "postDocument", "(", "'/v4/applications/'", ".", "$", "application",...
Add a Merchant Payment to the given application. Amount should be supplied in pence. @author SL @param string $application @param \DateTime $effectiveDate @param int $amount @param string $token @return array
[ "Add", "a", "Merchant", "Payment", "to", "the", "given", "application", ".", "Amount", "should", "be", "supplied", "in", "pence", "." ]
17b51a2a960933a0e6acdd775d4e0adae66c8900
https://github.com/PayBreak/paybreak-sdk-php/blob/17b51a2a960933a0e6acdd775d4e0adae66c8900/src/Gateways/ApplicationGateway.php#L167-L178
train
parable-php/di
src/Container.php
Container.get
public function get(string $name) { $name = $this->getDefinitiveName($name); if (!$this->has($name)) { $instance = $this->build($name); $this->store($instance); } return $this->instances[$name]; }
php
public function get(string $name) { $name = $this->getDefinitiveName($name); if (!$this->has($name)) { $instance = $this->build($name); $this->store($instance); } return $this->instances[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "getDefinitiveName", "(", "$", "name", ")", ";", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "$", "instance", ...
Returns a stored instance or creates a new one and stores it. @throws ContainerException
[ "Returns", "a", "stored", "instance", "or", "creates", "a", "new", "one", "and", "stores", "it", "." ]
8dd34615f3245c602bb387ab4a48128f922ca763
https://github.com/parable-php/di/blob/8dd34615f3245c602bb387ab4a48128f922ca763/src/Container.php#L41-L51
train
parable-php/di
src/Container.php
Container.has
public function has(string $name): bool { $name = $this->getDefinitiveName($name); return isset($this->instances[$name]); }
php
public function has(string $name): bool { $name = $this->getDefinitiveName($name); return isset($this->instances[$name]); }
[ "public", "function", "has", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "name", "=", "$", "this", "->", "getDefinitiveName", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "instances", "[", "$", "name", "]", ")"...
Returns whether an instance is currently stored or not.
[ "Returns", "whether", "an", "instance", "is", "currently", "stored", "or", "not", "." ]
8dd34615f3245c602bb387ab4a48128f922ca763
https://github.com/parable-php/di/blob/8dd34615f3245c602bb387ab4a48128f922ca763/src/Container.php#L56-L61
train
parable-php/di
src/Container.php
Container.createInstance
protected function createInstance(string $name, int $useStoredDependencies) { $name = $this->getDefinitiveName($name); if (interface_exists($name)) { throw new ContainerException(sprintf( "Cannot create instance for interface `%s`.", $name )); } try { $dependencies = $this->getDependenciesFor($name, $useStoredDependencies); } catch (Throwable $e) { throw new ContainerException($e->getMessage()); } return new $name(...$dependencies); }
php
protected function createInstance(string $name, int $useStoredDependencies) { $name = $this->getDefinitiveName($name); if (interface_exists($name)) { throw new ContainerException(sprintf( "Cannot create instance for interface `%s`.", $name )); } try { $dependencies = $this->getDependenciesFor($name, $useStoredDependencies); } catch (Throwable $e) { throw new ContainerException($e->getMessage()); } return new $name(...$dependencies); }
[ "protected", "function", "createInstance", "(", "string", "$", "name", ",", "int", "$", "useStoredDependencies", ")", "{", "$", "name", "=", "$", "this", "->", "getDefinitiveName", "(", "$", "name", ")", ";", "if", "(", "interface_exists", "(", "$", "name"...
Create an instance with either new or existing dependencies. @throws ContainerException
[ "Create", "an", "instance", "with", "either", "new", "or", "existing", "dependencies", "." ]
8dd34615f3245c602bb387ab4a48128f922ca763
https://github.com/parable-php/di/blob/8dd34615f3245c602bb387ab4a48128f922ca763/src/Container.php#L88-L106
train