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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bytepark/lib-migration | src/Repository/AbstractRepository.php | AbstractRepository.find | public function find(Uid $uniqueId)
{
if (!array_key_exists((string) $uniqueId, $this->unitOfWorkStore)) {
throw new UnitNotFoundException();
}
return $this->unitOfWorkStore[(string) $uniqueId];
} | php | public function find(Uid $uniqueId)
{
if (!array_key_exists((string) $uniqueId, $this->unitOfWorkStore)) {
throw new UnitNotFoundException();
}
return $this->unitOfWorkStore[(string) $uniqueId];
} | [
"public",
"function",
"find",
"(",
"Uid",
"$",
"uniqueId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"(",
"string",
")",
"$",
"uniqueId",
",",
"$",
"this",
"->",
"unitOfWorkStore",
")",
")",
"{",
"throw",
"new",
"UnitNotFoundException",
"(",
")"... | Finds the unit with the given Uid
@param Uid $uniqueId The Uid of the unit to find
@throws UnitNotFoundException
@return UnitOfWork | [
"Finds",
"the",
"unit",
"with",
"the",
"given",
"Uid"
] | 14d75f6978e257f456493c673175ca5d07b28c84 | https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L83-L90 | train |
bytepark/lib-migration | src/Repository/AbstractRepository.php | AbstractRepository.add | public function add(UnitOfWork $unitOfWork)
{
if ($this->contains($unitOfWork)) {
throw new UnitIsAlreadyPresentException();
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
} | php | public function add(UnitOfWork $unitOfWork)
{
if ($this->contains($unitOfWork)) {
throw new UnitIsAlreadyPresentException();
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
} | [
"public",
"function",
"add",
"(",
"UnitOfWork",
"$",
"unitOfWork",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"unitOfWork",
")",
")",
"{",
"throw",
"new",
"UnitIsAlreadyPresentException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"unitOfW... | Adds a UnitOfWork to the repository
@param UnitOfWork $unitOfWork The migration to add
@throws UnitIsAlreadyPresentException
@return void | [
"Adds",
"a",
"UnitOfWork",
"to",
"the",
"repository"
] | 14d75f6978e257f456493c673175ca5d07b28c84 | https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L101-L108 | train |
bytepark/lib-migration | src/Repository/AbstractRepository.php | AbstractRepository.replace | public function replace(UnitOfWork $unitOfWork)
{
if (!$this->contains($unitOfWork)) {
throw new UnitNotPresentException;
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
} | php | public function replace(UnitOfWork $unitOfWork)
{
if (!$this->contains($unitOfWork)) {
throw new UnitNotPresentException;
}
$this->unitOfWorkStore[$unitOfWork->getUniqueId()] = $unitOfWork;
} | [
"public",
"function",
"replace",
"(",
"UnitOfWork",
"$",
"unitOfWork",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"unitOfWork",
")",
")",
"{",
"throw",
"new",
"UnitNotPresentException",
";",
"}",
"$",
"this",
"->",
"unitOfWorkStore"... | Replaces with the given unit of work
@param UnitOfWork $unitOfWork The unit of work to replace with
@throws UnitNotPresentException
@return void | [
"Replaces",
"with",
"the",
"given",
"unit",
"of",
"work"
] | 14d75f6978e257f456493c673175ca5d07b28c84 | https://github.com/bytepark/lib-migration/blob/14d75f6978e257f456493c673175ca5d07b28c84/src/Repository/AbstractRepository.php#L119-L126 | train |
silencedis/protected-members-accessor | src/ProtectedMembersAccessor.php | ProtectedMembersAccessor.getReflectionMethod | protected function getReflectionMethod($class, $method)
{
if (!isset($this->methodReflectors[$class])) {
$this->methodReflectors[$class] = [];
}
if (!isset($this->methodReflectors[$class][$method])) {
$this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
}
return $this->methodReflectors[$class][$method];
} | php | protected function getReflectionMethod($class, $method)
{
if (!isset($this->methodReflectors[$class])) {
$this->methodReflectors[$class] = [];
}
if (!isset($this->methodReflectors[$class][$method])) {
$this->methodReflectors[$class][$method] = new \ReflectionMethod($class, $method);
}
return $this->methodReflectors[$class][$method];
} | [
"protected",
"function",
"getReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methodReflectors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"methodReflectors",
"[",
"$"... | Returns a method reflection
@param string $class
@param string $method
@return \ReflectionMethod | [
"Returns",
"a",
"method",
"reflection"
] | 0fcf525858a9555f3b4a90ad302549ea235678ff | https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L25-L35 | train |
silencedis/protected-members-accessor | src/ProtectedMembersAccessor.php | ProtectedMembersAccessor.getReflectionProperty | protected function getReflectionProperty($class, $property)
{
if (!isset($this->propertyReflectors[$class])) {
$this->propertyReflectors[$class] = [];
}
if (!isset($this->propertyReflectors[$class][$property])) {
$this->propertyReflectors[$class][$property] = new \ReflectionProperty($class, $property);
}
return $this->propertyReflectors[$class][$property];
} | php | protected function getReflectionProperty($class, $property)
{
if (!isset($this->propertyReflectors[$class])) {
$this->propertyReflectors[$class] = [];
}
if (!isset($this->propertyReflectors[$class][$property])) {
$this->propertyReflectors[$class][$property] = new \ReflectionProperty($class, $property);
}
return $this->propertyReflectors[$class][$property];
} | [
"protected",
"function",
"getReflectionProperty",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"propertyReflectors",
"[",
"$",
"class",
"]",
")",
")",
"{",
"$",
"this",
"->",
"propertyReflectors",
"[... | Returns a property reflection
@param string $class
@param string $property
@return \ReflectionProperty | [
"Returns",
"a",
"property",
"reflection"
] | 0fcf525858a9555f3b4a90ad302549ea235678ff | https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L45-L55 | train |
silencedis/protected-members-accessor | src/ProtectedMembersAccessor.php | ProtectedMembersAccessor.getProtectedMethod | public function getProtectedMethod(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionMethod($className, $name);
return $reflector->getClosure($object);
} | php | public function getProtectedMethod(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionMethod($className, $name);
return $reflector->getClosure($object);
} | [
"public",
"function",
"getProtectedMethod",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params",... | Returns a method as closure
@param array ...$params
@return \Closure
@throws ProtectedMembersAccessException | [
"Returns",
"a",
"method",
"as",
"closure"
] | 0fcf525858a9555f3b4a90ad302549ea235678ff | https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L91-L111 | train |
silencedis/protected-members-accessor | src/ProtectedMembersAccessor.php | ProtectedMembersAccessor.getProtectedProperty | public function getProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = new \ReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$value = $reflector->getValue($object);
if ($isProtected) {
$reflector->setAccessible(false);
}
return $value;
} | php | public function getProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name) = $params;
} elseif (is_object($params[0])) {
list($object, $name) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = new \ReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$value = $reflector->getValue($object);
if ($isProtected) {
$reflector->setAccessible(false);
}
return $value;
} | [
"public",
"function",
"getProtectedProperty",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
")",
"=",
"$",
"params... | Returns a value of a protected property of the object
@param array ...$params
@return mixed
@throws ProtectedMembersAccessException | [
"Returns",
"a",
"value",
"of",
"a",
"protected",
"property",
"of",
"the",
"object"
] | 0fcf525858a9555f3b4a90ad302549ea235678ff | https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L121-L149 | train |
silencedis/protected-members-accessor | src/ProtectedMembersAccessor.php | ProtectedMembersAccessor.setProtectedProperty | public function setProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name, $value) = $params;
} elseif (is_object($params[0])) {
list($object, $name, $value) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
/** @var mixed $value */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$reflector->setValue($object, $value);
if ($isProtected) {
$reflector->setAccessible(false);
}
} | php | public function setProtectedProperty(...$params)
{
if (is_string($params[0])) {
list($className, $object, $name, $value) = $params;
} elseif (is_object($params[0])) {
list($object, $name, $value) = $params;
$className = get_class($object);
}
/** @var string $className */
/** @var object $object */
/** @var string $name */
/** @var mixed $value */
$this->checkOnObject($object);
$this->checkOnMemberName($name);
$reflector = $this->getReflectionProperty($className, $name);
$isProtected = $reflector->isProtected() || $reflector->isPrivate();
if ($isProtected) {
$reflector->setAccessible(true);
}
$reflector->setValue($object, $value);
if ($isProtected) {
$reflector->setAccessible(false);
}
} | [
"public",
"function",
"setProtectedProperty",
"(",
"...",
"$",
"params",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"object",
",",
"$",
"name",
",",
"$",
"value",
")"... | Sets a protected property for the object
@param array ...$params
@throws ProtectedMembersAccessException | [
"Sets",
"a",
"protected",
"property",
"for",
"the",
"object"
] | 0fcf525858a9555f3b4a90ad302549ea235678ff | https://github.com/silencedis/protected-members-accessor/blob/0fcf525858a9555f3b4a90ad302549ea235678ff/src/ProtectedMembersAccessor.php#L157-L184 | train |
flavorzyb/simple | src/Middleware/VerifyCsrfToken.php | VerifyCsrfToken.getTokenString | protected function getTokenString()
{
$result = Request::post('_token', '');
if ('' == $result) {
$result = Request::get('_token', '');
}
if ('' == $result) {
$result = isset($_SERVER['X-CSRF-TOKEN']) ? $_SERVER['X-CSRF-TOKEN'] : '';
}
return $result;
} | php | protected function getTokenString()
{
$result = Request::post('_token', '');
if ('' == $result) {
$result = Request::get('_token', '');
}
if ('' == $result) {
$result = isset($_SERVER['X-CSRF-TOKEN']) ? $_SERVER['X-CSRF-TOKEN'] : '';
}
return $result;
} | [
"protected",
"function",
"getTokenString",
"(",
")",
"{",
"$",
"result",
"=",
"Request",
"::",
"post",
"(",
"'_token'",
",",
"''",
")",
";",
"if",
"(",
"''",
"==",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"Request",
"::",
"get",
"(",
"'_token'",
... | get token string
@return string | [
"get",
"token",
"string"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Middleware/VerifyCsrfToken.php#L40-L52 | train |
uthando-cms/uthando-common | src/UthandoCommon/Stdlib/ArrayUtils.php | ArrayUtils.removeKeysFromMultiArray | public static function removeKeysFromMultiArray(&$array, $keys)
{
foreach ($array as $key => &$value) {
if (is_array($value)) {
self::traverseArray($value, $keys);
} else {
if (in_array($key, $keys) || '' == $value) {
unset($array[$key]);
}
}
}
return $array;
} | php | public static function removeKeysFromMultiArray(&$array, $keys)
{
foreach ($array as $key => &$value) {
if (is_array($value)) {
self::traverseArray($value, $keys);
} else {
if (in_array($key, $keys) || '' == $value) {
unset($array[$key]);
}
}
}
return $array;
} | [
"public",
"static",
"function",
"removeKeysFromMultiArray",
"(",
"&",
"$",
"array",
",",
"$",
"keys",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"... | Traverse an array unsetting keys
@param array $array array to traverse
@param array $keys keys to remove
@return array | [
"Traverse",
"an",
"array",
"unsetting",
"keys"
] | feb915da5d26b60f536282e1bc3ad5c22e53f485 | https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/ArrayUtils.php#L28-L41 | train |
uthando-cms/uthando-common | src/UthandoCommon/Stdlib/ArrayUtils.php | ArrayUtils.listToMultiArray | public static function listToMultiArray($array)
{
$nested = [];
$depths = [];
foreach ($array as $key => $arr) {
if ($arr['depth'] == 0) {
$nested[$key] = $arr;
} else {
$parent =& $nested;
for ($i = 1; $i <= ($arr['depth']); $i++) {
$parent =& $parent[$depths[$i]];
}
$parent['pages'][$key] = $arr;
}
$depths[$arr['depth'] + 1] = $key;
}
return $nested;
} | php | public static function listToMultiArray($array)
{
$nested = [];
$depths = [];
foreach ($array as $key => $arr) {
if ($arr['depth'] == 0) {
$nested[$key] = $arr;
} else {
$parent =& $nested;
for ($i = 1; $i <= ($arr['depth']); $i++) {
$parent =& $parent[$depths[$i]];
}
$parent['pages'][$key] = $arr;
}
$depths[$arr['depth'] + 1] = $key;
}
return $nested;
} | [
"public",
"static",
"function",
"listToMultiArray",
"(",
"$",
"array",
")",
"{",
"$",
"nested",
"=",
"[",
"]",
";",
"$",
"depths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"... | transform a list into a multidimensional array
using a depth value
@param array $array
@return array | [
"transform",
"a",
"list",
"into",
"a",
"multidimensional",
"array",
"using",
"a",
"depth",
"value"
] | feb915da5d26b60f536282e1bc3ad5c22e53f485 | https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/ArrayUtils.php#L50-L73 | train |
keboola/debug-log-uploader | src/Keboola/DebugLogUploader/UploaderS3.php | UploaderS3.upload | public function upload($filePath, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . basename($filePath);
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'SourceFile' => $filePath,
]);
return $this->withUrlPrefix($s3FileName);
} | php | public function upload($filePath, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . basename($filePath);
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'SourceFile' => $filePath,
]);
return $this->withUrlPrefix($s3FileName);
} | [
"public",
"function",
"upload",
"(",
"$",
"filePath",
",",
"$",
"contentType",
"=",
"'text/plain'",
")",
"{",
"$",
"s3FileName",
"=",
"$",
"this",
"->",
"getFilePathAndUniquePrefix",
"(",
")",
".",
"basename",
"(",
"$",
"filePath",
")",
";",
"list",
"(",
... | Uploads file to s3
@param $filePath
@param string $contentType
@return string | [
"Uploads",
"file",
"to",
"s3"
] | ea124d136e8c6d18ce1768da5dcc51994df8b764 | https://github.com/keboola/debug-log-uploader/blob/ea124d136e8c6d18ce1768da5dcc51994df8b764/src/Keboola/DebugLogUploader/UploaderS3.php#L43-L58 | train |
keboola/debug-log-uploader | src/Keboola/DebugLogUploader/UploaderS3.php | UploaderS3.uploadString | public function uploadString($name, $content, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . $name;
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'Body' => $content,
]);
return $this->withUrlPrefix($s3FileName);
} | php | public function uploadString($name, $content, $contentType = 'text/plain')
{
$s3FileName = $this->getFilePathAndUniquePrefix() . $name;
list($bucket, $prefix) = explode('/', $this->s3path, 2);
$this->s3client->putObject([
'Bucket' => $bucket,
'Key' => (empty($prefix) ? '' : (trim($prefix, '/') . '/')) . $s3FileName,
'ContentType' => $contentType,
'ACL' => 'private',
'ServerSideEncryption' => 'AES256',
'Body' => $content,
]);
return $this->withUrlPrefix($s3FileName);
} | [
"public",
"function",
"uploadString",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"contentType",
"=",
"'text/plain'",
")",
"{",
"$",
"s3FileName",
"=",
"$",
"this",
"->",
"getFilePathAndUniquePrefix",
"(",
")",
".",
"$",
"name",
";",
"list",
"(",
"$... | Uploads string as file to s3
@param $name
@param $content
@param string $contentType
@return string | [
"Uploads",
"string",
"as",
"file",
"to",
"s3"
] | ea124d136e8c6d18ce1768da5dcc51994df8b764 | https://github.com/keboola/debug-log-uploader/blob/ea124d136e8c6d18ce1768da5dcc51994df8b764/src/Keboola/DebugLogUploader/UploaderS3.php#L67-L82 | train |
CableFramework/ServiceContainer | src/Cable/Component/Factory.php | Factory.create | public static function create(ProviderRepository $providerRepository = null)
{
$container = new Container(
$providerRepository
);
if (!$container->isProvided(AnnotationServiceProvider::class)) {
$container->addProvider(AnnotationServiceProvider::class);
}
$container->add(
Container::class,
function () use ($container) {
return $container;
}
)->alias(ContainerInterface::class);
return $container;
} | php | public static function create(ProviderRepository $providerRepository = null)
{
$container = new Container(
$providerRepository
);
if (!$container->isProvided(AnnotationServiceProvider::class)) {
$container->addProvider(AnnotationServiceProvider::class);
}
$container->add(
Container::class,
function () use ($container) {
return $container;
}
)->alias(ContainerInterface::class);
return $container;
} | [
"public",
"static",
"function",
"create",
"(",
"ProviderRepository",
"$",
"providerRepository",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"new",
"Container",
"(",
"$",
"providerRepository",
")",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"isProvided",
... | create a new container instance
@param ProviderRepository|null $providerRepository
@throws ProviderException
@return Container | [
"create",
"a",
"new",
"container",
"instance"
] | 0e48ad2e26de9b780d8fe336dd9ac48357285486 | https://github.com/CableFramework/ServiceContainer/blob/0e48ad2e26de9b780d8fe336dd9ac48357285486/src/Cable/Component/Factory.php#L22-L41 | train |
carno-php/log | src/Outputter/TCP.php | TCP.connecting | private function connecting() : void
{
$this->connected = false;
$this->closing
? $this->closed()->resolve()
: $this->client = Socket::connect($this->endpoint, $this->events)
;
} | php | private function connecting() : void
{
$this->connected = false;
$this->closing
? $this->closed()->resolve()
: $this->client = Socket::connect($this->endpoint, $this->events)
;
} | [
"private",
"function",
"connecting",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"connected",
"=",
"false",
";",
"$",
"this",
"->",
"closing",
"?",
"$",
"this",
"->",
"closed",
"(",
")",
"->",
"resolve",
"(",
")",
":",
"$",
"this",
"->",
"client... | reconnect to server if conn closed or error | [
"reconnect",
"to",
"server",
"if",
"conn",
"closed",
"or",
"error"
] | a96acf0a25e5ee0a8b763bac4f710f5350f2f70b | https://github.com/carno-php/log/blob/a96acf0a25e5ee0a8b763bac4f710f5350f2f70b/src/Outputter/TCP.php#L102-L109 | train |
extendsframework/extends-router | src/Routes.php | Routes.getRoutes | protected function getRoutes(): array
{
uasort($this->routes, function (RouteInterface $left, RouteInterface $right) {
if ($left instanceof GroupRoute || $right instanceof GroupRoute) {
return 1;
}
return 0;
});
return $this->routes;
} | php | protected function getRoutes(): array
{
uasort($this->routes, function (RouteInterface $left, RouteInterface $right) {
if ($left instanceof GroupRoute || $right instanceof GroupRoute) {
return 1;
}
return 0;
});
return $this->routes;
} | [
"protected",
"function",
"getRoutes",
"(",
")",
":",
"array",
"{",
"uasort",
"(",
"$",
"this",
"->",
"routes",
",",
"function",
"(",
"RouteInterface",
"$",
"left",
",",
"RouteInterface",
"$",
"right",
")",
"{",
"if",
"(",
"$",
"left",
"instanceof",
"Grou... | Get routes.
Sort children that group routes will be matched first, nested routes before flat routes.
@return RouteInterface[] | [
"Get",
"routes",
"."
] | 7c142749635c6fb1c58508bf3c8f594529e136d9 | https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Routes.php#L80-L91 | train |
Stratadox/Hydrator | src/HydrationFailed.php | HydrationFailed.encountered | public static function encountered(
Throwable $exception,
object $target
): CannotHydrate {
return new HydrationFailed(withMessage(
'Could not hydrate the `%s`: %s',
theClassOfThe($target),
$exception->getMessage()
), 0, $exception);
} | php | public static function encountered(
Throwable $exception,
object $target
): CannotHydrate {
return new HydrationFailed(withMessage(
'Could not hydrate the `%s`: %s',
theClassOfThe($target),
$exception->getMessage()
), 0, $exception);
} | [
"public",
"static",
"function",
"encountered",
"(",
"Throwable",
"$",
"exception",
",",
"object",
"$",
"target",
")",
":",
"CannotHydrate",
"{",
"return",
"new",
"HydrationFailed",
"(",
"withMessage",
"(",
"'Could not hydrate the `%s`: %s'",
",",
"theClassOfThe",
"(... | Notifies the client code that an exception was encountered during the
hydration process.
@param Throwable $exception The exception that was thrown.
@param object $target The object that was being hydrated.
@return CannotHydrate The exception to throw. | [
"Notifies",
"the",
"client",
"code",
"that",
"an",
"exception",
"was",
"encountered",
"during",
"the",
"hydration",
"process",
"."
] | 6895b1a39d84a157e3454be28bdef8e31359b3cd | https://github.com/Stratadox/Hydrator/blob/6895b1a39d84a157e3454be28bdef8e31359b3cd/src/HydrationFailed.php#L27-L36 | train |
webignition/web-resource-service | src/Service/Configuration.php | Configuration.getWebResourceClassName | public function getWebResourceClassName($contentType)
{
return ($this->hasMappedWebResourceClassName($contentType))
? $this->contentTypeWebResourceMap[(string)$contentType]
: self::DEFAULT_WEB_RESOURCE_MODEL;
} | php | public function getWebResourceClassName($contentType)
{
return ($this->hasMappedWebResourceClassName($contentType))
? $this->contentTypeWebResourceMap[(string)$contentType]
: self::DEFAULT_WEB_RESOURCE_MODEL;
} | [
"public",
"function",
"getWebResourceClassName",
"(",
"$",
"contentType",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"hasMappedWebResourceClassName",
"(",
"$",
"contentType",
")",
")",
"?",
"$",
"this",
"->",
"contentTypeWebResourceMap",
"[",
"(",
"string",
")"... | Get the WebResource subclass name for a given content type
@param string $contentType
@return string | [
"Get",
"the",
"WebResource",
"subclass",
"name",
"for",
"a",
"given",
"content",
"type"
] | 1789ff5e770daf326bccb6ac9e7b598fc2626b25 | https://github.com/webignition/web-resource-service/blob/1789ff5e770daf326bccb6ac9e7b598fc2626b25/src/Service/Configuration.php#L110-L115 | train |
ischenko/yii2-jsloader | src/base/Loader.php | Loader.setConfig | public function setConfig($config)
{
$configObject = $this->getConfig();
if (is_object($config)) {
$config = get_object_vars($config);
}
foreach ((array)$config as $key => $value) {
$configObject->$key = $value;
}
return $this;
} | php | public function setConfig($config)
{
$configObject = $this->getConfig();
if (is_object($config)) {
$config = get_object_vars($config);
}
foreach ((array)$config as $key => $value) {
$configObject->$key = $value;
}
return $this;
} | [
"public",
"function",
"setConfig",
"(",
"$",
"config",
")",
"{",
"$",
"configObject",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"get_object_vars",
"(",
"$",
"con... | Sets new configuration for the loader
@param ConfigInterface|array $config
@return $this | [
"Sets",
"new",
"configuration",
"for",
"the",
"loader"
] | 873242c4ab80eb160519d8ba0c4afb92aa89edfb | https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L110-L123 | train |
ischenko/yii2-jsloader | src/base/Loader.php | Loader.registerAssetBundle | public function registerAssetBundle($name)
{
if (($bundle = $this->getAssetBundleFromView($name)) === false) {
return $bundle;
}
$config = $this->getConfig();
if (!($module = $config->getModule($name))) {
$module = $config->addModule($name);
}
$options = $bundle->jsOptions;
if (!isset($options['position'])) {
$options['position'] = View::POS_END;
}
$options['baseUrl'] = $bundle->baseUrl;
$module->setOptions($options);
// TODO: think about optimization
foreach ($bundle->depends as $dependency) {
if (($dependency = $this->registerAssetBundle($dependency)) !== false) {
$module->addDependency($dependency);
}
}
$this->importJsFilesFromBundle($bundle, $module);
return $module;
} | php | public function registerAssetBundle($name)
{
if (($bundle = $this->getAssetBundleFromView($name)) === false) {
return $bundle;
}
$config = $this->getConfig();
if (!($module = $config->getModule($name))) {
$module = $config->addModule($name);
}
$options = $bundle->jsOptions;
if (!isset($options['position'])) {
$options['position'] = View::POS_END;
}
$options['baseUrl'] = $bundle->baseUrl;
$module->setOptions($options);
// TODO: think about optimization
foreach ($bundle->depends as $dependency) {
if (($dependency = $this->registerAssetBundle($dependency)) !== false) {
$module->addDependency($dependency);
}
}
$this->importJsFilesFromBundle($bundle, $module);
return $module;
} | [
"public",
"function",
"registerAssetBundle",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"(",
"$",
"bundle",
"=",
"$",
"this",
"->",
"getAssetBundleFromView",
"(",
"$",
"name",
")",
")",
"===",
"false",
")",
"{",
"return",
"$",
"bundle",
";",
"}",
"$",
"c... | Registers asset bundle in the loader
@param string $name
@return ModuleInterface|false an instance of registered module or false if asset bundle was not registered | [
"Registers",
"asset",
"bundle",
"in",
"the",
"loader"
] | 873242c4ab80eb160519d8ba0c4afb92aa89edfb | https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L132-L164 | train |
ischenko/yii2-jsloader | src/base/Loader.php | Loader.processAssets | public function processAssets()
{
$jsExpressions = [];
foreach ([
View::POS_HEAD,
View::POS_BEGIN,
View::POS_END,
View::POS_LOAD,
View::POS_READY
] as $position
) {
if ($this->ignoredPositions->match($position)) {
continue;
}
if (($jsExpression = $this->createJsExpression($position)) === null) {
continue;
}
$jsExpressions[$position] = $jsExpression;
}
$this->doRender($jsExpressions);
} | php | public function processAssets()
{
$jsExpressions = [];
foreach ([
View::POS_HEAD,
View::POS_BEGIN,
View::POS_END,
View::POS_LOAD,
View::POS_READY
] as $position
) {
if ($this->ignoredPositions->match($position)) {
continue;
}
if (($jsExpression = $this->createJsExpression($position)) === null) {
continue;
}
$jsExpressions[$position] = $jsExpression;
}
$this->doRender($jsExpressions);
} | [
"public",
"function",
"processAssets",
"(",
")",
"{",
"$",
"jsExpressions",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"View",
"::",
"POS_HEAD",
",",
"View",
"::",
"POS_BEGIN",
",",
"View",
"::",
"POS_END",
",",
"View",
"::",
"POS_LOAD",
",",
"View",
"::... | Performs processing of assets registered in the view
@return void | [
"Performs",
"processing",
"of",
"assets",
"registered",
"in",
"the",
"view"
] | 873242c4ab80eb160519d8ba0c4afb92aa89edfb | https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/base/Loader.php#L171-L195 | train |
InnoGr/FivePercent-Cache | src/ArrayCache.php | ArrayCache.set | public function set($key, $data, $ttl = null)
{
if ($ttl) {
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$expire = (int) $now->format('U') + $ttl;
} else {
$expire = 0;
}
$entry = array(
'expire' => $expire,
'value' => $data
);
$this->storage[$key] = $entry;
return true;
} | php | public function set($key, $data, $ttl = null)
{
if ($ttl) {
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$expire = (int) $now->format('U') + $ttl;
} else {
$expire = 0;
}
$entry = array(
'expire' => $expire,
'value' => $data
);
$this->storage[$key] = $entry;
return true;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"ttl",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")"... | Set data to cache storage
@param string $key
@param mixed $data
@param int $ttl
@return bool | [
"Set",
"data",
"to",
"cache",
"storage"
] | 0849e495bd440ce5faf0f8a5f6e66d93485f7627 | https://github.com/InnoGr/FivePercent-Cache/blob/0849e495bd440ce5faf0f8a5f6e66d93485f7627/src/ArrayCache.php#L71-L88 | train |
ivoba/stop | src/Stop/Stop.php | Stop.json | public static function json($var, $continue = false, $hide = false, $return = false){
$Stop = new \Stop\Dumper\Json($hide, $continue, $return, Dumper\AbstractDumper::FORMAT_JSON);
$Stop->var_dump($var);
} | php | public static function json($var, $continue = false, $hide = false, $return = false){
$Stop = new \Stop\Dumper\Json($hide, $continue, $return, Dumper\AbstractDumper::FORMAT_JSON);
$Stop->var_dump($var);
} | [
"public",
"static",
"function",
"json",
"(",
"$",
"var",
",",
"$",
"continue",
"=",
"false",
",",
"$",
"hide",
"=",
"false",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"Stop",
"=",
"new",
"\\",
"Stop",
"\\",
"Dumper",
"\\",
"Json",
"(",
"$"... | dump a variable as json
@param $var
@param bool $continue
@param bool $hide
@param bool $return | [
"dump",
"a",
"variable",
"as",
"json"
] | e534554c5cb203cd39767c3055fa767356617de7 | https://github.com/ivoba/stop/blob/e534554c5cb203cd39767c3055fa767356617de7/src/Stop/Stop.php#L128-L131 | train |
phossa2/libs | src/Phossa2/Query/Traits/StatementAbstract.php | StatementAbstract.buildSql | protected function buildSql(array $settings)/*# : string */
{
$result = $this->getType(); // type
$settings['join'] = $settings['seperator'] . $settings['indent'];
$result .= $this->buildBeforeAfter('AFTER', 'TYPE', $settings); // hint
foreach ($this->getConfigs() as $pos => $prefix) {
// before
$result .= $this->buildBeforeAfter('BEFORE', $pos, $settings);
$method = 'build' . ucfirst(strtolower($pos));
$result .= $this->{$method}($prefix, $settings);
// after
$result .= $this->buildBeforeAfter('AFTER', $pos, $settings);
}
$result .= $this->buildBeforeAfter('AFTER', 'STMT', $settings);
return $result;
} | php | protected function buildSql(array $settings)/*# : string */
{
$result = $this->getType(); // type
$settings['join'] = $settings['seperator'] . $settings['indent'];
$result .= $this->buildBeforeAfter('AFTER', 'TYPE', $settings); // hint
foreach ($this->getConfigs() as $pos => $prefix) {
// before
$result .= $this->buildBeforeAfter('BEFORE', $pos, $settings);
$method = 'build' . ucfirst(strtolower($pos));
$result .= $this->{$method}($prefix, $settings);
// after
$result .= $this->buildBeforeAfter('AFTER', $pos, $settings);
}
$result .= $this->buildBeforeAfter('AFTER', 'STMT', $settings);
return $result;
} | [
"protected",
"function",
"buildSql",
"(",
"array",
"$",
"settings",
")",
"/*# : string */",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"// type",
"$",
"settings",
"[",
"'join'",
"]",
"=",
"$",
"settings",
"[",
"'seperator'",
"]... | Build SQL statement clauses
@param array $settings
@param string
@access protected | [
"Build",
"SQL",
"statement",
"clauses"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Traits/StatementAbstract.php#L143-L162 | train |
SymBB/symbb | src/Symbb/Core/AdminBundle/Controller/Base/CrudController.php | CrudController.getFormEntity | protected function getFormEntity(Request $request)
{
if ($this->formEntity === null) {
$entityId = $request->get('id');
$repository = $this->getRepository();
$entity = null;
$id = 0;
if (!empty($entityId) && $entityId !== null) {
$entity = $repository->findOneById($entityId);
$id = $entity->getId();
}
if (!is_object($entity) || empty($id)) {
// new form, return empty entity
$entity_class_name = $repository->getClassName();
$entity = new $entity_class_name();
}
$this->formEntity = $entity;
}
return $this->formEntity;
} | php | protected function getFormEntity(Request $request)
{
if ($this->formEntity === null) {
$entityId = $request->get('id');
$repository = $this->getRepository();
$entity = null;
$id = 0;
if (!empty($entityId) && $entityId !== null) {
$entity = $repository->findOneById($entityId);
$id = $entity->getId();
}
if (!is_object($entity) || empty($id)) {
// new form, return empty entity
$entity_class_name = $repository->getClassName();
$entity = new $entity_class_name();
}
$this->formEntity = $entity;
}
return $this->formEntity;
} | [
"protected",
"function",
"getFormEntity",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formEntity",
"===",
"null",
")",
"{",
"$",
"entityId",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"repository",
"=",
... | Entity object for the form
Dont load the object twice and load from this method
@return Object | [
"Entity",
"object",
"for",
"the",
"form",
"Dont",
"load",
"the",
"object",
"twice",
"and",
"load",
"from",
"this",
"method"
] | be25357502e6a51016fa0b128a46c2dc87fa8fb2 | https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/AdminBundle/Controller/Base/CrudController.php#L188-L211 | train |
canis-io/yii2-key-provider | lib/providers/BaseFlysystemProvider.php | BaseFlysystemProvider.getFilesystem | protected function getFilesystem()
{
if (!isset($this->filesystem)) {
$this->filesystem = new Filesystem($this->getAdapter());
}
return $this->filesystem;
} | php | protected function getFilesystem()
{
if (!isset($this->filesystem)) {
$this->filesystem = new Filesystem($this->getAdapter());
}
return $this->filesystem;
} | [
"protected",
"function",
"getFilesystem",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filesystem",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"$",
"this",
"->",
"getAdapter",
"(",
")",
")",
";"... | Retrives the Filesystem object. Instantiate if it hasn't already been.
@return \League\Flysystem\Filesystem Flysystem filesystem object
@see http://flysystem.thephpleague.com/api | [
"Retrives",
"the",
"Filesystem",
"object",
".",
"Instantiate",
"if",
"it",
"hasn",
"t",
"already",
"been",
"."
] | c54f1c8af812bddf48872a05bc1d1e02112decc9 | https://github.com/canis-io/yii2-key-provider/blob/c54f1c8af812bddf48872a05bc1d1e02112decc9/lib/providers/BaseFlysystemProvider.php#L36-L42 | train |
kpacha/php-benchmark-tool | src/Kpacha/BenchmarkTool/Helper/GnuplotFactory.php | GnuplotFactory.create | public function create($template)
{
if (!isset($this->plotters[$template])) {
throw new \InvalidArgumentException("Unknown template [$template]");
}
$className = $this->plotters[$template];
return new $className($this->finderFactory);
} | php | public function create($template)
{
if (!isset($this->plotters[$template])) {
throw new \InvalidArgumentException("Unknown template [$template]");
}
$className = $this->plotters[$template];
return new $className($this->finderFactory);
} | [
"public",
"function",
"create",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"plotters",
"[",
"$",
"template",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unknown template [$template]\"",
... | Just get a new plotter by template!
@param string $template
@return \Kpacha\BenchmarkTool\Processor\Gnuplot
@throws \InvalidArgumentException | [
"Just",
"get",
"a",
"new",
"plotter",
"by",
"template!"
] | 71c73feadb01ba4c36d9df5ac947c07a7120c732 | https://github.com/kpacha/php-benchmark-tool/blob/71c73feadb01ba4c36d9df5ac947c07a7120c732/src/Kpacha/BenchmarkTool/Helper/GnuplotFactory.php#L31-L38 | train |
buybrain/nervus-php | src/Buybrain/Nervus/Util/TypedUtils.php | TypedUtils.groupByType | public static function groupByType(array $objects)
{
$perType = [];
foreach ($objects as $object) {
$type = $object->getType();
if (!isset($perType[$type])) {
$perType[$type] = [];
}
$perType[$type][] = $object;
}
return $perType;
} | php | public static function groupByType(array $objects)
{
$perType = [];
foreach ($objects as $object) {
$type = $object->getType();
if (!isset($perType[$type])) {
$perType[$type] = [];
}
$perType[$type][] = $object;
}
return $perType;
} | [
"public",
"static",
"function",
"groupByType",
"(",
"array",
"$",
"objects",
")",
"{",
"$",
"perType",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"type",
"=",
"$",
"object",
"->",
"getType",
"(",
")",
";... | Group typed objects by their type
@param Typed[] $objects
@return Typed[][] map indexed by types and lists of objects as values | [
"Group",
"typed",
"objects",
"by",
"their",
"type"
] | 96e00e30571b3ea4cf3494cd26c930ffa336c3bf | https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Util/TypedUtils.php#L28-L39 | train |
lamoni/restlyte | RESTLyte.php | RESTLyte.request | public function request($verb, $path, $accept, array $customCURLOptions=[])
{
$verb = strtoupper(
trim(
$verb
)
);
$instantiateClass = "\\Lamoni\\RESTLyte\\RESTLyteRequest\\RESTLyteRequest{$this->getResponseType()}";
$request = new $instantiateClass(
$this->getServer(),
$verb,
$path,
$this->getAuthCredentials(),
$accept,
$this->getVerifySSLPeer(),
$this->getHTTPHeaders(),
$customCURLOptions
);
return $request->getResponse();
} | php | public function request($verb, $path, $accept, array $customCURLOptions=[])
{
$verb = strtoupper(
trim(
$verb
)
);
$instantiateClass = "\\Lamoni\\RESTLyte\\RESTLyteRequest\\RESTLyteRequest{$this->getResponseType()}";
$request = new $instantiateClass(
$this->getServer(),
$verb,
$path,
$this->getAuthCredentials(),
$accept,
$this->getVerifySSLPeer(),
$this->getHTTPHeaders(),
$customCURLOptions
);
return $request->getResponse();
} | [
"public",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"path",
",",
"$",
"accept",
",",
"array",
"$",
"customCURLOptions",
"=",
"[",
"]",
")",
"{",
"$",
"verb",
"=",
"strtoupper",
"(",
"trim",
"(",
"$",
"verb",
")",
")",
";",
"$",
"instantiat... | Base for REST requests
@param $verb
@param $path
@param $accept
@param array $customCURLOptions
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract | [
"Base",
"for",
"REST",
"requests"
] | 10800f8ecc6efd43c6bd67a656c3a967758504cc | https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L242-L265 | train |
lamoni/restlyte | RESTLyte.php | RESTLyte.post | public function post($path, $postData, $accept="")
{
return $this->request(
'POST',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | php | public function post($path, $postData, $accept="")
{
return $this->request(
'POST',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | [
"public",
"function",
"post",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'POST'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
... | Launches a POST request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract | [
"Launches",
"a",
"POST",
"request",
"to",
"the",
"server"
] | 10800f8ecc6efd43c6bd67a656c3a967758504cc | https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L291-L302 | train |
lamoni/restlyte | RESTLyte.php | RESTLyte.put | public function put($path, $postData, $accept="")
{
return $this->request(
'PUT',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | php | public function put($path, $postData, $accept="")
{
return $this->request(
'PUT',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | [
"public",
"function",
"put",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'PUT'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"... | Launches a PUT request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract | [
"Launches",
"a",
"PUT",
"request",
"to",
"the",
"server"
] | 10800f8ecc6efd43c6bd67a656c3a967758504cc | https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L312-L323 | train |
lamoni/restlyte | RESTLyte.php | RESTLyte.patch | public function patch($path, $postData, $accept="")
{
return $this->request(
'PATCH',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | php | public function patch($path, $postData, $accept="")
{
return $this->request(
'PATCH',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | [
"public",
"function",
"patch",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'PATCH'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$",... | Launches a PATCH request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract | [
"Launches",
"a",
"PATCH",
"request",
"to",
"the",
"server"
] | 10800f8ecc6efd43c6bd67a656c3a967758504cc | https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L333-L344 | train |
lamoni/restlyte | RESTLyte.php | RESTLyte.delete | public function delete($path, $postData, $accept="")
{
return $this->request(
'DELETE',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | php | public function delete($path, $postData, $accept="")
{
return $this->request(
'DELETE',
$path,
$accept,
[
CURLOPT_POSTFIELDS => $postData
]
);
} | [
"public",
"function",
"delete",
"(",
"$",
"path",
",",
"$",
"postData",
",",
"$",
"accept",
"=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"path",
",",
"$",
"accept",
",",
"[",
"CURLOPT_POSTFIELDS",
"=>",
"$... | Launches a DELETE request to the server
@param $path
@param $postData
@param string $accept
@return \Lamoni\RESTLyte\RESTLyteRequest\RESTLyteRequestAbstract | [
"Launches",
"a",
"DELETE",
"request",
"to",
"the",
"server"
] | 10800f8ecc6efd43c6bd67a656c3a967758504cc | https://github.com/lamoni/restlyte/blob/10800f8ecc6efd43c6bd67a656c3a967758504cc/RESTLyte.php#L354-L365 | train |
webignition/node-jslint-output-parser | src/DecodedRawOutput.php | DecodedRawOutput.isWellFormed | public function isWellFormed()
{
if (!is_array($this->decodedRawOutput)) {
return false;
}
if (!isset($this->decodedRawOutput[0]) || !is_string($this->decodedRawOutput[0])) {
return false;
}
if (!isset($this->decodedRawOutput[1]) || !is_array($this->decodedRawOutput[1])) {
return false;
}
return true;
} | php | public function isWellFormed()
{
if (!is_array($this->decodedRawOutput)) {
return false;
}
if (!isset($this->decodedRawOutput[0]) || !is_string($this->decodedRawOutput[0])) {
return false;
}
if (!isset($this->decodedRawOutput[1]) || !is_array($this->decodedRawOutput[1])) {
return false;
}
return true;
} | [
"public",
"function",
"isWellFormed",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"decodedRawOutput",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"decodedRawOutput",
"[",
"0",
"]... | Is the decoded output of the format we expect?
Should be a two-element array with item zero being the path
of the file that was linted and the item one being the result set
@return bool | [
"Is",
"the",
"decoded",
"output",
"of",
"the",
"format",
"we",
"expect?",
"Should",
"be",
"a",
"two",
"-",
"element",
"array",
"with",
"item",
"zero",
"being",
"the",
"path",
"of",
"the",
"file",
"that",
"was",
"linted",
"and",
"the",
"item",
"one",
"b... | eb546e0922ea3e4d8d37987f54822a447e2e7610 | https://github.com/webignition/node-jslint-output-parser/blob/eb546e0922ea3e4d8d37987f54822a447e2e7610/src/DecodedRawOutput.php#L51-L66 | train |
orkestra/orkestra-transactor | lib/Orkestra/Transactor/Entity/Result.php | Result.setStatus | public function setStatus(Result\ResultStatus $status)
{
if (Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transacted = true;
$this->dateTransacted = new DateTime();
}
if (!$this->transaction->isParent()
&& Result\ResultStatus::ERROR !== $status->getValue()
&& Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transaction->getParent()->setStatus($status);
}
$this->transaction->setStatus($status);
$this->status = $status;
} | php | public function setStatus(Result\ResultStatus $status)
{
if (Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transacted = true;
$this->dateTransacted = new DateTime();
}
if (!$this->transaction->isParent()
&& Result\ResultStatus::ERROR !== $status->getValue()
&& Result\ResultStatus::UNPROCESSED !== $status->getValue()) {
$this->transaction->getParent()->setStatus($status);
}
$this->transaction->setStatus($status);
$this->status = $status;
} | [
"public",
"function",
"setStatus",
"(",
"Result",
"\\",
"ResultStatus",
"$",
"status",
")",
"{",
"if",
"(",
"Result",
"\\",
"ResultStatus",
"::",
"UNPROCESSED",
"!==",
"$",
"status",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"transacted",
... | Sets the result type
@param \Orkestra\Transactor\Entity\Result\ResultStatus $status | [
"Sets",
"the",
"result",
"type"
] | 0edaeb756f22c2d25d6fa2da4793df9b343f8811 | https://github.com/orkestra/orkestra-transactor/blob/0edaeb756f22c2d25d6fa2da4793df9b343f8811/lib/Orkestra/Transactor/Entity/Result.php#L206-L221 | train |
gossi/trixionary | src/model/Map/GroupTableMap.php | GroupTableMap.doInsert | public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from Group object
}
if ($criteria->containsKey(GroupTableMap::COL_ID) && $criteria->keyContainsValue(GroupTableMap::COL_ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::COL_ID.')');
}
// Set the correct dbName
$query = GroupQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
} | php | public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria; // rename for clarity
} else {
$criteria = $criteria->buildCriteria(); // build Criteria from Group object
}
if ($criteria->containsKey(GroupTableMap::COL_ID) && $criteria->keyContainsValue(GroupTableMap::COL_ID) ) {
throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::COL_ID.')');
}
// Set the correct dbName
$query = GroupQuery::create()->mergeWith($criteria);
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
return $con->transaction(function () use ($con, $query) {
return $query->doInsert($con);
});
} | [
"public",
"static",
"function",
"doInsert",
"(",
"$",
"criteria",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"ge... | Performs an INSERT on the database, given a Group or Criteria object.
@param mixed $criteria Criteria or Group object containing data that is used to create the INSERT statement.
@param ConnectionInterface $con the ConnectionInterface connection to use
@return mixed The new primary key.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"an",
"INSERT",
"on",
"the",
"database",
"given",
"a",
"Group",
"or",
"Criteria",
"object",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/GroupTableMap.php#L447-L472 | train |
apitude/apitude | src/Email/EmailService.php | EmailService.queueEmail | public function queueEmail(
$type,
$to,
$fromEmail,
$fromName,
$subject,
$body = null,
$contentType = 'text/html',
$template = null,
$parameters = [],
$cc = [],
$bcc = [],
$delaySeconds = 0
) {
$payload = [
'to' => $to,
'fromName' => $fromName,
'fromEmail' => $fromEmail,
'subject' => $subject,
'cc' => $cc,
'bcc' => $bcc,
];
if ($type === self::SEND_TEMPLATE) {
$method = 'performSendTemplate';
$payload['template'] = $template;
$payload['parameters'] = $parameters;
} else {
$method = 'performSend';
$payload['body'] = $body;
$payload['contentType'] = $contentType;
}
return $this->addJob('email', $payload, self::class, $delaySeconds, $method);
} | php | public function queueEmail(
$type,
$to,
$fromEmail,
$fromName,
$subject,
$body = null,
$contentType = 'text/html',
$template = null,
$parameters = [],
$cc = [],
$bcc = [],
$delaySeconds = 0
) {
$payload = [
'to' => $to,
'fromName' => $fromName,
'fromEmail' => $fromEmail,
'subject' => $subject,
'cc' => $cc,
'bcc' => $bcc,
];
if ($type === self::SEND_TEMPLATE) {
$method = 'performSendTemplate';
$payload['template'] = $template;
$payload['parameters'] = $parameters;
} else {
$method = 'performSend';
$payload['body'] = $body;
$payload['contentType'] = $contentType;
}
return $this->addJob('email', $payload, self::class, $delaySeconds, $method);
} | [
"public",
"function",
"queueEmail",
"(",
"$",
"type",
",",
"$",
"to",
",",
"$",
"fromEmail",
",",
"$",
"fromName",
",",
"$",
"subject",
",",
"$",
"body",
"=",
"null",
",",
"$",
"contentType",
"=",
"'text/html'",
",",
"$",
"template",
"=",
"null",
","... | Queues an email to be sent
@param string $type (SEND_BODY|SEND_TEMPLATE)
@param array $to
@param string $fromEmail
@param string $fromName
@param string $subject
@param null|string $body
@param string $contentType
@param null|string $template
@param array $parameters
@param array $cc
@param array $bcc
@param int $delaySeconds
@return string | [
"Queues",
"an",
"email",
"to",
"be",
"sent"
] | ccf503e42214184f96cd73b4e0fc5d06c377bce5 | https://github.com/apitude/apitude/blob/ccf503e42214184f96cd73b4e0fc5d06c377bce5/src/Email/EmailService.php#L129-L163 | train |
sbruggmann/WebExcess.Flow.Backup | Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php | BackupCommandController.restoreCommand | public function restoreCommand($selectedBackup = null)
{
$this->initialize();
if (is_null($selectedBackup)) {
$availableVersions = $this->backupService->getAvailableVersions();
if ( count($availableVersions)<=0 ) {
$this->output->outputLine();
$this->output->outputLine('<b>You have no Backups!</b>');
$this->output->outputLine();
$this->output->outputLine('Call \'./flow backup:now\' and create one.');
$this->output->outputLine();
return;
}
$selectedBackup = $this->askWithSelectForVersion($availableVersions);
}
$this->backupService->restoreBackup($selectedBackup);
} | php | public function restoreCommand($selectedBackup = null)
{
$this->initialize();
if (is_null($selectedBackup)) {
$availableVersions = $this->backupService->getAvailableVersions();
if ( count($availableVersions)<=0 ) {
$this->output->outputLine();
$this->output->outputLine('<b>You have no Backups!</b>');
$this->output->outputLine();
$this->output->outputLine('Call \'./flow backup:now\' and create one.');
$this->output->outputLine();
return;
}
$selectedBackup = $this->askWithSelectForVersion($availableVersions);
}
$this->backupService->restoreBackup($selectedBackup);
} | [
"public",
"function",
"restoreCommand",
"(",
"$",
"selectedBackup",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"selectedBackup",
")",
")",
"{",
"$",
"availableVersions",
"=",
"$",
"this",
"->",
... | Select & restore a Backup
@param string $selectedBackup
@return void | [
"Select",
"&",
"restore",
"a",
"Backup"
] | 3165300c554da7ef9d67c4b5a7f1a22ba08035b4 | https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L46-L66 | train |
sbruggmann/WebExcess.Flow.Backup | Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php | BackupCommandController.listCommand | public function listCommand()
{
$this->output->outputLine();
$this->output->outputLine('<b>Available Backups</b>');
$this->output->outputLine();
$this->output->outputLine('<b>Identifier Date Time</b>');
$this->initialize();
$availableVersions = $this->backupService->getAvailableVersions();
foreach ($availableVersions as $version) {
if ( is_numeric($version) ) {
$this->output->outputLine($version . ': ' . date('d.m.Y H:i', $version * 1));
}
}
$this->output->outputLine();
} | php | public function listCommand()
{
$this->output->outputLine();
$this->output->outputLine('<b>Available Backups</b>');
$this->output->outputLine();
$this->output->outputLine('<b>Identifier Date Time</b>');
$this->initialize();
$availableVersions = $this->backupService->getAvailableVersions();
foreach ($availableVersions as $version) {
if ( is_numeric($version) ) {
$this->output->outputLine($version . ': ' . date('d.m.Y H:i', $version * 1));
}
}
$this->output->outputLine();
} | [
"public",
"function",
"listCommand",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"'<b>Available Backups</b>'",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine... | Show available Backups
@return void | [
"Show",
"available",
"Backups"
] | 3165300c554da7ef9d67c4b5a7f1a22ba08035b4 | https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L84-L100 | train |
sbruggmann/WebExcess.Flow.Backup | Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php | BackupCommandController.clearCommand | public function clearCommand($force = null)
{
$this->initialize();
$this->backupService->removeAllBackups();
if ( $force===true ) {
$this->backupService->removeKeyfile();
}
} | php | public function clearCommand($force = null)
{
$this->initialize();
$this->backupService->removeAllBackups();
if ( $force===true ) {
$this->backupService->removeKeyfile();
}
} | [
"public",
"function",
"clearCommand",
"(",
"$",
"force",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"initialize",
"(",
")",
";",
"$",
"this",
"->",
"backupService",
"->",
"removeAllBackups",
"(",
")",
";",
"if",
"(",
"$",
"force",
"===",
"true",
")",
... | Remove all Backups
@param boolean $force
@return void | [
"Remove",
"all",
"Backups"
] | 3165300c554da7ef9d67c4b5a7f1a22ba08035b4 | https://github.com/sbruggmann/WebExcess.Flow.Backup/blob/3165300c554da7ef9d67c4b5a7f1a22ba08035b4/Classes/WebExcess/Flow/Backup/Command/BackupCommandController.php#L108-L115 | train |
Jinxes/layton | Layton/Services/RouteService.php | RouteService.attach | public function attach($methods, $match, $callable)
{
if (is_string($methods)) {
$methods = [$methods];
}
$route = new Route($methods, $callable);
$this->storage[$match] = $route;
return $route;
} | php | public function attach($methods, $match, $callable)
{
if (is_string($methods)) {
$methods = [$methods];
}
$route = new Route($methods, $callable);
$this->storage[$match] = $route;
return $route;
} | [
"public",
"function",
"attach",
"(",
"$",
"methods",
",",
"$",
"match",
",",
"$",
"callable",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"methods",
")",
")",
"{",
"$",
"methods",
"=",
"[",
"$",
"methods",
"]",
";",
"}",
"$",
"route",
"=",
"new",... | Attach a route field to storage.
@param string $method Http method.
@param string $match
@param callback $callable
@return Route | [
"Attach",
"a",
"route",
"field",
"to",
"storage",
"."
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Services/RouteService.php#L36-L44 | train |
thecmsthread/classes | src/Services.php | Services.registerCoreClass | public static function registerCoreClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Core") === true) {
self::$core_class = $class;
return true;
} else {
return false;
}
} | php | public static function registerCoreClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Core") === true) {
self::$core_class = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerCoreClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass"... | Register a core framework class
@param string $class The class name being registered
@return bool | [
"Register",
"a",
"core",
"framework",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L70-L82 | train |
thecmsthread/classes | src/Services.php | Services.registerModulesClass | public static function registerModulesClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
self::$modules_class = $class;
return true;
} else {
return false;
}
} | php | public static function registerModulesClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
self::$modules_class = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerModulesClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionCla... | Register a modules framework class
@param string $class The class name being registered
@return bool | [
"Register",
"a",
"modules",
"framework",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L101-L113 | train |
thecmsthread/classes | src/Services.php | Services.registerThemeClass | public static function registerThemeClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Theme") === true) {
self::$theme_class = $class;
return true;
} else {
return false;
}
} | php | public static function registerThemeClass(string $class): bool
{
if (class_exists($class) === false) {
return false;
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Theme") === true) {
self::$theme_class = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerThemeClass",
"(",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"check",
"=",
"new",
"ReflectionClass... | Register a theme class
@param string $class The class name being registered
@return bool | [
"Register",
"a",
"theme",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L132-L144 | train |
thecmsthread/classes | src/Services.php | Services.registerPluginClass | public static function registerPluginClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$plugin_classes === null) {
self::$plugin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
self::$plugin_classes[$name] = $class;
return true;
} else {
return false;
}
} | php | public static function registerPluginClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$plugin_classes === null) {
self::$plugin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
self::$plugin_classes[$name] = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerPluginClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
... | Register a plugin class
@param string $name The name the class is registered under
@param string $class The class name
@return bool | [
"Register",
"a",
"plugin",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L164-L179 | train |
thecmsthread/classes | src/Services.php | Services.getPluginClass | public static function getPluginClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$plugin_classes[$name]) === false) {
$class = self::$plugin_classes[$name];
}
return $class;
} | php | public static function getPluginClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$plugin_classes[$name]) === false) {
$class = self::$plugin_classes[$name];
}
return $class;
} | [
"public",
"static",
"function",
"getPluginClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"plugin_classes",
... | Return a plugin class name registered under a given name
@param string $name The name the class is registered under
@return string | [
"Return",
"a",
"plugin",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L188-L195 | train |
thecmsthread/classes | src/Services.php | Services.registerExtensionClass | public static function registerExtensionClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$extension_classes === null) {
self::$extension_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
self::$extension_classes[$name] = $class;
return true;
} else {
return false;
}
} | php | public static function registerExtensionClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$extension_classes === null) {
self::$extension_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
self::$extension_classes[$name] = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerExtensionClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(... | Register an extension framework class
@param string $name The name the class is registered under
@param string $class The class name
@return bool | [
"Register",
"an",
"extension",
"framework",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L215-L230 | train |
thecmsthread/classes | src/Services.php | Services.getExtensionClass | public static function getExtensionClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$extension_classes[$name]) === false) {
$class = self::$extension_classes[$name];
}
return $class;
} | php | public static function getExtensionClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$extension_classes[$name]) === false) {
$class = self::$extension_classes[$name];
}
return $class;
} | [
"public",
"static",
"function",
"getExtensionClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"extension_class... | Return a extension framework class name registered under a given name
@param string $name The name the class is registered under
@return string | [
"Return",
"a",
"extension",
"framework",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L239-L246 | train |
thecmsthread/classes | src/Services.php | Services.registerAdminClass | public static function registerAdminClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$admin_classes === null) {
self::$admin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Admin") === true) {
self::$admin_classes[$name] = $class;
return true;
} else {
return false;
}
} | php | public static function registerAdminClass(string $name, string $class): bool
{
if (class_exists($class) === false) {
return false;
}
if (self::$admin_classes === null) {
self::$admin_classes = [];
}
$check = new ReflectionClass($class);
if ($check->implementsInterface("TheCMSThread\\Classes\\Admin") === true) {
self::$admin_classes[$name] = $class;
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"registerAdminClass",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
")",
":",
"bool",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
... | Register an admin class
@param string $name The name the class is registered under
@param string $class The class name
@return bool | [
"Register",
"an",
"admin",
"class"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L266-L281 | train |
thecmsthread/classes | src/Services.php | Services.getAdminClass | public static function getAdminClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$admin_classes[$name]) === false) {
$class = self::$admin_classes[$name];
}
return $class;
} | php | public static function getAdminClass(string $name): string
{
$class = "";
if (empty($name) === false && empty(self::$admin_classes[$name]) === false) {
$class = self::$admin_classes[$name];
}
return $class;
} | [
"public",
"static",
"function",
"getAdminClass",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"\"\"",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"self",
"::",
"$",
"admin_classes",
"... | Return a admin class name registered under a given name
@param string $name The name the class is registered under
@return string | [
"Return",
"a",
"admin",
"class",
"name",
"registered",
"under",
"a",
"given",
"name"
] | d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c | https://github.com/thecmsthread/classes/blob/d0fafb5534f2b654b822e7d1dd2230f8dd0b8d6c/src/Services.php#L290-L297 | train |
vinala/kernel | src/Event/Event.php | Event.register | public static function register()
{
$namespace = "Vinala\App\Events";
foreach (get_declared_classes() as $value) {
if (Strings::contains($value, $namespace)) {
$name = self::getName($value);
$events = $value::getEvents();
if (!is_null($events)) {
foreach ($events as $key => $value) {
$data[$name.'.'.$key] = $value;
}
}
self::$listners = array_collapse([$data, self::$listners]);
}
}
} | php | public static function register()
{
$namespace = "Vinala\App\Events";
foreach (get_declared_classes() as $value) {
if (Strings::contains($value, $namespace)) {
$name = self::getName($value);
$events = $value::getEvents();
if (!is_null($events)) {
foreach ($events as $key => $value) {
$data[$name.'.'.$key] = $value;
}
}
self::$listners = array_collapse([$data, self::$listners]);
}
}
} | [
"public",
"static",
"function",
"register",
"(",
")",
"{",
"$",
"namespace",
"=",
"\"Vinala\\App\\Events\"",
";",
"foreach",
"(",
"get_declared_classes",
"(",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"Strings",
"::",
"contains",
"(",
"$",
"value",
","... | Register all listners.
@return null | [
"Register",
"all",
"listners",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L22-L41 | train |
vinala/kernel | src/Event/Event.php | Event.trigger | public static function trigger()
{
$args = func_get_args();
//Check if trigger have parrams
$haveParams = count($args) > 1 ? true : false;
//Get events
$events = self::splite($args[0]);
if ($haveParams && count($events) > 1) {
throw new ManyListenersArgumentsException();
}
if (count($events) > 1) {
self::runMany($events);
} elseif (count($events) == 1) {
self::runOne($events, array_except($args, 0));
}
return true;
} | php | public static function trigger()
{
$args = func_get_args();
//Check if trigger have parrams
$haveParams = count($args) > 1 ? true : false;
//Get events
$events = self::splite($args[0]);
if ($haveParams && count($events) > 1) {
throw new ManyListenersArgumentsException();
}
if (count($events) > 1) {
self::runMany($events);
} elseif (count($events) == 1) {
self::runOne($events, array_except($args, 0));
}
return true;
} | [
"public",
"static",
"function",
"trigger",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"//Check if trigger have parrams",
"$",
"haveParams",
"=",
"count",
"(",
"$",
"args",
")",
">",
"1",
"?",
"true",
":",
"false",
";",
"//Get events",... | Fire a trigger.
@param
@param
@return | [
"Fire",
"a",
"trigger",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L65-L86 | train |
vinala/kernel | src/Event/Event.php | Event.splite | protected static function splite($pattern)
{
if (is_array($pattern)) {
$events = [];
foreach ($pattern as $value) {
$events = array_collapse([$events, self::extract($value)]);
}
return $events;
} elseif (is_string($pattern)) {
return self::extract($pattern);
}
} | php | protected static function splite($pattern)
{
if (is_array($pattern)) {
$events = [];
foreach ($pattern as $value) {
$events = array_collapse([$events, self::extract($value)]);
}
return $events;
} elseif (is_string($pattern)) {
return self::extract($pattern);
}
} | [
"protected",
"static",
"function",
"splite",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pattern",
")",
")",
"{",
"$",
"events",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pattern",
"as",
"$",
"value",
")",
"{",
"$",
"events",
... | Get events from event pattern.
@param mixed $pattern
@return array | [
"Get",
"events",
"from",
"event",
"pattern",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L95-L108 | train |
vinala/kernel | src/Event/Event.php | Event.extract | protected static function extract($pattern)
{
if (str_contains($pattern, '|')) {
$segements = explode('|', $pattern);
$events[$segements[0]] = explode('.', $segements[1]);
} else {
$segements = explode('.', $pattern);
$events[$segements[0]] = $segements[1];
}
return $events;
} | php | protected static function extract($pattern)
{
if (str_contains($pattern, '|')) {
$segements = explode('|', $pattern);
$events[$segements[0]] = explode('.', $segements[1]);
} else {
$segements = explode('.', $pattern);
$events[$segements[0]] = $segements[1];
}
return $events;
} | [
"protected",
"static",
"function",
"extract",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"pattern",
",",
"'|'",
")",
")",
"{",
"$",
"segements",
"=",
"explode",
"(",
"'|'",
",",
"$",
"pattern",
")",
";",
"$",
"events",
"[",
... | Extract events from string pattern.
@param string $pattern
@return array | [
"Extract",
"events",
"from",
"string",
"pattern",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L117-L130 | train |
vinala/kernel | src/Event/Event.php | Event.runMany | public static function runMany($events)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
if (is_array($value)) {
foreach ($value as $function) {
$function = self::$listners[$key.'.'.$function];
$object->$function();
}
} elseif (is_string($value)) {
$function = self::$listners[$key.'.'.$value];
$object->$function();
}
}
return true;
} | php | public static function runMany($events)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
if (is_array($value)) {
foreach ($value as $function) {
$function = self::$listners[$key.'.'.$function];
$object->$function();
}
} elseif (is_string($value)) {
$function = self::$listners[$key.'.'.$value];
$object->$function();
}
}
return true;
} | [
"public",
"static",
"function",
"runMany",
"(",
"$",
"events",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'\\Vinala\\App\\Events\\\\'",
".",
"$",
"key",
";",
"$",
"object",
"=",
"new",
... | Run and execute many events trigger.
@param array $events
@return bool | [
"Run",
"and",
"execute",
"many",
"events",
"trigger",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L139-L160 | train |
vinala/kernel | src/Event/Event.php | Event.runOne | public static function runOne($events, $args)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
$function = self::$listners[$key.'.'.$value];
call_user_func_array([$object, $function], $args);
}
return true;
} | php | public static function runOne($events, $args)
{
foreach ($events as $key => $value) {
$name = '\Vinala\App\Events\\'.$key;
$object = new $name();
$function = self::$listners[$key.'.'.$value];
call_user_func_array([$object, $function], $args);
}
return true;
} | [
"public",
"static",
"function",
"runOne",
"(",
"$",
"events",
",",
"$",
"args",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"'\\Vinala\\App\\Events\\\\'",
".",
"$",
"key",
";",
"$",
"obje... | Run and execute one event trigger.
@param array $events
@return bool | [
"Run",
"and",
"execute",
"one",
"event",
"trigger",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Event/Event.php#L169-L182 | train |
mszewcz/php-light-framework | src/Log/Backend/Filesystem.php | Filesystem.rawLog | public function rawLog(string $type = '', string $message = '', ?string $source = null, ?string $excp = null): bool
{
$src = $source !== null
? \sprintf('[%s] ', \is_object($source) ? '\\'.\get_class($source) : (string)$source)
: '';
$exc = $excp !== null && ($excp instanceof \Exception) ? \sprintf('[Ex: %s] ', $excp->getMessage()) : '';
$exc = \str_replace(["\r", "\n", "\t"], '', $exc);
$msg = \sprintf('%s %s %s%s%s%s', \date('d-m-Y H:i:s'), $type, $src, $exc, $message, Tags::CRLF);
return File::append($this->logFile, $msg);
} | php | public function rawLog(string $type = '', string $message = '', ?string $source = null, ?string $excp = null): bool
{
$src = $source !== null
? \sprintf('[%s] ', \is_object($source) ? '\\'.\get_class($source) : (string)$source)
: '';
$exc = $excp !== null && ($excp instanceof \Exception) ? \sprintf('[Ex: %s] ', $excp->getMessage()) : '';
$exc = \str_replace(["\r", "\n", "\t"], '', $exc);
$msg = \sprintf('%s %s %s%s%s%s', \date('d-m-Y H:i:s'), $type, $src, $exc, $message, Tags::CRLF);
return File::append($this->logFile, $msg);
} | [
"public",
"function",
"rawLog",
"(",
"string",
"$",
"type",
"=",
"''",
",",
"string",
"$",
"message",
"=",
"''",
",",
"?",
"string",
"$",
"source",
"=",
"null",
",",
"?",
"string",
"$",
"excp",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"src",
"=",... | Logs message to file
@param string $type
@param string $message
@param null|string $source
@param null|string $excp
@return bool | [
"Logs",
"message",
"to",
"file"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Log/Backend/Filesystem.php#L50-L60 | train |
mszewcz/php-light-framework | src/Log/Backend/Filesystem.php | Filesystem.logDebug | public function logDebug(string $message = '', ?string $source = null, ?string $exception = null): bool
{
$ret = false;
if ($this->logLevel & Log::LOG_DEBUG) {
$ret = $this->rawLog('[ DEBUG]', $message, $source, $exception);
}
return $ret;
} | php | public function logDebug(string $message = '', ?string $source = null, ?string $exception = null): bool
{
$ret = false;
if ($this->logLevel & Log::LOG_DEBUG) {
$ret = $this->rawLog('[ DEBUG]', $message, $source, $exception);
}
return $ret;
} | [
"public",
"function",
"logDebug",
"(",
"string",
"$",
"message",
"=",
"''",
",",
"?",
"string",
"$",
"source",
"=",
"null",
",",
"?",
"string",
"$",
"exception",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"ret",
"=",
"false",
";",
"if",
"(",
"$",
"... | Logs debug information
@param string $message
@param null|string $source
@param null|string $exception
@return bool | [
"Logs",
"debug",
"information"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Log/Backend/Filesystem.php#L70-L77 | train |
vpg/titon.common | src/Titon/Common/Augment/InfoAugment.php | InfoAugment.methods | public function methods() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicMethods(),
$this->protectedMethods(),
$this->privateMethods(),
$this->staticMethods()
));
});
} | php | public function methods() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicMethods(),
$this->protectedMethods(),
$this->privateMethods(),
$this->staticMethods()
));
});
} | [
"public",
"function",
"methods",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"return",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"publicMethods",
"(",
")",
",",
"$",
"this",
... | Return an array of public, protected, private and static methods.
@return string[] | [
"Return",
"an",
"array",
"of",
"public",
"protected",
"private",
"and",
"static",
"methods",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L118-L127 | train |
vpg/titon.common | src/Titon/Common/Augment/InfoAugment.php | InfoAugment.properties | public function properties() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicProperties(),
$this->protectedProperties(),
$this->privateProperties(),
$this->staticProperties()
));
});
} | php | public function properties() {
return $this->cache(__METHOD__, function() {
return array_unique(array_merge(
$this->publicProperties(),
$this->protectedProperties(),
$this->privateProperties(),
$this->staticProperties()
));
});
} | [
"public",
"function",
"properties",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"__METHOD__",
",",
"function",
"(",
")",
"{",
"return",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"publicProperties",
"(",
")",
",",
"$",
"thi... | Return an array of public, protected, private and static properties.
@return string[] | [
"Return",
"an",
"array",
"of",
"public",
"protected",
"private",
"and",
"static",
"properties",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L170-L179 | train |
vpg/titon.common | src/Titon/Common/Augment/InfoAugment.php | InfoAugment.traits | public function traits() {
$traits = $this->reflection()->getTraitNames();
$parent = get_parent_class($this->_class);
while ($parent) {
$traits = array_merge($traits, class_uses($parent));
$parent = get_parent_class($parent);
}
return array_values($traits);
} | php | public function traits() {
$traits = $this->reflection()->getTraitNames();
$parent = get_parent_class($this->_class);
while ($parent) {
$traits = array_merge($traits, class_uses($parent));
$parent = get_parent_class($parent);
}
return array_values($traits);
} | [
"public",
"function",
"traits",
"(",
")",
"{",
"$",
"traits",
"=",
"$",
"this",
"->",
"reflection",
"(",
")",
"->",
"getTraitNames",
"(",
")",
";",
"$",
"parent",
"=",
"get_parent_class",
"(",
"$",
"this",
"->",
"_class",
")",
";",
"while",
"(",
"$",... | Return an array of traits that the class implements.
@return string[] | [
"Return",
"an",
"array",
"of",
"traits",
"that",
"the",
"class",
"implements",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L240-L250 | train |
vpg/titon.common | src/Titon/Common/Augment/InfoAugment.php | InfoAugment._methods | protected function _methods($key, $scope) {
return $this->cache($key, function() use ($scope) {
$methods = [];
foreach ($this->reflection()->getMethods($scope) as $method) {
$methods[] = $method->getName();
}
return $methods;
});
} | php | protected function _methods($key, $scope) {
return $this->cache($key, function() use ($scope) {
$methods = [];
foreach ($this->reflection()->getMethods($scope) as $method) {
$methods[] = $method->getName();
}
return $methods;
});
} | [
"protected",
"function",
"_methods",
"(",
"$",
"key",
",",
"$",
"scope",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"$",
"key",
",",
"function",
"(",
")",
"use",
"(",
"$",
"scope",
")",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach"... | Return an array of methods for the defined scope.
@param string $key
@param int $scope
@return string[] | [
"Return",
"an",
"array",
"of",
"methods",
"for",
"the",
"defined",
"scope",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L268-L278 | train |
vpg/titon.common | src/Titon/Common/Augment/InfoAugment.php | InfoAugment._properties | protected function _properties($key, $scope) {
return $this->cache($key, function() use ($scope) {
$props = [];
foreach ($this->reflection()->getProperties($scope) as $prop) {
$props[] = $prop->getName();
}
return $props;
});
} | php | protected function _properties($key, $scope) {
return $this->cache($key, function() use ($scope) {
$props = [];
foreach ($this->reflection()->getProperties($scope) as $prop) {
$props[] = $prop->getName();
}
return $props;
});
} | [
"protected",
"function",
"_properties",
"(",
"$",
"key",
",",
"$",
"scope",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"(",
"$",
"key",
",",
"function",
"(",
")",
"use",
"(",
"$",
"scope",
")",
"{",
"$",
"props",
"=",
"[",
"]",
";",
"foreach... | Return an array of properties for the defined scope.
@param string $key
@param int $scope
@return string[] | [
"Return",
"an",
"array",
"of",
"properties",
"for",
"the",
"defined",
"scope",
"."
] | 41fe62bd5134bf76db3ff9caa16f280d9d534ef9 | https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/InfoAugment.php#L287-L297 | train |
indigophp/indigo-skeleton | classes/Controller.php | Controller.check_access | protected function check_access($action = null)
{
is_null($action) and $action = $this->request->action;
if ($this->has_access($action) === false)
{
$context = array(
'form' => array(
'%action%' => $action,
'%items%' => $this->get_name(999),
)
);
\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);
return \Response::redirect_back(\Uri::admin(false));
}
} | php | protected function check_access($action = null)
{
is_null($action) and $action = $this->request->action;
if ($this->has_access($action) === false)
{
$context = array(
'form' => array(
'%action%' => $action,
'%items%' => $this->get_name(999),
)
);
\Logger::instance('alert')->error(gettext('You are not authorized to %action% %items%.'), $context);
return \Response::redirect_back(\Uri::admin(false));
}
} | [
"protected",
"function",
"check_access",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"is_null",
"(",
"$",
"action",
")",
"and",
"$",
"action",
"=",
"$",
"this",
"->",
"request",
"->",
"action",
";",
"if",
"(",
"$",
"this",
"->",
"has_access",
"(",
"$"... | Checks whether user has access to an action | [
"Checks",
"whether",
"user",
"has",
"access",
"to",
"an",
"action"
] | d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d | https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L83-L100 | train |
indigophp/indigo-skeleton | classes/Controller.php | Controller.find | protected function find($id = null)
{
$query = $this->query();
$query->where('id', $id);
if (is_null($id) or is_null($model = $query->get_one()))
{
throw new \HttpNotFoundException();
}
return $model;
} | php | protected function find($id = null)
{
$query = $this->query();
$query->where('id', $id);
if (is_null($id) or is_null($model = $query->get_one()))
{
throw new \HttpNotFoundException();
}
return $model;
} | [
"protected",
"function",
"find",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"id",
")... | Finds an entity of model
@param integer $id
@return Model | [
"Finds",
"an",
"entity",
"of",
"model"
] | d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d | https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L147-L158 | train |
indigophp/indigo-skeleton | classes/Controller.php | Controller.forge | protected function forge($data = [], $new = true, $view = null, $cache = true)
{
return call_user_func([$this->get_model(), 'forge'], $data, $new, $view, $cache);
} | php | protected function forge($data = [], $new = true, $view = null, $cache = true)
{
return call_user_func([$this->get_model(), 'forge'], $data, $new, $view, $cache);
} | [
"protected",
"function",
"forge",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"new",
"=",
"true",
",",
"$",
"view",
"=",
"null",
",",
"$",
"cache",
"=",
"true",
")",
"{",
"return",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"get_model",
"(",
"... | Forge a new Model
@see Model::forge
@return Model | [
"Forge",
"a",
"new",
"Model"
] | d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d | https://github.com/indigophp/indigo-skeleton/blob/d6fc206d8b8d48ae9812cc9a06ddc9ccfd0a341d/classes/Controller.php#L167-L170 | train |
vinala/kernel | src/Processes/Exception.php | Exception.create | public static function create($name, $message, $view)
{
$root = Process::root;
$name = ucfirst($name);
$path = $root."app/exceptions/$name.php";
//
if (!File::exists($path)) {
File::put($path, self::set($name, $message, $view));
return true;
} else {
return false;
}
} | php | public static function create($name, $message, $view)
{
$root = Process::root;
$name = ucfirst($name);
$path = $root."app/exceptions/$name.php";
//
if (!File::exists($path)) {
File::put($path, self::set($name, $message, $view));
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"message",
",",
"$",
"view",
")",
"{",
"$",
"root",
"=",
"Process",
"::",
"root",
";",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"name",
")",
";",
"$",
"path",
"=",
"$",
"root",
... | Create exception.
@param string $name
@param string $message
@param string $view
@return bool | [
"Create",
"exception",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Processes/Exception.php#L22-L36 | train |
LasseHaslev/api-response | src/Transformers/TransformerTrait.php | TransformerTrait.includeDefaultIncludes | protected function includeDefaultIncludes($model, $data)
{
// Create an return array
$returnData = [];
// If we have default includes
if ( ! empty( $this->defaultIncludes ) ) {
// Loop through all includes
foreach ($this->defaultIncludes as $include) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
// Return data
return array_merge( $data, $returnData );
} | php | protected function includeDefaultIncludes($model, $data)
{
// Create an return array
$returnData = [];
// If we have default includes
if ( ! empty( $this->defaultIncludes ) ) {
// Loop through all includes
foreach ($this->defaultIncludes as $include) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
// Return data
return array_merge( $data, $returnData );
} | [
"protected",
"function",
"includeDefaultIncludes",
"(",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// Create an return array",
"$",
"returnData",
"=",
"[",
"]",
";",
"// If we have default includes",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"defaultInclu... | Include default includes
@return Array | [
"Include",
"default",
"includes"
] | 323be67cb1013d7ef73b8175a139f3e5937fa90f | https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L115-L135 | train |
LasseHaslev/api-response | src/Transformers/TransformerTrait.php | TransformerTrait.includeAvailableIncludes | protected function includeAvailableIncludes($model, $data )
{
// Get available includes from url parameters
$includes = $this->getAvailableIncludesFromUrlParameters();
// Create an return array
$returnData = [];
// Check if we have includes and include parameter values
if ( ! empty( $includes ) && ! empty( $this->availableIncludes ) ) {
// Loop through all includes
foreach ($this->availableIncludes as $include) {
// If the words exists in both includes
if ( in_array( $include, $includes ) ) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
}
// Return data
return array_merge( $data, $returnData );
} | php | protected function includeAvailableIncludes($model, $data )
{
// Get available includes from url parameters
$includes = $this->getAvailableIncludesFromUrlParameters();
// Create an return array
$returnData = [];
// Check if we have includes and include parameter values
if ( ! empty( $includes ) && ! empty( $this->availableIncludes ) ) {
// Loop through all includes
foreach ($this->availableIncludes as $include) {
// If the words exists in both includes
if ( in_array( $include, $includes ) ) {
// Add the new data
$returnData[ $include ] = $this->includeByName( $include, $model );
}
}
}
// Return data
return array_merge( $data, $returnData );
} | [
"protected",
"function",
"includeAvailableIncludes",
"(",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// Get available includes from url parameters",
"$",
"includes",
"=",
"$",
"this",
"->",
"getAvailableIncludesFromUrlParameters",
"(",
")",
";",
"// Create an return array... | Include available includes
@return Array | [
"Include",
"available",
"includes"
] | 323be67cb1013d7ef73b8175a139f3e5937fa90f | https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L142-L169 | train |
LasseHaslev/api-response | src/Transformers/TransformerTrait.php | TransformerTrait.includeByName | protected function includeByName( $name, $model )
{
$functionName = sprintf( 'include%s', ucfirst( $name ) );
if ( ! method_exists( static::class, $functionName ) ) {
throw new \Exception(sprintf( 'The function name "%s" does not exists on %s', $functionName, static::class ));
}
return $this->{$functionName}( $model );
} | php | protected function includeByName( $name, $model )
{
$functionName = sprintf( 'include%s', ucfirst( $name ) );
if ( ! method_exists( static::class, $functionName ) ) {
throw new \Exception(sprintf( 'The function name "%s" does not exists on %s', $functionName, static::class ));
}
return $this->{$functionName}( $model );
} | [
"protected",
"function",
"includeByName",
"(",
"$",
"name",
",",
"$",
"model",
")",
"{",
"$",
"functionName",
"=",
"sprintf",
"(",
"'include%s'",
",",
"ucfirst",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"static",
"::",
"cl... | Call the include function thats equal to the name
@return Array | [
"Call",
"the",
"include",
"function",
"thats",
"equal",
"to",
"the",
"name"
] | 323be67cb1013d7ef73b8175a139f3e5937fa90f | https://github.com/LasseHaslev/api-response/blob/323be67cb1013d7ef73b8175a139f3e5937fa90f/src/Transformers/TransformerTrait.php#L176-L187 | train |
factorio-item-browser/api-database | src/Repository/IconFileRepository.php | IconFileRepository.findByHashes | public function findByHashes(array $hashes): array
{
$result = [];
if (count($hashes) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if')
->from(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values(array_map('hex2bin', $hashes)));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | php | public function findByHashes(array $hashes): array
{
$result = [];
if (count($hashes) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if')
->from(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values(array_map('hex2bin', $hashes)));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | [
"public",
"function",
"findByHashes",
"(",
"array",
"$",
"hashes",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"hashes",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManag... | Finds the icon files with the specified hashes.
@param array|string[] $hashes
@return array|IconFile[] | [
"Finds",
"the",
"icon",
"files",
"with",
"the",
"specified",
"hashes",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L22-L35 | train |
factorio-item-browser/api-database | src/Repository/IconFileRepository.php | IconFileRepository.removeOrphans | public function removeOrphans(): void
{
$hashes = $this->findOrphanedHashes();
if (count($hashes) > 0) {
$this->removeHashes($hashes);
}
} | php | public function removeOrphans(): void
{
$hashes = $this->findOrphanedHashes();
if (count($hashes) > 0) {
$this->removeHashes($hashes);
}
} | [
"public",
"function",
"removeOrphans",
"(",
")",
":",
"void",
"{",
"$",
"hashes",
"=",
"$",
"this",
"->",
"findOrphanedHashes",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"hashes",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"removeHashes",
"(",
... | Removes any orphaned icon files, i.e. icon files no longer used by any icon. | [
"Removes",
"any",
"orphaned",
"icon",
"files",
"i",
".",
"e",
".",
"icon",
"files",
"no",
"longer",
"used",
"by",
"any",
"icon",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L40-L46 | train |
factorio-item-browser/api-database | src/Repository/IconFileRepository.php | IconFileRepository.findOrphanedHashes | protected function findOrphanedHashes(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if.hash AS hash')
->from(IconFile::class, 'if')
->leftJoin('if.icons', 'i')
->andWhere('i.id IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = $data['hash'];
}
return $result;
} | php | protected function findOrphanedHashes(): array
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('if.hash AS hash')
->from(IconFile::class, 'if')
->leftJoin('if.icons', 'i')
->andWhere('i.id IS NULL');
$result = [];
foreach ($queryBuilder->getQuery()->getResult() as $data) {
$result[] = $data['hash'];
}
return $result;
} | [
"protected",
"function",
"findOrphanedHashes",
"(",
")",
":",
"array",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'if.hash AS hash'",
")",
"->",
"from... | Returns the hashes of orphaned icon files, which are no longer used by any icon.
@return array|string[] | [
"Returns",
"the",
"hashes",
"of",
"orphaned",
"icon",
"files",
"which",
"are",
"no",
"longer",
"used",
"by",
"any",
"icon",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L52-L65 | train |
factorio-item-browser/api-database | src/Repository/IconFileRepository.php | IconFileRepository.removeHashes | protected function removeHashes(array $hashes): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values($hashes));
$queryBuilder->getQuery()->execute();
} | php | protected function removeHashes(array $hashes): void
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->delete(IconFile::class, 'if')
->andWhere('if.hash IN (:hashes)')
->setParameter('hashes', array_values($hashes));
$queryBuilder->getQuery()->execute();
} | [
"protected",
"function",
"removeHashes",
"(",
"array",
"$",
"hashes",
")",
":",
"void",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"delete",
"(",
"IconFile",
"::",
... | Removes the icon files with the specified hashes from the database.
@param array|string[] $hashes | [
"Removes",
"the",
"icon",
"files",
"with",
"the",
"specified",
"hashes",
"from",
"the",
"database",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/IconFileRepository.php#L71-L79 | train |
loopsframework/base | src/Loops/Application/LoopsAdmin.php | LoopsAdmin.exec | public function exec($arguments) {
//parse
$options = $this->parse();
// check if help was requested
if(is_integer($options)) {
return $options;
}
// extract and remove special vars
$instance = $options["__instance"];
$method = $options["__method"];
unset($options["__instance"]);
unset($options["__method"]);
// execute action - print error on failure
try {
return (int)Misc::reflectionFunction([ $instance, $method ], self::adjustOptions($options));
}
catch(Exception $e) {
return $this->printError($e->getMessage());
}
} | php | public function exec($arguments) {
//parse
$options = $this->parse();
// check if help was requested
if(is_integer($options)) {
return $options;
}
// extract and remove special vars
$instance = $options["__instance"];
$method = $options["__method"];
unset($options["__instance"]);
unset($options["__method"]);
// execute action - print error on failure
try {
return (int)Misc::reflectionFunction([ $instance, $method ], self::adjustOptions($options));
}
catch(Exception $e) {
return $this->printError($e->getMessage());
}
} | [
"public",
"function",
"exec",
"(",
"$",
"arguments",
")",
"{",
"//parse",
"$",
"options",
"=",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"// check if help was requested",
"if",
"(",
"is_integer",
"(",
"$",
"options",
")",
")",
"{",
"return",
"$",
"optio... | Forwards the call to parsed module name and action
See class documentation for details. | [
"Forwards",
"the",
"call",
"to",
"parsed",
"module",
"name",
"and",
"action"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L193-L216 | train |
loopsframework/base | src/Loops/Application/LoopsAdmin.php | LoopsAdmin.adjustOptions | private static function adjustOptions(array $options) {
$result = [];
foreach($options as $key => $value) {
$result[str_replace("-", "_", $key)] = $value;
}
return $result;
} | php | private static function adjustOptions(array $options) {
$result = [];
foreach($options as $key => $value) {
$result[str_replace("-", "_", $key)] = $value;
}
return $result;
} | [
"private",
"static",
"function",
"adjustOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"str_replace",
"(",
"\"-\... | replaces dashes with underscore in keys of an array | [
"replaces",
"dashes",
"with",
"underscore",
"in",
"keys",
"of",
"an",
"array"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L221-L229 | train |
loopsframework/base | src/Loops/Application/LoopsAdmin.php | LoopsAdmin.ident | private function ident($text, $length = 4, $chunk = 76, $break = "\n") {
$lines = [];
foreach(explode($break, $text) as $line) {
$text = trim(wordwrap($line, $chunk - $length, $break));
foreach(explode($break, $text) as $part) {
$lines[] = str_repeat(" ", $length).$part;
}
}
return implode($break, $lines);
} | php | private function ident($text, $length = 4, $chunk = 76, $break = "\n") {
$lines = [];
foreach(explode($break, $text) as $line) {
$text = trim(wordwrap($line, $chunk - $length, $break));
foreach(explode($break, $text) as $part) {
$lines[] = str_repeat(" ", $length).$part;
}
}
return implode($break, $lines);
} | [
"private",
"function",
"ident",
"(",
"$",
"text",
",",
"$",
"length",
"=",
"4",
",",
"$",
"chunk",
"=",
"76",
",",
"$",
"break",
"=",
"\"\\n\"",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"break",
",",
"$",... | Idents and chunk splits a text | [
"Idents",
"and",
"chunk",
"splits",
"a",
"text"
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/LoopsAdmin.php#L234-L245 | train |
slickframework/i18n | src/TranslateMethods.php | TranslateMethods.translatePlural | public function translatePlural($singular, $plural, $number)
{
$this->checkTranslator();
return $this->translator->translatePlural($singular, $plural, $number);
} | php | public function translatePlural($singular, $plural, $number)
{
$this->checkTranslator();
return $this->translator->translatePlural($singular, $plural, $number);
} | [
"public",
"function",
"translatePlural",
"(",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"number",
")",
"{",
"$",
"this",
"->",
"checkTranslator",
"(",
")",
";",
"return",
"$",
"this",
"->",
"translator",
"->",
"translatePlural",
"(",
"$",
"singular",
... | Translates the provided message to singular or plural according to the number
@param string $singular
@param string $plural
@param integer $number
@return string | [
"Translates",
"the",
"provided",
"message",
"to",
"singular",
"or",
"plural",
"according",
"to",
"the",
"number"
] | 3d6d9bad8e0f7ac02f6e9919821cf49371fc9353 | https://github.com/slickframework/i18n/blob/3d6d9bad8e0f7ac02f6e9919821cf49371fc9353/src/TranslateMethods.php#L49-L53 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.showAction | public function showAction(MeasureUnit $measureunit)
{
$editForm = $this->createForm(MeasureUnitType::class, $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction(MeasureUnit $measureunit)
{
$editForm = $this->createForm(MeasureUnitType::class, $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"MeasureUnit",
"$",
"measureunit",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"MeasureUnitType",
"::",
"class",
",",
"$",
"measureunit",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"... | Finds and displays a MeasureUnit entity.
@Route("/{id}/show", name="admin_shop_measure_unit_show", requirements={"id"="\d+"})
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"MeasureUnit",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L47-L62 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.newAction | public function newAction()
{
$measureunit = new MeasureUnit();
$form = $this->createForm(MeasureUnitType::class, $measureunit);
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$measureunit = new MeasureUnit();
$form = $this->createForm(MeasureUnitType::class, $measureunit);
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"measureunit",
"=",
"new",
"MeasureUnit",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"MeasureUnitType",
"::",
"class",
",",
"$",
"measureunit",
")",
";",
"return",
"array"... | Displays a form to create a new MeasureUnit entity.
@Route("/new", name="admin_shop_measure_unit_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"MeasureUnit",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L71-L80 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.createAction | public function createAction(Request $request)
{
$measureunit = new MeasureUnit();
$form = $this->createForm(new MeasureUnitType(), $measureunit);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($measureunit);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
} | php | public function createAction(Request $request)
{
$measureunit = new MeasureUnit();
$form = $this->createForm(new MeasureUnitType(), $measureunit);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($measureunit);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
return array(
'measureunit' => $measureunit,
'form' => $form->createView(),
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"measureunit",
"=",
"new",
"MeasureUnit",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"MeasureUnitType",
"(",
")",
",",
"$",
"measureun... | Creates a new MeasureUnit entity.
@Route("/create", name="admin_shop_measure_unit_create")
@Method("POST")
@Template("FlowerStockBundle:MeasureUnit:new.html.twig") | [
"Creates",
"a",
"new",
"MeasureUnit",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L89-L105 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.updateAction | public function updateAction(MeasureUnit $measureunit, Request $request)
{
$editForm = $this->createForm(new MeasureUnitType(), $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | php | public function updateAction(MeasureUnit $measureunit, Request $request)
{
$editForm = $this->createForm(new MeasureUnitType(), $measureunit, array(
'action' => $this->generateUrl('admin_shop_measure_unit_update', array('id' => $measureunit->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_measure_unit_show', array('id' => $measureunit->getId())));
}
$deleteForm = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
return array(
'measureunit' => $measureunit,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"updateAction",
"(",
"MeasureUnit",
"$",
"measureunit",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"MeasureUnitType",
"(",
")",
",",
"$",
"measureunit",
",",
"array",
"... | Edits an existing MeasureUnit entity.
@Route("/{id}/update", name="admin_shop_measure_unit_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:MeasureUnit:edit.html.twig") | [
"Edits",
"an",
"existing",
"MeasureUnit",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L136-L154 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.sortAction | public function sortAction($field, $type)
{
$this->setOrder('measureunit', $field, $type);
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
} | php | public function sortAction($field, $type)
{
$this->setOrder('measureunit', $field, $type);
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
} | [
"public",
"function",
"sortAction",
"(",
"$",
"field",
",",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"setOrder",
"(",
"'measureunit'",
",",
"$",
"field",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
... | Save order.
@Route("/order/{field}/{type}", name="admin_shop_measure_unit_sort") | [
"Save",
"order",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L162-L167 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php | AdminMeasureUnitController.deleteAction | public function deleteAction(MeasureUnit $measureunit, Request $request)
{
$form = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($measureunit);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
} | php | public function deleteAction(MeasureUnit $measureunit, Request $request)
{
$form = $this->createDeleteForm($measureunit->getId(), 'admin_shop_measure_unit_delete');
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($measureunit);
$em->flush();
}
return $this->redirect($this->generateUrl('admin_shop_measure_unit'));
} | [
"public",
"function",
"deleteAction",
"(",
"MeasureUnit",
"$",
"measureunit",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"measureunit",
"->",
"getId",
"(",
")",
",",
"'admin_shop_measure_unit_de... | Deletes a MeasureUnit entity.
@Route("/{id}/delete", name="admin_shop_measure_unit_delete", requirements={"id"="\d+"})
@Method("DELETE") | [
"Deletes",
"a",
"MeasureUnit",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminMeasureUnitController.php#L208-L218 | train |
lciolecki/zf-extensions-library | library/Extlib/Mail/Message/Html.php | Html.getScript | protected function getScript()
{
if (null === $this->getScriptName()) {
$request = $this->frontController->getRequest();
$this->setScriptName($request->getControllerName() . DIRECTORY_SEPARATOR . $request->getActionName());
}
return $this->getScriptName() . '.' . $this->getViewSuffix();
} | php | protected function getScript()
{
if (null === $this->getScriptName()) {
$request = $this->frontController->getRequest();
$this->setScriptName($request->getControllerName() . DIRECTORY_SEPARATOR . $request->getActionName());
}
return $this->getScriptName() . '.' . $this->getViewSuffix();
} | [
"protected",
"function",
"getScript",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"getScriptName",
"(",
")",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"frontController",
"->",
"getRequest",
"(",
")",
";",
"$",
"this",
"->",
"s... | Get full name of script to render
@return string | [
"Get",
"full",
"name",
"of",
"script",
"to",
"render"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Mail/Message/Html.php#L100-L108 | train |
lciolecki/zf-extensions-library | library/Extlib/Mail/Message/Html.php | Html.setData | public function setData(array $data)
{
foreach ($data as $name => $value) {
if (is_string($name)) {
$this->__set($name, $value);
}
}
return $this;
} | php | public function setData(array $data)
{
foreach ($data as $name => $value) {
if (is_string($name)) {
$this->__set($name, $value);
}
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"__set",
"(",
"$",
"... | Set data collections in View
@param array $data
@return \Extlib\Mail\Message\Html | [
"Set",
"data",
"collections",
"in",
"View"
] | f479a63188d17f1488b392d4fc14fe47a417ea55 | https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Mail/Message/Html.php#L182-L191 | train |
Consumerr/php | src/Consumerr/Configuration.php | Configuration.getSenderClass | public function getSenderClass($options)
{
if (empty($options['sender'])) {
if (function_exists('extension_loaded') && extension_loaded('curl') && PHP_VERSION_ID >= 50300) {
return /**/
'Consumerr\Sender\CurlSender' /**/ /*5.2*'Consumerr_CurlSender'*/
;
} else {
return /**/
'Consumerr\Sender\PhpSender' /**/ /*5.2*'Consumerr_PhpSender'*/
;
}
} else {
if (isset($this->senderAlias[$options['sender']])) {
return $this->senderAlias[$options['sender']];
} else {
if (!class_exists($options['sender'])) {
throw new AssertionException("Sender class {$options['sender']} was not found.");
}
return $options['sender'];
}
}
} | php | public function getSenderClass($options)
{
if (empty($options['sender'])) {
if (function_exists('extension_loaded') && extension_loaded('curl') && PHP_VERSION_ID >= 50300) {
return /**/
'Consumerr\Sender\CurlSender' /**/ /*5.2*'Consumerr_CurlSender'*/
;
} else {
return /**/
'Consumerr\Sender\PhpSender' /**/ /*5.2*'Consumerr_PhpSender'*/
;
}
} else {
if (isset($this->senderAlias[$options['sender']])) {
return $this->senderAlias[$options['sender']];
} else {
if (!class_exists($options['sender'])) {
throw new AssertionException("Sender class {$options['sender']} was not found.");
}
return $options['sender'];
}
}
} | [
"public",
"function",
"getSenderClass",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'sender'",
"]",
")",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'extension_loaded'",
")",
"&&",
"extension_loaded",
"(",
"'curl'",
")",... | Determine sender handler from configuration
@internal
@param array $options
@return string | [
"Determine",
"sender",
"handler",
"from",
"configuration"
] | 2a33401e70d1309b1e0669160044350a881e6603 | https://github.com/Consumerr/php/blob/2a33401e70d1309b1e0669160044350a881e6603/src/Consumerr/Configuration.php#L133-L156 | train |
krutush/krutush | src/Router.php | Router.add | public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
} | php | public function add(string $path, $callable): Route{
$route = new Route($path, $callable);
$this->routes[] = $route;
return $route;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"path",
",",
"$",
"callable",
")",
":",
"Route",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"callable",
")",
";",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"route",
... | Register a new Route
@param string $path Url from Root
@param callable|string $callable Function to run or 'Controller#function'
@return Route | [
"Register",
"a",
"new",
"Route"
] | 3c42b524d7bd199d43fb3a5035b9e1bb39f5575b | https://github.com/krutush/krutush/blob/3c42b524d7bd199d43fb3a5035b9e1bb39f5575b/src/Router.php#L34-L38 | train |
jmpantoja/planb-utils | src/Type/Path/PathNormalizer.php | PathNormalizer.configureSlashPrefix | private function configureSlashPrefix(array $pieces): self
{
$first = array_shift($pieces);
$pattern = sprintf('#^%s#', DIRECTORY_SEPARATOR);
if (preg_match($pattern, $first)) {
$this->prefix .= DIRECTORY_SEPARATOR;
}
return $this;
} | php | private function configureSlashPrefix(array $pieces): self
{
$first = array_shift($pieces);
$pattern = sprintf('#^%s#', DIRECTORY_SEPARATOR);
if (preg_match($pattern, $first)) {
$this->prefix .= DIRECTORY_SEPARATOR;
}
return $this;
} | [
"private",
"function",
"configureSlashPrefix",
"(",
"array",
"$",
"pieces",
")",
":",
"self",
"{",
"$",
"first",
"=",
"array_shift",
"(",
"$",
"pieces",
")",
";",
"$",
"pattern",
"=",
"sprintf",
"(",
"'#^%s#'",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"if",
... | Configura el normalizer para tratar con rutas absolutas
@param string[] $pieces
@return \PlanB\Type\Path\PathNormalizer | [
"Configura",
"el",
"normalizer",
"para",
"tratar",
"con",
"rutas",
"absolutas"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L62-L72 | train |
jmpantoja/planb-utils | src/Type/Path/PathNormalizer.php | PathNormalizer.getPartsFromSegment | private function getPartsFromSegment(string $segment): array
{
$parts = explode(DIRECTORY_SEPARATOR, $segment);
return array_filter($parts, function ($part) {
return $this->isNotEmpty($part);
});
} | php | private function getPartsFromSegment(string $segment): array
{
$parts = explode(DIRECTORY_SEPARATOR, $segment);
return array_filter($parts, function ($part) {
return $this->isNotEmpty($part);
});
} | [
"private",
"function",
"getPartsFromSegment",
"(",
"string",
"$",
"segment",
")",
":",
"array",
"{",
"$",
"parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"segment",
")",
";",
"return",
"array_filter",
"(",
"$",
"parts",
",",
"function",
"(",
... | Separa un segmento en varias partes, cortando por DIRECTORY_SEPARATOR
@param string $segment
@return string[] | [
"Separa",
"un",
"segmento",
"en",
"varias",
"partes",
"cortando",
"por",
"DIRECTORY_SEPARATOR"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L100-L107 | train |
jmpantoja/planb-utils | src/Type/Path/PathNormalizer.php | PathNormalizer.toString | protected function toString(): string
{
$normalized = sprintf('%s%s', $this->prefix, implode(DIRECTORY_SEPARATOR, $this->stack));
return trim($normalized);
} | php | protected function toString(): string
{
$normalized = sprintf('%s%s', $this->prefix, implode(DIRECTORY_SEPARATOR, $this->stack));
return trim($normalized);
} | [
"protected",
"function",
"toString",
"(",
")",
":",
"string",
"{",
"$",
"normalized",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"this",
"->",
"prefix",
",",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"stack",
")",
")",
";",
"return",
... | Devuelve la ruta normalizada
@return string | [
"Devuelve",
"la",
"ruta",
"normalizada"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathNormalizer.php#L197-L202 | train |
vox-tecnologia/functions | src/Functions/ServiceFunctions.php | ServiceFunctions.isValidEmail | public function isValidEmail(string $email): bool
{
return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL) !== false;
} | php | public function isValidEmail(string $email): bool
{
return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL) !== false;
} | [
"public",
"function",
"isValidEmail",
"(",
"string",
"$",
"email",
")",
":",
"bool",
"{",
"return",
"filter_var",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_SANITIZE_EMAIL",
")",
",",
"FILTER_VALIDATE_EMAIL",
")",
"!==",
"false",
";",
"}"
] | Validate a email address.
@param string $email The email address to validate
@return bool | [
"Validate",
"a",
"email",
"address",
"."
] | 1da249ac87f9d7c46d1c714d65443cda9face807 | https://github.com/vox-tecnologia/functions/blob/1da249ac87f9d7c46d1c714d65443cda9face807/src/Functions/ServiceFunctions.php#L294-L297 | train |
encorephp/repl | src/Command.php | Command.repl | public function repl()
{
$input = $this->prompt();
$buffer = null;
while ($input != 'exit;') {
try {
$buffer .= $input;
if ((new ShallowParser)->statements($buffer)) {
ob_start();
$app = $this->container;
eval($buffer);
$response = ob_get_clean();
if ( ! empty($response)) $this->output->writeln(trim($response));
$buffer = null;
}
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$input = $this->prompt($buffer !== null);
}
if ($input == 'exit;') exit;
} | php | public function repl()
{
$input = $this->prompt();
$buffer = null;
while ($input != 'exit;') {
try {
$buffer .= $input;
if ((new ShallowParser)->statements($buffer)) {
ob_start();
$app = $this->container;
eval($buffer);
$response = ob_get_clean();
if ( ! empty($response)) $this->output->writeln(trim($response));
$buffer = null;
}
} catch (\Exception $e) {
$this->error($e->getMessage());
}
$input = $this->prompt($buffer !== null);
}
if ($input == 'exit;') exit;
} | [
"public",
"function",
"repl",
"(",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"prompt",
"(",
")",
";",
"$",
"buffer",
"=",
"null",
";",
"while",
"(",
"$",
"input",
"!=",
"'exit;'",
")",
"{",
"try",
"{",
"$",
"buffer",
".=",
"$",
"input",
"... | Run the REPL loop
@return void | [
"Run",
"the",
"REPL",
"loop"
] | c53973941b8741a3ccac5b1f95e426f72ee04727 | https://github.com/encorephp/repl/blob/c53973941b8741a3ccac5b1f95e426f72ee04727/src/Command.php#L36-L63 | train |
encorephp/repl | src/Command.php | Command.prompt | protected function prompt($indent = false)
{
$dialog = $this->getHelperSet()->get('dialog');
$indent = $indent ? '*' : null;
return $dialog->ask($this->output, "<info>encore{$indent}></info>", null);
} | php | protected function prompt($indent = false)
{
$dialog = $this->getHelperSet()->get('dialog');
$indent = $indent ? '*' : null;
return $dialog->ask($this->output, "<info>encore{$indent}></info>", null);
} | [
"protected",
"function",
"prompt",
"(",
"$",
"indent",
"=",
"false",
")",
"{",
"$",
"dialog",
"=",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"get",
"(",
"'dialog'",
")",
";",
"$",
"indent",
"=",
"$",
"indent",
"?",
"'*'",
":",
"null",
";",... | Prompt the user for an input
@param boolean $indent
@return string | [
"Prompt",
"the",
"user",
"for",
"an",
"input"
] | c53973941b8741a3ccac5b1f95e426f72ee04727 | https://github.com/encorephp/repl/blob/c53973941b8741a3ccac5b1f95e426f72ee04727/src/Command.php#L71-L78 | train |
Silvestra/Silvestra | src/Silvestra/Component/Media/Filesystem.php | Filesystem.getActualFileDir | public function getActualFileDir($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getPath(array($this->getMediaRootDir(), $subDir, $this->getFileDirPrefix($filename)));
} | php | public function getActualFileDir($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getPath(array($this->getMediaRootDir(), $subDir, $this->getFileDirPrefix($filename)));
} | [
"public",
"function",
"getActualFileDir",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"return",
"$",
"this",
"->",
"getPath",
"(",
"array",
"(",
"$",
"this",
"->",
"getMediaRootDir",
"(",
")",
",",
"$",
"sub... | Get actual file dir.
@param string $filename
@param string $subDir
@return string | [
"Get",
"actual",
"file",
"dir",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L83-L86 | train |
Silvestra/Silvestra | src/Silvestra/Component/Media/Filesystem.php | Filesystem.getFileDirPrefix | public function getFileDirPrefix($filename)
{
if (empty($filename)) {
throw new InvalidArgumentException('Invalid filename argument');
}
$path = array();
$parts = explode('.', $filename);
for ($i = 0; $i < min(strlen($parts[0]), $this->prefixSize); $i++) {
$path[] = $filename[$i];
}
$path = $this->getPath($path);
return $path;
} | php | public function getFileDirPrefix($filename)
{
if (empty($filename)) {
throw new InvalidArgumentException('Invalid filename argument');
}
$path = array();
$parts = explode('.', $filename);
for ($i = 0; $i < min(strlen($parts[0]), $this->prefixSize); $i++) {
$path[] = $filename[$i];
}
$path = $this->getPath($path);
return $path;
} | [
"public",
"function",
"getFileDirPrefix",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid filename argument'",
")",
";",
"}",
"$",
"path",
"=",
"array",
"(",
... | Get file dir prefix.
@param string $filename
@return string
@throws InvalidArgumentException | [
"Get",
"file",
"dir",
"prefix",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L97-L113 | train |
Silvestra/Silvestra | src/Silvestra/Component/Media/Filesystem.php | Filesystem.getAbsoluteFilePath | public function getAbsoluteFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getRootDir() . $this->getRelativeFilePath($filename, $subDir);
} | php | public function getAbsoluteFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
return $this->getRootDir() . $this->getRelativeFilePath($filename, $subDir);
} | [
"public",
"function",
"getAbsoluteFilePath",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"return",
"$",
"this",
"->",
"getRootDir",
"(",
")",
".",
"$",
"this",
"->",
"getRelativeFilePath",
"(",
"$",
"filename",
... | Get absolute file path.
@param string $filename
@param string $subDir
@return string | [
"Get",
"absolute",
"file",
"path",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L168-L171 | train |
Silvestra/Silvestra | src/Silvestra/Component/Media/Filesystem.php | Filesystem.getRelativeFilePath | public function getRelativeFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
$pathParts = array(Media::NAME, $subDir, $this->getFileDirPrefix($filename), $filename);
return DIRECTORY_SEPARATOR . $this->getPath($pathParts);
} | php | public function getRelativeFilePath($filename, $subDir = self::UPLOADER_SUB_DIR)
{
$pathParts = array(Media::NAME, $subDir, $this->getFileDirPrefix($filename), $filename);
return DIRECTORY_SEPARATOR . $this->getPath($pathParts);
} | [
"public",
"function",
"getRelativeFilePath",
"(",
"$",
"filename",
",",
"$",
"subDir",
"=",
"self",
"::",
"UPLOADER_SUB_DIR",
")",
"{",
"$",
"pathParts",
"=",
"array",
"(",
"Media",
"::",
"NAME",
",",
"$",
"subDir",
",",
"$",
"this",
"->",
"getFileDirPrefi... | Get relative file path.
@param string $filename
@param string $subDir
@return string | [
"Get",
"relative",
"file",
"path",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Filesystem.php#L181-L186 | train |
Ara95/user | src/User/User.php | User.verifyPassword | public function verifyPassword($email, $password)
{
$this->find("email", $email);
return password_verify($password, $this->password);
} | php | public function verifyPassword($email, $password)
{
$this->find("email", $email);
return password_verify($password, $this->password);
} | [
"public",
"function",
"verifyPassword",
"(",
"$",
"email",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"email",
")",
";",
"return",
"password_verify",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"password",
... | Verify the acronym and the password, if successful the object contains
all details from the database row.
@param string $acronym acronym to check.
@param string $password the password to use.
@return boolean true if acronym and password matches, else false. | [
"Verify",
"the",
"acronym",
"and",
"the",
"password",
"if",
"successful",
"the",
"object",
"contains",
"all",
"details",
"from",
"the",
"database",
"row",
"."
] | 96e15a19906562a689abedf6bcf4818ad8437a3b | https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/User/User.php#L54-L58 | train |
Ara95/user | src/User/User.php | User.isEmailUnique | public function isEmailUnique($email)
{
$this->find("email", $email);
if (isset($this->id)) {
return false;
}
return true;
} | php | public function isEmailUnique($email)
{
$this->find("email", $email);
if (isset($this->id)) {
return false;
}
return true;
} | [
"public",
"function",
"isEmailUnique",
"(",
"$",
"email",
")",
"{",
"$",
"this",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"email",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
... | Check whether the user is an Admin
@return boolean true if user is an Admin | [
"Check",
"whether",
"the",
"user",
"is",
"an",
"Admin"
] | 96e15a19906562a689abedf6bcf4818ad8437a3b | https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/User/User.php#L86-L93 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.