repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
geniv/nette-thumbnail | src/Thumbnail.php | Thumbnail.getUnusedFiles | public static function getUnusedFiles(array $path): array
{
// load thumbnail files
$thumbFiles = self::getThumbFiles();
// load path files
$pathFiles = self::getPathFiles($path);
return $diff = array_diff($pathFiles, $thumbFiles);
} | php | public static function getUnusedFiles(array $path): array
{
// load thumbnail files
$thumbFiles = self::getThumbFiles();
// load path files
$pathFiles = self::getPathFiles($path);
return $diff = array_diff($pathFiles, $thumbFiles);
} | [
"public",
"static",
"function",
"getUnusedFiles",
"(",
"array",
"$",
"path",
")",
":",
"array",
"{",
"// load thumbnail files",
"$",
"thumbFiles",
"=",
"self",
"::",
"getThumbFiles",
"(",
")",
";",
"// load path files",
"$",
"pathFiles",
"=",
"self",
"::",
"ge... | Get unused files.
@param array $path
@return array | [
"Get",
"unused",
"files",
"."
] | train | https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/Thumbnail.php#L150-L159 |
geniv/nette-thumbnail | src/Thumbnail.php | Thumbnail.isSrcPathExists | public static function isSrcPathExists(string $path, string $file = null): bool
{
$src = self::$parameters['dir'] . $path . $file;
return file_exists($src) && is_file($src);
} | php | public static function isSrcPathExists(string $path, string $file = null): bool
{
$src = self::$parameters['dir'] . $path . $file;
return file_exists($src) && is_file($src);
} | [
"public",
"static",
"function",
"isSrcPathExists",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"file",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"src",
"=",
"self",
"::",
"$",
"parameters",
"[",
"'dir'",
"]",
".",
"$",
"path",
".",
"$",
"file",
... | Is src path exists.
@param string $path
@param string|null $file
@return bool | [
"Is",
"src",
"path",
"exists",
"."
] | train | https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/Thumbnail.php#L169-L173 |
geniv/nette-thumbnail | src/Thumbnail.php | Thumbnail.getSrcPath | public static function getSrcPath(string $path, string $file = null, string $width = null, string $height = null, array $flags = [], int $quality = null): string
{
$cacheName = 'getSrcPath' . $path . $file . $width . $height . implode($flags) . $quality;
$destination = (self::$parameters['cache'] ? ... | php | public static function getSrcPath(string $path, string $file = null, string $width = null, string $height = null, array $flags = [], int $quality = null): string
{
$cacheName = 'getSrcPath' . $path . $file . $width . $height . implode($flags) . $quality;
$destination = (self::$parameters['cache'] ? ... | [
"public",
"static",
"function",
"getSrcPath",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"file",
"=",
"null",
",",
"string",
"$",
"width",
"=",
"null",
",",
"string",
"$",
"height",
"=",
"null",
",",
"array",
"$",
"flags",
"=",
"[",
"]",
",",
... | Get src path.
@param string $path
@param string|null $file
@param string|null $width
@param string|null $height
@param array $flags
@param int|null $quality
@return string
@throws \Exception | [
"Get",
"src",
"path",
"."
] | train | https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/Thumbnail.php#L188-L216 |
geniv/nette-thumbnail | src/Thumbnail.php | Thumbnail.getImageFlag | private static function getImageFlag(array $flags): int
{
$res = 0;
foreach ($flags as $flag) {
$res |= constant(Image::class . '::' . $flag);
}
return $res;
} | php | private static function getImageFlag(array $flags): int
{
$res = 0;
foreach ($flags as $flag) {
$res |= constant(Image::class . '::' . $flag);
}
return $res;
} | [
"private",
"static",
"function",
"getImageFlag",
"(",
"array",
"$",
"flags",
")",
":",
"int",
"{",
"$",
"res",
"=",
"0",
";",
"foreach",
"(",
"$",
"flags",
"as",
"$",
"flag",
")",
"{",
"$",
"res",
"|=",
"constant",
"(",
"Image",
"::",
"class",
".",... | Get image flag.
@param array $flags
@return int | [
"Get",
"image",
"flag",
"."
] | train | https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/Thumbnail.php#L225-L232 |
geniv/nette-thumbnail | src/Thumbnail.php | Thumbnail.resizeImage | private static function resizeImage(string $path, string $file = null, $width = null, $height = null, array $flags = [], int $quality = null)
{
$parameters = self::$parameters;
if ($flags) {
$flag = self::getImageFlag($flags);
} else {
$flag = $parameters['defaultFlag... | php | private static function resizeImage(string $path, string $file = null, $width = null, $height = null, array $flags = [], int $quality = null)
{
$parameters = self::$parameters;
if ($flags) {
$flag = self::getImageFlag($flags);
} else {
$flag = $parameters['defaultFlag... | [
"private",
"static",
"function",
"resizeImage",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"file",
"=",
"null",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
",",
"array",
"$",
"flags",
"=",
"[",
"]",
",",
"int",
"$",
"quali... | Resize image.
@param string $path
@param string|null $file
@param null $width
@param null $height
@param array $flags
@param int|null $quality
@return string | [
"Resize",
"image",
"."
] | train | https://github.com/geniv/nette-thumbnail/blob/408fc61e0df99113a873ca1ec463e4fc85016eed/src/Thumbnail.php#L301-L359 |
DevGroup-ru/yii2-data-structure-tools | src/propertyHandler/HiddenField.php | HiddenField.getValidationRules | public function getValidationRules(Property $property)
{
$key = $property->key;
if (true === $property->canTranslate()) {
return [
[$key, ValuesValidator::class, 'skipOnEmpty' => true],
];
} else {
$rule = Property::dataTypeValidator($prope... | php | public function getValidationRules(Property $property)
{
$key = $property->key;
if (true === $property->canTranslate()) {
return [
[$key, ValuesValidator::class, 'skipOnEmpty' => true],
];
} else {
$rule = Property::dataTypeValidator($prope... | [
"public",
"function",
"getValidationRules",
"(",
"Property",
"$",
"property",
")",
"{",
"$",
"key",
"=",
"$",
"property",
"->",
"key",
";",
"if",
"(",
"true",
"===",
"$",
"property",
"->",
"canTranslate",
"(",
")",
")",
"{",
"return",
"[",
"[",
"$",
... | Get validation rules for a property.
@param Property $property
@return array of ActiveRecord validation rules | [
"Get",
"validation",
"rules",
"for",
"a",
"property",
"."
] | train | https://github.com/DevGroup-ru/yii2-data-structure-tools/blob/a5b24d7c0b24d4b0d58cacd91ec7fd876e979097/src/propertyHandler/HiddenField.php#L44-L63 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.get | public static function get($array, $key = null, $default = null, $useDotSyntax = false)
{
// Check arguments
if (empty($array)) {
return $default;
}
// Check if key is empty
if (is_null($key)) {
return $array;
}
// Check if value exis... | php | public static function get($array, $key = null, $default = null, $useDotSyntax = false)
{
// Check arguments
if (empty($array)) {
return $default;
}
// Check if key is empty
if (is_null($key)) {
return $array;
}
// Check if value exis... | [
"public",
"static",
"function",
"get",
"(",
"$",
"array",
",",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"// Check arguments",
"if",
"(",
"empty",
"(",
"$",
"array",
")",
")",
"{",
... | Get an item from an array.
@param array $array
@param string $key
@param mixed $default
@param bool $useDotSyntax
@return mixed | [
"Get",
"an",
"item",
"from",
"an",
"array",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L32-L74 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.filter | public static function filter(array $array, $callback = null, $default = [], $length = null)
{
// Set result array
$result = [];
// Check callback
if (is_callable($callback)) {
// Filter array elements
foreach ($array as $key => $value) {
if (... | php | public static function filter(array $array, $callback = null, $default = [], $length = null)
{
// Set result array
$result = [];
// Check callback
if (is_callable($callback)) {
// Filter array elements
foreach ($array as $key => $value) {
if (... | [
"public",
"static",
"function",
"filter",
"(",
"array",
"$",
"array",
",",
"$",
"callback",
"=",
"null",
",",
"$",
"default",
"=",
"[",
"]",
",",
"$",
"length",
"=",
"null",
")",
"{",
"// Set result array",
"$",
"result",
"=",
"[",
"]",
";",
"// Chec... | Filter array elements with a given callback function.
It returns the item that matches the callback function.
If the callback function is empty, it will return the array as is.
If the array is empty or no element matches the callback, it will return the default value.
The callback function should accept as parameter... | [
"Filter",
"array",
"elements",
"with",
"a",
"given",
"callback",
"function",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L163-L184 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.merge | public static function merge(array $array1, array $array2, $deep = false)
{
// Normal array merge
if (!$deep) {
return array_merge($array1, $array2);
}
// Perform a deep merge
$merged = $array1;
foreach ($array2 as $key => $value) {
if (is_ar... | php | public static function merge(array $array1, array $array2, $deep = false)
{
// Normal array merge
if (!$deep) {
return array_merge($array1, $array2);
}
// Perform a deep merge
$merged = $array1;
foreach ($array2 as $key => $value) {
if (is_ar... | [
"public",
"static",
"function",
"merge",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
",",
"$",
"deep",
"=",
"false",
")",
"{",
"// Normal array merge",
"if",
"(",
"!",
"$",
"deep",
")",
"{",
"return",
"array_merge",
"(",
"$",
"array1",
",... | Perform a merge on the given two arrays.
Deep merge will merge the two arrays in full depth.
@param array $array1
@param array $array2
@param bool $deep
@return array | [
"Perform",
"a",
"merge",
"on",
"the",
"given",
"two",
"arrays",
".",
"Deep",
"merge",
"will",
"merge",
"the",
"two",
"arrays",
"in",
"full",
"depth",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L196-L219 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.objectToArray | public static function objectToArray($objectArray)
{
$array = [];
foreach ($objectArray as $object) {
$itemArray = method_exists($object, 'toArray') ? $object->toArray() : [];
$array[] = $itemArray;
}
return $array;
} | php | public static function objectToArray($objectArray)
{
$array = [];
foreach ($objectArray as $object) {
$itemArray = method_exists($object, 'toArray') ? $object->toArray() : [];
$array[] = $itemArray;
}
return $array;
} | [
"public",
"static",
"function",
"objectToArray",
"(",
"$",
"objectArray",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"objectArray",
"as",
"$",
"object",
")",
"{",
"$",
"itemArray",
"=",
"method_exists",
"(",
"$",
"object",
",",
"'... | Transform an array of objects (with a function toArray())
to an array of arrays.
@param object[]|mixed $objectArray
@return array | [
"Transform",
"an",
"array",
"of",
"objects",
"(",
"with",
"a",
"function",
"toArray",
"()",
")",
"to",
"an",
"array",
"of",
"arrays",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L229-L238 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.toKeyIndex | public static function toKeyIndex($collection, $key, $useDotSyntax = false)
{
$keyIndexArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key, null, ... | php | public static function toKeyIndex($collection, $key, $useDotSyntax = false)
{
$keyIndexArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key, null, ... | [
"public",
"static",
"function",
"toKeyIndex",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"$",
"keyIndexArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
")",
"{",
"$",
"i... | Return the array and replace the default keys with the values
of the array, based on the given key.
@param array|object[]|mixed $collection
@param string $key
@param bool $useDotSyntax
@return array | [
"Return",
"the",
"array",
"and",
"replace",
"the",
"default",
"keys",
"with",
"the",
"values",
"of",
"the",
"array",
"based",
"on",
"the",
"given",
"key",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L250-L260 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.toKeyGroup | public static function toKeyGroup($collection, $key, $useDotSyntax = false)
{
$keyGroupArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key, null, ... | php | public static function toKeyGroup($collection, $key, $useDotSyntax = false)
{
$keyGroupArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key, null, ... | [
"public",
"static",
"function",
"toKeyGroup",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"$",
"keyGroupArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
")",
"{",
"$",
"i... | Group all array items by the given key.
@param array|object[]|mixed $collection
@param string $key
@param bool $useDotSyntax
@return array | [
"Group",
"all",
"array",
"items",
"by",
"the",
"given",
"key",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L271-L281 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.toKeyValue | public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
{
$keyValueArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key... | php | public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
{
$keyValueArray = [];
foreach ($collection as $item) {
$itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
$keyValue = self::get($itemArray, $key... | [
"public",
"static",
"function",
"toKeyValue",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"$",
"keyValueArray",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
... | Return the array in a key-value form, based on the
given parameters for key and value.
@param array|object[] $collection
@param string $key
@param string $value
@param bool $useDotSyntax
@return array | [
"Return",
"the",
"array",
"in",
"a",
"key",
"-",
"value",
"form",
"based",
"on",
"the",
"given",
"parameters",
"for",
"key",
"and",
"value",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L294-L304 |
PandaPlatform/framework | src/Panda/Support/Helpers/ArrayHelper.php | ArrayHelper.sortByKey | public static function sortByKey($array, $key, $useDotSyntax = false)
{
uasort($array, function ($a, $b) use ($key, $useDotSyntax) {
$valueA = self::get($a, $key, null, $useDotSyntax);
$valueB = self::get($b, $key, null, $useDotSyntax);
if ($valueA == $valueB) {
... | php | public static function sortByKey($array, $key, $useDotSyntax = false)
{
uasort($array, function ($a, $b) use ($key, $useDotSyntax) {
$valueA = self::get($a, $key, null, $useDotSyntax);
$valueB = self::get($b, $key, null, $useDotSyntax);
if ($valueA == $valueB) {
... | [
"public",
"static",
"function",
"sortByKey",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"useDotSyntax",
"=",
"false",
")",
"{",
"uasort",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"key",
",",
"$",
... | Sort an array by a given value, based on the given key.
@param array $array
@param string $key
@param bool $useDotSyntax
@return array | [
"Sort",
"an",
"array",
"by",
"a",
"given",
"value",
"based",
"on",
"the",
"given",
"key",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/ArrayHelper.php#L315-L328 |
transfer-framework/transfer | src/Transfer/Manifest/ManifestRunner.php | ManifestRunner.run | public function run(ManifestInterface $manifest)
{
$builder = new ProcedureBuilder();
$processor = $manifest->getProcessor();
if ($this->dispatcher) {
$processor->setEventDispatcher($this->dispatcher);
}
$manifest->configureProcedureBuilder($builder);
$m... | php | public function run(ManifestInterface $manifest)
{
$builder = new ProcedureBuilder();
$processor = $manifest->getProcessor();
if ($this->dispatcher) {
$processor->setEventDispatcher($this->dispatcher);
}
$manifest->configureProcedureBuilder($builder);
$m... | [
"public",
"function",
"run",
"(",
"ManifestInterface",
"$",
"manifest",
")",
"{",
"$",
"builder",
"=",
"new",
"ProcedureBuilder",
"(",
")",
";",
"$",
"processor",
"=",
"$",
"manifest",
"->",
"getProcessor",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
... | Configures and runs a manifest.
@param ManifestInterface $manifest Manifest to be run | [
"Configures",
"and",
"runs",
"a",
"manifest",
"."
] | train | https://github.com/transfer-framework/transfer/blob/9225ae068d5924982f14ad4446b15f75384a058a/src/Transfer/Manifest/ManifestRunner.php#L40-L57 |
todstoychev/icr | src/Manipulator/Box.php | Box.setWidth | public function setWidth($width)
{
if (!is_numeric($width)) {
throw new \LogicException('Box width is NaN!');
}
$this->width = (int) $width;
return $this;
} | php | public function setWidth($width)
{
if (!is_numeric($width)) {
throw new \LogicException('Box width is NaN!');
}
$this->width = (int) $width;
return $this;
} | [
"public",
"function",
"setWidth",
"(",
"$",
"width",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"width",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Box width is NaN!'",
")",
";",
"}",
"$",
"this",
"->",
"width",
"=",
"(",
"i... | @param int $width
@return Box | [
"@param",
"int",
"$width"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L60-L69 |
todstoychev/icr | src/Manipulator/Box.php | Box.setHeight | public function setHeight($height)
{
if (!is_numeric($height)) {
throw new \LogicException('Box height is NaN!');
}
$this->height = (int) $height;
return $this;
} | php | public function setHeight($height)
{
if (!is_numeric($height)) {
throw new \LogicException('Box height is NaN!');
}
$this->height = (int) $height;
return $this;
} | [
"public",
"function",
"setHeight",
"(",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"height",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Box height is NaN!'",
")",
";",
"}",
"$",
"this",
"->",
"height",
"=",
"(",... | @param int $height
@return Box | [
"@param",
"int",
"$height"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L84-L93 |
todstoychev/icr | src/Manipulator/Box.php | Box.scale | public function scale($ratio)
{
if (!is_numeric($ratio)) {
throw new \LogicException('Provided scale ration is NaN!');
}
if ($ratio < 0) {
throw new \LogicException('Scale ratio is negative!');
}
$this->checkAttributes();
return new Box(roun... | php | public function scale($ratio)
{
if (!is_numeric($ratio)) {
throw new \LogicException('Provided scale ration is NaN!');
}
if ($ratio < 0) {
throw new \LogicException('Scale ratio is negative!');
}
$this->checkAttributes();
return new Box(roun... | [
"public",
"function",
"scale",
"(",
"$",
"ratio",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"ratio",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Provided scale ration is NaN!'",
")",
";",
"}",
"if",
"(",
"$",
"ratio",
"<",
"0"... | {@inheritdoc} | [
"{"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L98-L111 |
todstoychev/icr | src/Manipulator/Box.php | Box.increase | public function increase($size)
{
if (!is_numeric($size)) {
throw new \LogicException('Increase size is NaN!');
}
$width = (int) $size + $this->width;
$height = (int) $size + $this->height;
if ($width < 0 || $height < 0) {
throw new \LogicException('... | php | public function increase($size)
{
if (!is_numeric($size)) {
throw new \LogicException('Increase size is NaN!');
}
$width = (int) $size + $this->width;
$height = (int) $size + $this->height;
if ($width < 0 || $height < 0) {
throw new \LogicException('... | [
"public",
"function",
"increase",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"size",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Increase size is NaN!'",
")",
";",
"}",
"$",
"width",
"=",
"(",
"int",
")",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L116-L130 |
todstoychev/icr | src/Manipulator/Box.php | Box.widen | public function widen($width)
{
if (!is_numeric($width)) {
throw new \LogicException('Provided width is NaN!');
}
if ($width < 0) {
throw new \LogicException('Width can not be negative!');
}
$this->checkAttributes();
return $this->scale($wid... | php | public function widen($width)
{
if (!is_numeric($width)) {
throw new \LogicException('Provided width is NaN!');
}
if ($width < 0) {
throw new \LogicException('Width can not be negative!');
}
$this->checkAttributes();
return $this->scale($wid... | [
"public",
"function",
"widen",
"(",
"$",
"width",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"width",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Provided width is NaN!'",
")",
";",
"}",
"if",
"(",
"$",
"width",
"<",
"0",
")"... | {@inheritdoc} | [
"{"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L163-L176 |
todstoychev/icr | src/Manipulator/Box.php | Box.heighten | public function heighten($height)
{
if (!is_numeric($height)) {
throw new \LogicException('Provided height is NaN!');
}
if ($height < 0) {
throw new \LogicException('Height can not be negative!');
}
$this->checkAttributes();
return $this->sc... | php | public function heighten($height)
{
if (!is_numeric($height)) {
throw new \LogicException('Provided height is NaN!');
}
if ($height < 0) {
throw new \LogicException('Height can not be negative!');
}
$this->checkAttributes();
return $this->sc... | [
"public",
"function",
"heighten",
"(",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"height",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Provided height is NaN!'",
")",
";",
"}",
"if",
"(",
"$",
"height",
"<",
"0"... | {@inheritdoc} | [
"{"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L181-L194 |
todstoychev/icr | src/Manipulator/Box.php | Box.checkAttributes | protected function checkAttributes()
{
if ($this->width < 1 || $this->height < 1) {
throw new InvalidArgumentException(sprintf('Length of either side cannot be 0 or negative, current size is %sx%s', $this->width, $this->height));
}
} | php | protected function checkAttributes()
{
if ($this->width < 1 || $this->height < 1) {
throw new InvalidArgumentException(sprintf('Length of either side cannot be 0 or negative, current size is %sx%s', $this->width, $this->height));
}
} | [
"protected",
"function",
"checkAttributes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"width",
"<",
"1",
"||",
"$",
"this",
"->",
"height",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Length of either side cannot... | Checks the attributes
@throws InvalidArgumentException | [
"Checks",
"the",
"attributes"
] | train | https://github.com/todstoychev/icr/blob/0214c7bc76e44488e98758d55deb707b72e24000/src/Manipulator/Box.php#L201-L206 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.create | public static function create($realPart, $imaginaryPart = null)
{
if (is_string($realPart)) {
return self::fromString($realPart);
}
if ($realPart instanceof ComplexType) {
return clone $realPart;
}
if (is_null($imaginaryPart)) {
$imaginar... | php | public static function create($realPart, $imaginaryPart = null)
{
if (is_string($realPart)) {
return self::fromString($realPart);
}
if ($realPart instanceof ComplexType) {
return clone $realPart;
}
if (is_null($imaginaryPart)) {
$imaginar... | [
"public",
"static",
"function",
"create",
"(",
"$",
"realPart",
",",
"$",
"imaginaryPart",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"realPart",
")",
")",
"{",
"return",
"self",
"::",
"fromString",
"(",
"$",
"realPart",
")",
";",
"}",
... | Complex type factory
Construct and return a complex number. You can send in
- a string conforming to 'a+bi', 'a-bi', '-a+bi', '-a-bi' where a & b
are integer or float numbers e.g. '-12+0.67i'
- mixture of numeric (int,float,'1234' etc), IntType and FloatType corresponding to a & b
@param string|float|int|AbstractType... | [
"Complex",
"type",
"factory"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L48-L72 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.fromString | public static function fromString($string)
{
$matches = array();
$valid = \preg_match(
'#^([-,\+])?([0-9]*[\.\/]?[0-9]*)([-,\+]){1}([0-9]*[\.\/]?[0-9]*)i$#',
\trim($string),
$matches
);
if ($valid !== 1) {
throw new \InvalidArgumentExc... | php | public static function fromString($string)
{
$matches = array();
$valid = \preg_match(
'#^([-,\+])?([0-9]*[\.\/]?[0-9]*)([-,\+]){1}([0-9]*[\.\/]?[0-9]*)i$#',
\trim($string),
$matches
);
if ($valid !== 1) {
throw new \InvalidArgumentExc... | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"string",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"valid",
"=",
"\\",
"preg_match",
"(",
"'#^([-,\\+])?([0-9]*[\\.\\/]?[0-9]*)([-,\\+]){1}([0-9]*[\\.\\/]?[0-9]*)i$#'",
",",
"\\",
"trim",
"... | Create a complex number from a string in form '[+,-]<num>(+,-)<num>i'
The trailing 'i' character is required
No spaces are allowed in the string
@param string $string
@return \Chippyash\Type\Number\Complex\ComplexType
@throws \InvalidArgumentException | [
"Create",
"a",
"complex",
"number",
"from",
"a",
"string",
"in",
"form",
"[",
"+",
"-",
"]",
"<num",
">",
"(",
"+",
"-",
")",
"<num",
">",
"i",
"The",
"trailing",
"i",
"character",
"is",
"required",
"No",
"spaces",
"are",
"allowed",
"in",
"the",
"s... | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L85-L111 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.fromPolar | public static function fromPolar(AbstractRationalType $radius, AbstractRationalType $theta)
{
if (self::getRequiredType() == self::TYPE_GMP) {
/** @noinspection PhpParamsInspection */
return self::fromGmpPolar($radius, $theta);
}
/** @noinspection PhpParamsInspection ... | php | public static function fromPolar(AbstractRationalType $radius, AbstractRationalType $theta)
{
if (self::getRequiredType() == self::TYPE_GMP) {
/** @noinspection PhpParamsInspection */
return self::fromGmpPolar($radius, $theta);
}
/** @noinspection PhpParamsInspection ... | [
"public",
"static",
"function",
"fromPolar",
"(",
"AbstractRationalType",
"$",
"radius",
",",
"AbstractRationalType",
"$",
"theta",
")",
"{",
"if",
"(",
"self",
"::",
"getRequiredType",
"(",
")",
"==",
"self",
"::",
"TYPE_GMP",
")",
"{",
"/** @noinspection PhpPa... | Create complex type from polar co-ordinates
Be aware that you may lose a bit of precision e.g.
$c = ComplexTypeFactory::create('2/7+3/4i');
$c2 = ComplexTypeFactory::fromPolar($c->radius(), $c->theta());
returns 132664833738225/464326918083788+3382204885901775/4509606514535696i
which is ~0.2857142857142854066 + ~0.750... | [
"Create",
"complex",
"type",
"from",
"polar",
"co",
"-",
"ordinates"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L131-L139 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.fromNativePolar | public static function fromNativePolar(RationalType $radius, RationalType $theta)
{
$cos = RationalTypeFactory::fromFloat(cos($theta()));
$sin = RationalTypeFactory::fromFloat(sin($theta()));
list($realNumerator, $realDenominator) = self::getRealPartsFromRadiusAndCos($radius, $cos);
... | php | public static function fromNativePolar(RationalType $radius, RationalType $theta)
{
$cos = RationalTypeFactory::fromFloat(cos($theta()));
$sin = RationalTypeFactory::fromFloat(sin($theta()));
list($realNumerator, $realDenominator) = self::getRealPartsFromRadiusAndCos($radius, $cos);
... | [
"public",
"static",
"function",
"fromNativePolar",
"(",
"RationalType",
"$",
"radius",
",",
"RationalType",
"$",
"theta",
")",
"{",
"$",
"cos",
"=",
"RationalTypeFactory",
"::",
"fromFloat",
"(",
"cos",
"(",
"$",
"theta",
"(",
")",
")",
")",
";",
"$",
"s... | Create complex type from polar co-ordinates - Native version
z = radius x (cos(theta) + i.sin(theta))
real = radius x cos(theta)
imag = radius x sin(theta)
@param \Chippyash\Type\Number\Rational\RationalType $radius
@param \Chippyash\Type\Number\Rational\RationalType $theta angle expressed in radians
@return \Chippy... | [
"Create",
"complex",
"type",
"from",
"polar",
"co",
"-",
"ordinates",
"-",
"Native",
"version"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L153-L165 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.fromGmpPolar | public static function fromGmpPolar(GMPRationalType $radius, GMPRationalType $theta)
{
$cos = RationalTypeFactory::fromFloat(cos($theta()));
$sin = RationalTypeFactory::fromFloat(sin($theta()));
//real = radius * cos
$rNum = TypeFactory::create(
'int',
gmp_st... | php | public static function fromGmpPolar(GMPRationalType $radius, GMPRationalType $theta)
{
$cos = RationalTypeFactory::fromFloat(cos($theta()));
$sin = RationalTypeFactory::fromFloat(sin($theta()));
//real = radius * cos
$rNum = TypeFactory::create(
'int',
gmp_st... | [
"public",
"static",
"function",
"fromGmpPolar",
"(",
"GMPRationalType",
"$",
"radius",
",",
"GMPRationalType",
"$",
"theta",
")",
"{",
"$",
"cos",
"=",
"RationalTypeFactory",
"::",
"fromFloat",
"(",
"cos",
"(",
"$",
"theta",
"(",
")",
")",
")",
";",
"$",
... | Create complex type from polar co-ordinates - GMP version
@param \Chippyash\Type\Number\Rational\GMPRationalType $radius
@param \Chippyash\Type\Number\Rational\GMPRationalType $theta angle expressed in radians
@return \Chippyash\Type\Number\Complex\GMPComplexType
@codeCoverageIgnore | [
"Create",
"complex",
"type",
"from",
"polar",
"co",
"-",
"ordinates",
"-",
"GMP",
"version"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L177-L225 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.convertType | protected static function convertType($original)
{
if ($original instanceof AbstractRationalType) {
return RationalTypeFactory::create(
$original->numerator()->get(),
$original->denominator()->get()
);
}
if (is_numeric($original)) {
... | php | protected static function convertType($original)
{
if ($original instanceof AbstractRationalType) {
return RationalTypeFactory::create(
$original->numerator()->get(),
$original->denominator()->get()
);
}
if (is_numeric($original)) {
... | [
"protected",
"static",
"function",
"convertType",
"(",
"$",
"original",
")",
"{",
"if",
"(",
"$",
"original",
"instanceof",
"AbstractRationalType",
")",
"{",
"return",
"RationalTypeFactory",
"::",
"create",
"(",
"$",
"original",
"->",
"numerator",
"(",
")",
"-... | Convert to RationalType
@param mixed $original
@return \Chippyash\Type\Number\Rational\RationalType|\Chippyash\Type\Number\Rational\GMPRationalType
@throws InvalidTypeException | [
"Convert",
"to",
"RationalType"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L236-L267 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.getRealPartsFromRadiusAndCos | private static function getRealPartsFromRadiusAndCos(RationalType $radius, RationalType $cos)
{
return array(
TypeFactory::create('int', $radius->numerator()->get() * $cos->numerator()->get()),
TypeFactory::create('int', $radius->denominator()->get() * $cos->denominator()->get())
... | php | private static function getRealPartsFromRadiusAndCos(RationalType $radius, RationalType $cos)
{
return array(
TypeFactory::create('int', $radius->numerator()->get() * $cos->numerator()->get()),
TypeFactory::create('int', $radius->denominator()->get() * $cos->denominator()->get())
... | [
"private",
"static",
"function",
"getRealPartsFromRadiusAndCos",
"(",
"RationalType",
"$",
"radius",
",",
"RationalType",
"$",
"cos",
")",
"{",
"return",
"array",
"(",
"TypeFactory",
"::",
"create",
"(",
"'int'",
",",
"$",
"radius",
"->",
"numerator",
"(",
")"... | @param RationalType $radius
@param RationalType $cos
@return array
@throws InvalidTypeException | [
"@param",
"RationalType",
"$radius",
"@param",
"RationalType",
"$cos"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L277-L283 |
chippyash/Strong-Type | src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php | ComplexTypeFactory.getImaginaryPartsFromRadiusAndSin | private static function getImaginaryPartsFromRadiusAndSin(RationalType $radius, RationalType $sin)
{
return array(
TypeFactory::create('int', $radius->numerator()->get() * $sin->numerator()->get()),
TypeFactory::create('int', $radius->denominator()->get() * $sin->denominator()->get()... | php | private static function getImaginaryPartsFromRadiusAndSin(RationalType $radius, RationalType $sin)
{
return array(
TypeFactory::create('int', $radius->numerator()->get() * $sin->numerator()->get()),
TypeFactory::create('int', $radius->denominator()->get() * $sin->denominator()->get()... | [
"private",
"static",
"function",
"getImaginaryPartsFromRadiusAndSin",
"(",
"RationalType",
"$",
"radius",
",",
"RationalType",
"$",
"sin",
")",
"{",
"return",
"array",
"(",
"TypeFactory",
"::",
"create",
"(",
"'int'",
",",
"$",
"radius",
"->",
"numerator",
"(",
... | @param RationalType $radius
@param RationalType $sin
@return array
@throws InvalidTypeException | [
"@param",
"RationalType",
"$radius",
"@param",
"RationalType",
"$sin"
] | train | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/Number/Complex/ComplexTypeFactory.php#L293-L299 |
fuelphp/filesystem | src/Directory.php | Directory.delete | public function delete($recursive = false)
{
if ( ! $recursive)
{
return parent::delete();
}
$finder = new Finder();
$contents = $finder->listContents($this->path);
foreach($contents as $item)
{
$item->delete(true);
}
return parent::delete();
} | php | public function delete($recursive = false)
{
if ( ! $recursive)
{
return parent::delete();
}
$finder = new Finder();
$contents = $finder->listContents($this->path);
foreach($contents as $item)
{
$item->delete(true);
}
return parent::delete();
} | [
"public",
"function",
"delete",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"return",
"parent",
"::",
"delete",
"(",
")",
";",
"}",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"contents",
... | Deletes a directory
@param boolean $recursive
@return boolean | [
"Deletes",
"a",
"directory"
] | train | https://github.com/fuelphp/filesystem/blob/770a8cb04caca920af8029d7aad7208bc0592743/src/Directory.php#L33-L49 |
fuelphp/filesystem | src/Directory.php | Directory.listFiles | public function listFiles($depth = 0, $filter = null, $asHandlers = false)
{
return $this->listContents($depth, $filter, 'file', $asHandlers);
} | php | public function listFiles($depth = 0, $filter = null, $asHandlers = false)
{
return $this->listContents($depth, $filter, 'file', $asHandlers);
} | [
"public",
"function",
"listFiles",
"(",
"$",
"depth",
"=",
"0",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"asHandlers",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"listContents",
"(",
"$",
"depth",
",",
"$",
"filter",
",",
"'file'",
",",
... | Lists all files in a directory
@param integer $depth
@param mixed $filter
@param boolean $asHandlers
@return array | [
"Lists",
"all",
"files",
"in",
"a",
"directory"
] | train | https://github.com/fuelphp/filesystem/blob/770a8cb04caca920af8029d7aad7208bc0592743/src/Directory.php#L60-L63 |
fuelphp/filesystem | src/Directory.php | Directory.listDirs | public function listDirs($depth = 0, $filter = null, $asHandlers = false)
{
return $this->listContents($depth, $filter, 'dir', $asHandlers);
} | php | public function listDirs($depth = 0, $filter = null, $asHandlers = false)
{
return $this->listContents($depth, $filter, 'dir', $asHandlers);
} | [
"public",
"function",
"listDirs",
"(",
"$",
"depth",
"=",
"0",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"asHandlers",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"listContents",
"(",
"$",
"depth",
",",
"$",
"filter",
",",
"'dir'",
",",
"... | Lists all directories in a directory
@param integer $depth
@param mixed $filter
@param boolean $asHandlers
@return array | [
"Lists",
"all",
"directories",
"in",
"a",
"directory"
] | train | https://github.com/fuelphp/filesystem/blob/770a8cb04caca920af8029d7aad7208bc0592743/src/Directory.php#L87-L90 |
fuelphp/filesystem | src/Directory.php | Directory.listContents | public function listContents($depth = 0, $filter = null, $type = 'all', $asHandlers = false)
{
$pattern = $this->path.'/*';
if (is_array($filter))
{
$filters = $filter;
$filter = new Filter;
foreach ($filters as $f => $type)
{
if ( ! is_int($f))
{
$f = $type;
$type = null;
}
... | php | public function listContents($depth = 0, $filter = null, $type = 'all', $asHandlers = false)
{
$pattern = $this->path.'/*';
if (is_array($filter))
{
$filters = $filter;
$filter = new Filter;
foreach ($filters as $f => $type)
{
if ( ! is_int($f))
{
$f = $type;
$type = null;
}
... | [
"public",
"function",
"listContents",
"(",
"$",
"depth",
"=",
"0",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"type",
"=",
"'all'",
",",
"$",
"asHandlers",
"=",
"false",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"path",
".",
"'/*'",
";",
... | Lists all files and directories in a directory
@param integer $depth
@param mixed $filter
@param string $type
@param boolean $asHandlers
@return array | [
"Lists",
"all",
"files",
"and",
"directories",
"in",
"a",
"directory"
] | train | https://github.com/fuelphp/filesystem/blob/770a8cb04caca920af8029d7aad7208bc0592743/src/Directory.php#L115-L215 |
yosmanyga/validation | src/Yosmanyga/Validation/Validator/ExceptionValidator.php | ExceptionValidator.validate | public function validate($value)
{
$errors = $this->validator->validate($value);
if (!$errors) {
return [];
}
throw new \RuntimeException(sprintf('Invalid value %s, got this error: %s', print_r($value, true), implode('. ', $errors)));
} | php | public function validate($value)
{
$errors = $this->validator->validate($value);
if (!$errors) {
return [];
}
throw new \RuntimeException(sprintf('Invalid value %s, got this error: %s', print_r($value, true), implode('. ', $errors)));
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"errors",
")",
"{",
"return",
"[",
"]",
";",
"}",
"throw",
"new... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/validation/blob/dded99a6e24b79f808250791ba1db632fd44c5c4/src/Yosmanyga/Validation/Validator/ExceptionValidator.php#L23-L32 |
mamuz/MamuzBlog | src/MamuzBlog/Crypt/HashIdAdapterFactory.php | HashIdAdapterFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = (array) $serviceLocator->get('Config');
$this->validate($config);
$hashIdconfig = $config['crypt']['hashid'];
$hashIds = new HashIds(
$hashIdconfig['sault'],
$hashIdconfig['min... | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = (array) $serviceLocator->get('Config');
$this->validate($config);
$hashIdconfig = $config['crypt']['hashid'];
$hashIds = new HashIds(
$hashIdconfig['sault'],
$hashIdconfig['min... | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"(",
"array",
")",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"this",
"->",
"validate",
"(",
"$",
"config",
... | {@inheritdoc}
@return AdapterInterface | [
"{"
] | train | https://github.com/mamuz/MamuzBlog/blob/cb43be5c39031e3dcc939283e284824c4d07da38/src/MamuzBlog/Crypt/HashIdAdapterFactory.php#L16-L29 |
skeeks-cms/cms-rbac | src/DbManager.php | DbManager.saveToCache | private function saveToCache($part, $data)
{
if ($this->enableCaching) {
$this->cache->set($this->buildKey($part), $data, $this->cacheDuration, new TagDependency([
'tags' => $part
]));
}
} | php | private function saveToCache($part, $data)
{
if ($this->enableCaching) {
$this->cache->set($this->buildKey($part), $data, $this->cacheDuration, new TagDependency([
'tags' => $part
]));
}
} | [
"private",
"function",
"saveToCache",
"(",
"$",
"part",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"enableCaching",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"$",
"this",
"->",
"buildKey",
"(",
"$",
"part",
")",
",",
... | Save data to cache
@param string $part
@param mixed $data | [
"Save",
"data",
"to",
"cache"
] | train | https://github.com/skeeks-cms/cms-rbac/blob/1e5b17c1eb405f1ea87279da2ce56162c0281def/src/DbManager.php#L584-L591 |
skeeks-cms/cms-rbac | src/DbManager.php | DbManager.loadAssignments | private function loadAssignments($userId)
{
if (!isset($this->_assignments[$userId])) {
$query = (new Query)
->select('item_name')
->from($this->assignmentTable)
->where(['user_id' => $userId]);
$this->_assignments[$userId] = $query->c... | php | private function loadAssignments($userId)
{
if (!isset($this->_assignments[$userId])) {
$query = (new Query)
->select('item_name')
->from($this->assignmentTable)
->where(['user_id' => $userId]);
$this->_assignments[$userId] = $query->c... | [
"private",
"function",
"loadAssignments",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_assignments",
"[",
"$",
"userId",
"]",
")",
")",
"{",
"$",
"query",
"=",
"(",
"new",
"Query",
")",
"->",
"select",
"(",
"'ite... | Load data. If avaliable in memory, get from memory
If no, get from cache. If no avaliable, get from database. | [
"Load",
"data",
".",
"If",
"avaliable",
"in",
"memory",
"get",
"from",
"memory",
"If",
"no",
"get",
"from",
"cache",
".",
"If",
"no",
"avaliable",
"get",
"from",
"database",
"."
] | train | https://github.com/skeeks-cms/cms-rbac/blob/1e5b17c1eb405f1ea87279da2ce56162c0281def/src/DbManager.php#L662-L672 |
mimmi20/Wurfl | src/Handlers/Normalizer/Specific/Opera.php | Opera.normalize | public function normalize($userAgent)
{
// Repair Opera user agents using fake version 9.80
// Normalize: Opera/9.80 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
// Into: Opera/11.50 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
if (Utils::checkIfStartsWith($user... | php | public function normalize($userAgent)
{
// Repair Opera user agents using fake version 9.80
// Normalize: Opera/9.80 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
// Into: Opera/11.50 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
if (Utils::checkIfStartsWith($user... | [
"public",
"function",
"normalize",
"(",
"$",
"userAgent",
")",
"{",
"// Repair Opera user agents using fake version 9.80",
"// Normalize: Opera/9.80 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50",
"// Into: Opera/11.50 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50",
"if",
... | @param string $userAgent
@return string | [
"@param",
"string",
"$userAgent"
] | train | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/Normalizer/Specific/Opera.php#L40-L60 |
cicada/cicada | src/Routing/Router.php | Router.route | public function route(Application $app, Request $request)
{
$url = $request->getPathInfo();
$method = $request->getMethod();
/** @var $route Route */
foreach ($this->routes as $route) {
// Match by method
if ($route->getMethod() == $method) {
... | php | public function route(Application $app, Request $request)
{
$url = $request->getPathInfo();
$method = $request->getMethod();
/** @var $route Route */
foreach ($this->routes as $route) {
// Match by method
if ($route->getMethod() == $method) {
... | [
"public",
"function",
"route",
"(",
"Application",
"$",
"app",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"url",
"=",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
";",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"/** @... | Routes the request, and returns a Response.
@param Application $app
@param Request $request
@return Response | [
"Routes",
"the",
"request",
"and",
"returns",
"a",
"Response",
"."
] | train | https://github.com/cicada/cicada/blob/5a54bd05dfa1df38e7aa3d704d270853f0329e13/src/Routing/Router.php#L67-L96 |
cicada/cicada | src/Routing/Router.php | Router.getRoute | public function getRoute($name)
{
if (empty($name)) {
throw new \InvalidArgumentException("Route name not provided.");
}
// TODO: This is not very efficient, maybe find a better way
foreach ($this->routes as $route) {
if ($route->getName() === $name) {
... | php | public function getRoute($name)
{
if (empty($name)) {
throw new \InvalidArgumentException("Route name not provided.");
}
// TODO: This is not very efficient, maybe find a better way
foreach ($this->routes as $route) {
if ($route->getName() === $name) {
... | [
"public",
"function",
"getRoute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Route name not provided.\"",
")",
";",
"}",
"// TODO: This is not very efficient, maybe fin... | Returns a route by name.
@param string $name
@return Route
@throws \Exception If no route with given name is found.
@throws \InvalidArgumentException If given name is empty. | [
"Returns",
"a",
"route",
"by",
"name",
"."
] | train | https://github.com/cicada/cicada/blob/5a54bd05dfa1df38e7aa3d704d270853f0329e13/src/Routing/Router.php#L115-L129 |
mimmi20/Wurfl | src/Handlers/MSIEHandler.php | MSIEHandler.canHandle | public function canHandle($userAgent)
{
if (Utils::isMobileBrowser($userAgent)) {
return false;
}
if (Utils::checkIfStartsWith($userAgent, 'Mozilla') === false) {
return false;
}
if (Utils::checkIfContainsAnyOf($userAgent, array('Opera', 'armv', 'MOT... | php | public function canHandle($userAgent)
{
if (Utils::isMobileBrowser($userAgent)) {
return false;
}
if (Utils::checkIfStartsWith($userAgent, 'Mozilla') === false) {
return false;
}
if (Utils::checkIfContainsAnyOf($userAgent, array('Opera', 'armv', 'MOT... | [
"public",
"function",
"canHandle",
"(",
"$",
"userAgent",
")",
"{",
"if",
"(",
"Utils",
"::",
"isMobileBrowser",
"(",
"$",
"userAgent",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Utils",
"::",
"checkIfStartsWith",
"(",
"$",
"userAgent",
",",... | @param string $userAgent
@return bool | [
"@param",
"string",
"$userAgent"
] | train | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/MSIEHandler.php#L56-L80 |
mimmi20/Wurfl | src/Handlers/MSIEHandler.php | MSIEHandler.applyConclusiveMatch | public function applyConclusiveMatch($userAgent)
{
$matches = array();
if (preg_match('#^Mozilla/5\.0 \(Windows NT.+? Edge/(\d+)\.(\d+)#', $userAgent, $matches)
|| preg_match('#^Mozilla/5\.0 \(.+?Trident.+?; rv:(\d\d)\.(\d+)\)#', $userAgent, $matches)
|| preg_match('#^Mozill... | php | public function applyConclusiveMatch($userAgent)
{
$matches = array();
if (preg_match('#^Mozilla/5\.0 \(Windows NT.+? Edge/(\d+)\.(\d+)#', $userAgent, $matches)
|| preg_match('#^Mozilla/5\.0 \(.+?Trident.+?; rv:(\d\d)\.(\d+)\)#', $userAgent, $matches)
|| preg_match('#^Mozill... | [
"public",
"function",
"applyConclusiveMatch",
"(",
"$",
"userAgent",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#^Mozilla/5\\.0 \\(Windows NT.+? Edge/(\\d+)\\.(\\d+)#'",
",",
"$",
"userAgent",
",",
"$",
"matches",
")",
... | @param string $userAgent
@return null|string | [
"@param",
"string",
"$userAgent"
] | train | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/MSIEHandler.php#L87-L110 |
vardius/crud-bundle | Controller/CrudController.php | CrudController.checkAccess | public function checkAccess($attributes, $object = null, string $message = 'Access Denied.')
{
$this->denyAccessUnlessGranted($attributes, $object, $message);
} | php | public function checkAccess($attributes, $object = null, string $message = 'Access Denied.')
{
$this->denyAccessUnlessGranted($attributes, $object, $message);
} | [
"public",
"function",
"checkAccess",
"(",
"$",
"attributes",
",",
"$",
"object",
"=",
"null",
",",
"string",
"$",
"message",
"=",
"'Access Denied.'",
")",
"{",
"$",
"this",
"->",
"denyAccessUnlessGranted",
"(",
"$",
"attributes",
",",
"$",
"object",
",",
"... | Throws an exception unless the attributes are granted against the current authentication token and optionally
supplied object.
@param mixed $attributes The attributes
@param mixed $object The object
@param string $message The message passed to the exception
@throws AccessDeniedException | [
"Throws",
"an",
"exception",
"unless",
"the",
"attributes",
"are",
"granted",
"against",
"the",
"current",
"authentication",
"token",
"and",
"optionally",
"supplied",
"object",
"."
] | train | https://github.com/vardius/crud-bundle/blob/dda957e3f8516c3b0d6270ea5a6eb50d98e71444/Controller/CrudController.php#L192-L195 |
gyselroth/php-stream-iterator | src/StreamIterator.php | StreamIterator.seek | public function seek($offset, $whence = SEEK_SET)
{
if (!is_int($offset) && !is_numeric($offset)) {
return false;
}
$offset = (int) $offset;
if ($offset < 0) {
return false;
}
$key = $this->iterator->key();
if (!is_int($key) && !is_nu... | php | public function seek($offset, $whence = SEEK_SET)
{
if (!is_int($offset) && !is_numeric($offset)) {
return false;
}
$offset = (int) $offset;
if ($offset < 0) {
return false;
}
$key = $this->iterator->key();
if (!is_int($key) && !is_nu... | [
"public",
"function",
"seek",
"(",
"$",
"offset",
",",
"$",
"whence",
"=",
"SEEK_SET",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"offset",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"off... | Seek the iterator.
@param int $offset Stream offset
@param int $whence ignored
@return bool returns TRUE on success or FALSE on failure | [
"Seek",
"the",
"iterator",
"."
] | train | https://github.com/gyselroth/php-stream-iterator/blob/714b83d529301a2dcb51418fad08abda128686b8/src/StreamIterator.php#L140-L170 |
gyselroth/php-stream-iterator | src/StreamIterator.php | StreamIterator.read | public function read($length)
{
$index = 0;
$contents = '';
while ($this->iterator->valid() && $index < $length) {
if ($this->stringify !== null) {
$contents .= $this->stringify->call($this, $this->iterator->current());
} else {
$conten... | php | public function read($length)
{
$index = 0;
$contents = '';
while ($this->iterator->valid() && $index < $length) {
if ($this->stringify !== null) {
$contents .= $this->stringify->call($this, $this->iterator->current());
} else {
$conten... | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
"{",
"$",
"index",
"=",
"0",
";",
"$",
"contents",
"=",
"''",
";",
"while",
"(",
"$",
"this",
"->",
"iterator",
"->",
"valid",
"(",
")",
"&&",
"$",
"index",
"<",
"$",
"length",
")",
"{",
"i... | Read content from iterator with a lenght limit (number of entries).
@param int $length Read up to $length items from the iterator
@return string | [
"Read",
"content",
"from",
"iterator",
"with",
"a",
"lenght",
"limit",
"(",
"number",
"of",
"entries",
")",
"."
] | train | https://github.com/gyselroth/php-stream-iterator/blob/714b83d529301a2dcb51418fad08abda128686b8/src/StreamIterator.php#L222-L239 |
eliep/avro-rpc-php | lib/avro/ipc.php | Requestor.request | public function request($message_name, $request_datum)
{
$io = new AvroStringIO();
$encoder = new AvroIOBinaryEncoder($io);
$this->write_handshake_request($encoder);
$this->write_call_request($message_name, $request_datum, $encoder);
$call_request = $io->string();
if ($this->local_protoco... | php | public function request($message_name, $request_datum)
{
$io = new AvroStringIO();
$encoder = new AvroIOBinaryEncoder($io);
$this->write_handshake_request($encoder);
$this->write_call_request($message_name, $request_datum, $encoder);
$call_request = $io->string();
if ($this->local_protoco... | [
"public",
"function",
"request",
"(",
"$",
"message_name",
",",
"$",
"request_datum",
")",
"{",
"$",
"io",
"=",
"new",
"AvroStringIO",
"(",
")",
";",
"$",
"encoder",
"=",
"new",
"AvroIOBinaryEncoder",
"(",
"$",
"io",
")",
";",
"$",
"this",
"->",
"write... | Writes a request message and reads a response or error message.
@param string $message_name : name of the IPC method
@param mixed $request_datum : IPC request
@throw AvroException when $message_name is not registered on the local or remote protocol
@throw AvroRemoteException when server send an error | [
"Writes",
"a",
"request",
"message",
"and",
"reads",
"a",
"response",
"or",
"error",
"message",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L155-L185 |
eliep/avro-rpc-php | lib/avro/ipc.php | Requestor.write_handshake_request | public function write_handshake_request(AvroIOBinaryEncoder $encoder)
{
if ($this->transceiver->is_connected())
return;
$remote_name = $this->transceiver->remote_name();
$local_hash = $this->local_protocol->md5();
$remote_hash = (!isset($this->remote_hash[$remote_name])) ? null : $this... | php | public function write_handshake_request(AvroIOBinaryEncoder $encoder)
{
if ($this->transceiver->is_connected())
return;
$remote_name = $this->transceiver->remote_name();
$local_hash = $this->local_protocol->md5();
$remote_hash = (!isset($this->remote_hash[$remote_name])) ? null : $this... | [
"public",
"function",
"write_handshake_request",
"(",
"AvroIOBinaryEncoder",
"$",
"encoder",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"transceiver",
"->",
"is_connected",
"(",
")",
")",
"return",
";",
"$",
"remote_name",
"=",
"$",
"this",
"->",
"transceiver",
... | Write the handshake request.
@param AvroIOBinaryEncoder $encoder : Encoder to write the handshake request into. | [
"Write",
"the",
"handshake",
"request",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L191-L211 |
eliep/avro-rpc-php | lib/avro/ipc.php | Requestor.write_call_request | public function write_call_request($message_name, $request_datum, AvroIOBinaryEncoder $encoder)
{
$request_metadata = array();
$this->meta_writer->write($request_metadata, $encoder);
if (!isset($this->local_protocol->messages[$message_name]))
throw new AvroException("Unknown message: $message_n... | php | public function write_call_request($message_name, $request_datum, AvroIOBinaryEncoder $encoder)
{
$request_metadata = array();
$this->meta_writer->write($request_metadata, $encoder);
if (!isset($this->local_protocol->messages[$message_name]))
throw new AvroException("Unknown message: $message_n... | [
"public",
"function",
"write_call_request",
"(",
"$",
"message_name",
",",
"$",
"request_datum",
",",
"AvroIOBinaryEncoder",
"$",
"encoder",
")",
"{",
"$",
"request_metadata",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"meta_writer",
"->",
"write",
"(",
... | The format of a call request is:
- request metadata, a map with values of type bytes
- the message name, an Avro string, followed by
- the message parameters. Parameters are serialized according to the message's request declaration.
@param string $message_name : name of the IPC method
@param mixed $request_datum : IPC ... | [
"The",
"format",
"of",
"a",
"call",
"request",
"is",
":",
"-",
"request",
"metadata",
"a",
"map",
"with",
"values",
"of",
"type",
"bytes",
"-",
"the",
"message",
"name",
"an",
"Avro",
"string",
"followed",
"by",
"-",
"the",
"message",
"parameters",
".",
... | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L223-L234 |
eliep/avro-rpc-php | lib/avro/ipc.php | Requestor.read_handshake_response | public function read_handshake_response(AvroIOBinaryDecoder $decoder)
{
// if the handshake has been successfully made previously,
// no need to do it again
if ($this->transceiver->is_connected())
return true;
$established = false;
$handshake_response = $this->handshake_requestor_reader... | php | public function read_handshake_response(AvroIOBinaryDecoder $decoder)
{
// if the handshake has been successfully made previously,
// no need to do it again
if ($this->transceiver->is_connected())
return true;
$established = false;
$handshake_response = $this->handshake_requestor_reader... | [
"public",
"function",
"read_handshake_response",
"(",
"AvroIOBinaryDecoder",
"$",
"decoder",
")",
"{",
"// if the handshake has been successfully made previously,",
"// no need to do it again",
"if",
"(",
"$",
"this",
"->",
"transceiver",
"->",
"is_connected",
"(",
")",
")"... | Reads and processes the handshake response message.
@param AvroIOBinaryDecoder $decoder : Decoder to read messages from.
@return boolean true if a response exists.
@throw AvroException when server respond an unknown handshake match | [
"Reads",
"and",
"processes",
"the",
"handshake",
"response",
"message",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L242-L276 |
eliep/avro-rpc-php | lib/avro/ipc.php | Requestor.read_call_response | public function read_call_response($message_name, AvroIOBinaryDecoder $decoder)
{
$response_metadata = $this->meta_reader->read($decoder);
if (!isset($this->remote->messages[$message_name]))
throw new AvroException("Unknown remote message: $message_name");
$remote_message_schema = $this->remot... | php | public function read_call_response($message_name, AvroIOBinaryDecoder $decoder)
{
$response_metadata = $this->meta_reader->read($decoder);
if (!isset($this->remote->messages[$message_name]))
throw new AvroException("Unknown remote message: $message_name");
$remote_message_schema = $this->remot... | [
"public",
"function",
"read_call_response",
"(",
"$",
"message_name",
",",
"AvroIOBinaryDecoder",
"$",
"decoder",
")",
"{",
"$",
"response_metadata",
"=",
"$",
"this",
"->",
"meta_reader",
"->",
"read",
"(",
"$",
"decoder",
")",
";",
"if",
"(",
"!",
"isset",... | Reads and processes a method call response.
The format of a call response is:
- response metadata, a map with values of type bytes
- a one-byte error flag boolean, followed by either:
- if the error flag is false, the message response, serialized per the message's response schema.
- if the error flag is true, the error... | [
"Reads",
"and",
"processes",
"a",
"method",
"call",
"response",
".",
"The",
"format",
"of",
"a",
"call",
"response",
"is",
":",
"-",
"response",
"metadata",
"a",
"map",
"with",
"values",
"of",
"type",
"bytes",
"-",
"a",
"one",
"-",
"byte",
"error",
"fl... | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L297-L318 |
eliep/avro-rpc-php | lib/avro/ipc.php | Responder.respond | public function respond($call_request, Transceiver $transceiver)
{
$buffer_reader = new AvroStringIO($call_request);
$decoder = new AvroIOBinaryDecoder($buffer_reader);
$buffer_writer = new AvroStringIO();
$encoder = new AvroIOBinaryEncoder($buffer_writer);
$error = null;
$response_m... | php | public function respond($call_request, Transceiver $transceiver)
{
$buffer_reader = new AvroStringIO($call_request);
$decoder = new AvroIOBinaryDecoder($buffer_reader);
$buffer_writer = new AvroStringIO();
$encoder = new AvroIOBinaryEncoder($buffer_writer);
$error = null;
$response_m... | [
"public",
"function",
"respond",
"(",
"$",
"call_request",
",",
"Transceiver",
"$",
"transceiver",
")",
"{",
"$",
"buffer_reader",
"=",
"new",
"AvroStringIO",
"(",
"$",
"call_request",
")",
";",
"$",
"decoder",
"=",
"new",
"AvroIOBinaryDecoder",
"(",
"$",
"b... | Entry point to process one procedure call.
@param string $call_request the serialized procedure call request
@param Transceiver $transceiver the transceiver used for the response
@return string|null the serialiazed procedure call response or null if it's a one-way message
@throw AvroException | [
"Entry",
"point",
"to",
"process",
"one",
"procedure",
"call",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L384-L445 |
eliep/avro-rpc-php | lib/avro/ipc.php | Responder.process_handshake | public function process_handshake(AvroIOBinaryDecoder $decoder, AvroIOBinaryEncoder $encoder, Transceiver $transceiver)
{
if ($transceiver->is_connected())
return $transceiver->get_remote();
$handshake_request = $this->handshake_responder_reader->read($decoder);
$client_hash = $handshake_reque... | php | public function process_handshake(AvroIOBinaryDecoder $decoder, AvroIOBinaryEncoder $encoder, Transceiver $transceiver)
{
if ($transceiver->is_connected())
return $transceiver->get_remote();
$handshake_request = $this->handshake_responder_reader->read($decoder);
$client_hash = $handshake_reque... | [
"public",
"function",
"process_handshake",
"(",
"AvroIOBinaryDecoder",
"$",
"decoder",
",",
"AvroIOBinaryEncoder",
"$",
"encoder",
",",
"Transceiver",
"$",
"transceiver",
")",
"{",
"if",
"(",
"$",
"transceiver",
"->",
"is_connected",
"(",
")",
")",
"return",
"$"... | Processes an RPC handshake.
@param AvroIOBinaryDecoder $decoder Where to read from
@param AvroIOBinaryEncoder $encoder Where to write to.
@param Transceiver $transceiver the transceiver used for the response
@return AvroProtocol The requested Protocol. | [
"Processes",
"an",
"RPC",
"handshake",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L454-L492 |
eliep/avro-rpc-php | lib/avro/ipc.php | SocketTransceiver.create | public static function create($host, $port)
{
$transceiver = new SocketTransceiver();
$transceiver->createSocket($host, $port);
return $transceiver;
} | php | public static function create($host, $port)
{
$transceiver = new SocketTransceiver();
$transceiver->createSocket($host, $port);
return $transceiver;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"host",
",",
"$",
"port",
")",
"{",
"$",
"transceiver",
"=",
"new",
"SocketTransceiver",
"(",
")",
";",
"$",
"transceiver",
"->",
"createSocket",
"(",
"$",
"host",
",",
"$",
"port",
")",
";",
"return"... | Create a SocketTransceiver with a new socket connected to $host:$port
@param string $host
@param int $host
@return SocketTransceiver | [
"Create",
"a",
"SocketTransceiver",
"with",
"a",
"new",
"socket",
"connected",
"to",
"$host",
":",
"$port"
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L583-L589 |
eliep/avro-rpc-php | lib/avro/ipc.php | SocketTransceiver.read_message | public function read_message()
{
$message = "";
while (true) {
socket_recv ( $this->socket , $buf , 4 , MSG_WAITALL );
if ($buf == null)
return $buf;
$frame_size = unpack("Nsize", $buf);
$frame_size = $frame_size["size"];
if ($frame_size == 0)
return $message;
... | php | public function read_message()
{
$message = "";
while (true) {
socket_recv ( $this->socket , $buf , 4 , MSG_WAITALL );
if ($buf == null)
return $buf;
$frame_size = unpack("Nsize", $buf);
$frame_size = $frame_size["size"];
if ($frame_size == 0)
return $message;
... | [
"public",
"function",
"read_message",
"(",
")",
"{",
"$",
"message",
"=",
"\"\"",
";",
"while",
"(",
"true",
")",
"{",
"socket_recv",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"buf",
",",
"4",
",",
"MSG_WAITALL",
")",
";",
"if",
"(",
"$",
"buf",
... | Reads a single message from the channel.
Blocks until a message can be read.
@return string The message read from the channel. | [
"Reads",
"a",
"single",
"message",
"from",
"the",
"channel",
".",
"Blocks",
"until",
"a",
"message",
"can",
"be",
"read",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L620-L637 |
eliep/avro-rpc-php | lib/avro/ipc.php | SocketTransceiver.write_message | public function write_message($message)
{
$binary_length = strlen($message);
$max_binary_frame_length = BUFFER_SIZE - 4;
$sended_length = 0;
$frames = array();
while ($sended_length < $binary_length) {
$not_sended_length = $binary_length - $sended_length;
$binary_frame_length... | php | public function write_message($message)
{
$binary_length = strlen($message);
$max_binary_frame_length = BUFFER_SIZE - 4;
$sended_length = 0;
$frames = array();
while ($sended_length < $binary_length) {
$not_sended_length = $binary_length - $sended_length;
$binary_frame_length... | [
"public",
"function",
"write_message",
"(",
"$",
"message",
")",
"{",
"$",
"binary_length",
"=",
"strlen",
"(",
"$",
"message",
")",
";",
"$",
"max_binary_frame_length",
"=",
"BUFFER_SIZE",
"-",
"4",
";",
"$",
"sended_length",
"=",
"0",
";",
"$",
"frames",... | Writes a message into the channel. Blocks until the message has been written.
@param string $message | [
"Writes",
"a",
"message",
"into",
"the",
"channel",
".",
"Blocks",
"until",
"the",
"message",
"has",
"been",
"written",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L643-L666 |
eliep/avro-rpc-php | lib/avro/ipc.php | NettyFramedSocketTransceiver.create | public static function create($host, $port)
{
$transceiver = new NettyFramedSocketTransceiver();
$transceiver->createSocket($host, $port);
return $transceiver;
} | php | public static function create($host, $port)
{
$transceiver = new NettyFramedSocketTransceiver();
$transceiver->createSocket($host, $port);
return $transceiver;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"host",
",",
"$",
"port",
")",
"{",
"$",
"transceiver",
"=",
"new",
"NettyFramedSocketTransceiver",
"(",
")",
";",
"$",
"transceiver",
"->",
"createSocket",
"(",
"$",
"host",
",",
"$",
"port",
")",
";",... | Create a SocketTransceiver with a new socket connected to $host:$port
@param string $host
@param int $host
@return NettyFramedSocketTransceiver | [
"Create",
"a",
"SocketTransceiver",
"with",
"a",
"new",
"socket",
"connected",
"to",
"$host",
":",
"$port"
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L717-L723 |
eliep/avro-rpc-php | lib/avro/ipc.php | NettyFramedSocketTransceiver.read_message | public function read_message()
{
socket_recv ( $this->socket , $buf , 8 , MSG_WAITALL );
if ($buf == null)
return $buf;
$frame_count = unpack("Nserial/Ncount", $buf);
$frame_count = $frame_count["count"];
$message = "";
for ($i = 0; $i < $frame_count; $i++ ) {
socket_recv ( $t... | php | public function read_message()
{
socket_recv ( $this->socket , $buf , 8 , MSG_WAITALL );
if ($buf == null)
return $buf;
$frame_count = unpack("Nserial/Ncount", $buf);
$frame_count = $frame_count["count"];
$message = "";
for ($i = 0; $i < $frame_count; $i++ ) {
socket_recv ( $t... | [
"public",
"function",
"read_message",
"(",
")",
"{",
"socket_recv",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"buf",
",",
"8",
",",
"MSG_WAITALL",
")",
";",
"if",
"(",
"$",
"buf",
"==",
"null",
")",
"return",
"$",
"buf",
";",
"$",
"frame_count",
... | Reads a single message from the channel.
Blocks until a message can be read.
@return string The message read from the channel. | [
"Reads",
"a",
"single",
"message",
"from",
"the",
"channel",
".",
"Blocks",
"until",
"a",
"message",
"can",
"be",
"read",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L743-L763 |
eliep/avro-rpc-php | lib/avro/ipc.php | NettyFramedSocketTransceiver.write_message | public function write_message($message)
{
$binary_length = strlen($message);
$max_binary_frame_length = BUFFER_SIZE - 4;
$sended_length = 0;
$frames = array();
while ($sended_length < $binary_length) {
$not_sended_length = $binary_length - $sended_length;
$binary_frame_length... | php | public function write_message($message)
{
$binary_length = strlen($message);
$max_binary_frame_length = BUFFER_SIZE - 4;
$sended_length = 0;
$frames = array();
while ($sended_length < $binary_length) {
$not_sended_length = $binary_length - $sended_length;
$binary_frame_length... | [
"public",
"function",
"write_message",
"(",
"$",
"message",
")",
"{",
"$",
"binary_length",
"=",
"strlen",
"(",
"$",
"message",
")",
";",
"$",
"max_binary_frame_length",
"=",
"BUFFER_SIZE",
"-",
"4",
";",
"$",
"sended_length",
"=",
"0",
";",
"$",
"frames",... | Writes a message into the channel. Blocks until the message has been written.
@param string $message | [
"Writes",
"a",
"message",
"into",
"the",
"channel",
".",
"Blocks",
"until",
"the",
"message",
"has",
"been",
"written",
"."
] | train | https://github.com/eliep/avro-rpc-php/blob/645321e5224eac9234fc79dbf447de3973a9ed1e/lib/avro/ipc.php#L769-L792 |
vardius/crud-bundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('vardius_crud');
$rootNode
->children()
->enumNode('db_driver')
->defaultValue('orm')
->values(['orm', 'propel'])
... | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('vardius_crud');
$rootNode
->children()
->enumNode('db_driver')
->defaultValue('orm')
->values(['orm', 'propel'])
... | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'vardius_crud'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/vardius/crud-bundle/blob/dda957e3f8516c3b0d6270ea5a6eb50d98e71444/DependencyInjection/Configuration.php#L30-L44 |
liquidpineapple/color | src/Color.php | Color.fromRGB | public static function fromRGB($red, $green, $blue)
{
if ($red < 0 || $red > 255 ||
$green < 0 || $green > 255 ||
$blue < 0 || $blue > 255) {
throw new InvalidArgumentException('Values $red, $blue and $green can only be 0 to 255');
}
$red /= 255;
$... | php | public static function fromRGB($red, $green, $blue)
{
if ($red < 0 || $red > 255 ||
$green < 0 || $green > 255 ||
$blue < 0 || $blue > 255) {
throw new InvalidArgumentException('Values $red, $blue and $green can only be 0 to 255');
}
$red /= 255;
$... | [
"public",
"static",
"function",
"fromRGB",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
")",
"{",
"if",
"(",
"$",
"red",
"<",
"0",
"||",
"$",
"red",
">",
"255",
"||",
"$",
"green",
"<",
"0",
"||",
"$",
"green",
">",
"255",
"||",
"$",... | Creates a Color instance based on the given RGB-formatted color.
@param int $red (0-255) The red value of the given color
@param int $green (0-255) The green value of the given color
@param int $blue (0-255) The blue value of the given color
@return Color | [
"Creates",
"a",
"Color",
"instance",
"based",
"on",
"the",
"given",
"RGB",
"-",
"formatted",
"color",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L49-L79 |
liquidpineapple/color | src/Color.php | Color.fromHEX | public static function fromHEX($hex)
{
$hex = preg_replace('/[^0-9A-Fa-f]/', '', $hex);
$rgb = [];
if (strlen($hex) == 6) {
$colorVal = hexdec($hex);
$rgb['red'] = 0xFF & ($colorVal >> 0x10);
$rgb['green'] = 0xFF & ($colorVal >> 0x8);
$rgb['blu... | php | public static function fromHEX($hex)
{
$hex = preg_replace('/[^0-9A-Fa-f]/', '', $hex);
$rgb = [];
if (strlen($hex) == 6) {
$colorVal = hexdec($hex);
$rgb['red'] = 0xFF & ($colorVal >> 0x10);
$rgb['green'] = 0xFF & ($colorVal >> 0x8);
$rgb['blu... | [
"public",
"static",
"function",
"fromHEX",
"(",
"$",
"hex",
")",
"{",
"$",
"hex",
"=",
"preg_replace",
"(",
"'/[^0-9A-Fa-f]/'",
",",
"''",
",",
"$",
"hex",
")",
";",
"$",
"rgb",
"=",
"[",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"==",... | Creates a Color instance based on the given Hexadecimal-formatted color.
@param string $hex A hexadecimal color value, the # isn't required but can be given
@return Color | [
"Creates",
"a",
"Color",
"instance",
"based",
"on",
"the",
"given",
"Hexadecimal",
"-",
"formatted",
"color",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L88-L106 |
liquidpineapple/color | src/Color.php | Color.fromHSV | public static function fromHSV($hue, $saturation, $value)
{
if ($hue < 0 || $hue > 360 ||
$saturation < 0 || $saturation > 100 ||
$value < 0 || $value > 100) {
throw new InvalidArgumentException('Value $hue can only be 0 to 360, $saturation and $value can only be 0 to 100... | php | public static function fromHSV($hue, $saturation, $value)
{
if ($hue < 0 || $hue > 360 ||
$saturation < 0 || $saturation > 100 ||
$value < 0 || $value > 100) {
throw new InvalidArgumentException('Value $hue can only be 0 to 360, $saturation and $value can only be 0 to 100... | [
"public",
"static",
"function",
"fromHSV",
"(",
"$",
"hue",
",",
"$",
"saturation",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"hue",
"<",
"0",
"||",
"$",
"hue",
">",
"360",
"||",
"$",
"saturation",
"<",
"0",
"||",
"$",
"saturation",
">",
"100"... | Creates a Color instance based on the given HSV-formatted color.
@param int $hue (0-360) The hue of the color (format: HSV)
@param int $saturation (0-100) The saturation of the color (format: HSV)
@param int $value (0-100) The value of the color (format: HSV)
@return Color | [
"Creates",
"a",
"Color",
"instance",
"based",
"on",
"the",
"given",
"HSV",
"-",
"formatted",
"color",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L117-L151 |
liquidpineapple/color | src/Color.php | Color.fromHSL | public static function fromHSL($hue, $saturation, $lightness)
{
if ($hue < 0 || $hue > 360 ||
$saturation < 0 || $saturation > 100 ||
$lightness < 0 || $lightness > 100) {
throw new InvalidArgumentException('Value $hue can only be 0 to 360, $saturation and $lightness can ... | php | public static function fromHSL($hue, $saturation, $lightness)
{
if ($hue < 0 || $hue > 360 ||
$saturation < 0 || $saturation > 100 ||
$lightness < 0 || $lightness > 100) {
throw new InvalidArgumentException('Value $hue can only be 0 to 360, $saturation and $lightness can ... | [
"public",
"static",
"function",
"fromHSL",
"(",
"$",
"hue",
",",
"$",
"saturation",
",",
"$",
"lightness",
")",
"{",
"if",
"(",
"$",
"hue",
"<",
"0",
"||",
"$",
"hue",
">",
"360",
"||",
"$",
"saturation",
"<",
"0",
"||",
"$",
"saturation",
">",
"... | Creates a Color instance based on the given HSL-formatted color.
@param int $hue (0-360) The hue of the color (format: HSL)
@param int $saturation (0-100) The saturation of the color (format: HSL)
@param int $lightness (0-100) The lightness of the color (format: HSL)
@return Color | [
"Creates",
"a",
"Color",
"instance",
"based",
"on",
"the",
"given",
"HSL",
"-",
"formatted",
"color",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L162-L171 |
liquidpineapple/color | src/Color.php | Color.lighten | public function lighten($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->lightness += (100 - $this->lightness) * $amount;
return $this;
} | php | public function lighten($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->lightness += (100 - $this->lightness) * $amount;
return $this;
} | [
"public",
"function",
"lighten",
"(",
"$",
"amount",
")",
"{",
"if",
"(",
"$",
"amount",
"<",
"0",
"||",
"$",
"amount",
">",
"100",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The given amount must be between 0 and 100'",
")",
";",
"}",
"$",... | Alters the color by lightening it with the given percentage.
@param int $amount (0-100) Percentage with which to lighten the color
@return Color | [
"Alters",
"the",
"color",
"by",
"lightening",
"it",
"with",
"the",
"given",
"percentage",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L180-L189 |
liquidpineapple/color | src/Color.php | Color.darken | public function darken($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->lightness -= $this->lightness * $amount;
return $this;
} | php | public function darken($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->lightness -= $this->lightness * $amount;
return $this;
} | [
"public",
"function",
"darken",
"(",
"$",
"amount",
")",
"{",
"if",
"(",
"$",
"amount",
"<",
"0",
"||",
"$",
"amount",
">",
"100",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The given amount must be between 0 and 100'",
")",
";",
"}",
"$",
... | Alters the color by darkening it with the given percentage.
@param int $amount (0-100) Percentage with which to darken the color
@return Color | [
"Alters",
"the",
"color",
"by",
"darkening",
"it",
"with",
"the",
"given",
"percentage",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L198-L207 |
liquidpineapple/color | src/Color.php | Color.saturate | public function saturate($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->saturation += (100 - $this->saturation) * $amount;
return $this;
} | php | public function saturate($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->saturation += (100 - $this->saturation) * $amount;
return $this;
} | [
"public",
"function",
"saturate",
"(",
"$",
"amount",
")",
"{",
"if",
"(",
"$",
"amount",
"<",
"0",
"||",
"$",
"amount",
">",
"100",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The given amount must be between 0 and 100'",
")",
";",
"}",
"$"... | Alters the color by saturating it with the given percentage.
@param int $amount (0-100) Percentage with which to saturate the color
@return Color | [
"Alters",
"the",
"color",
"by",
"saturating",
"it",
"with",
"the",
"given",
"percentage",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L216-L225 |
liquidpineapple/color | src/Color.php | Color.desaturate | public function desaturate($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->saturation -= $this->saturation * $amount;
return $this;
} | php | public function desaturate($amount)
{
if ($amount < 0 || $amount > 100) {
throw new InvalidArgumentException('The given amount must be between 0 and 100');
}
$amount /= 100;
$this->saturation -= $this->saturation * $amount;
return $this;
} | [
"public",
"function",
"desaturate",
"(",
"$",
"amount",
")",
"{",
"if",
"(",
"$",
"amount",
"<",
"0",
"||",
"$",
"amount",
">",
"100",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The given amount must be between 0 and 100'",
")",
";",
"}",
"... | Alters the color by desaturating it with the given percentage.
@param int $amount (0-100) Percentage with which to desaturate the color
@return Color | [
"Alters",
"the",
"color",
"by",
"desaturating",
"it",
"with",
"the",
"given",
"percentage",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L234-L243 |
liquidpineapple/color | src/Color.php | Color.toHSL | public function toHSL()
{
return [
round($this->hue),
round($this->saturation),
round($this->lightness),
];
} | php | public function toHSL()
{
return [
round($this->hue),
round($this->saturation),
round($this->lightness),
];
} | [
"public",
"function",
"toHSL",
"(",
")",
"{",
"return",
"[",
"round",
"(",
"$",
"this",
"->",
"hue",
")",
",",
"round",
"(",
"$",
"this",
"->",
"saturation",
")",
",",
"round",
"(",
"$",
"this",
"->",
"lightness",
")",
",",
"]",
";",
"}"
] | Outputs the color using the HSL format.
@return array HSL representation of the color | [
"Outputs",
"the",
"color",
"using",
"the",
"HSL",
"format",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L250-L257 |
liquidpineapple/color | src/Color.php | Color.toRGB | public function toRGB()
{
$h = $this->hue;
$s = $this->saturation / 100;
$l = $this->lightness / 100;
$r;
$g;
$b;
$c = (1 - abs(2 * $l - 1)) * $s;
$x = $c * (1 - abs(fmod(($h / 60), 2) - 1));
$m = $l - ($c / 2);
if ($h < 60) {
... | php | public function toRGB()
{
$h = $this->hue;
$s = $this->saturation / 100;
$l = $this->lightness / 100;
$r;
$g;
$b;
$c = (1 - abs(2 * $l - 1)) * $s;
$x = $c * (1 - abs(fmod(($h / 60), 2) - 1));
$m = $l - ($c / 2);
if ($h < 60) {
... | [
"public",
"function",
"toRGB",
"(",
")",
"{",
"$",
"h",
"=",
"$",
"this",
"->",
"hue",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"saturation",
"/",
"100",
";",
"$",
"l",
"=",
"$",
"this",
"->",
"lightness",
"/",
"100",
";",
"$",
"r",
";",
"$",
... | Outputs the color using the RGB format.
@return array RGB representation of the color | [
"Outputs",
"the",
"color",
"using",
"the",
"RGB",
"format",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L276-L309 |
liquidpineapple/color | src/Color.php | Color.toHEX | public function toHEX()
{
list($red, $green, $blue) = $this->toRGB();
return strtoupper(sprintf('#%02x%02x%02x', $red, $green, $blue));
} | php | public function toHEX()
{
list($red, $green, $blue) = $this->toRGB();
return strtoupper(sprintf('#%02x%02x%02x', $red, $green, $blue));
} | [
"public",
"function",
"toHEX",
"(",
")",
"{",
"list",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
")",
"=",
"$",
"this",
"->",
"toRGB",
"(",
")",
";",
"return",
"strtoupper",
"(",
"sprintf",
"(",
"'#%02x%02x%02x'",
",",
"$",
"red",
",",
... | Outputs the color using the HEX format.
@return array HEX representation of the color | [
"Outputs",
"the",
"color",
"using",
"the",
"HEX",
"format",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L328-L333 |
liquidpineapple/color | src/Color.php | Color.toHSV | public function toHSV()
{
list($red, $green, $blue) = $this->toRGB();
$red /= 255;
$green /= 255;
$blue /= 255;
$maxRGB = max($red, $green, $blue);
$minRGB = min($red, $green, $blue);
$chroma = $maxRGB - $minRGB;
$value = 100 * $maxRGB;
if (... | php | public function toHSV()
{
list($red, $green, $blue) = $this->toRGB();
$red /= 255;
$green /= 255;
$blue /= 255;
$maxRGB = max($red, $green, $blue);
$minRGB = min($red, $green, $blue);
$chroma = $maxRGB - $minRGB;
$value = 100 * $maxRGB;
if (... | [
"public",
"function",
"toHSV",
"(",
")",
"{",
"list",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
")",
"=",
"$",
"this",
"->",
"toRGB",
"(",
")",
";",
"$",
"red",
"/=",
"255",
";",
"$",
"green",
"/=",
"255",
";",
"$",
"blue",
"/=",
... | Outputs the color using the HSV format.
@return array HSV representation of the color | [
"Outputs",
"the",
"color",
"using",
"the",
"HSV",
"format",
"."
] | train | https://github.com/liquidpineapple/color/blob/f0f323e99a884d482ec35abf21b49af5ab3fa9c3/src/Color.php#L350-L384 |
o2system/parser | src/Template/Adapters/Dwoo.php | Dwoo.initialize | public function initialize(array $config = [])
{
if (empty($this->engine)) {
if ($this->isSupported()) {
$this->engine = new \Dwoo();
} else {
throw new RuntimeException(
'PARSER_E_THIRD_PARTY',
0,
... | php | public function initialize(array $config = [])
{
if (empty($this->engine)) {
if ($this->isSupported()) {
$this->engine = new \Dwoo();
} else {
throw new RuntimeException(
'PARSER_E_THIRD_PARTY',
0,
... | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"engine",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSupported",
"(",
")",
")",
"{",
"$",
"this",
"->",
"... | Dwoo::initialize
@param array $config
@return static
@throws \O2System\Spl\Exceptions\RuntimeException | [
"Dwoo",
"::",
"initialize"
] | train | https://github.com/o2system/parser/blob/1b85fe676ea043a500842e61731ab4d38e5323e4/src/Template/Adapters/Dwoo.php#L38-L53 |
CloudObjects/RDFUtilities | Arc2JsonLdConverter.php | Arc2JsonLdConverter.triplesToQuads | public static function triplesToQuads(array $triples) {
$quads = array();
foreach ($triples as $t) {
$quads[] = new Quad(new IRI($t['s']), new IRI($t['p']),
($t['o_type'] == 'uri') ? new IRI($t['o']) : new TypedValue($t['o'],
(isset($t['o_datatype']) && $t['o_datatype']!='') ? $t['o_datatype']... | php | public static function triplesToQuads(array $triples) {
$quads = array();
foreach ($triples as $t) {
$quads[] = new Quad(new IRI($t['s']), new IRI($t['p']),
($t['o_type'] == 'uri') ? new IRI($t['o']) : new TypedValue($t['o'],
(isset($t['o_datatype']) && $t['o_datatype']!='') ? $t['o_datatype']... | [
"public",
"static",
"function",
"triplesToQuads",
"(",
"array",
"$",
"triples",
")",
"{",
"$",
"quads",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"triples",
"as",
"$",
"t",
")",
"{",
"$",
"quads",
"[",
"]",
"=",
"new",
"Quad",
"(",
"new",
... | Converts an array of ARC2 triples into an array of RDF quads
in JsonLD library format.
@param array $triples ARC2 triples | [
"Converts",
"an",
"array",
"of",
"ARC2",
"triples",
"into",
"an",
"array",
"of",
"RDF",
"quads",
"in",
"JsonLD",
"library",
"format",
"."
] | train | https://github.com/CloudObjects/RDFUtilities/blob/cd086981557352073b18b9e2fec1d99cfaacd285/Arc2JsonLdConverter.php#L19-L28 |
CloudObjects/RDFUtilities | Arc2JsonLdConverter.php | Arc2JsonLdConverter.indexToQuads | public static function indexToQuads(array $index) {
$quads = array();
foreach ($index as $subject => $predicates) {
foreach ($predicates as $predicate => $objects) {
foreach ($objects as $object) {
$quads[] = new Quad(new IRI($subject),
new IRI($predicate),
($obje... | php | public static function indexToQuads(array $index) {
$quads = array();
foreach ($index as $subject => $predicates) {
foreach ($predicates as $predicate => $objects) {
foreach ($objects as $object) {
$quads[] = new Quad(new IRI($subject),
new IRI($predicate),
($obje... | [
"public",
"static",
"function",
"indexToQuads",
"(",
"array",
"$",
"index",
")",
"{",
"$",
"quads",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"index",
"as",
"$",
"subject",
"=>",
"$",
"predicates",
")",
"{",
"foreach",
"(",
"$",
"predicates",
... | Converts an ARC2 index into an array of RDF quads in JsonLD
library format.
@param array $index ARC2 index | [
"Converts",
"an",
"ARC2",
"index",
"into",
"an",
"array",
"of",
"RDF",
"quads",
"in",
"JsonLD",
"library",
"format",
"."
] | train | https://github.com/CloudObjects/RDFUtilities/blob/cd086981557352073b18b9e2fec1d99cfaacd285/Arc2JsonLdConverter.php#L35-L50 |
CloudObjects/RDFUtilities | Arc2JsonLdConverter.php | Arc2JsonLdConverter.quadsToTriples | public static function quadsToTriples(array $quads) {
$arcTriples = array();
foreach ($quads as $q) {
$arcTriples[] = array(
's' => (string)$q->getSubject(),
'p' => (string)$q->getProperty(),
'o' => (is_a($q->getObject(), 'ML\JsonLD\TypedValue'))
? $q->getObject()->getVal... | php | public static function quadsToTriples(array $quads) {
$arcTriples = array();
foreach ($quads as $q) {
$arcTriples[] = array(
's' => (string)$q->getSubject(),
'p' => (string)$q->getProperty(),
'o' => (is_a($q->getObject(), 'ML\JsonLD\TypedValue'))
? $q->getObject()->getVal... | [
"public",
"static",
"function",
"quadsToTriples",
"(",
"array",
"$",
"quads",
")",
"{",
"$",
"arcTriples",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"quads",
"as",
"$",
"q",
")",
"{",
"$",
"arcTriples",
"[",
"]",
"=",
"array",
"(",
"'s'",
"... | Converts an array of RDF quads in JsonLD library format into
an array of ARC2 triples.
@param array $quads JsonLD quads | [
"Converts",
"an",
"array",
"of",
"RDF",
"quads",
"in",
"JsonLD",
"library",
"format",
"into",
"an",
"array",
"of",
"ARC2",
"triples",
"."
] | train | https://github.com/CloudObjects/RDFUtilities/blob/cd086981557352073b18b9e2fec1d99cfaacd285/Arc2JsonLdConverter.php#L57-L74 |
guillaumemonet/Rad | src/Rad/Middleware/Middleware.php | Middleware.layer | public function layer($layers) {
if ($layers instanceof Middleware) {
$layers = $layers->toArray();
}
if ($layers instanceof MiddlewareInterface) {
$layers = [$layers];
}
if (!is_array($layers)) {
throw new InvalidArgumentException(get_... | php | public function layer($layers) {
if ($layers instanceof Middleware) {
$layers = $layers->toArray();
}
if ($layers instanceof MiddlewareInterface) {
$layers = [$layers];
}
if (!is_array($layers)) {
throw new InvalidArgumentException(get_... | [
"public",
"function",
"layer",
"(",
"$",
"layers",
")",
"{",
"if",
"(",
"$",
"layers",
"instanceof",
"Middleware",
")",
"{",
"$",
"layers",
"=",
"$",
"layers",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"$",
"layers",
"instanceof",
"MiddlewareInte... | Add layer(s) or Middleware
@param mixed $layers | [
"Add",
"layer",
"(",
"s",
")",
"or",
"Middleware"
] | train | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Middleware/Middleware.php#L36-L47 |
guillaumemonet/Rad | src/Rad/Middleware/Middleware.php | Middleware.createCoreFunction | private function createCoreFunction(Closure $core): Closure {
return function(ServerRequestInterface $request, ResponseInterface $response, Route $route) use($core) {
return call_user_func_array($core, [&$request, &$response, &$route]);
};
} | php | private function createCoreFunction(Closure $core): Closure {
return function(ServerRequestInterface $request, ResponseInterface $response, Route $route) use($core) {
return call_user_func_array($core, [&$request, &$response, &$route]);
};
} | [
"private",
"function",
"createCoreFunction",
"(",
"Closure",
"$",
"core",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"Route",
"$",
"route",
")",
"use",
"(",
"$"... | Create the core function
@param Closure $core the core function
@return Closure | [
"Create",
"the",
"core",
"function"
] | train | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Middleware/Middleware.php#L79-L83 |
guillaumemonet/Rad | src/Rad/Middleware/Middleware.php | Middleware.createLayer | private function createLayer($nextLayer, $layer): Closure {
return function(ServerRequestInterface $request, ResponseInterface $response, Route $route) use($nextLayer, $layer) {
return call_user_func_array([$layer, 'call'], [&$request, &$response, &$route, $nextLayer]);
};
} | php | private function createLayer($nextLayer, $layer): Closure {
return function(ServerRequestInterface $request, ResponseInterface $response, Route $route) use($nextLayer, $layer) {
return call_user_func_array([$layer, 'call'], [&$request, &$response, &$route, $nextLayer]);
};
} | [
"private",
"function",
"createLayer",
"(",
"$",
"nextLayer",
",",
"$",
"layer",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"Route",
"$",
"route",
")",
"use",
... | Create Layer
@param MiddlewareInterface $nextLayer
@param MiddlewareInterface $layer
@return Closure | [
"Create",
"Layer"
] | train | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Middleware/Middleware.php#L91-L95 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.startsWith | public static function startsWith($haystack, $needle)
{
$length = strlen($needle);
return substr($haystack, 0, $length) === $needle;
} | php | public static function startsWith($haystack, $needle)
{
$length = strlen($needle);
return substr($haystack, 0, $length) === $needle;
} | [
"public",
"static",
"function",
"startsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"needle",
")",
";",
"return",
"substr",
"(",
"$",
"haystack",
",",
"0",
",",
"$",
"length",
")",
"===",
"$",
"... | @param string $haystack
@param string $needle
@return bool | [
"@param",
"string",
"$haystack",
"@param",
"string",
"$needle"
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L26-L31 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.concatenate | public static function concatenate($str, $suffix, $separator)
{
if (empty($suffix)) {
return $str;
}
if (empty($str)) {
return $suffix;
}
return $str . $separator . $suffix;
} | php | public static function concatenate($str, $suffix, $separator)
{
if (empty($suffix)) {
return $str;
}
if (empty($str)) {
return $suffix;
}
return $str . $separator . $suffix;
} | [
"public",
"static",
"function",
"concatenate",
"(",
"$",
"str",
",",
"$",
"suffix",
",",
"$",
"separator",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"suffix",
")",
")",
"{",
"return",
"$",
"str",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"str",
")",
... | @param string $str
@param string $suffix
@param string $separator
@return string | [
"@param",
"string",
"$str",
"@param",
"string",
"$suffix",
"@param",
"string",
"$separator"
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L56-L66 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.interpolate | public static function interpolate($string, $parameters = [], $openingTag = '%{', $closingTag = '}', $fallback = true)
{
// Match all items
preg_match_all(sprintf('/%s(.*)%s/U', preg_quote($openingTag), preg_quote($closingTag)), $string, $matches);
foreach ($matches[1] as $match) {
... | php | public static function interpolate($string, $parameters = [], $openingTag = '%{', $closingTag = '}', $fallback = true)
{
// Match all items
preg_match_all(sprintf('/%s(.*)%s/U', preg_quote($openingTag), preg_quote($closingTag)), $string, $matches);
foreach ($matches[1] as $match) {
... | [
"public",
"static",
"function",
"interpolate",
"(",
"$",
"string",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"openingTag",
"=",
"'%{'",
",",
"$",
"closingTag",
"=",
"'}'",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"// Match all items",
"preg_ma... | Look for parameters in the given string and replace them with the given values.
This function works using the annotation %{parameter_name} (proposed) and {parameter_name} (fallback)
It is advised to use the first one.
Dot syntax can be used to dive in the array fields, example: %{group1.field2.value} will
use ArrayHel... | [
"Look",
"for",
"parameters",
"in",
"the",
"given",
"string",
"and",
"replace",
"them",
"with",
"the",
"given",
"values",
".",
"This",
"function",
"works",
"using",
"the",
"annotation",
"%",
"{",
"parameter_name",
"}",
"(",
"proposed",
")",
"and",
"{",
"par... | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L84-L107 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.explode | public static function explode($string, $delimiter = ' ', $groupQuotes = false)
{
if (!$groupQuotes) {
return explode($delimiter, $string);
} else {
preg_match_all('([^\s"\'“”]+|"[^"]*"|\'[^\']*\'|“[^”]*”|“[^“]*“|”[^”]*”|”[^“]*“)', $string, $matches);
// Remove q... | php | public static function explode($string, $delimiter = ' ', $groupQuotes = false)
{
if (!$groupQuotes) {
return explode($delimiter, $string);
} else {
preg_match_all('([^\s"\'“”]+|"[^"]*"|\'[^\']*\'|“[^”]*”|“[^“]*“|”[^”]*”|”[^“]*“)', $string, $matches);
// Remove q... | [
"public",
"static",
"function",
"explode",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"' '",
",",
"$",
"groupQuotes",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"groupQuotes",
")",
"{",
"return",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"st... | @param string $string
@param string $delimiter
@param bool $groupQuotes
@return array | [
"@param",
"string",
"$string",
"@param",
"string",
"$delimiter",
"@param",
"bool",
"$groupQuotes"
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L116-L131 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.emptyString | public static function emptyString($value, $isNull = true)
{
if (is_string($value)) {
return strlen($value) === 0;
}
return ($isNull && is_null($value)) || false;
} | php | public static function emptyString($value, $isNull = true)
{
if (is_string($value)) {
return strlen($value) === 0;
}
return ($isNull && is_null($value)) || false;
} | [
"public",
"static",
"function",
"emptyString",
"(",
"$",
"value",
",",
"$",
"isNull",
"=",
"true",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"strlen",
"(",
"$",
"value",
")",
"===",
"0",
";",
"}",
"return",
"(",
... | Checks if a string is empty or not.
If the $value parameter is not a string, the method will always return false
@param string $value
@param bool $isNull
@return bool true if string is empty (has 0 length); otherwise false | [
"Checks",
"if",
"a",
"string",
"is",
"empty",
"or",
"not",
".",
"If",
"the",
"$value",
"parameter",
"is",
"not",
"a",
"string",
"the",
"method",
"will",
"always",
"return",
"false"
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L142-L149 |
PandaPlatform/framework | src/Panda/Support/Helpers/StringHelper.php | StringHelper.contains | public static function contains($haystack, $needle)
{
// Check arguments
if (empty($haystack) || empty($needle)) {
return false;
}
// Needle is string
if (!is_array($needle)) {
return mb_strpos($haystack, $needle) !== false;
}
// Need... | php | public static function contains($haystack, $needle)
{
// Check arguments
if (empty($haystack) || empty($needle)) {
return false;
}
// Needle is string
if (!is_array($needle)) {
return mb_strpos($haystack, $needle) !== false;
}
// Need... | [
"public",
"static",
"function",
"contains",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"// Check arguments",
"if",
"(",
"empty",
"(",
"$",
"haystack",
")",
"||",
"empty",
"(",
"$",
"needle",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Need... | Check if a given string contains a given substring.
@param string $haystack
@param string|array $needle
@return bool | [
"Check",
"if",
"a",
"given",
"string",
"contains",
"a",
"given",
"substring",
"."
] | train | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/StringHelper.php#L159-L179 |
cicada/cicada | src/ExceptionHandler.php | ExceptionHandler.add | public function add(callable $callback)
{
$reflection = new \ReflectionFunction($callback);
$params = $reflection->getParameters();
if (empty($params)) {
throw new \InvalidArgumentException(
"Invalid exception callback: Has no arguments. Expected at least one."
... | php | public function add(callable $callback)
{
$reflection = new \ReflectionFunction($callback);
$params = $reflection->getParameters();
if (empty($params)) {
throw new \InvalidArgumentException(
"Invalid exception callback: Has no arguments. Expected at least one."
... | [
"public",
"function",
"add",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"params",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
... | Adds an exception callback.
The exception callback should be a callable
function which has one argument, and that argument must have a type hint
of an exception class. It should return a
`Symfony\Component\HttpFoundation\Response` object.
For example:
```
$handler->add(function(SomeException $ex) {
return new Respon... | [
"Adds",
"an",
"exception",
"callback",
"."
] | train | https://github.com/cicada/cicada/blob/5a54bd05dfa1df38e7aa3d704d270853f0329e13/src/ExceptionHandler.php#L45-L66 |
cicada/cicada | src/ExceptionHandler.php | ExceptionHandler.handle | public function handle(\Exception $ex, Request $request)
{
foreach ($this->callbacks as $exClass => $callback) {
if ($ex instanceof $exClass) {
$invoker = new Invoker();
return $invoker->invoke($callback, [], [$ex, $request]);
}
}
} | php | public function handle(\Exception $ex, Request $request)
{
foreach ($this->callbacks as $exClass => $callback) {
if ($ex instanceof $exClass) {
$invoker = new Invoker();
return $invoker->invoke($callback, [], [$ex, $request]);
}
}
} | [
"public",
"function",
"handle",
"(",
"\\",
"Exception",
"$",
"ex",
",",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"as",
"$",
"exClass",
"=>",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"ex",
"instanceof",
"$... | Calls the first callback which matches the given exception (is of the
same class or parent).
@param Exception $ex The exception to handle.
@return Response|null Returns a response returned by the handler, or null
if no callbacks matched the exception. | [
"Calls",
"the",
"first",
"callback",
"which",
"matches",
"the",
"given",
"exception",
"(",
"is",
"of",
"the",
"same",
"class",
"or",
"parent",
")",
"."
] | train | https://github.com/cicada/cicada/blob/5a54bd05dfa1df38e7aa3d704d270853f0329e13/src/ExceptionHandler.php#L76-L84 |
antarestupin/Accessible | lib/Accessible/Reader/CollectionsReader.php | CollectionsReader.getCollectionsItemNames | public static function getCollectionsItemNames($properties, $annotationReader)
{
$objectCollectionsItemNames = array(
"byProperty" => array(),
"byItemName" => array()
);
foreach ($properties as $propertyName => $property) {
$annotation = null;
... | php | public static function getCollectionsItemNames($properties, $annotationReader)
{
$objectCollectionsItemNames = array(
"byProperty" => array(),
"byItemName" => array()
);
foreach ($properties as $propertyName => $property) {
$annotation = null;
... | [
"public",
"static",
"function",
"getCollectionsItemNames",
"(",
"$",
"properties",
",",
"$",
"annotationReader",
")",
"{",
"$",
"objectCollectionsItemNames",
"=",
"array",
"(",
"\"byProperty\"",
"=>",
"array",
"(",
")",
",",
"\"byItemName\"",
"=>",
"array",
"(",
... | Get a list linking an item name with the property it refers to and what kind of collection it is.
Ex: [
"byItemName" => "user" => ["property" => "users", "behavior" => "list", "methods" => ["add", "remove"]],
"byProperty" => "users" => ["itemName" => "user", "behavior" => "list", "methods" => ["add", "remove"]]
]
@par... | [
"Get",
"a",
"list",
"linking",
"an",
"item",
"name",
"with",
"the",
"property",
"it",
"refers",
"to",
"and",
"what",
"kind",
"of",
"collection",
"it",
"is",
".",
"Ex",
":",
"[",
"byItemName",
"=",
">",
"user",
"=",
">",
"[",
"property",
"=",
">",
"... | train | https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/CollectionsReader.php#L21-L60 |
yosmanyga/validation | src/Yosmanyga/Validation/Validator/ScalarValidator.php | ScalarValidator.validate | public function validate($value)
{
$errors = [];
$this->configureMessages();
if ($value === null) {
if ($this->options['allowNull'] === false) {
return [new Error($this->options['messages']['null'])];
}
return [];
}
if (... | php | public function validate($value)
{
$errors = [];
$this->configureMessages();
if ($value === null) {
if ($this->options['allowNull'] === false) {
return [new Error($this->options['messages']['null'])];
}
return [];
}
if (... | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"configureMessages",
"(",
")",
";",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/validation/blob/dded99a6e24b79f808250791ba1db632fd44c5c4/src/Yosmanyga/Validation/Validator/ScalarValidator.php#L52-L111 |
unimapper/unimapper | src/Entity/Collection.php | Collection.offsetExists | public function offsetExists($key)
{
return isset($this->data[$key]) || array_key_exists($key, $this->data);
} | php | public function offsetExists($key)
{
return isset($this->data[$key]) || array_key_exists($key, $this->data);
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
")",
";",
"}"
] | Determines whether a item exists.
@param integer $key Key
@return boolean | [
"Determines",
"whether",
"a",
"item",
"exists",
"."
] | train | https://github.com/unimapper/unimapper/blob/a63b39f38a790fec7e852c8ef1e4c31653e689f7/src/Entity/Collection.php#L212-L215 |
unimapper/unimapper | src/Entity/Collection.php | Collection.toArray | public function toArray($nesting = false)
{
return array_map(function (Entity $entity) use ($nesting) {
return $entity->toArray($nesting);
}, $this->data);
} | php | public function toArray($nesting = false)
{
return array_map(function (Entity $entity) use ($nesting) {
return $entity->toArray($nesting);
}, $this->data);
} | [
"public",
"function",
"toArray",
"(",
"$",
"nesting",
"=",
"false",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"Entity",
"$",
"entity",
")",
"use",
"(",
"$",
"nesting",
")",
"{",
"return",
"$",
"entity",
"->",
"toArray",
"(",
"$",
"nesting"... | Convert collection to an array
@param boolean $nesting Convert nested entities and collections too
@return array | [
"Convert",
"collection",
"to",
"an",
"array"
] | train | https://github.com/unimapper/unimapper/blob/a63b39f38a790fec7e852c8ef1e4c31653e689f7/src/Entity/Collection.php#L234-L239 |
unimapper/unimapper | src/Entity/Collection.php | Collection.getByPrimary | public function getByPrimary($value)
{
foreach ($this->data as $entity) {
$primaryPropertyName = $entity::getReflection()
->getPrimaryProperty()
->getName();
$primaryValue = $entity->{$primaryPropertyName};
if ($primaryValue === $value &&... | php | public function getByPrimary($value)
{
foreach ($this->data as $entity) {
$primaryPropertyName = $entity::getReflection()
->getPrimaryProperty()
->getName();
$primaryValue = $entity->{$primaryPropertyName};
if ($primaryValue === $value &&... | [
"public",
"function",
"getByPrimary",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"entity",
")",
"{",
"$",
"primaryPropertyName",
"=",
"$",
"entity",
"::",
"getReflection",
"(",
")",
"->",
"getPrimaryProperty",
"(",
... | Get entity by primary value
@param mixed $value
@return Entity|false | [
"Get",
"entity",
"by",
"primary",
"value"
] | train | https://github.com/unimapper/unimapper/blob/a63b39f38a790fec7e852c8ef1e4c31653e689f7/src/Entity/Collection.php#L260-L274 |
ipunkt/social-auth | src/Ipunkt/SocialAuth/Repositories/EloquentSocialLoginRepository.php | EloquentSocialLoginRepository.findByUserAndProvider | function findByUserAndProvider(UserInterface $user, $providerName) {
return SocialProfile::where('provider', '=', $providerName)->whereUserId($user->getAuthIdentifier())->first();
} | php | function findByUserAndProvider(UserInterface $user, $providerName) {
return SocialProfile::where('provider', '=', $providerName)->whereUserId($user->getAuthIdentifier())->first();
} | [
"function",
"findByUserAndProvider",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"providerName",
")",
"{",
"return",
"SocialProfile",
"::",
"where",
"(",
"'provider'",
",",
"'='",
",",
"$",
"providerName",
")",
"->",
"whereUserId",
"(",
"$",
"user",
"->",
"... | Attempt to find the Profile of User $user with provider $providerName
@param UserInterface $user
@param string $providerName
@return mixed | [
"Attempt",
"to",
"find",
"the",
"Profile",
"of",
"User",
"$user",
"with",
"provider",
"$providerName"
] | train | https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/Ipunkt/SocialAuth/Repositories/EloquentSocialLoginRepository.php#L72-L74 |
allebb/collection | lib/Collection.php | Collection.reset | public function reset($items = null)
{
$this->items = [];
if ((func_get_args() > 0) && is_array($items)) {
$this->items = $items;
}
return $this;
} | php | public function reset($items = null)
{
$this->items = [];
if ((func_get_args() > 0) && is_array($items)) {
$this->items = $items;
}
return $this;
} | [
"public",
"function",
"reset",
"(",
"$",
"items",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"func_get_args",
"(",
")",
">",
"0",
")",
"&&",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"$",
"this",
... | Resets the collection with the specified array content.
@param array $items
@return Collection | [
"Resets",
"the",
"collection",
"with",
"the",
"specified",
"array",
"content",
"."
] | train | https://github.com/allebb/collection/blob/651e6c8360e7fe7e56b3d8bbd5556af294a97718/lib/Collection.php#L43-L50 |
allebb/collection | lib/Collection.php | Collection.push | public function push($item)
{
if (!is_array($item)) {
$this->items = array_merge($this->items, [$item]);
return $this;
}
$this->items = array_merge($this->items, $item);
return $this;
} | php | public function push($item)
{
if (!is_array($item)) {
$this->items = array_merge($this->items, [$item]);
return $this;
}
$this->items = array_merge($this->items, $item);
return $this;
} | [
"public",
"function",
"push",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"items",
",",
"[",
"$",
"item",
"]",
")",
";",
"retur... | Push a new item (or array of items) into the collection onto the end
of the collection.
@param mixed $item
@return Collection | [
"Push",
"a",
"new",
"item",
"(",
"or",
"array",
"of",
"items",
")",
"into",
"the",
"collection",
"onto",
"the",
"end",
"of",
"the",
"collection",
"."
] | train | https://github.com/allebb/collection/blob/651e6c8360e7fe7e56b3d8bbd5556af294a97718/lib/Collection.php#L70-L78 |
allebb/collection | lib/Collection.php | Collection.pull | public function pull($key)
{
if ($this->has($key)) {
$pulled = $this->get($key);
$this->remove($key);
return $pulled;
}
return false;
} | php | public function pull($key)
{
if ($this->has($key)) {
$pulled = $this->get($key);
$this->remove($key);
return $pulled;
}
return false;
} | [
"public",
"function",
"pull",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"pulled",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"k... | Pull an item from the collection and remove it from the collection.
@param string $key
@return mixed|false | [
"Pull",
"an",
"item",
"from",
"the",
"collection",
"and",
"remove",
"it",
"from",
"the",
"collection",
"."
] | train | https://github.com/allebb/collection/blob/651e6c8360e7fe7e56b3d8bbd5556af294a97718/lib/Collection.php#L115-L123 |
assely/fielder | src/FielderServiceProvider.php | FielderServiceProvider.register | public function register()
{
$this->app->singleton('fielder', function ($app) {
$fielder = new Fielder($app);
$fielder->register($this->fields);
return $fielder;
});
$this->app->alias('fielder', Fielder::class);
} | php | public function register()
{
$this->app->singleton('fielder', function ($app) {
$fielder = new Fielder($app);
$fielder->register($this->fields);
return $fielder;
});
$this->app->alias('fielder', Fielder::class);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'fielder'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"fielder",
"=",
"new",
"Fielder",
"(",
"$",
"app",
")",
";",
"$",
"fielder",
"->",
"reg... | Register fielder services.
@return void | [
"Register",
"fielder",
"services",
"."
] | train | https://github.com/assely/fielder/blob/c702ef2426522d1a0a9ca9945547513a7788fcdc/src/FielderServiceProvider.php#L45-L56 |
assely/fielder | src/FielderServiceProvider.php | FielderServiceProvider.dispatchAssets | public function dispatchAssets()
{
$this->app['asset.factory']->add('fielder-vendors', [
'path' => FIELDER_URI.'public/js/vendors.js',
])->area('admin');
$this->app['asset.factory']->add('fielder', [
'path' => FIELDER_URI.'public/js/fielder.js',
'dependen... | php | public function dispatchAssets()
{
$this->app['asset.factory']->add('fielder-vendors', [
'path' => FIELDER_URI.'public/js/vendors.js',
])->area('admin');
$this->app['asset.factory']->add('fielder', [
'path' => FIELDER_URI.'public/js/fielder.js',
'dependen... | [
"public",
"function",
"dispatchAssets",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'asset.factory'",
"]",
"->",
"add",
"(",
"'fielder-vendors'",
",",
"[",
"'path'",
"=>",
"FIELDER_URI",
".",
"'public/js/vendors.js'",
",",
"]",
")",
"->",
"area",
"(",
"... | Dispatch fielder assets.
@return void | [
"Dispatch",
"fielder",
"assets",
"."
] | train | https://github.com/assely/fielder/blob/c702ef2426522d1a0a9ca9945547513a7788fcdc/src/FielderServiceProvider.php#L75-L89 |
markwatkinson/luminous | src/Luminous/Scanners/DiffScanner.php | DiffScanner.getChildScanner | public function getChildScanner($filename)
{
// HACK - pretty mode should be reflected elsewhere than here.
if (!$this->prettyMode) {
return null;
}
// $luminous_ is a singleton from the main calling API. It may or may not
// exist here, but if it does, we're goin... | php | public function getChildScanner($filename)
{
// HACK - pretty mode should be reflected elsewhere than here.
if (!$this->prettyMode) {
return null;
}
// $luminous_ is a singleton from the main calling API. It may or may not
// exist here, but if it does, we're goin... | [
"public",
"function",
"getChildScanner",
"(",
"$",
"filename",
")",
"{",
"// HACK - pretty mode should be reflected elsewhere than here.",
"if",
"(",
"!",
"$",
"this",
"->",
"prettyMode",
")",
"{",
"return",
"null",
";",
"}",
"// $luminous_ is a singleton from the main ca... | /* TODO: plug this into the language code selector in the old EasyAPI
when we port it across
This function is just a placeholder and will be implemented properly
later. | [
"/",
"*",
"TODO",
":",
"plug",
"this",
"into",
"the",
"language",
"code",
"selector",
"in",
"the",
"old",
"EasyAPI",
"when",
"we",
"port",
"it",
"across",
"This",
"function",
"is",
"just",
"a",
"placeholder",
"and",
"will",
"be",
"implemented",
"properly",... | train | https://github.com/markwatkinson/luminous/blob/4adc18f414534abe986133d6d38e8e9787d32e69/src/Luminous/Scanners/DiffScanner.php#L27-L51 |
dphn/ScContent | src/ScContent/Controller/Back/LayoutController.php | LayoutController.indexAction | public function indexAction()
{
$service = $this->getLayoutService();
try {
$theme = $service->getTheme(
$this->params()->fromRoute('theme')
);
} catch (RuntimeException $e) {
$this->flashMessenger()->addMessage($e->getMessage());
... | php | public function indexAction()
{
$service = $this->getLayoutService();
try {
$theme = $service->getTheme(
$this->params()->fromRoute('theme')
);
} catch (RuntimeException $e) {
$this->flashMessenger()->addMessage($e->getMessage());
... | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getLayoutService",
"(",
")",
";",
"try",
"{",
"$",
"theme",
"=",
"$",
"service",
"->",
"getTheme",
"(",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRou... | Shows a layout.
@return \Zend\Stdlib\ResponseInterface|\Zend\View\Model\ViewModel | [
"Shows",
"a",
"layout",
"."
] | train | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/LayoutController.php#L34-L73 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.