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
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.isAnimated
public function isAnimated($asset): bool { $source = new LocalSourceImageModel($asset); $source->getLocalCopy(); if ($source->extension !== 'gif') { return false; } if (!($fh = @fopen($source->getFilePath(), 'rb'))) { return false; } ...
php
public function isAnimated($asset): bool { $source = new LocalSourceImageModel($asset); $source->getLocalCopy(); if ($source->extension !== 'gif') { return false; } if (!($fh = @fopen($source->getFilePath(), 'rb'))) { return false; } ...
[ "public", "function", "isAnimated", "(", "$", "asset", ")", ":", "bool", "{", "$", "source", "=", "new", "LocalSourceImageModel", "(", "$", "asset", ")", ";", "$", "source", "->", "getLocalCopy", "(", ")", ";", "if", "(", "$", "source", "->", "extensio...
Checks if asset is animated. An animated gif contains multiple "frames", with each frame having a header made up of: - a static 4-byte sequence (\x00\x21\xF9\x04) - 4 variable bytes - a static 2-byte sequence (\x00\x2C) We read through the file til we reach the end of the file, or we've found at least 2 frame headers...
[ "Checks", "if", "asset", "is", "animated", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L416-L441
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.removeTransformsForAsset
public function removeTransformsForAsset(Asset $asset) { $config = self::getConfig(); try { $sourceModel = new LocalSourceImageModel($asset); $targetModel = new LocalTargetImageModel($sourceModel, []); if (strpos($targetModel->path, $config->imagerSystemPath) !=...
php
public function removeTransformsForAsset(Asset $asset) { $config = self::getConfig(); try { $sourceModel = new LocalSourceImageModel($asset); $targetModel = new LocalTargetImageModel($sourceModel, []); if (strpos($targetModel->path, $config->imagerSystemPath) !=...
[ "public", "function", "removeTransformsForAsset", "(", "Asset", "$", "asset", ")", "{", "$", "config", "=", "self", "::", "getConfig", "(", ")", ";", "try", "{", "$", "sourceModel", "=", "new", "LocalSourceImageModel", "(", "$", "asset", ")", ";", "$", "...
Remove transforms for a given asset @param Asset $asset
[ "Remove", "transforms", "for", "a", "given", "asset" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L448-L478
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.deleteImageTransformCaches
public function deleteImageTransformCaches() { $path = Plugin::$plugin->getSettings()->imagerSystemPath; try { FileHelper::clearDirectory(FileHelper::normalizePath($path)); } catch (ErrorException $e) { Craft::error('Could not clear directory "'.$path.'" ('.$e->getMe...
php
public function deleteImageTransformCaches() { $path = Plugin::$plugin->getSettings()->imagerSystemPath; try { FileHelper::clearDirectory(FileHelper::normalizePath($path)); } catch (ErrorException $e) { Craft::error('Could not clear directory "'.$path.'" ('.$e->getMe...
[ "public", "function", "deleteImageTransformCaches", "(", ")", "{", "$", "path", "=", "Plugin", "::", "$", "plugin", "->", "getSettings", "(", ")", "->", "imagerSystemPath", ";", "try", "{", "FileHelper", "::", "clearDirectory", "(", "FileHelper", "::", "normal...
Clear all image transforms caches
[ "Clear", "all", "image", "transforms", "caches" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L483-L494
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.deleteRemoteImageCaches
public function deleteRemoteImageCaches() { $path = Craft::$app->getPath()->getRuntimePath().'/imager/'; try { FileHelper::clearDirectory(FileHelper::normalizePath($path)); } catch (ErrorException $e) { Craft::error('Could not clear directory "'.$path.'" ('.$e->getMe...
php
public function deleteRemoteImageCaches() { $path = Craft::$app->getPath()->getRuntimePath().'/imager/'; try { FileHelper::clearDirectory(FileHelper::normalizePath($path)); } catch (ErrorException $e) { Craft::error('Could not clear directory "'.$path.'" ('.$e->getMe...
[ "public", "function", "deleteRemoteImageCaches", "(", ")", "{", "$", "path", "=", "Craft", "::", "$", "app", "->", "getPath", "(", ")", "->", "getRuntimePath", "(", ")", ".", "'/imager/'", ";", "try", "{", "FileHelper", "::", "clearDirectory", "(", "FileHe...
Clear all remote image caches
[ "Clear", "all", "remote", "image", "caches" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L499-L510
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.fillTransforms
private function fillTransforms($transforms): array { $r = []; $attributeName = self::$transformConfig->fillAttribute; $interval = self::$transformConfig->fillInterval; $r[] = $transforms[0]; for ($i = 1, $l = \count($transforms); $i < $l; $i++) { $prevTransfor...
php
private function fillTransforms($transforms): array { $r = []; $attributeName = self::$transformConfig->fillAttribute; $interval = self::$transformConfig->fillInterval; $r[] = $transforms[0]; for ($i = 1, $l = \count($transforms); $i < $l; $i++) { $prevTransfor...
[ "private", "function", "fillTransforms", "(", "$", "transforms", ")", ":", "array", "{", "$", "r", "=", "[", "]", ";", "$", "attributeName", "=", "self", "::", "$", "transformConfig", "->", "fillAttribute", ";", "$", "interval", "=", "self", "::", "$", ...
Fills in the missing transform objects @param array $transforms @return array
[ "Fills", "in", "the", "missing", "transform", "objects" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L538-L571
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.mergeTransforms
private function mergeTransforms($transforms, $defaults): array { $r = []; foreach ($transforms as $t) { $r[] = ($defaults !== null ? array_merge($defaults, $t) : $t); } return $r; }
php
private function mergeTransforms($transforms, $defaults): array { $r = []; foreach ($transforms as $t) { $r[] = ($defaults !== null ? array_merge($defaults, $t) : $t); } return $r; }
[ "private", "function", "mergeTransforms", "(", "$", "transforms", ",", "$", "defaults", ")", ":", "array", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "transforms", "as", "$", "t", ")", "{", "$", "r", "[", "]", "=", "(", "$", "default...
Merges default transform object into an array of transforms @param array $transforms @param array $defaults @return array
[ "Merges", "default", "transform", "object", "into", "an", "array", "of", "transforms" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L581-L590
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.normalizeTransforms
private function normalizeTransforms($transforms): array { $r = []; foreach ($transforms as $t) { $r[] = $this->normalizeTransform((array)$t); } return $r; }
php
private function normalizeTransforms($transforms): array { $r = []; foreach ($transforms as $t) { $r[] = $this->normalizeTransform((array)$t); } return $r; }
[ "private", "function", "normalizeTransforms", "(", "$", "transforms", ")", ":", "array", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "transforms", "as", "$", "t", ")", "{", "$", "r", "[", "]", "=", "$", "this", "->", "normalizeTransform",...
Merges default transform object into an array of transforms @param array $transforms @return array
[ "Merges", "default", "transform", "object", "into", "an", "array", "of", "transforms" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L599-L608
aelvan/Imager-Craft
src/services/ImagerService.php
ImagerService.normalizeTransform
private function normalizeTransform($transform): array { // if resize mode is not crop or croponly, remove position if (isset($transform['mode'], $transform['position']) && (($transform['mode'] !== 'crop') && ($transform['mode'] !== 'croponly'))) { unset($transform['position']); ...
php
private function normalizeTransform($transform): array { // if resize mode is not crop or croponly, remove position if (isset($transform['mode'], $transform['position']) && (($transform['mode'] !== 'crop') && ($transform['mode'] !== 'croponly'))) { unset($transform['position']); ...
[ "private", "function", "normalizeTransform", "(", "$", "transform", ")", ":", "array", "{", "// if resize mode is not crop or croponly, remove position", "if", "(", "isset", "(", "$", "transform", "[", "'mode'", "]", ",", "$", "transform", "[", "'position'", "]", ...
Normalize transform object and values @param array $transform @return array
[ "Normalize", "transform", "object", "and", "values" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerService.php#L617-L674
aelvan/Imager-Craft
src/controllers/CacheController.php
CacheController.actionClearTransforms
public function actionClearTransforms() { $config = Plugin::$plugin->getSettings(); $request = Craft::$app->getRequest(); $key = $request->getParam('key', ''); $setKey = $config->clearKey; if ($setKey === '' || $key != $setKey) { throw new \Exception('Unautorize...
php
public function actionClearTransforms() { $config = Plugin::$plugin->getSettings(); $request = Craft::$app->getRequest(); $key = $request->getParam('key', ''); $setKey = $config->clearKey; if ($setKey === '' || $key != $setKey) { throw new \Exception('Unautorize...
[ "public", "function", "actionClearTransforms", "(", ")", "{", "$", "config", "=", "Plugin", "::", "$", "plugin", "->", "getSettings", "(", ")", ";", "$", "request", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", ";", "$", "key", "=", "...
Controller action to clear image transforms @throws \yii\base\ErrorException
[ "Controller", "action", "to", "clear", "image", "transforms" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/controllers/CacheController.php#L42-L57
aelvan/Imager-Craft
src/controllers/CacheController.php
CacheController.actionClearRemoteImages
public function actionClearRemoteImages() { $config = Plugin::$plugin->getSettings(); $request = Craft::$app->getRequest(); $key = $request->getParam('key', ''); $setKey = $config->clearKey; if ($setKey === '' || $key != $setKey) { throw new \Exception('Unautori...
php
public function actionClearRemoteImages() { $config = Plugin::$plugin->getSettings(); $request = Craft::$app->getRequest(); $key = $request->getParam('key', ''); $setKey = $config->clearKey; if ($setKey === '' || $key != $setKey) { throw new \Exception('Unautori...
[ "public", "function", "actionClearRemoteImages", "(", ")", "{", "$", "config", "=", "Plugin", "::", "$", "plugin", "->", "getSettings", "(", ")", ";", "$", "request", "=", "Craft", "::", "$", "app", "->", "getRequest", "(", ")", ";", "$", "key", "=", ...
Controller action to clear remote images @throws \yii\base\ErrorException
[ "Controller", "action", "to", "clear", "remote", "images" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/controllers/CacheController.php#L64-L79
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.transformImage
public function transformImage($file, $transform, $transformDefaults = null, $configOverrides = null) { $image = Plugin::$plugin->imager->transformImage($file, $transform, $transformDefaults, $configOverrides); return $image; }
php
public function transformImage($file, $transform, $transformDefaults = null, $configOverrides = null) { $image = Plugin::$plugin->imager->transformImage($file, $transform, $transformDefaults, $configOverrides); return $image; }
[ "public", "function", "transformImage", "(", "$", "file", ",", "$", "transform", ",", "$", "transformDefaults", "=", "null", ",", "$", "configOverrides", "=", "null", ")", "{", "$", "image", "=", "Plugin", "::", "$", "plugin", "->", "imager", "->", "tran...
Transforms an image @param Asset|string $file @param array $transform @param array $transformDefaults @param array $configOverrides @return mixed @throws ImagerException
[ "Transforms", "an", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L35-L40
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.srcset
public function srcset($images, $descriptor = 'w'): string { return Plugin::$plugin->imager->srcset($images, $descriptor); }
php
public function srcset($images, $descriptor = 'w'): string { return Plugin::$plugin->imager->srcset($images, $descriptor); }
[ "public", "function", "srcset", "(", "$", "images", ",", "$", "descriptor", "=", "'w'", ")", ":", "string", "{", "return", "Plugin", "::", "$", "plugin", "->", "imager", "->", "srcset", "(", "$", "images", ",", "$", "descriptor", ")", ";", "}" ]
Takes an array of models that supports getUrl() and getWidth(), and returns a srcset and returns a srcset string @param array $images @param string $descriptor @return string
[ "Takes", "an", "array", "of", "models", "that", "supports", "getUrl", "()", "and", "getWidth", "()", "and", "returns", "a", "srcset", "and", "returns", "a", "srcset", "string" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L51-L54
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.getDominantColor
public function getDominantColor($image, $quality = 10, $colorValue = 'hex') { return Plugin::$plugin->color->getDominantColor($image, $quality, $colorValue); }
php
public function getDominantColor($image, $quality = 10, $colorValue = 'hex') { return Plugin::$plugin->color->getDominantColor($image, $quality, $colorValue); }
[ "public", "function", "getDominantColor", "(", "$", "image", ",", "$", "quality", "=", "10", ",", "$", "colorValue", "=", "'hex'", ")", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "getDominantColor", "(", "$", "image", ",", "$", ...
Gets the dominant color of an image @param Asset|string $image @param string $colorValue @param int $quality @return mixed
[ "Gets", "the", "dominant", "color", "of", "an", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L92-L95
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.getColorPalette
public function getColorPalette($image, $colorCount = 8, $quality = 10, $colorValue = 'hex') { return Plugin::$plugin->color->getColorPalette($image, $colorCount, $quality, $colorValue); }
php
public function getColorPalette($image, $colorCount = 8, $quality = 10, $colorValue = 'hex') { return Plugin::$plugin->color->getColorPalette($image, $colorCount, $quality, $colorValue); }
[ "public", "function", "getColorPalette", "(", "$", "image", ",", "$", "colorCount", "=", "8", ",", "$", "quality", "=", "10", ",", "$", "colorValue", "=", "'hex'", ")", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "getColorPalette",...
Gets a palette of colors from an image @param Asset|string $image @param string $colorValue @param int $colorCount @param int $quality @return mixed
[ "Gets", "a", "palette", "of", "colors", "from", "an", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L107-L110
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.isBright
public function isBright($color, $threshold=127.5): bool { return Plugin::$plugin->color->isBright($color, $threshold); }
php
public function isBright($color, $threshold=127.5): bool { return Plugin::$plugin->color->isBright($color, $threshold); }
[ "public", "function", "isBright", "(", "$", "color", ",", "$", "threshold", "=", "127.5", ")", ":", "bool", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "isBright", "(", "$", "color", ",", "$", "threshold", ")", ";", "}" ]
Checks brightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 127.5. @param string|array $color @param float $threshold @return bool
[ "Checks", "brightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "127", ".", "5", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L176-L179
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.isLight
public function isLight($color, $threshold=50): bool { return Plugin::$plugin->color->isLight($color, $threshold); }
php
public function isLight($color, $threshold=50): bool { return Plugin::$plugin->color->isLight($color, $threshold); }
[ "public", "function", "isLight", "(", "$", "color", ",", "$", "threshold", "=", "50", ")", ":", "bool", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "isLight", "(", "$", "color", ",", "$", "threshold", ")", ";", "}" ]
Checks lightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 50.0. @param string|array $color @param int $threshold @return bool
[ "Checks", "lightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "50", ".", "0", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L188-L191
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.looksBright
public function looksBright($color, $threshold=127.5): bool { return Plugin::$plugin->color->looksBright($color, $threshold); }
php
public function looksBright($color, $threshold=127.5): bool { return Plugin::$plugin->color->looksBright($color, $threshold); }
[ "public", "function", "looksBright", "(", "$", "color", ",", "$", "threshold", "=", "127.5", ")", ":", "bool", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "looksBright", "(", "$", "color", ",", "$", "threshold", ")", ";", "}" ]
Checks perceived_brightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 127.5. @param string|array $color @param float $threshold @return bool
[ "Checks", "perceived_brightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "127", ".", "5", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L200-L203
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.getBrightnessDifference
public function getBrightnessDifference($color1, $color2): float { return Plugin::$plugin->color->getBrightnessDifference($color1, $color2); }
php
public function getBrightnessDifference($color1, $color2): float { return Plugin::$plugin->color->getBrightnessDifference($color1, $color2); }
[ "public", "function", "getBrightnessDifference", "(", "$", "color1", ",", "$", "color2", ")", ":", "float", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "getBrightnessDifference", "(", "$", "color1", ",", "$", "color2", ")", ";", "}" ...
Calculates brightness difference (https://www.w3.org/TR/AERT#color-contrast) on a scale from 0 to 255. @param string|array $color1 @param string|array $color2 @return float
[ "Calculates", "brightness", "difference", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "AERT#color", "-", "contrast", ")", "on", "a", "scale", "from", "0", "to", "255", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L245-L248
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.getColorDifference
public function getColorDifference($color1, $color2): int { return Plugin::$plugin->color->getColorDifference($color1, $color2); }
php
public function getColorDifference($color1, $color2): int { return Plugin::$plugin->color->getColorDifference($color1, $color2); }
[ "public", "function", "getColorDifference", "(", "$", "color1", ",", "$", "color2", ")", ":", "int", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "getColorDifference", "(", "$", "color1", ",", "$", "color2", ")", ";", "}" ]
Calculates color difference (https://www.w3.org/TR/AERT#color-contrast) on a scale from 0 to 765. @param string|array $color1 @param string|array $color2 @return int
[ "Calculates", "color", "difference", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "AERT#color", "-", "contrast", ")", "on", "a", "scale", "from", "0", "to", "765", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L257-L260
aelvan/Imager-Craft
src/variables/ImagerVariable.php
ImagerVariable.getContrastRatio
public function getContrastRatio($color1, $color2): float { return Plugin::$plugin->color->getContrastRatio($color1, $color2); }
php
public function getContrastRatio($color1, $color2): float { return Plugin::$plugin->color->getContrastRatio($color1, $color2); }
[ "public", "function", "getContrastRatio", "(", "$", "color1", ",", "$", "color2", ")", ":", "float", "{", "return", "Plugin", "::", "$", "plugin", "->", "color", "->", "getContrastRatio", "(", "$", "color1", ",", "$", "color2", ")", ";", "}" ]
Calculates the contrast ratio (https://www.w3.org/TR/WCAG20/#contrast-ratiodef) between two colors on a scale from 1 to 21. @param string|array $color1 @param string|array $color2 @return float
[ "Calculates", "the", "contrast", "ratio", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "WCAG20", "/", "#contrast", "-", "ratiodef", ")", "between", "two", "colors", "on", "a", "scale", "from", "1", "to", "21", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/variables/ImagerVariable.php#L269-L272
aelvan/Imager-Craft
src/services/ImgixService.php
ImgixService.getCanPurge
public static function getCanPurge(): bool { if (!isset(self::$canPurge)) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // No Imgix config, no purging $imgixConfigArr = $config->getSetting('imgixConfig'); if...
php
public static function getCanPurge(): bool { if (!isset(self::$canPurge)) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // No Imgix config, no purging $imgixConfigArr = $config->getSetting('imgixConfig'); if...
[ "public", "static", "function", "getCanPurge", "(", ")", ":", "bool", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "canPurge", ")", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";...
Purging is possible if there's an `imgixConfig` map, and all sources/profiles have an API key set Used for determining if the ImgixPurgeElementAction element action and various related event handlers should be bootstrapped or not @return bool
[ "Purging", "is", "possible", "if", "there", "s", "an", "imgixConfig", "map", "and", "all", "sources", "/", "profiles", "have", "an", "API", "key", "set", "Used", "for", "determining", "if", "the", "ImgixPurgeElementAction", "element", "action", "and", "various...
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImgixService.php#L59-L88
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getCropSize
public static function getCropSize($originalSize, $transform, $allowUpscale): Box { $width = $originalSize->getWidth(); $height = $originalSize->getHeight(); $aspect = $width / $height; if (isset($transform['width'], $transform['height'])) { $width = (int)$transform['wid...
php
public static function getCropSize($originalSize, $transform, $allowUpscale): Box { $width = $originalSize->getWidth(); $height = $originalSize->getHeight(); $aspect = $width / $height; if (isset($transform['width'], $transform['height'])) { $width = (int)$transform['wid...
[ "public", "static", "function", "getCropSize", "(", "$", "originalSize", ",", "$", "transform", ",", "$", "allowUpscale", ")", ":", "Box", "{", "$", "width", "=", "$", "originalSize", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "originalSiz...
Creates the destination crop size box @param \Imagine\Image\Box $originalSize @param array $transform @param bool $allowUpscale @return Box @throws \Imagine\Exception\InvalidArgumentException
[ "Creates", "the", "destination", "crop", "size", "box" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L33-L68
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getResizeSize
public static function getResizeSize($originalSize, $transform, $allowUpscale): Box { $width = $originalSize->getWidth(); $height = $originalSize->getHeight(); $aspect = $width / $height; $mode = isset($transform['mode']) ? mb_strtolower($transform['mode']) : 'crop'; if ($m...
php
public static function getResizeSize($originalSize, $transform, $allowUpscale): Box { $width = $originalSize->getWidth(); $height = $originalSize->getHeight(); $aspect = $width / $height; $mode = isset($transform['mode']) ? mb_strtolower($transform['mode']) : 'crop'; if ($m...
[ "public", "static", "function", "getResizeSize", "(", "$", "originalSize", ",", "$", "transform", ",", "$", "allowUpscale", ")", ":", "Box", "{", "$", "width", "=", "$", "originalSize", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "originalS...
Creates the resize size box @param \Imagine\Image\Box $originalSize @param array $transform @param bool $allowUpscale @return Box @throws ImagerException
[ "Creates", "the", "resize", "size", "box" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L80-L147
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.enforceMaxSize
private static function enforceMaxSize($width, $height, $originalSize, $maintainAspect, $zoomFactor = 1.0): array { $adjustedWidth = $width; $adjustedHeight = $height; if ($adjustedWidth > $originalSize->getWidth() * $zoomFactor) { $adjustedWidth = floor($originalSize->getWidth(...
php
private static function enforceMaxSize($width, $height, $originalSize, $maintainAspect, $zoomFactor = 1.0): array { $adjustedWidth = $width; $adjustedHeight = $height; if ($adjustedWidth > $originalSize->getWidth() * $zoomFactor) { $adjustedWidth = floor($originalSize->getWidth(...
[ "private", "static", "function", "enforceMaxSize", "(", "$", "width", ",", "$", "height", ",", "$", "originalSize", ",", "$", "maintainAspect", ",", "$", "zoomFactor", "=", "1.0", ")", ":", "array", "{", "$", "adjustedWidth", "=", "$", "width", ";", "$",...
Enforces a max size if allowUpscale is false @param int $width @param int $height @param BoxInterface $originalSize @param bool $maintainAspect @param float $zoomFactor @return array
[ "Enforces", "a", "max", "size", "if", "allowUpscale", "is", "false" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L160-L182
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getCropPoint
public static function getCropPoint($resizeSize, $cropSize, $position): Point { // Get the offsets, left and top, now as an int, representing the % offset list($leftOffset, $topOffset) = explode(' ', $position); // Get position that crop should center around $leftPos = floor($resize...
php
public static function getCropPoint($resizeSize, $cropSize, $position): Point { // Get the offsets, left and top, now as an int, representing the % offset list($leftOffset, $topOffset) = explode(' ', $position); // Get position that crop should center around $leftPos = floor($resize...
[ "public", "static", "function", "getCropPoint", "(", "$", "resizeSize", ",", "$", "cropSize", ",", "$", "position", ")", ":", "Point", "{", "// Get the offsets, left and top, now as an int, representing the % offset", "list", "(", "$", "leftOffset", ",", "$", "topOffs...
Gets crop point @param \Imagine\Image\Box $resizeSize @param \Imagine\Image\Box $cropSize @param string $position @return \Imagine\Image\Point @throws ImagerException
[ "Gets", "crop", "point" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L210-L231
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getTransformPathForAsset
public static function getTransformPathForAsset($asset): string { /** @var Volume $volume */ try { $volume = $asset->getVolume(); } catch (InvalidConfigException $e) { \Craft::error($e->getMessage(), __METHOD__); throw new ImagerException($e->getMessage(),...
php
public static function getTransformPathForAsset($asset): string { /** @var Volume $volume */ try { $volume = $asset->getVolume(); } catch (InvalidConfigException $e) { \Craft::error($e->getMessage(), __METHOD__); throw new ImagerException($e->getMessage(),...
[ "public", "static", "function", "getTransformPathForAsset", "(", "$", "asset", ")", ":", "string", "{", "/** @var Volume $volume */", "try", "{", "$", "volume", "=", "$", "asset", "->", "getVolume", "(", ")", ";", "}", "catch", "(", "InvalidConfigException", "...
Returns the transform path for a given asset. @param Asset $asset @return string @throws ImagerException
[ "Returns", "the", "transform", "path", "for", "a", "given", "asset", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L241-L262
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getTransformPathForPath
public static function getTransformPathForPath($path): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $hashPath = $config->hashPath; $pathParts = pathinfo($path); if ($hashPath) { return FileHelper::normalizePath('/' . md5($path...
php
public static function getTransformPathForPath($path): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $hashPath = $config->hashPath; $pathParts = pathinfo($path); if ($hashPath) { return FileHelper::normalizePath('/' . md5($path...
[ "public", "static", "function", "getTransformPathForPath", "(", "$", "path", ")", ":", "string", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "hashPath", "=", "$", "config", "->", "hashPath...
Returns the transform path for a given local path. @param $path @return string
[ "Returns", "the", "transform", "path", "for", "a", "given", "local", "path", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L271-L284
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.getTransformPathForUrl
public static function getTransformPathForUrl($url): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $urlParts = parse_url($url); $pathParts = pathinfo($urlParts['path']); $hashRemoteUrl = $config->getSetting('hashRemoteUrl'); $hashPa...
php
public static function getTransformPathForUrl($url): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $urlParts = parse_url($url); $pathParts = pathinfo($urlParts['path']); $hashRemoteUrl = $config->getSetting('hashRemoteUrl'); $hashPa...
[ "public", "static", "function", "getTransformPathForUrl", "(", "$", "url", ")", ":", "string", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "urlParts", "=", "parse_url", "(", "$", "url", ...
Returns the transform path for a given url. @param $url @return string
[ "Returns", "the", "transform", "path", "for", "a", "given", "url", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L293-L320
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.createTransformFilestring
public static function createTransformFilestring($transform): string { $r = ''; foreach ($transform as $k => $v) { if ($k === 'effects' || $k === 'preEffects') { $effectString = ''; foreach ($v as $eff => $param) { if (\is_array($param...
php
public static function createTransformFilestring($transform): string { $r = ''; foreach ($transform as $k => $v) { if ($k === 'effects' || $k === 'preEffects') { $effectString = ''; foreach ($v as $eff => $param) { if (\is_array($param...
[ "public", "static", "function", "createTransformFilestring", "(", "$", "transform", ")", ":", "string", "{", "$", "r", "=", "''", ";", "foreach", "(", "$", "transform", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "k", "===", "'effects'"...
Creates additional file string that is appended to filename @param array $transform @return string
[ "Creates", "additional", "file", "string", "that", "is", "appended", "to", "filename" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L329-L376
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.normalizeAssetTransformToObject
public static function normalizeAssetTransformToObject($assetTransform): array { $transformArray = $assetTransform->toArray(); $validParams = ['width', 'height', 'format', 'mode', 'position', 'interlace', 'quality']; $r = []; foreach ($validParams as $param) { if (isset...
php
public static function normalizeAssetTransformToObject($assetTransform): array { $transformArray = $assetTransform->toArray(); $validParams = ['width', 'height', 'format', 'mode', 'position', 'interlace', 'quality']; $r = []; foreach ($validParams as $param) { if (isset...
[ "public", "static", "function", "normalizeAssetTransformToObject", "(", "$", "assetTransform", ")", ":", "array", "{", "$", "transformArray", "=", "$", "assetTransform", "->", "toArray", "(", ")", ";", "$", "validParams", "=", "[", "'width'", ",", "'height'", ...
Converts a native asset transform object into an Imager transform. @param AssetTransform $assetTransform @return array
[ "Converts", "a", "native", "asset", "transform", "object", "into", "an", "Imager", "transform", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L384-L398
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.moveArrayKeyToPos
public static function moveArrayKeyToPos($key, $pos, $arr): array { if (!isset($arr[$key])) { return $arr; } $tempValue = $arr[$key]; unset($arr[$key]); if ($pos === 0) { return [$key => $tempValue] + $arr; } if ($pos > \count($arr))...
php
public static function moveArrayKeyToPos($key, $pos, $arr): array { if (!isset($arr[$key])) { return $arr; } $tempValue = $arr[$key]; unset($arr[$key]); if ($pos === 0) { return [$key => $tempValue] + $arr; } if ($pos > \count($arr))...
[ "public", "static", "function", "moveArrayKeyToPos", "(", "$", "key", ",", "$", "pos", ",", "$", "arr", ")", ":", "array", "{", "if", "(", "!", "isset", "(", "$", "arr", "[", "$", "key", "]", ")", ")", "{", "return", "$", "arr", ";", "}", "$", ...
Moves a named key in an associative array to a given position @param string $key @param int $pos @param array $arr @return array
[ "Moves", "a", "named", "key", "in", "an", "associative", "array", "to", "a", "given", "position" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L409-L439
aelvan/Imager-Craft
src/helpers/ImagerHelpers.php
ImagerHelpers.fixSlashes
public static function fixSlashes($str, $removeInitial = false, $removeTrailing = false) { $r = str_replace('//', '/', $str); if (\strlen($r) > 0) { if ($removeInitial && ($r[0] === '/')) { $r = substr($r, 1); } if ($removeTrailing && ($r[\strlen...
php
public static function fixSlashes($str, $removeInitial = false, $removeTrailing = false) { $r = str_replace('//', '/', $str); if (\strlen($r) > 0) { if ($removeInitial && ($r[0] === '/')) { $r = substr($r, 1); } if ($removeTrailing && ($r[\strlen...
[ "public", "static", "function", "fixSlashes", "(", "$", "str", ",", "$", "removeInitial", "=", "false", ",", "$", "removeTrailing", "=", "false", ")", "{", "$", "r", "=", "str_replace", "(", "'//'", ",", "'/'", ",", "$", "str", ")", ";", "if", "(", ...
Fixes slashes in path @param string $str @param bool|false $removeInitial @param bool|false $removeTrailing @return mixed|string
[ "Fixes", "slashes", "in", "path" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L451-L466
aelvan/Imager-Craft
src/elementactions/ImgixPurgeElementAction.php
ImgixPurgeElementAction.performAction
public function performAction(ElementQueryInterface $query): bool { $imagesToPurge = $query->kind('image')->all(); if (empty($imagesToPurge)) { $this->setMessage(Craft::t('imager', 'No images to purge')); return true; } /** @var Imager $imagerPlugin */ ...
php
public function performAction(ElementQueryInterface $query): bool { $imagesToPurge = $query->kind('image')->all(); if (empty($imagesToPurge)) { $this->setMessage(Craft::t('imager', 'No images to purge')); return true; } /** @var Imager $imagerPlugin */ ...
[ "public", "function", "performAction", "(", "ElementQueryInterface", "$", "query", ")", ":", "bool", "{", "$", "imagesToPurge", "=", "$", "query", "->", "kind", "(", "'image'", ")", "->", "all", "(", ")", ";", "if", "(", "empty", "(", "$", "imagesToPurge...
Purges selected image Assets from Imgix @param ElementQueryInterface $query @return bool
[ "Purges", "selected", "image", "Assets", "from", "Imgix" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/elementactions/ImgixPurgeElementAction.php#L39-L71
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.getDominantColor
public function getDominantColor($image, $quality, $colorValue) { try { $source = new LocalSourceImageModel($image); $source->getLocalCopy(); } catch (ImagerException $e) { return null; } $dominantColor = ColorThief::getColor($source->getFilePath(...
php
public function getDominantColor($image, $quality, $colorValue) { try { $source = new LocalSourceImageModel($image); $source->getLocalCopy(); } catch (ImagerException $e) { return null; } $dominantColor = ColorThief::getColor($source->getFilePath(...
[ "public", "function", "getDominantColor", "(", "$", "image", ",", "$", "quality", ",", "$", "colorValue", ")", "{", "try", "{", "$", "source", "=", "new", "LocalSourceImageModel", "(", "$", "image", ")", ";", "$", "source", "->", "getLocalCopy", "(", ")"...
Get dominant color of image @param Asset|string $image @param int $quality @param string $colorValue @return string|array|boolean|null
[ "Get", "dominant", "color", "of", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L69-L87
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.getColorPalette
public function getColorPalette($image, $colorCount, $quality, $colorValue) { try { $source = new LocalSourceImageModel($image); $source->getLocalCopy(); } catch (ImagerException $e) { return null; } $palette = ColorThief::getPalette($source->getF...
php
public function getColorPalette($image, $colorCount, $quality, $colorValue) { try { $source = new LocalSourceImageModel($image); $source->getLocalCopy(); } catch (ImagerException $e) { return null; } $palette = ColorThief::getPalette($source->getF...
[ "public", "function", "getColorPalette", "(", "$", "image", ",", "$", "colorCount", ",", "$", "quality", ",", "$", "colorValue", ")", "{", "try", "{", "$", "source", "=", "new", "LocalSourceImageModel", "(", "$", "image", ")", ";", "$", "source", "->", ...
Gets color palette for image @param Asset|string $image @param int $colorCount @param int $quality @param string $colorValue @return array|null
[ "Gets", "color", "palette", "for", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L99-L113
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.isBright
public function isBright($color, $threshold=127.5): bool { $c = color($color); return is_bright($c, $threshold); }
php
public function isBright($color, $threshold=127.5): bool { $c = color($color); return is_bright($c, $threshold); }
[ "public", "function", "isBright", "(", "$", "color", ",", "$", "threshold", "=", "127.5", ")", ":", "bool", "{", "$", "c", "=", "color", "(", "$", "color", ")", ";", "return", "is_bright", "(", "$", "c", ",", "$", "threshold", ")", ";", "}" ]
Checks brightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 127.5. @param string|array $color @param float $threshold @return bool
[ "Checks", "brightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "127", ".", "5", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L158-L162
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.isLight
public function isLight($color, $threshold=50): bool { $c = color($color); return is_light($c, $threshold); }
php
public function isLight($color, $threshold=50): bool { $c = color($color); return is_light($c, $threshold); }
[ "public", "function", "isLight", "(", "$", "color", ",", "$", "threshold", "=", "50", ")", ":", "bool", "{", "$", "c", "=", "color", "(", "$", "color", ")", ";", "return", "is_light", "(", "$", "c", ",", "$", "threshold", ")", ";", "}" ]
Checks lightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 50.0. @param string|array $color @param int $threshold @return bool
[ "Checks", "lightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "50", ".", "0", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L171-L175
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.looksBright
public function looksBright($color, $threshold = 127.5): bool { $c = color($color); return looks_bright($c, $threshold); }
php
public function looksBright($color, $threshold = 127.5): bool { $c = color($color); return looks_bright($c, $threshold); }
[ "public", "function", "looksBright", "(", "$", "color", ",", "$", "threshold", "=", "127.5", ")", ":", "bool", "{", "$", "c", "=", "color", "(", "$", "color", ")", ";", "return", "looks_bright", "(", "$", "c", ",", "$", "threshold", ")", ";", "}" ]
Checks perceived_brightness($color) >= $threshold. Accepts an optional $threshold float as the last parameter with a default of 127.5. @param string|array $color @param float $threshold @return bool
[ "Checks", "perceived_brightness", "(", "$color", ")", ">", "=", "$threshold", ".", "Accepts", "an", "optional", "$threshold", "float", "as", "the", "last", "parameter", "with", "a", "default", "of", "127", ".", "5", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L184-L188
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.getBrightnessDifference
public function getBrightnessDifference($color1, $color2): float { $c1 = color($color1); $c2 = color($color2); return brightness_difference($c1, $c2); }
php
public function getBrightnessDifference($color1, $color2): float { $c1 = color($color1); $c2 = color($color2); return brightness_difference($c1, $c2); }
[ "public", "function", "getBrightnessDifference", "(", "$", "color1", ",", "$", "color2", ")", ":", "float", "{", "$", "c1", "=", "color", "(", "$", "color1", ")", ";", "$", "c2", "=", "color", "(", "$", "color2", ")", ";", "return", "brightness_differe...
Calculates brightness difference (https://www.w3.org/TR/AERT#color-contrast) on a scale from 0 to 255. @param string|array $color1 @param string|array $color2 @return float
[ "Calculates", "brightness", "difference", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "AERT#color", "-", "contrast", ")", "on", "a", "scale", "from", "0", "to", "255", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L233-L238
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.getColorDifference
public function getColorDifference($color1, $color2): int { $c1 = color($color1); $c2 = color($color2); return color_difference($c1, $c2); }
php
public function getColorDifference($color1, $color2): int { $c1 = color($color1); $c2 = color($color2); return color_difference($c1, $c2); }
[ "public", "function", "getColorDifference", "(", "$", "color1", ",", "$", "color2", ")", ":", "int", "{", "$", "c1", "=", "color", "(", "$", "color1", ")", ";", "$", "c2", "=", "color", "(", "$", "color2", ")", ";", "return", "color_difference", "(",...
Calculates color difference (https://www.w3.org/TR/AERT#color-contrast) on a scale from 0 to 765. @param string|array $color1 @param string|array $color2 @return int
[ "Calculates", "color", "difference", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "AERT#color", "-", "contrast", ")", "on", "a", "scale", "from", "0", "to", "765", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L247-L252
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.getContrastRatio
public function getContrastRatio($color1, $color2): float { $c1 = color($color1); $c2 = color($color2); return contrast_ratio($c1, $c2); }
php
public function getContrastRatio($color1, $color2): float { $c1 = color($color1); $c2 = color($color2); return contrast_ratio($c1, $c2); }
[ "public", "function", "getContrastRatio", "(", "$", "color1", ",", "$", "color2", ")", ":", "float", "{", "$", "c1", "=", "color", "(", "$", "color1", ")", ";", "$", "c2", "=", "color", "(", "$", "color2", ")", ";", "return", "contrast_ratio", "(", ...
Calculates the contrast ratio (https://www.w3.org/TR/WCAG20/#contrast-ratiodef) between two colors on a scale from 1 to 21. @param string|array $color1 @param string|array $color2 @return float
[ "Calculates", "the", "contrast", "ratio", "(", "https", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "WCAG20", "/", "#contrast", "-", "ratiodef", ")", "between", "two", "colors", "on", "a", "scale", "from", "1", "to", "21", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L261-L266
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.hex2rgb
public static function hex2rgb($hex): array { $hex = str_replace('#', '', $hex); if (\strlen($hex) === 3) { $r = hexdec($hex[0] . $hex[0]); $g = hexdec($hex[1] . $hex[1]); $b = hexdec($hex[2] . $hex[2]); } else { $r = hexdec($hex[0] . $hex[1])...
php
public static function hex2rgb($hex): array { $hex = str_replace('#', '', $hex); if (\strlen($hex) === 3) { $r = hexdec($hex[0] . $hex[0]); $g = hexdec($hex[1] . $hex[1]); $b = hexdec($hex[2] . $hex[2]); } else { $r = hexdec($hex[0] . $hex[1])...
[ "public", "static", "function", "hex2rgb", "(", "$", "hex", ")", ":", "array", "{", "$", "hex", "=", "str_replace", "(", "'#'", ",", "''", ",", "$", "hex", ")", ";", "if", "(", "\\", "strlen", "(", "$", "hex", ")", "===", "3", ")", "{", "$", ...
Convert hex color to rgb @param string $hex @return array
[ "Convert", "hex", "color", "to", "rgb" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L287-L302
aelvan/Imager-Craft
src/services/ImagerColorService.php
ImagerColorService.paletteToHex
private function paletteToHex($palette): array { $r = []; foreach ($palette as $paletteColor) { $r[] = self::rgb2hex($paletteColor); } return $r; }
php
private function paletteToHex($palette): array { $r = []; foreach ($palette as $paletteColor) { $r[] = self::rgb2hex($paletteColor); } return $r; }
[ "private", "function", "paletteToHex", "(", "$", "palette", ")", ":", "array", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "palette", "as", "$", "paletteColor", ")", "{", "$", "r", "[", "]", "=", "self", "::", "rgb2hex", "(", "$", "pa...
Convert palette to array of hex colors @param array $palette @return array
[ "Convert", "palette", "to", "array", "of", "hex", "colors" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/ImagerColorService.php#L311-L319
aelvan/Imager-Craft
src/models/CraftTransformedImageModel.php
CraftTransformedImageModel.getSize
public function getSize($unit = 'b', $precision = 2) { $unit = strtolower($unit); switch ($unit) { case 'g': case 'gb': return round(((int)$this->size) / 1024 / 1024 / 1024, $precision); case 'm': case 'mb': return roun...
php
public function getSize($unit = 'b', $precision = 2) { $unit = strtolower($unit); switch ($unit) { case 'g': case 'gb': return round(((int)$this->size) / 1024 / 1024 / 1024, $precision); case 'm': case 'mb': return roun...
[ "public", "function", "getSize", "(", "$", "unit", "=", "'b'", ",", "$", "precision", "=", "2", ")", "{", "$", "unit", "=", "strtolower", "(", "$", "unit", ")", ";", "switch", "(", "$", "unit", ")", "{", "case", "'g'", ":", "case", "'gb'", ":", ...
@param string $unit @param int $precision @return float|int
[ "@param", "string", "$unit", "@param", "int", "$precision" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/CraftTransformedImageModel.php#L136-L153
aelvan/Imager-Craft
src/services/PlaceholderService.php
PlaceholderService.placeholder
public function placeholder($config = null): string { $config = array_merge($this->defaults, $config ?? []); switch ($config['type']) { case 'svg': return $this->placeholderSVG($config); case 'gif': return $this->placeholderGIF($config); ...
php
public function placeholder($config = null): string { $config = array_merge($this->defaults, $config ?? []); switch ($config['type']) { case 'svg': return $this->placeholderSVG($config); case 'gif': return $this->placeholderGIF($config); ...
[ "public", "function", "placeholder", "(", "$", "config", "=", "null", ")", ":", "string", "{", "$", "config", "=", "array_merge", "(", "$", "this", "->", "defaults", ",", "$", "config", "??", "[", "]", ")", ";", "switch", "(", "$", "config", "[", "...
Main public placeholder method. @param array|null $config @return string @throws ImagerException
[ "Main", "public", "placeholder", "method", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/PlaceholderService.php#L50-L64
aelvan/Imager-Craft
src/services/PlaceholderService.php
PlaceholderService.placeholderSVG
private function placeholderSVG($config): string { $width = $config['width']; $height = $config['height']; $color = $config['color'] ?? 'transparent'; return 'data:image/svg+xml;charset=utf-8,' . rawurlencode("<svg xmlns='http://www.w3.org/2000/svg' width='$width' height='$height' s...
php
private function placeholderSVG($config): string { $width = $config['width']; $height = $config['height']; $color = $config['color'] ?? 'transparent'; return 'data:image/svg+xml;charset=utf-8,' . rawurlencode("<svg xmlns='http://www.w3.org/2000/svg' width='$width' height='$height' s...
[ "private", "function", "placeholderSVG", "(", "$", "config", ")", ":", "string", "{", "$", "width", "=", "$", "config", "[", "'width'", "]", ";", "$", "height", "=", "$", "config", "[", "'height'", "]", ";", "$", "color", "=", "$", "config", "[", "...
Returns a SVG placeholder @param $config @return string
[ "Returns", "a", "SVG", "placeholder" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/PlaceholderService.php#L72-L79
aelvan/Imager-Craft
src/services/PlaceholderService.php
PlaceholderService.placeholderGIF
private function placeholderGIF($config): string { $width = $config['width']; $height = $config['height']; $color = $config['color'] ?? 'transparent'; if ($width === 1 && $height === 1 && $color === 'transparent') { return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///...
php
private function placeholderGIF($config): string { $width = $config['width']; $height = $config['height']; $color = $config['color'] ?? 'transparent'; if ($width === 1 && $height === 1 && $color === 'transparent') { return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///...
[ "private", "function", "placeholderGIF", "(", "$", "config", ")", ":", "string", "{", "$", "width", "=", "$", "config", "[", "'width'", "]", ";", "$", "height", "=", "$", "config", "[", "'height'", "]", ";", "$", "color", "=", "$", "config", "[", "...
Returns a GIF placeholder. @param $config @return string
[ "Returns", "a", "GIF", "placeholder", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/PlaceholderService.php#L87-L115
aelvan/Imager-Craft
src/services/PlaceholderService.php
PlaceholderService.placeholderSilhuette
private function placeholderSilhuette($config): string { $source = $config['source'] ?? null; $size = $config['size']; $color = $config['color'] ?? '#fefefe'; $fgColor = $config['fgColor'] ?? '#e0e0e0'; $silhouetteType = $config['silhouetteType']; if ($source...
php
private function placeholderSilhuette($config): string { $source = $config['source'] ?? null; $size = $config['size']; $color = $config['color'] ?? '#fefefe'; $fgColor = $config['fgColor'] ?? '#e0e0e0'; $silhouetteType = $config['silhouetteType']; if ($source...
[ "private", "function", "placeholderSilhuette", "(", "$", "config", ")", ":", "string", "{", "$", "source", "=", "$", "config", "[", "'source'", "]", "??", "null", ";", "$", "size", "=", "$", "config", "[", "'size'", "]", ";", "$", "color", "=", "$", ...
Returns a silhouette placeholder. @param $config @return string @throws ImagerException
[ "Returns", "a", "silhouette", "placeholder", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/PlaceholderService.php#L124-L149
aelvan/Imager-Craft
src/services/PlaceholderService.php
PlaceholderService.createImagineInstance
private function createImagineInstance() { $extension = mb_strtolower(\Craft::$app->getConfig()->getGeneral()->imageDriver); try { if ($extension === 'gd') { return new \Imagine\Gd\Imagine(); } if ($extension === 'imagick') { ...
php
private function createImagineInstance() { $extension = mb_strtolower(\Craft::$app->getConfig()->getGeneral()->imageDriver); try { if ($extension === 'gd') { return new \Imagine\Gd\Imagine(); } if ($extension === 'imagick') { ...
[ "private", "function", "createImagineInstance", "(", ")", "{", "$", "extension", "=", "mb_strtolower", "(", "\\", "Craft", "::", "$", "app", "->", "getConfig", "(", ")", "->", "getGeneral", "(", ")", "->", "imageDriver", ")", ";", "try", "{", "if", "(", ...
Creates the Imagine instance depending on the chosen image driver. @return \Imagine\Gd\Imagine|\Imagine\Imagick\Imagine|null
[ "Creates", "the", "Imagine", "instance", "depending", "on", "the", "chosen", "image", "driver", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/services/PlaceholderService.php#L156-L173
aelvan/Imager-Craft
src/helpers/ImgixHelpers.php
ImgixHelpers.getUrlEncodedPath
public static function getUrlEncodedPath($path): string { $entities = array('+', '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); $replacements = array(' ', '!', '*', "'", '(', ')', ';', ':', '@', '&', '=', '+', '$'...
php
public static function getUrlEncodedPath($path): string { $entities = array('+', '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D'); $replacements = array(' ', '!', '*', "'", '(', ')', ';', ':', '@', '&', '=', '+', '$'...
[ "public", "static", "function", "getUrlEncodedPath", "(", "$", "path", ")", ":", "string", "{", "$", "entities", "=", "array", "(", "'+'", ",", "'%21'", ",", "'%2A'", ",", "'%27'", ",", "'%28'", ",", "'%29'", ",", "'%3B'", ",", "'%3A'", ",", "'%40'", ...
URL encode the asset path properly @param string $path @return string
[ "URL", "encode", "the", "asset", "path", "properly" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImgixHelpers.php#L75-L82
aelvan/Imager-Craft
src/effects/ColorizeEffect.php
ColorizeEffect.apply
public static function apply($imageInstance, $params) { if (ImagerService::$imageDriver === 'gd') { $color = $imageInstance->palette()->color($params); $imageInstance->effects()->colorize($color); } if (ImagerService::$imageDriver === 'imagick') { /** @va...
php
public static function apply($imageInstance, $params) { if (ImagerService::$imageDriver === 'gd') { $color = $imageInstance->palette()->color($params); $imageInstance->effects()->colorize($color); } if (ImagerService::$imageDriver === 'imagick') { /** @va...
[ "public", "static", "function", "apply", "(", "$", "imageInstance", ",", "$", "params", ")", "{", "if", "(", "ImagerService", "::", "$", "imageDriver", "===", "'gd'", ")", "{", "$", "color", "=", "$", "imageInstance", "->", "palette", "(", ")", "->", "...
@param GdImage|ImagickImage $imageInstance @param array|string|int|float|null $params @throws \ImagickException @throws \Imagine\Image\Palette\InvalidArgumentException
[ "@param", "GdImage|ImagickImage", "$imageInstance", "@param", "array|string|int|float|null", "$params" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/effects/ColorizeEffect.php#L20-L34
aelvan/Imager-Craft
src/Imager.php
Imager.init
public function init() { parent::init(); self::$plugin = $this; // Register services $this->setComponents([ 'imager' => ImagerService::class, 'placeholder' => PlaceholderService::class, 'color' => ImagerColorService::class, 'imgix' =>...
php
public function init() { parent::init(); self::$plugin = $this; // Register services $this->setComponents([ 'imager' => ImagerService::class, 'placeholder' => PlaceholderService::class, 'color' => ImagerColorService::class, 'imgix' =>...
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "self", "::", "$", "plugin", "=", "$", "this", ";", "// Register services", "$", "this", "->", "setComponents", "(", "[", "'imager'", "=>", "ImagerService", "::", "class"...
=========================================================================
[ "=========================================================================" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/Imager.php#L106-L241
aelvan/Imager-Craft
src/Imager.php
Imager.registerEffects
private function registerEffects() { // Both for GD and Imagick ImagerService::registerEffect('grayscale', GreyscaleEffect::class); ImagerService::registerEffect('greyscale', GreyscaleEffect::class); ImagerService::registerEffect('negative', NegativeEffect::class); ImagerServ...
php
private function registerEffects() { // Both for GD and Imagick ImagerService::registerEffect('grayscale', GreyscaleEffect::class); ImagerService::registerEffect('greyscale', GreyscaleEffect::class); ImagerService::registerEffect('negative', NegativeEffect::class); ImagerServ...
[ "private", "function", "registerEffects", "(", ")", "{", "// Both for GD and Imagick", "ImagerService", "::", "registerEffect", "(", "'grayscale'", ",", "GreyscaleEffect", "::", "class", ")", ";", "ImagerService", "::", "registerEffect", "(", "'greyscale'", ",", "Grey...
Register built-in effects
[ "Register", "built", "-", "in", "effects" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/Imager.php#L254-L278
aelvan/Imager-Craft
src/Imager.php
Imager.registerOptimizers
private function registerOptimizers() { ImagerService::registerOptimizer('jpegoptim', JpegoptimOptimizer::class); ImagerService::registerOptimizer('jpegtran', JpegtranOptimizer::class); ImagerService::registerOptimizer('mozjpeg', MozjpegOptimizer::class); ImagerService::registerOptim...
php
private function registerOptimizers() { ImagerService::registerOptimizer('jpegoptim', JpegoptimOptimizer::class); ImagerService::registerOptimizer('jpegtran', JpegtranOptimizer::class); ImagerService::registerOptimizer('mozjpeg', MozjpegOptimizer::class); ImagerService::registerOptim...
[ "private", "function", "registerOptimizers", "(", ")", "{", "ImagerService", "::", "registerOptimizer", "(", "'jpegoptim'", ",", "JpegoptimOptimizer", "::", "class", ")", ";", "ImagerService", "::", "registerOptimizer", "(", "'jpegtran'", ",", "JpegtranOptimizer", "::...
Register built-in optimizers
[ "Register", "built", "-", "in", "optimizers" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/Imager.php#L283-L294
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.transform
public function transform($image, $transforms) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $sourceModel = new LocalSourceImageModel($image); $transformedImages = []; foreach ($transforms as $transform) { $transformedImages[] = $thi...
php
public function transform($image, $transforms) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $sourceModel = new LocalSourceImageModel($image); $transformedImages = []; foreach ($transforms as $transform) { $transformedImages[] = $thi...
[ "public", "function", "transform", "(", "$", "image", ",", "$", "transforms", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "sourceModel", "=", "new", "LocalSourceImageModel", "(", "$",...
Main transform method @param Asset|string $image @param array $transforms @return array|null @throws ImagerException
[ "Main", "transform", "method" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L80-L114
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.store
public function store(CraftTransformedImageModel $image, bool $isFinalVersion) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if (empty($config->storages)) { return; } $path = $image->path; $uri = str_replace($config->imagerSys...
php
public function store(CraftTransformedImageModel $image, bool $isFinalVersion) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if (empty($config->storages)) { return; } $path = $image->path; $uri = str_replace($config->imagerSys...
[ "public", "function", "store", "(", "CraftTransformedImageModel", "$", "image", ",", "bool", "$", "isFinalVersion", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "if", "(", "empty", "(", "$"...
Store transformed image in configured storages @param CraftTransformedImageModel $image @param bool $isFinalVersion @throws ImagerException
[ "Store", "transformed", "image", "in", "configured", "storages" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L124-L159
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.getTransformedImage
private function getTransformedImage($sourceModel, $transform) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($config->getSetting('noop', $transform)) { // todo : just return source image unmodified } if ($this->imagineInstance ===...
php
private function getTransformedImage($sourceModel, $transform) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($config->getSetting('noop', $transform)) { // todo : just return source image unmodified } if ($this->imagineInstance ===...
[ "private", "function", "getTransformedImage", "(", "$", "sourceModel", ",", "$", "transform", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "if", "(", "$", "config", "->", "getSetting", "(",...
Gets one transformed image based on source image and transform @param LocalSourceImageModel $sourceModel @param array $transform @return CraftTransformedImageModel|null @throws ImagerException
[ "Gets", "one", "transformed", "image", "based", "on", "source", "image", "and", "transform" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L174-L323
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.transformLayer
private function transformLayer(&$layer, $transform, $sourceExtension) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // Apply any pre resize filters if (isset($transform['preEffects'])) { $this->applyEffects($layer, $transform['preEffects']); ...
php
private function transformLayer(&$layer, $transform, $sourceExtension) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // Apply any pre resize filters if (isset($transform['preEffects'])) { $this->applyEffects($layer, $transform['preEffects']); ...
[ "private", "function", "transformLayer", "(", "&", "$", "layer", ",", "$", "transform", ",", "$", "sourceExtension", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "// Apply any pre resize filter...
Apply transforms to an image or layer. @param GdImage|ImagickImage $layer @param array $transform @param string $sourceExtension @throws ImagerException
[ "Apply", "transforms", "to", "an", "image", "or", "layer", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L334-L400
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.createImagineInstance
private function createImagineInstance() { try { if (ImagerService::$imageDriver === 'gd') { return new \Imagine\Gd\Imagine(); } if (ImagerService::$imageDriver === 'imagick') { return new \Imagine\Imagick\Imagine(); } ...
php
private function createImagineInstance() { try { if (ImagerService::$imageDriver === 'gd') { return new \Imagine\Gd\Imagine(); } if (ImagerService::$imageDriver === 'imagick') { return new \Imagine\Imagick\Imagine(); } ...
[ "private", "function", "createImagineInstance", "(", ")", "{", "try", "{", "if", "(", "ImagerService", "::", "$", "imageDriver", "===", "'gd'", ")", "{", "return", "new", "\\", "Imagine", "\\", "Gd", "\\", "Imagine", "(", ")", ";", "}", "if", "(", "Ima...
Creates the Imagine instance depending on the chosen image driver. @return \Imagine\Gd\Imagine|\Imagine\Imagick\Imagine|null
[ "Creates", "the", "Imagine", "instance", "depending", "on", "the", "chosen", "image", "driver", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L407-L422
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.getFilterMethod
private function getFilterMethod($transform): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); return ImagerService::$imageDriver === 'imagick' ? ImagerService::$filterKeyTranslate[(string)$config->getSetting('resizeFilter', $transform)] : ImageInterface::FIL...
php
private function getFilterMethod($transform): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); return ImagerService::$imageDriver === 'imagick' ? ImagerService::$filterKeyTranslate[(string)$config->getSetting('resizeFilter', $transform)] : ImageInterface::FIL...
[ "private", "function", "getFilterMethod", "(", "$", "transform", ")", ":", "string", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "return", "ImagerService", "::", "$", "imageDriver", "===", "'imag...
Returns the filter method for resize operations @param array $transform @return string
[ "Returns", "the", "filter", "method", "for", "resize", "operations" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L431-L437
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.saveAsWebp
private function saveAsWebp($imageInstance, $path, $sourceExtension, $saveOptions) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($config->getSetting('useCwebp')) { // Save temp file $tempFile = $this->saveTemporaryFile($imageInstance,...
php
private function saveAsWebp($imageInstance, $path, $sourceExtension, $saveOptions) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($config->getSetting('useCwebp')) { // Save temp file $tempFile = $this->saveTemporaryFile($imageInstance,...
[ "private", "function", "saveAsWebp", "(", "$", "imageInstance", ",", "$", "path", ",", "$", "sourceExtension", ",", "$", "saveOptions", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "if", ...
Saves image as webp @param GdImage|ImagickImage $imageInstance @param string $path @param string $sourceExtension @param array $saveOptions @throws ImagerException
[ "Saves", "image", "as", "webp" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L450-L514
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.saveTemporaryFile
private function saveTemporaryFile($imageInstance, $sourceExtension): string { $tempPath = Craft::$app->getPath()->getRuntimePath().'imager/temp/'; // Check if the path exists if (!realpath($tempPath)) { try { FileHelper::createDirectory($tempPath); }...
php
private function saveTemporaryFile($imageInstance, $sourceExtension): string { $tempPath = Craft::$app->getPath()->getRuntimePath().'imager/temp/'; // Check if the path exists if (!realpath($tempPath)) { try { FileHelper::createDirectory($tempPath); }...
[ "private", "function", "saveTemporaryFile", "(", "$", "imageInstance", ",", "$", "sourceExtension", ")", ":", "string", "{", "$", "tempPath", "=", "Craft", "::", "$", "app", "->", "getPath", "(", ")", "->", "getRuntimePath", "(", ")", ".", "'imager/temp/'", ...
Save temporary file and return filename @param GdImage|ImagickImage $imageInstance @param string $sourceExtension @return string @throws ImagerException
[ "Save", "temporary", "file", "and", "return", "filename" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L526-L556
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.getSaveOptions
private function getSaveOptions($extension, $transform): array { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); switch (mb_strtolower($extension)) { case 'jpg': case 'jpeg': return ['jpeg_quality' => $config->getSetting('jpegQ...
php
private function getSaveOptions($extension, $transform): array { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); switch (mb_strtolower($extension)) { case 'jpg': case 'jpeg': return ['jpeg_quality' => $config->getSetting('jpegQ...
[ "private", "function", "getSaveOptions", "(", "$", "extension", ",", "$", "transform", ")", ":", "array", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "switch", "(", "mb_strtolower", "(", "$", ...
Get the save options based on extension and transform @param string $extension @param array $transform @return array
[ "Get", "the", "save", "options", "based", "on", "extension", "and", "transform" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L566-L584
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.applyLetterbox
private function applyLetterbox(&$imageInstance, $transform) { if (isset($transform['width'], $transform['height'])) { // if both isn't set, there's no need for a letterbox /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $letterboxDef = $config->g...
php
private function applyLetterbox(&$imageInstance, $transform) { if (isset($transform['width'], $transform['height'])) { // if both isn't set, there's no need for a letterbox /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $letterboxDef = $config->g...
[ "private", "function", "applyLetterbox", "(", "&", "$", "imageInstance", ",", "$", "transform", ")", "{", "if", "(", "isset", "(", "$", "transform", "[", "'width'", "]", ",", "$", "transform", "[", "'height'", "]", ")", ")", "{", "// if both isn't set, the...
Apply letterbox to image @param GdImage|ImagickImage|ImageInterface $imageInstance @param array $transform @throws ImagerException
[ "Apply", "letterbox", "to", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L594-L626
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.applyBackgroundColor
private function applyBackgroundColor(&$imageInstance, $bgColor) { $palette = new RGB(); $color = $palette->color($bgColor); try { $topLeft = new Point(0, 0); } catch (InvalidArgumentException $e) { Craft::error($e->getMessage(), __METHOD__); thro...
php
private function applyBackgroundColor(&$imageInstance, $bgColor) { $palette = new RGB(); $color = $palette->color($bgColor); try { $topLeft = new Point(0, 0); } catch (InvalidArgumentException $e) { Craft::error($e->getMessage(), __METHOD__); thro...
[ "private", "function", "applyBackgroundColor", "(", "&", "$", "imageInstance", ",", "$", "bgColor", ")", "{", "$", "palette", "=", "new", "RGB", "(", ")", ";", "$", "color", "=", "$", "palette", "->", "color", "(", "$", "bgColor", ")", ";", "try", "{...
Apply background color to image when converting from transparent to non-transparent @param GdImage|ImagickImage|ImageInterface $imageInstance @param string $bgColor @throws ImagerException
[ "Apply", "background", "color", "to", "image", "when", "converting", "from", "transparent", "to", "non", "-", "transparent" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L636-L653
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.applyWatermark
private function applyWatermark($imageInstance, $watermark) { if (!isset($watermark['image'])) { $msg = Craft::t('imager', 'Watermark image property not set'); Craft::error($msg, __METHOD__); throw new ImagerException($msg); } if (!isset($watermark['width...
php
private function applyWatermark($imageInstance, $watermark) { if (!isset($watermark['image'])) { $msg = Craft::t('imager', 'Watermark image property not set'); Craft::error($msg, __METHOD__); throw new ImagerException($msg); } if (!isset($watermark['width...
[ "private", "function", "applyWatermark", "(", "$", "imageInstance", ",", "$", "watermark", ")", "{", "if", "(", "!", "isset", "(", "$", "watermark", "[", "'image'", "]", ")", ")", "{", "$", "msg", "=", "Craft", "::", "t", "(", "'imager'", ",", "'Wate...
Apply watermark to image @param GdImage|ImagickImage|ImageInterface $imageInstance @param array $watermark @throws ImagerException
[ "Apply", "watermark", "to", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L663-L761
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.applyEffects
private function applyEffects($image, $effects) { foreach ($effects as $effect => $value) { $effect = mb_strtolower($effect); if (isset(ImagerService::$effects[$effect])) { /** @var ImagerEffectsInterface $effectClass */ $effectClass = ImagerService::...
php
private function applyEffects($image, $effects) { foreach ($effects as $effect => $value) { $effect = mb_strtolower($effect); if (isset(ImagerService::$effects[$effect])) { /** @var ImagerEffectsInterface $effectClass */ $effectClass = ImagerService::...
[ "private", "function", "applyEffects", "(", "$", "image", ",", "$", "effects", ")", "{", "foreach", "(", "$", "effects", "as", "$", "effect", "=>", "$", "value", ")", "{", "$", "effect", "=", "mb_strtolower", "(", "$", "effect", ")", ";", "if", "(", ...
Applies effects to image. @param GdImage|ImagickImage $image @param array $effects
[ "Applies", "effects", "to", "image", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L769-L780
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.getFramesVars
private function getFramesVars($layers, $transform): array { $startFrame = 0; $endFrame = \count($layers) - 1; $interval = 1; if (isset($transform['frames'])) { $framesIntArr = explode('@', $transform['frames']); if (\count($framesIntArr) > 1) { ...
php
private function getFramesVars($layers, $transform): array { $startFrame = 0; $endFrame = \count($layers) - 1; $interval = 1; if (isset($transform['frames'])) { $framesIntArr = explode('@', $transform['frames']); if (\count($framesIntArr) > 1) { ...
[ "private", "function", "getFramesVars", "(", "$", "layers", ",", "$", "transform", ")", ":", "array", "{", "$", "startFrame", "=", "0", ";", "$", "endFrame", "=", "\\", "count", "(", "$", "layers", ")", "-", "1", ";", "$", "interval", "=", "1", ";"...
Get vars for animated gif frames setup @param LayersInterface|array $layers @param array $transform @return array
[ "Get", "vars", "for", "animated", "gif", "frames", "setup" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L790-L820
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.optimize
private function optimize($transformedImage): bool { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // If there are no enabled optimizers, exit now if (empty($config->optimizers)) { return true; } $jobCreated = false; for...
php
private function optimize($transformedImage): bool { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // If there are no enabled optimizers, exit now if (empty($config->optimizers)) { return true; } $jobCreated = false; for...
[ "private", "function", "optimize", "(", "$", "transformedImage", ")", ":", "bool", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "// If there are no enabled optimizers, exit now", "if", "(", "empty", "...
Post optimizations @param CraftTransformedImageModel $transformedImage @return bool Return if the image is the final version or not. If a task was set up, it's not.
[ "Post", "optimizations" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L829-L867
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.shouldOptimizeByExtension
private function shouldOptimizeByExtension(string $extension, array $validExtensions): bool { return \in_array($extension === 'jpeg' ? 'jpg' : $extension, $validExtensions, true); }
php
private function shouldOptimizeByExtension(string $extension, array $validExtensions): bool { return \in_array($extension === 'jpeg' ? 'jpg' : $extension, $validExtensions, true); }
[ "private", "function", "shouldOptimizeByExtension", "(", "string", "$", "extension", ",", "array", "$", "validExtensions", ")", ":", "bool", "{", "return", "\\", "in_array", "(", "$", "extension", "===", "'jpeg'", "?", "'jpg'", ":", "$", "extension", ",", "$...
Checks if extension is in array of extensions @param string $extension @param array $validExtensions @return bool
[ "Checks", "if", "extension", "is", "in", "array", "of", "extensions" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L877-L880
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.createOptimizeJob
private function createOptimizeJob(string $handle, string $filePath, array $settings) { $queue = Craft::$app->getQueue(); $jobId = $queue->push(new OptimizeJob([ 'description' => Craft::t('imager', 'Optimizing images ('.$handle.')'), 'optimizer' => $handle, 'opti...
php
private function createOptimizeJob(string $handle, string $filePath, array $settings) { $queue = Craft::$app->getQueue(); $jobId = $queue->push(new OptimizeJob([ 'description' => Craft::t('imager', 'Optimizing images ('.$handle.')'), 'optimizer' => $handle, 'opti...
[ "private", "function", "createOptimizeJob", "(", "string", "$", "handle", ",", "string", "$", "filePath", ",", "array", "$", "settings", ")", "{", "$", "queue", "=", "Craft", "::", "$", "app", "->", "getQueue", "(", ")", ";", "$", "jobId", "=", "$", ...
Creates optimize queue job @param string $handle @param string $filePath @param array $settings
[ "Creates", "optimize", "queue", "job" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L889-L901
aelvan/Imager-Craft
src/transformers/CraftTransformer.php
CraftTransformer.triggerQueueNow
private function triggerQueueNow() { $url = UrlHelper::actionUrl('queue/run'); if (\function_exists('curl_init')) { $ch = curl_init($url); $options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => false, CURLOPT_N...
php
private function triggerQueueNow() { $url = UrlHelper::actionUrl('queue/run'); if (\function_exists('curl_init')) { $ch = curl_init($url); $options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => false, CURLOPT_N...
[ "private", "function", "triggerQueueNow", "(", ")", "{", "$", "url", "=", "UrlHelper", "::", "actionUrl", "(", "'queue/run'", ")", ";", "if", "(", "\\", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "url", ...
Trigger queue/run immediately
[ "Trigger", "queue", "/", "run", "immediately" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/CraftTransformer.php#L906-L929
aelvan/Imager-Craft
src/models/LocalTargetImageModel.php
LocalTargetImageModel.createTargetFilename
private function createTargetFilename($source, $transform): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $useFilenamePattern = $config->getSetting('useFilenamePattern', $transform); $hashFilename = $config->getSetting('hashFilename', $transform); ...
php
private function createTargetFilename($source, $transform): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $useFilenamePattern = $config->getSetting('useFilenamePattern', $transform); $hashFilename = $config->getSetting('hashFilename', $transform); ...
[ "private", "function", "createTargetFilename", "(", "$", "source", ",", "$", "transform", ")", ":", "string", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "useFilenamePattern", "=", "$", "c...
Creates target filename base on source and transform @param LocalSourceImageModel $source @param array $transform @return string
[ "Creates", "target", "filename", "base", "on", "source", "and", "transform" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalTargetImageModel.php#L70-L127
aelvan/Imager-Craft
src/transformers/ImgixTransformer.php
ImgixTransformer.transform
public function transform($image, $transforms) { $transformedImages = []; foreach ($transforms as $transform) { $transformedImages[] = $this->getTransformedImage($image, $transform); } return $transformedImages; }
php
public function transform($image, $transforms) { $transformedImages = []; foreach ($transforms as $transform) { $transformedImages[] = $this->getTransformedImage($image, $transform); } return $transformedImages; }
[ "public", "function", "transform", "(", "$", "image", ",", "$", "transforms", ")", "{", "$", "transformedImages", "=", "[", "]", ";", "foreach", "(", "$", "transforms", "as", "$", "transform", ")", "{", "$", "transformedImages", "[", "]", "=", "$", "th...
Main transform method @param Asset|string $image @param array $transforms @return array|null @throws ImagerException
[ "Main", "transform", "method" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/ImgixTransformer.php#L68-L77
aelvan/Imager-Craft
src/transformers/ImgixTransformer.php
ImgixTransformer.getTransformedImage
private function getTransformedImage($image, $transform): ImgixTransformedImageModel { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $profile = $config->getSetting('imgixProfile', $transform); $imgixConfigArr = $config->getSetting('imgixConfig', $transform)...
php
private function getTransformedImage($image, $transform): ImgixTransformedImageModel { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $profile = $config->getSetting('imgixProfile', $transform); $imgixConfigArr = $config->getSetting('imgixConfig', $transform)...
[ "private", "function", "getTransformedImage", "(", "$", "image", ",", "$", "transform", ")", ":", "ImgixTransformedImageModel", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "profile", "=", "$...
Transform one image @param Asset|string $image @param array $transform @return ImgixTransformedImageModel @throws ImagerException
[ "Transform", "one", "image" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/ImgixTransformer.php#L89-L135
aelvan/Imager-Craft
src/transformers/ImgixTransformer.php
ImgixTransformer.createParams
private function createParams($transform, $image, $imgixConfig): array { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $r = []; // Merge in default values if (\is_array($imgixConfig->defaultParams)) { $transform = array_merge($imgixConf...
php
private function createParams($transform, $image, $imgixConfig): array { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $r = []; // Merge in default values if (\is_array($imgixConfig->defaultParams)) { $transform = array_merge($imgixConf...
[ "private", "function", "createParams", "(", "$", "transform", ",", "$", "image", ",", "$", "imgixConfig", ")", ":", "array", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "r", "=", "[", ...
Create Imgix transform params @param array $transform @param Asset|string $image @param ImgixSettings $imgixConfig @return array
[ "Create", "Imgix", "transform", "params" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/ImgixTransformer.php#L146-L298
aelvan/Imager-Craft
src/transformers/ImgixTransformer.php
ImgixTransformer.getLetterboxColor
private function getLetterboxColor($letterboxDef): string { $color = $letterboxDef['color']; $opacity = $letterboxDef['opacity']; $color = str_replace('#', '', $color); if (\strlen($color) === 3) { $opacity = dechex($opacity * 15); return $opacity.$color; ...
php
private function getLetterboxColor($letterboxDef): string { $color = $letterboxDef['color']; $opacity = $letterboxDef['opacity']; $color = str_replace('#', '', $color); if (\strlen($color) === 3) { $opacity = dechex($opacity * 15); return $opacity.$color; ...
[ "private", "function", "getLetterboxColor", "(", "$", "letterboxDef", ")", ":", "string", "{", "$", "color", "=", "$", "letterboxDef", "[", "'color'", "]", ";", "$", "opacity", "=", "$", "letterboxDef", "[", "'opacity'", "]", ";", "$", "color", "=", "str...
Gets letterbox params string @param $letterboxDef @return string
[ "Gets", "letterbox", "params", "string" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/ImgixTransformer.php#L321-L349
aelvan/Imager-Craft
src/transformers/ImgixTransformer.php
ImgixTransformer.getQualityFromExtension
private function getQualityFromExtension($ext, $transform = null): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); switch ($ext) { case 'png': $pngCompression = $config->getSetting('pngCompressionLevel', $transform); ...
php
private function getQualityFromExtension($ext, $transform = null): string { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); switch ($ext) { case 'png': $pngCompression = $config->getSetting('pngCompressionLevel', $transform); ...
[ "private", "function", "getQualityFromExtension", "(", "$", "ext", ",", "$", "transform", "=", "null", ")", ":", "string", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "switch", "(", "$", "ext...
Gets the quality setting based on the extension. @param string $ext @param array|null $transform @return string
[ "Gets", "the", "quality", "setting", "based", "on", "the", "extension", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/transformers/ImgixTransformer.php#L359-L375
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.init
private function init($image) { /** @var ConfigModel $settings */ $settings = ImagerService::getConfig(); if (\is_string($image)) { if (strncmp($image, $settings->imagerUrl, \strlen($settings->imagerUrl)) === 0) { // Url to a file that is in the imager library ...
php
private function init($image) { /** @var ConfigModel $settings */ $settings = ImagerService::getConfig(); if (\is_string($image)) { if (strncmp($image, $settings->imagerUrl, \strlen($settings->imagerUrl)) === 0) { // Url to a file that is in the imager library ...
[ "private", "function", "init", "(", "$", "image", ")", "{", "/** @var ConfigModel $settings */", "$", "settings", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "if", "(", "\\", "is_string", "(", "$", "image", ")", ")", "{", "if", "(", "strncmp", ...
Init method @param $image @throws ImagerException
[ "Init", "method" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L71-L122
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getLocalCopy
public function getLocalCopy() { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($this->type !== 'local') { if (!file_exists($this->getFilePath()) || (($config->cacheDurationRemoteFiles !== false) && ((FileHelper::lastModifiedTime($this->getFilePath()...
php
public function getLocalCopy() { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); if ($this->type !== 'local') { if (!file_exists($this->getFilePath()) || (($config->cacheDurationRemoteFiles !== false) && ((FileHelper::lastModifiedTime($this->getFilePath()...
[ "public", "function", "getLocalCopy", "(", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "if", "(", "$", "this", "->", "type", "!==", "'local'", ")", "{", "if", "(", "!", "file_exists", ...
Get a local copy of source file @throws ImagerException
[ "Get", "a", "local", "copy", "of", "source", "file" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L137-L171
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getPathsForLocalAsset
private function getPathsForLocalAsset(Asset $image) { /** @var LocalVolumeInterface $volume */ try { $volume = $image->getVolume(); $this->transformPath = ImagerHelpers::getTransformPathForAsset($image); } catch (InvalidConfigException $e) { Craft::error(...
php
private function getPathsForLocalAsset(Asset $image) { /** @var LocalVolumeInterface $volume */ try { $volume = $image->getVolume(); $this->transformPath = ImagerHelpers::getTransformPathForAsset($image); } catch (InvalidConfigException $e) { Craft::error(...
[ "private", "function", "getPathsForLocalAsset", "(", "Asset", "$", "image", ")", "{", "/** @var LocalVolumeInterface $volume */", "try", "{", "$", "volume", "=", "$", "image", "->", "getVolume", "(", ")", ";", "$", "this", "->", "transformPath", "=", "ImagerHelp...
Get paths for a local asset @param Asset $image @throws ImagerException
[ "Get", "paths", "for", "a", "local", "asset" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L181-L197
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getPathsForVolumeAsset
private function getPathsForVolumeAsset($image) { try { $this->transformPath = ImagerHelpers::getTransformPathForAsset($image); } catch (InvalidConfigException $e) { Craft::error($e->getMessage(), __METHOD__); throw new ImagerException($e->getMessage(), $e->getCod...
php
private function getPathsForVolumeAsset($image) { try { $this->transformPath = ImagerHelpers::getTransformPathForAsset($image); } catch (InvalidConfigException $e) { Craft::error($e->getMessage(), __METHOD__); throw new ImagerException($e->getMessage(), $e->getCod...
[ "private", "function", "getPathsForVolumeAsset", "(", "$", "image", ")", "{", "try", "{", "$", "this", "->", "transformPath", "=", "ImagerHelpers", "::", "getTransformPathForAsset", "(", "$", "image", ")", ";", "}", "catch", "(", "InvalidConfigException", "$", ...
Get paths for an asset on an external Craft volume. @param Asset $image @throws ImagerException
[ "Get", "paths", "for", "an", "asset", "on", "an", "external", "Craft", "volume", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L206-L229
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getPathsForLocalImagerFile
private function getPathsForLocalImagerFile($image) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $imageString = '/'.str_replace($config->getSetting('imagerUrl'), '', $image); $pathParts = pathinfo($imageString); $this->transformPath = $pathPart...
php
private function getPathsForLocalImagerFile($image) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $imageString = '/'.str_replace($config->getSetting('imagerUrl'), '', $image); $pathParts = pathinfo($imageString); $this->transformPath = $pathPart...
[ "private", "function", "getPathsForLocalImagerFile", "(", "$", "image", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "imageString", "=", "'/'", ".", "str_replace", "(", "$", "config", ...
Get paths for a local file that's in the imager path @param $image
[ "Get", "paths", "for", "a", "local", "file", "that", "s", "in", "the", "imager", "path" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L236-L251
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getPathsForLocalFile
private function getPathsForLocalFile($image) { $this->transformPath = ImagerHelpers::getTransformPathForPath($image); $pathParts = pathinfo($image); $this->path = FileHelper::normalizePath(Yii::getAlias('@webroot').'/'.$pathParts['dirname']); $this->url = $image; $this->fil...
php
private function getPathsForLocalFile($image) { $this->transformPath = ImagerHelpers::getTransformPathForPath($image); $pathParts = pathinfo($image); $this->path = FileHelper::normalizePath(Yii::getAlias('@webroot').'/'.$pathParts['dirname']); $this->url = $image; $this->fil...
[ "private", "function", "getPathsForLocalFile", "(", "$", "image", ")", "{", "$", "this", "->", "transformPath", "=", "ImagerHelpers", "::", "getTransformPathForPath", "(", "$", "image", ")", ";", "$", "pathParts", "=", "pathinfo", "(", "$", "image", ")", ";"...
Get paths for a local file that's not in the imager path @param $image
[ "Get", "paths", "for", "a", "local", "file", "that", "s", "not", "in", "the", "imager", "path" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L258-L268
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.getPathsForUrl
private function getPathsForUrl($image) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/'; $convertedImageStr = StringHelper::toAscii(urldecode($image)); $this->transformPath = I...
php
private function getPathsForUrl($image) { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); $runtimeImagerPath = Craft::$app->getPath()->getRuntimePath().'/imager/'; $convertedImageStr = StringHelper::toAscii(urldecode($image)); $this->transformPath = I...
[ "private", "function", "getPathsForUrl", "(", "$", "image", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "$", "runtimeImagerPath", "=", "Craft", "::", "$", "app", "->", "getPath", "(", ")...
Get paths for an external file (really external, or on an external source type) @param $image @throws ImagerException
[ "Get", "paths", "for", "an", "external", "file", "(", "really", "external", "or", "on", "an", "external", "source", "type", ")" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L277-L302
aelvan/Imager-Craft
src/models/LocalSourceImageModel.php
LocalSourceImageModel.downloadFile
private function downloadFile() { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // url encode filename to account for non-ascii characters in filenames. $imageUrlArr = explode('?', $this->url); $imageUrlArr[0] = preg_replace_callback('#://([^/]+)/(...
php
private function downloadFile() { /** @var ConfigModel $settings */ $config = ImagerService::getConfig(); // url encode filename to account for non-ascii characters in filenames. $imageUrlArr = explode('?', $this->url); $imageUrlArr[0] = preg_replace_callback('#://([^/]+)/(...
[ "private", "function", "downloadFile", "(", ")", "{", "/** @var ConfigModel $settings */", "$", "config", "=", "ImagerService", "::", "getConfig", "(", ")", ";", "// url encode filename to account for non-ascii characters in filenames.", "$", "imageUrlArr", "=", "explode", ...
Downloads an external url and places it in the source path. @throws ImagerException
[ "Downloads", "an", "external", "url", "and", "places", "it", "in", "the", "source", "path", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/LocalSourceImageModel.php#L309-L373
aelvan/Imager-Craft
src/models/ConfigModel.php
ConfigModel.getSetting
public function getSetting($key, $transform = null) { if (isset($transform[$key])) { return $transform[$key]; } return $this[$key]; }
php
public function getSetting($key, $transform = null) { if (isset($transform[$key])) { return $transform[$key]; } return $this[$key]; }
[ "public", "function", "getSetting", "(", "$", "key", ",", "$", "transform", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "transform", "[", "$", "key", "]", ")", ")", "{", "return", "$", "transform", "[", "$", "key", "]", ";", "}", "return...
Get setting by key. If there is an override in transform, that is returned instead of the value in the model. @param string $key @param array|null $transform @return mixed
[ "Get", "setting", "by", "key", ".", "If", "there", "is", "an", "override", "in", "transform", "that", "is", "returned", "instead", "of", "the", "value", "in", "the", "model", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/ConfigModel.php#L67-L74
aelvan/Imager-Craft
src/models/ConfigModel.php
ConfigModel.addToOverrideFilestring
private function addToOverrideFilestring($key, $value) { $r = (ImagerService::$transformKeyTranslate[$key] ?? $key).(\is_array($value) ? md5(implode('-', $value)) : $value); $this->configOverrideString .= '_'.str_replace('%', '', str_replace([' ', '.'], '-', $r)); }
php
private function addToOverrideFilestring($key, $value) { $r = (ImagerService::$transformKeyTranslate[$key] ?? $key).(\is_array($value) ? md5(implode('-', $value)) : $value); $this->configOverrideString .= '_'.str_replace('%', '', str_replace([' ', '.'], '-', $r)); }
[ "private", "function", "addToOverrideFilestring", "(", "$", "key", ",", "$", "value", ")", "{", "$", "r", "=", "(", "ImagerService", "::", "$", "transformKeyTranslate", "[", "$", "key", "]", "??", "$", "key", ")", ".", "(", "\\", "is_array", "(", "$", ...
Creates additional file string based on config overrides that is appended to filename @param string $key @param mixed $value
[ "Creates", "additional", "file", "string", "based", "on", "config", "overrides", "that", "is", "appended", "to", "filename" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/ConfigModel.php#L92-L96
aelvan/Imager-Craft
src/traits/RunShellCommandTrait.php
RunShellCommandTrait.runShellCommand
private static function runShellCommand($commandString): string { $shellCommand = new Command(); $shellCommand->setCommand($commandString); if ($shellCommand->execute()) { $result = $shellCommand->getOutput(); } else { $result = $shellCommand->getError(); ...
php
private static function runShellCommand($commandString): string { $shellCommand = new Command(); $shellCommand->setCommand($commandString); if ($shellCommand->execute()) { $result = $shellCommand->getOutput(); } else { $result = $shellCommand->getError(); ...
[ "private", "static", "function", "runShellCommand", "(", "$", "commandString", ")", ":", "string", "{", "$", "shellCommand", "=", "new", "Command", "(", ")", ";", "$", "shellCommand", "->", "setCommand", "(", "$", "commandString", ")", ";", "if", "(", "$",...
Runs a shell command through mikehaertl\shellcommand @param $commandString @return string
[ "Runs", "a", "shell", "command", "through", "mikehaertl", "\\", "shellcommand" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/traits/RunShellCommandTrait.php#L17-L29
aelvan/Imager-Craft
src/effects/ColorBlendEffect.php
ColorBlendEffect.colorBlend
private static function colorBlend($imagickInstance, $color, $alpha = 1, $composite_flag = \Imagick::COMPOSITE_COLORIZE) { $draw = new \ImagickDraw(); $draw->setFillColor($color); $width = $imagickInstance->getImageWidth(); $height = $imagickInstance->getImageHeight(); $dra...
php
private static function colorBlend($imagickInstance, $color, $alpha = 1, $composite_flag = \Imagick::COMPOSITE_COLORIZE) { $draw = new \ImagickDraw(); $draw->setFillColor($color); $width = $imagickInstance->getImageWidth(); $height = $imagickInstance->getImageHeight(); $dra...
[ "private", "static", "function", "colorBlend", "(", "$", "imagickInstance", ",", "$", "color", ",", "$", "alpha", "=", "1", ",", "$", "composite_flag", "=", "\\", "Imagick", "::", "COMPOSITE_COLORIZE", ")", "{", "$", "draw", "=", "new", "\\", "ImagickDraw"...
Color blend filter, more advanced version of colorize. Code by olav@redwall.ee on http://php.net/manual/en/imagick.colorizeimage.php @param Imagick $imagickInstance @param $color @param int|float $alpha @param int $composite_flag
[ "Color", "blend", "filter", "more", "advanced", "version", "of", "colorize", "." ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/effects/ColorBlendEffect.php#L46-L81
aelvan/Imager-Craft
src/elementactions/ClearTransformsElementAction.php
ClearTransformsElementAction.performAction
public function performAction(ElementQueryInterface $query): bool { try { foreach ($query->all() as $asset) { Plugin::$plugin->imager->removeTransformsForAsset($asset); } } catch (Exception $exception) { $this->setMessage($exception->getMessage());...
php
public function performAction(ElementQueryInterface $query): bool { try { foreach ($query->all() as $asset) { Plugin::$plugin->imager->removeTransformsForAsset($asset); } } catch (Exception $exception) { $this->setMessage($exception->getMessage());...
[ "public", "function", "performAction", "(", "ElementQueryInterface", "$", "query", ")", ":", "bool", "{", "try", "{", "foreach", "(", "$", "query", "->", "all", "(", ")", "as", "$", "asset", ")", "{", "Plugin", "::", "$", "plugin", "->", "imager", "->"...
Clears transforms for selected assets @param ElementQueryInterface $query @return bool
[ "Clears", "transforms", "for", "selected", "assets" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/elementactions/ClearTransformsElementAction.php#L38-L51
aelvan/Imager-Craft
src/models/ImgixTransformedImageModel.php
ImgixTransformedImageModel.getSourceImageDimensions
protected function getSourceImageDimensions($source): array { if ($source instanceof Asset) { return [$source->getWidth(), $source->getHeight()]; } if ($this->profileConfig !== null && $this->profileConfig->getExternalImageDimensions) { $sourceModel = new LocalSource...
php
protected function getSourceImageDimensions($source): array { if ($source instanceof Asset) { return [$source->getWidth(), $source->getHeight()]; } if ($this->profileConfig !== null && $this->profileConfig->getExternalImageDimensions) { $sourceModel = new LocalSource...
[ "protected", "function", "getSourceImageDimensions", "(", "$", "source", ")", ":", "array", "{", "if", "(", "$", "source", "instanceof", "Asset", ")", "{", "return", "[", "$", "source", "->", "getWidth", "(", ")", ",", "$", "source", "->", "getHeight", "...
@param $source @return array @throws ImagerException
[ "@param", "$source" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/ImgixTransformedImageModel.php#L110-L126
aelvan/Imager-Craft
src/models/ImgixTransformedImageModel.php
ImgixTransformedImageModel.calculateTargetSize
protected function calculateTargetSize($params, $sourceWidth, $sourceHeight): array { $fit = $params['fit']; // clamp, clip, crop, facearea, fill, fillmax, max, min, and scale. $ratio = $sourceWidth / $sourceHeight; $w = $params['w'] ?? null; $h = $params['h'] ?? null; swi...
php
protected function calculateTargetSize($params, $sourceWidth, $sourceHeight): array { $fit = $params['fit']; // clamp, clip, crop, facearea, fill, fillmax, max, min, and scale. $ratio = $sourceWidth / $sourceHeight; $w = $params['w'] ?? null; $h = $params['h'] ?? null; swi...
[ "protected", "function", "calculateTargetSize", "(", "$", "params", ",", "$", "sourceWidth", ",", "$", "sourceHeight", ")", ":", "array", "{", "$", "fit", "=", "$", "params", "[", "'fit'", "]", ";", "// clamp, clip, crop, facearea, fill, fillmax, max, min, and scale...
@param $params @param $sourceWidth @param $sourceHeight @return array
[ "@param", "$params", "@param", "$sourceWidth", "@param", "$sourceHeight" ]
train
https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/models/ImgixTransformedImageModel.php#L135-L172
grpc/grpc-php
src/lib/BaseStub.php
BaseStub.getDefaultChannel
public static function getDefaultChannel($hostname, array $opts) { $channel_opts = self::updateOpts($opts); return new Channel($hostname, $opts); }
php
public static function getDefaultChannel($hostname, array $opts) { $channel_opts = self::updateOpts($opts); return new Channel($hostname, $opts); }
[ "public", "static", "function", "getDefaultChannel", "(", "$", "hostname", ",", "array", "$", "opts", ")", "{", "$", "channel_opts", "=", "self", "::", "updateOpts", "(", "$", "opts", ")", ";", "return", "new", "Channel", "(", "$", "hostname", ",", "$", ...
Creates and returns the default Channel @param array $opts Channel constructor options @return Channel The channel
[ "Creates", "and", "returns", "the", "default", "Channel" ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L113-L117
grpc/grpc-php
src/lib/BaseStub.php
BaseStub.waitForReady
public function waitForReady($timeout) { $new_state = $this->getConnectivityState(true); if ($this->_checkConnectivityState($new_state)) { return true; } $now = Timeval::now(); $delta = new Timeval($timeout); $deadline = $now->add($delta); while ...
php
public function waitForReady($timeout) { $new_state = $this->getConnectivityState(true); if ($this->_checkConnectivityState($new_state)) { return true; } $now = Timeval::now(); $delta = new Timeval($timeout); $deadline = $now->add($delta); while ...
[ "public", "function", "waitForReady", "(", "$", "timeout", ")", "{", "$", "new_state", "=", "$", "this", "->", "getConnectivityState", "(", "true", ")", ";", "if", "(", "$", "this", "->", "_checkConnectivityState", "(", "$", "new_state", ")", ")", "{", "...
@param int $timeout in microseconds @return bool true if channel is ready @throw Exception if channel is in FATAL_ERROR state
[ "@param", "int", "$timeout", "in", "microseconds" ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L143-L165
grpc/grpc-php
src/lib/BaseStub.php
BaseStub._checkConnectivityState
private function _checkConnectivityState($new_state) { if ($new_state == \Grpc\CHANNEL_READY) { return true; } if ($new_state == \Grpc\CHANNEL_FATAL_FAILURE) { throw new \Exception('Failed to connect to server'); } return false; }
php
private function _checkConnectivityState($new_state) { if ($new_state == \Grpc\CHANNEL_READY) { return true; } if ($new_state == \Grpc\CHANNEL_FATAL_FAILURE) { throw new \Exception('Failed to connect to server'); } return false; }
[ "private", "function", "_checkConnectivityState", "(", "$", "new_state", ")", "{", "if", "(", "$", "new_state", "==", "\\", "Grpc", "\\", "CHANNEL_READY", ")", "{", "return", "true", ";", "}", "if", "(", "$", "new_state", "==", "\\", "Grpc", "\\", "CHANN...
@param $new_state Connect state @return bool true if state is CHANNEL_READY @throw Exception if state is CHANNEL_FATAL_FAILURE
[ "@param", "$new_state", "Connect", "state" ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L181-L191
grpc/grpc-php
src/lib/BaseStub.php
BaseStub._get_jwt_aud_uri
private function _get_jwt_aud_uri($method) { $last_slash_idx = strrpos($method, '/'); if ($last_slash_idx === false) { throw new \InvalidArgumentException( 'service name must have a slash' ); } $service_name = substr($method, 0, $last_slash_idx...
php
private function _get_jwt_aud_uri($method) { $last_slash_idx = strrpos($method, '/'); if ($last_slash_idx === false) { throw new \InvalidArgumentException( 'service name must have a slash' ); } $service_name = substr($method, 0, $last_slash_idx...
[ "private", "function", "_get_jwt_aud_uri", "(", "$", "method", ")", "{", "$", "last_slash_idx", "=", "strrpos", "(", "$", "method", ",", "'/'", ")", ";", "if", "(", "$", "last_slash_idx", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentExce...
constructs the auth uri for the jwt. @param string $method The method string @return string The URL string
[ "constructs", "the", "auth", "uri", "for", "the", "jwt", "." ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L200-L217
grpc/grpc-php
src/lib/BaseStub.php
BaseStub._validate_and_normalize_metadata
private function _validate_and_normalize_metadata($metadata) { $metadata_copy = []; foreach ($metadata as $key => $value) { if (!preg_match('/^[A-Za-z\d_-]+$/', $key)) { throw new \InvalidArgumentException( 'Metadata keys must be nonempty strings conta...
php
private function _validate_and_normalize_metadata($metadata) { $metadata_copy = []; foreach ($metadata as $key => $value) { if (!preg_match('/^[A-Za-z\d_-]+$/', $key)) { throw new \InvalidArgumentException( 'Metadata keys must be nonempty strings conta...
[ "private", "function", "_validate_and_normalize_metadata", "(", "$", "metadata", ")", "{", "$", "metadata_copy", "=", "[", "]", ";", "foreach", "(", "$", "metadata", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[...
validate and normalize the metadata array. @param array $metadata The metadata map @return array $metadata Validated and key-normalized metadata map @throw InvalidArgumentException if key contains invalid characters
[ "validate", "and", "normalize", "the", "metadata", "array", "." ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L227-L241
grpc/grpc-php
src/lib/BaseStub.php
BaseStub._GrpcUnaryUnary
private function _GrpcUnaryUnary($channel) { return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) { $call = $this->call_invoker->UnaryCall( ...
php
private function _GrpcUnaryUnary($channel) { return function ($method, $argument, $deserialize, array $metadata = [], array $options = []) use ($channel) { $call = $this->call_invoker->UnaryCall( ...
[ "private", "function", "_GrpcUnaryUnary", "(", "$", "channel", ")", "{", "return", "function", "(", "$", "method", ",", "$", "argument", ",", "$", "deserialize", ",", "array", "$", "metadata", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]",...
Create a function which can be used to create UnaryCall @param Channel|InterceptorChannel $channel @param callable $deserialize A function that deserializes the response @return \Closure
[ "Create", "a", "function", "which", "can", "be", "used", "to", "create", "UnaryCall" ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L251-L278
grpc/grpc-php
src/lib/BaseStub.php
BaseStub._GrpcStreamUnary
private function _GrpcStreamUnary($channel) { return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) { $call = $this->call_invoker->ClientStreamingCall( $channel,...
php
private function _GrpcStreamUnary($channel) { return function ($method, $deserialize, array $metadata = [], array $options = []) use ($channel) { $call = $this->call_invoker->ClientStreamingCall( $channel,...
[ "private", "function", "_GrpcStreamUnary", "(", "$", "channel", ")", "{", "return", "function", "(", "$", "method", ",", "$", "deserialize", ",", "array", "$", "metadata", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "use", "(", "...
Create a function which can be used to create ServerStreamingCall @param Channel|InterceptorChannel $channel @param callable $deserialize A function that deserializes the response @return \Closure
[ "Create", "a", "function", "which", "can", "be", "used", "to", "create", "ServerStreamingCall" ]
train
https://github.com/grpc/grpc-php/blob/0f1ffdde45bfb9257c5d9eab81695d0f042bea22/src/lib/BaseStub.php#L288-L314