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 |
|---|---|---|---|---|---|---|---|---|---|---|
zestframework/Zest_Framework | src/Common/Container/Dependency.php | Dependency.getResolveDependencies | public function getResolveDependencies($parameters, $params)
{
$dependencies = [];
foreach ($parameters as $parameter) {
// get the type hinted class
$dependency = $parameter->getClass();
if ($dependency === null) {
// check if default value for a parameter is available
if ($parameter->isDefaultValueAvailable()) {
// get default value of parameter
$dependencies[] = $parameter->getDefaultValue();
} else {
if (empty($params[$parameter->name])) {
throw new \Exception("Can not resolve class dependency {$parameter->name}", 500);
}
$dependencies[] = $params[$parameter->name];
}
} else {
// get dependency resolved
$this->loader = $dependency->name;
$dependencies[] = $this->get($dependency->name);
}
}
return $dependencies;
} | php | public function getResolveDependencies($parameters, $params)
{
$dependencies = [];
foreach ($parameters as $parameter) {
// get the type hinted class
$dependency = $parameter->getClass();
if ($dependency === null) {
// check if default value for a parameter is available
if ($parameter->isDefaultValueAvailable()) {
// get default value of parameter
$dependencies[] = $parameter->getDefaultValue();
} else {
if (empty($params[$parameter->name])) {
throw new \Exception("Can not resolve class dependency {$parameter->name}", 500);
}
$dependencies[] = $params[$parameter->name];
}
} else {
// get dependency resolved
$this->loader = $dependency->name;
$dependencies[] = $this->get($dependency->name);
}
}
return $dependencies;
} | [
"public",
"function",
"getResolveDependencies",
"(",
"$",
"parameters",
",",
"$",
"params",
")",
"{",
"$",
"dependencies",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"// get the type hinted class",
"$",
"dependency... | Get all dependencies resolved.
@param (array) $parameters required params
@param (array) $params constructure args.
@since 3.0.0
@return array | [
"Get",
"all",
"dependencies",
"resolved",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Container/Dependency.php#L83-L108 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageSave | public function imageSave($params)
{
if (is_array($params)) {
imagejpeg($params['image'], $params['target'], 100);
imagedestroy($params['image']);
return true;
} else {
return false;
}
} | php | public function imageSave($params)
{
if (is_array($params)) {
imagejpeg($params['image'], $params['target'], 100);
imagedestroy($params['image']);
return true;
} else {
return false;
}
} | [
"public",
"function",
"imageSave",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"imagejpeg",
"(",
"$",
"params",
"[",
"'image'",
"]",
",",
"$",
"params",
"[",
"'target'",
"]",
",",
"100",
")",
";",
"imaged... | Save the Image.
@param $params (array)
'image' => Source valid image file
'target' => target + new name of file
@since 1.0.0
@return image | [
"Save",
"the",
"Image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L47-L57 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageExtension | public function imageExtension($image)
{
$filename = $image;
$extension = explode('.', $filename);
$ext = strtolower(end($extension));
return $ext;
} | php | public function imageExtension($image)
{
$filename = $image;
$extension = explode('.', $filename);
$ext = strtolower(end($extension));
return $ext;
} | [
"public",
"function",
"imageExtension",
"(",
"$",
"image",
")",
"{",
"$",
"filename",
"=",
"$",
"image",
";",
"$",
"extension",
"=",
"explode",
"(",
"'.'",
",",
"$",
"filename",
")",
";",
"$",
"ext",
"=",
"strtolower",
"(",
"end",
"(",
"$",
"extensio... | Extension of image.
@param $params (string)
'image' => Source valid image file
@since 1.0.0
@return string | [
"Extension",
"of",
"image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L69-L76 |
zestframework/Zest_Framework | src/Image/Image.php | Image.ImageResize | public function ImageResize($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
$width = $params['w'];
$height = $params['h'];
$img_size = getimagesize($params['source']);
$o_width = $img_size[0];
$o_height = $img_size[1];
if ($width > $o_width or $height > $o_height) {
$width = $width - 100;
$height = $height - 100;
}
$image_c = imagecreatetruecolor($width, $height);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
imagecopyresampled($image_c, $image, 0, 0, 0, 0, $width, $height, $o_width, $o_height);
$img = imagejpeg($image_c);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave(
['image' => $image_c,
'target' => $params['target'], ]);
}
imagedestroy($image_c);
return $img;
}
} | php | public function ImageResize($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
$width = $params['w'];
$height = $params['h'];
$img_size = getimagesize($params['source']);
$o_width = $img_size[0];
$o_height = $img_size[1];
if ($width > $o_width or $height > $o_height) {
$width = $width - 100;
$height = $height - 100;
}
$image_c = imagecreatetruecolor($width, $height);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
imagecopyresampled($image_c, $image, 0, 0, 0, 0, $width, $height, $o_width, $o_height);
$img = imagejpeg($image_c);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave(
['image' => $image_c,
'target' => $params['target'], ]);
}
imagedestroy($image_c);
return $img;
}
} | [
"public",
"function",
"ImageResize",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
... | Resize the Image.
@param $params (array)
'source' => Source valid image file
'w' => New width of image
'h' => New height of image
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Resize",
"the",
"Image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L93-L128 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageBrightness | public function imageBrightness($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
imagefilter($image, IMG_FILTER_BRIGHTNESS, $params['brightness']);
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'],
]
);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | php | public function imageBrightness($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
imagefilter($image, IMG_FILTER_BRIGHTNESS, $params['brightness']);
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'],
]
);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | [
"public",
"function",
"imageBrightness",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"("... | Resize the Image.
@param $params (array)
'source' => Source valid image file
'brightness' => Brightnes to-be set valid -255 to 255
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Resize",
"the",
"Image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L144-L173 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageBlur | public function imageBlur($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$blur_opacity = $params['blur_opacity'];
if ($params['blur_opacity'] === 0 or $params['blur_opacity'] === 1) {
$blur_opacity += 5;
}
for ($x = 1; $x <= $blur_opacity; $x++) {
imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
}
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | php | public function imageBlur($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$blur_opacity = $params['blur_opacity'];
if ($params['blur_opacity'] === 0 or $params['blur_opacity'] === 1) {
$blur_opacity += 5;
}
for ($x = 1; $x <= $blur_opacity; $x++) {
imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
}
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | [
"public",
"function",
"imageBlur",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
"$... | Resize the Image.
@param $params (array)
'source' => Source valid image file
'blur_opacity' => blur_opacity recommended 100 otherwise you provide whatever you want
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Resize",
"the",
"Image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L189-L222 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageEffects | public function imageEffects($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if ($params['effect'] === 'gray') {
imagefilter($image, IMG_FILTER_GRAYSCALE);
}
if ($params['effect'] === 'sepia') {
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0);
}
if ($params['effect'] === 'sepia1') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 0);
}
if ($params['effect'] === 'amazing') {
imagefilter($image, IMG_FILTER_CONTRAST, -20);
}
if ($params['effect'] === 'amazing1') {
imagefilter($image, IMG_FILTER_CONTRAST, -100);
}
if ($params['effect'] === 'amazing2') {
imagefilter($image, IMG_FILTER_COLORIZE, 100, 0, 0);
}
if ($params['effect'] === 'aqua') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 70, 0, 30);
}
if ($params['effect'] === 'gama') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 0, 255, 0);
}
if ($params['effect'] === 'gama2') {
imagefilter($image, IMG_FILTER_COLORIZE, -150, -252, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 10);
}
if ($params['effect'] === 'ybulb') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 10, -50);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -200);
}
if ($params['effect'] === 'moon') {
imagefilter($image, IMG_FILTER_BRIGHTNESS, -200);
}
if ($params['effect'] === 'fire') {
imagefilter($image, IMG_FILTER_COLORIZE, 100, 10, -240);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
}
if ($params['effect'] === 'flesh') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
}
if ($params['effect'] === 'green_day') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
imagefilter($image, IMG_FILTER_COLORIZE, -111, -12, -45);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 45);
}
if ($params['effect'] === 'green_night') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
imagefilter($image, IMG_FILTER_COLORIZE, -111, -12, -45);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'frozen') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 113, 5);
}
if ($params['effect'] === 'green') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 12, 12);
}
if ($params['effect'] === 'froz') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 54, 100, 64);
}
if ($params['effect'] === 'negative') {
imagefilter($image, IMG_FILTER_NEGATE);
}
if ($params['effect'] === 'emboss') {
imagefilter($image, IMG_FILTER_EMBOSS);
}
if ($params['effect'] === 'highlight') {
imagefilter($image, IMG_FILTER_MEAN_REMOVAL);
}
if ($params['effect'] === 'edegdetect') {
imagefilter($image, IMG_FILTER_EDGEDETECT);
}
if ($params['effect'] === 'pixel') {
imagefilter($image, IMG_FILTER_PIXELATE, 10, 0);
}
if ($params['effect'] === 'pixel1') {
imagefilter($image, IMG_FILTER_PIXELATE, 50, 0);
}
if ($params['effect'] === 'pixel2') {
imagefilter($image, IMG_FILTER_PIXELATE, 10, 0);
imagefilter($image, IMG_FILTER_COLORIZE, 0, 140, 255, 140);
}
if ($params['effect'] === 'hot') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 100, -255);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'gold') {
imagefilter($image, IMG_FILTER_COLORIZE, 215, 215, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -20);
}
if ($params['effect'] === 'tpink') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, -50, -12);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -20);
}
if ($params['effect'] === 'blood') {
imagefilter($image, IMG_FILTER_COLORIZE, 30, -255, -255);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 20);
}
if ($params['effect'] === 'cold') {
imagefilter($image, IMG_FILTER_COLORIZE, -255, -100, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 20);
}
if ($params['effect'] === 'cloudy') {
imagefilter($image, IMG_FILTER_COLORIZE, -70, -50, 30);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'sunshine') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 10, -50);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'light') {
$matrix = [[
2, 0, 1,
],
[
0, -1, 0,
],
[
0, 0, -1,
],
];
imageconvolution($image, $matrix, 1, 127);
}
if ($params['effect'] === 'bubbles') {
$pattern = imagecreatefromstring(file_get_contents('patterns/bubbles.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'bubbles1') {
$pattern = imagecreatefromstring(file_get_contents('patterns/bubbles1.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x2, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'cloud') {
$pattern = imagecreatefromstring(file_get_contents('patterns/cloud.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x2, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave(['image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | php | public function imageEffects($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if ($params['effect'] === 'gray') {
imagefilter($image, IMG_FILTER_GRAYSCALE);
}
if ($params['effect'] === 'sepia') {
imagefilter($image, IMG_FILTER_GRAYSCALE);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($image, IMG_FILTER_COLORIZE, 100, 50, 0);
}
if ($params['effect'] === 'sepia1') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 0);
}
if ($params['effect'] === 'amazing') {
imagefilter($image, IMG_FILTER_CONTRAST, -20);
}
if ($params['effect'] === 'amazing1') {
imagefilter($image, IMG_FILTER_CONTRAST, -100);
}
if ($params['effect'] === 'amazing2') {
imagefilter($image, IMG_FILTER_COLORIZE, 100, 0, 0);
}
if ($params['effect'] === 'aqua') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 70, 0, 30);
}
if ($params['effect'] === 'gama') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 0, 255, 0);
}
if ($params['effect'] === 'gama2') {
imagefilter($image, IMG_FILTER_COLORIZE, -150, -252, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 10);
}
if ($params['effect'] === 'ybulb') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 10, -50);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -200);
}
if ($params['effect'] === 'moon') {
imagefilter($image, IMG_FILTER_BRIGHTNESS, -200);
}
if ($params['effect'] === 'fire') {
imagefilter($image, IMG_FILTER_COLORIZE, 100, 10, -240);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
}
if ($params['effect'] === 'flesh') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
}
if ($params['effect'] === 'green_day') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
imagefilter($image, IMG_FILTER_COLORIZE, -111, -12, -45);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 45);
}
if ($params['effect'] === 'green_night') {
imagefilter($image, IMG_FILTER_COLORIZE, 90, 90, 90);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -160);
imagefilter($image, IMG_FILTER_COLORIZE, -111, -12, -45);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'frozen') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 113, 5);
}
if ($params['effect'] === 'green') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 12, 12);
}
if ($params['effect'] === 'froz') {
imagefilter($image, IMG_FILTER_COLORIZE, 0, 54, 100, 64);
}
if ($params['effect'] === 'negative') {
imagefilter($image, IMG_FILTER_NEGATE);
}
if ($params['effect'] === 'emboss') {
imagefilter($image, IMG_FILTER_EMBOSS);
}
if ($params['effect'] === 'highlight') {
imagefilter($image, IMG_FILTER_MEAN_REMOVAL);
}
if ($params['effect'] === 'edegdetect') {
imagefilter($image, IMG_FILTER_EDGEDETECT);
}
if ($params['effect'] === 'pixel') {
imagefilter($image, IMG_FILTER_PIXELATE, 10, 0);
}
if ($params['effect'] === 'pixel1') {
imagefilter($image, IMG_FILTER_PIXELATE, 50, 0);
}
if ($params['effect'] === 'pixel2') {
imagefilter($image, IMG_FILTER_PIXELATE, 10, 0);
imagefilter($image, IMG_FILTER_COLORIZE, 0, 140, 255, 140);
}
if ($params['effect'] === 'hot') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 100, -255);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'gold') {
imagefilter($image, IMG_FILTER_COLORIZE, 215, 215, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -20);
}
if ($params['effect'] === 'tpink') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, -50, -12);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -20);
}
if ($params['effect'] === 'blood') {
imagefilter($image, IMG_FILTER_COLORIZE, 30, -255, -255);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 20);
}
if ($params['effect'] === 'cold') {
imagefilter($image, IMG_FILTER_COLORIZE, -255, -100, 10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 20);
}
if ($params['effect'] === 'cloudy') {
imagefilter($image, IMG_FILTER_COLORIZE, -70, -50, 30);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'sunshine') {
imagefilter($image, IMG_FILTER_COLORIZE, 10, 10, -50);
imagefilter($image, IMG_FILTER_BRIGHTNESS, 40);
}
if ($params['effect'] === 'light') {
$matrix = [[
2, 0, 1,
],
[
0, -1, 0,
],
[
0, 0, -1,
],
];
imageconvolution($image, $matrix, 1, 127);
}
if ($params['effect'] === 'bubbles') {
$pattern = imagecreatefromstring(file_get_contents('patterns/bubbles.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'bubbles1') {
$pattern = imagecreatefromstring(file_get_contents('patterns/bubbles1.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x2, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
if ($params['effect'] === 'cloud') {
$pattern = imagecreatefromstring(file_get_contents('patterns/cloud.png'));
$x = imagesx($image);
$y = imagesy($image);
$x2 = imagesx($pattern);
$y2 = imagesy($pattern);
$th = imagecreatetruecolor($x, $y);
imagecopyresized($th, $pattern, 0, 0, 0, 0, $x, $y, $x2, $y2);
imagecopymerge($image, $th, 0, 0, 0, 0, $x2, $y, $params['opacity']);
imagefilter($image, IMG_FILTER_CONTRAST, -10);
imagefilter($image, IMG_FILTER_BRIGHTNESS, -30);
}
$img = imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave(['image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
return $img;
} else {
return false;
}
} | [
"public",
"function",
"imageEffects",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
... | Resize the Image.
@param $params (array)
'source' => Source valid image file
'effect' => Different effect supported
=> blackwhite
=> negative
=> emboss
=> highlight
=> edegdetect
for bubbles.bubbles1,cloud effect opacity is required
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Resize",
"the",
"Image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L244-L434 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageCrop | public function imageCrop($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
$img_size = getimagesize($params['source']);
$width = $img_size[0];
$height = $img_size[1];
$image_c = imagecreatetruecolor($width, $height);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$size = min(imagesx($image), imagesy($image));
$image2 = imagecrop($image, ['x' => $params['x'], 'y' => $params['y'], 'width' => $size, 'height' => $size]);
$img = imagejpeg($image2);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image2,
'target' => $params['target'], ]);
}
imagedestroy($image2);
return $img;
}
} | php | public function imageCrop($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
$img_size = getimagesize($params['source']);
$width = $img_size[0];
$height = $img_size[1];
$image_c = imagecreatetruecolor($width, $height);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$size = min(imagesx($image), imagesy($image));
$image2 = imagecrop($image, ['x' => $params['x'], 'y' => $params['y'], 'width' => $size, 'height' => $size]);
$img = imagejpeg($image2);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image2,
'target' => $params['target'], ]);
}
imagedestroy($image2);
return $img;
}
} | [
"public",
"function",
"imageCrop",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
"$... | Crop the image.
@param $params (array)
'source' => Source valid image file
'x' => x coordinate of image e.g 45
'y' => y coordinate of image e.g 11
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Crop",
"the",
"image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L451-L481 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageFlip | public function imageFlip($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if ($params['flip'] === 'horizontal') {
imageflip($image, IMG_FLIP_HORIZONTAL);
} elseif ($params['flip'] === 'vertical') {
imageflip($image, IMG_FLIP_VERTICAL);
} else {
imageflip($image, IMG_FLIP_BOTH);
}
imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
} else {
return false;
}
} | php | public function imageFlip($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if ($params['flip'] === 'horizontal') {
imageflip($image, IMG_FLIP_HORIZONTAL);
} elseif ($params['flip'] === 'vertical') {
imageflip($image, IMG_FLIP_VERTICAL);
} else {
imageflip($image, IMG_FLIP_BOTH);
}
imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
} else {
return false;
}
} | [
"public",
"function",
"imageFlip",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
"$... | Flip the image.
@param $params (array)
'source' => Source valid image file
'flip' => support two different value
'horizontal' => flip image horizontally
'vertical' => flip image vertically
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Flip",
"the",
"image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L499-L529 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageRotate | public function imageRotate($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if (isset($params['bg_color'])) {
$bg_color = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
$rotate = imagerotate($image, $params['rotate'], $bg_color, 0);
} else {
$rotate = imagerotate($image, $params['rotate'], 0);
}
imagejpeg($rotate);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $rotate,
'target' => $params['target'], ]);
}
imagedestroy($image);
imagedestroy($rotate);
} else {
return false;
}
} | php | public function imageRotate($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
if (isset($params['bg_color'])) {
$bg_color = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
$rotate = imagerotate($image, $params['rotate'], $bg_color, 0);
} else {
$rotate = imagerotate($image, $params['rotate'], 0);
}
imagejpeg($rotate);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $rotate,
'target' => $params['target'], ]);
}
imagedestroy($image);
imagedestroy($rotate);
} else {
return false;
}
} | [
"public",
"function",
"imageRotate",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
... | Rotate the image.
@param $params (array)
'source' => Source valid image file
'rotate' => Rotate in degree e.g 90,150 etc...
'bg_color' => (optional) if you want provide color of the uncovered zone after the rotation support three argument valid value for rgb
'red' => red color
'green' => green color
'blue' => blue color
Learn more about rgb https://en.wikipedia.org/wiki/RGB_color_model
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Rotate",
"the",
"image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L550-L581 |
zestframework/Zest_Framework | src/Image/Image.php | Image.imageBorder | public function imageBorder($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$border_colors = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
$x = 0;
$y = 0;
$w = imagesx($image) - 1;
$h = imagesy($image) - 1;
imagesetthickness($image, $params['thickness']);
//left
imageline($image, $x, $y, $x, $y + $h, $border_colors);
//top
imageline($image, $x, $y, $x + $w, $y, $border_colors);
//right
imageline($image, $x + $w, $y, $x + $w, $y + $h, $border_colors);
//bottom
imageline($image, $x, $y + $h, $x + $w, $y + $h, $border_colors);
imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
} else {
return false;
}
} | php | public function imageBorder($params)
{
if (is_array($params)) {
$filename = $params['source'];
$ext = $this->imageExtension($filename);
if ($ext === 'png') {
$image = imagecreatefromstring(file_get_contents($filename));
} elseif ($ext === 'jpeg') {
$image = imagecreatefromjpeg($filename);
} elseif ($ext === 'gif') {
$image = imagecreatefromgif($filename);
} else {
return false;
}
$border_colors = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
$x = 0;
$y = 0;
$w = imagesx($image) - 1;
$h = imagesy($image) - 1;
imagesetthickness($image, $params['thickness']);
//left
imageline($image, $x, $y, $x, $y + $h, $border_colors);
//top
imageline($image, $x, $y, $x + $w, $y, $border_colors);
//right
imageline($image, $x + $w, $y, $x + $w, $y + $h, $border_colors);
//bottom
imageline($image, $x, $y + $h, $x + $w, $y + $h, $border_colors);
imagejpeg($image);
if (isset($params['save']) and $params['save'] === true) {
$this->imageSave([
'image' => $image,
'target' => $params['target'], ]);
}
imagedestroy($image);
} else {
return false;
}
} | [
"public",
"function",
"imageBorder",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"filename",
"=",
"$",
"params",
"[",
"'source'",
"]",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"imageExtension",
"(",
... | Add Border to the image.
@param $params (array)
'source' => Source valid image file
'thickness' => thickness of border
'bg_color' => three argument valid value for rgb
'red' => red color
'green' => green color
'blue' => blue color
Learn more about rgb https://en.wikipedia.org/wiki/RGB_color_model
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file
@since 1.0.0
@return image | [
"Add",
"Border",
"to",
"the",
"image",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Image.php#L602-L640 |
zestframework/Zest_Framework | src/Encryption/Adapter/SodiumEncryption.php | SodiumEncryption.encrypt | public function encrypt($data)
{
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$token = base64_encode($nonce.sodium_crypto_secretbox($data, $nonce, $this->key).'&&'.$this->key);
return $token;
} | php | public function encrypt($data)
{
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$token = base64_encode($nonce.sodium_crypto_secretbox($data, $nonce, $this->key).'&&'.$this->key);
return $token;
} | [
"public",
"function",
"encrypt",
"(",
"$",
"data",
")",
"{",
"$",
"nonce",
"=",
"random_bytes",
"(",
"SODIUM_CRYPTO_SECRETBOX_NONCEBYTES",
")",
";",
"$",
"token",
"=",
"base64_encode",
"(",
"$",
"nonce",
".",
"sodium_crypto_secretbox",
"(",
"$",
"data",
",",
... | Encrypt the message.
@param (mixed) $data data to be encrypted
@since 3.0.0
@return mixed | [
"Encrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Adapter/SodiumEncryption.php#L53-L59 |
zestframework/Zest_Framework | src/Encryption/Adapter/SodiumEncryption.php | SodiumEncryption.decrypt | public function decrypt($token)
{
$decoded = base64_decode($token);
list($decoded, $this->key) = explode('&&', $decoded);
if ($decoded === false) {
throw new Exception('The decoding failed');
}
if (mb_strlen($decoded, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) {
throw new \Exception('The token was truncated');
}
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
$plain = sodium_crypto_secretbox_open($ciphertext,
$nonce, $this->key);
if ($plain === false) {
throw new \Exception('The message was tampered with in transit');
}
return $plain;
} | php | public function decrypt($token)
{
$decoded = base64_decode($token);
list($decoded, $this->key) = explode('&&', $decoded);
if ($decoded === false) {
throw new Exception('The decoding failed');
}
if (mb_strlen($decoded, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) {
throw new \Exception('The token was truncated');
}
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
$plain = sodium_crypto_secretbox_open($ciphertext,
$nonce, $this->key);
if ($plain === false) {
throw new \Exception('The message was tampered with in transit');
}
return $plain;
} | [
"public",
"function",
"decrypt",
"(",
"$",
"token",
")",
"{",
"$",
"decoded",
"=",
"base64_decode",
"(",
"$",
"token",
")",
";",
"list",
"(",
"$",
"decoded",
",",
"$",
"this",
"->",
"key",
")",
"=",
"explode",
"(",
"'&&'",
",",
"$",
"decoded",
")",... | Decrypt the message.
@param (mixed) $token encrypted token
@since 3.0.0
@return mixed | [
"Decrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Adapter/SodiumEncryption.php#L70-L91 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.setMethod | public function setMethod($method)
{
$valid = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'];
$method = strtoupper($method);
if (!in_array($method, $valid)) {
throw new \Exception('Error: That request method is not valid.');
}
$this->method = $method;
return $this;
} | php | public function setMethod($method)
{
$valid = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'];
$method = strtoupper($method);
if (!in_array($method, $valid)) {
throw new \Exception('Error: That request method is not valid.');
}
$this->method = $method;
return $this;
} | [
"public",
"function",
"setMethod",
"(",
"$",
"method",
")",
"{",
"$",
"valid",
"=",
"[",
"'GET'",
",",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
",",
"'DELETE'",
",",
"'HEAD'",
",",
"'OPTIONS'",
",",
"'TRACE'",
",",
"'CONNECT'",
"]",
";",
"$",
"method",
... | Set the method.
@param (string) $method
@since 3.0.0
@return object | [
"Set",
"the",
"method",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L229-L240 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.setFields | public function setFields(array $fields)
{
foreach ($fields as $name => $value) {
$this->setField($name, $value);
}
$this->prepareQuery();
return $this;
} | php | public function setFields(array $fields)
{
foreach ($fields as $name => $value) {
$this->setField($name, $value);
}
$this->prepareQuery();
return $this;
} | [
"public",
"function",
"setFields",
"(",
"array",
"$",
"fields",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setField",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"$",
"thi... | Set fields.
@param (array) $fields
@since 3.0.0
@return object | [
"Set",
"fields",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L280-L289 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.getField | public function getField($name)
{
return (isset($this->fields[$name])) ? $this->fields[$name] : false;
} | php | public function getField($name)
{
return (isset($this->fields[$name])) ? $this->fields[$name] : false;
} | [
"public",
"function",
"getField",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"?",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
":",
"false",
";",
"}"
] | Get a field.
@param (string) $name name of field
@since 3.0.0
@return string | [
"Get",
"a",
"field",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L300-L303 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.removeField | public function removeField($name)
{
if (isset($this->fields[$name])) {
unset($this->fields[$name]);
}
$this->prepareQuery();
return $this;
} | php | public function removeField($name)
{
if (isset($this->fields[$name])) {
unset($this->fields[$name]);
}
$this->prepareQuery();
return $this;
} | [
"public",
"function",
"removeField",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
... | Remove a field.
@param (string) $name name of field
@since 3.0.0
@return object | [
"Remove",
"a",
"field",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L314-L323 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.getQueryLength | public function getQueryLength($mb = true)
{
return ($mb) ? mb_strlen($this->query) : strlen($this->query);
} | php | public function getQueryLength($mb = true)
{
return ($mb) ? mb_strlen($this->query) : strlen($this->query);
} | [
"public",
"function",
"getQueryLength",
"(",
"$",
"mb",
"=",
"true",
")",
"{",
"return",
"(",
"$",
"mb",
")",
"?",
"mb_strlen",
"(",
"$",
"this",
"->",
"query",
")",
":",
"strlen",
"(",
"$",
"this",
"->",
"query",
")",
";",
"}"
] | Get HTTP query length.
@param (bool) $mb
@since 3.0.0
@return int | [
"Get",
"HTTP",
"query",
"length",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L360-L363 |
zestframework/Zest_Framework | src/http/Clients/AbstractClient.php | AbstractClient.getRequestHeader | public function getRequestHeader($name)
{
return (isset($this->requestHeaders[$name])) ? $this->requestHeaders[$name] : null;
} | php | public function getRequestHeader($name)
{
return (isset($this->requestHeaders[$name])) ? $this->requestHeaders[$name] : null;
} | [
"public",
"function",
"getRequestHeader",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestHeaders",
"[",
"$",
"name",
"]",
")",
")",
"?",
"$",
"this",
"->",
"requestHeaders",
"[",
"$",
"name",
"]",
":",
"null",
";"... | Get a request header.
@param (string) $name
@since 3.0.0
@return mixed | [
"Get",
"a",
"request",
"header",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Clients/AbstractClient.php#L407-L410 |
zestframework/Zest_Framework | src/Common/Minify.php | Minify.htmlMinify | public function htmlMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = $this->cleanSpaces($file);
$file = $this->fixMaster($file);
$file = $this->removeComments($file);
return $file;
} | php | public function htmlMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = $this->cleanSpaces($file);
$file = $this->fixMaster($file);
$file = $this->removeComments($file);
return $file;
} | [
"public",
"function",
"htmlMinify",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"'file'",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"file",
",",
"$",
"type",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"cleanSpaces",
"("... | Minify html.
@param (mixed) $file valid code.
@since 2.0.3
@return mixed | [
"Minify",
"html",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Minify.php#L93-L101 |
zestframework/Zest_Framework | src/Common/Minify.php | Minify.cssMinify | public function cssMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = $this->cleanSpaces($file);
$file = $this->fixMaster($file);
$file = $this->removeComments($file);
return preg_replace(['/;[\s\r\n\t]*?}[\s\r\n\t]*/ims', '/;[\s\r\n\t]/ims', '/[\s\r\n\t]*:[\s\r\n\t][\s+\/]/ims', '/[\s\r\n\t]*,[\s\r\n\t]*?([^\s\r\n\t]\.[\s+\/])/ims', '/[\s\r\n\t]/ims', '/([\d\.]+)[\s\r\n\t]+(px|em|pt|%)/ims', '/([^\s\.]0)(px|em|pt|%|ex|mm|in|pc|vh|vw|vmin)/ims', '/\s+/'], ['}', ';$1', ',$1', '$1', '$1$2', '$1$2', ' '], $file);
} | php | public function cssMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = $this->cleanSpaces($file);
$file = $this->fixMaster($file);
$file = $this->removeComments($file);
return preg_replace(['/;[\s\r\n\t]*?}[\s\r\n\t]*/ims', '/;[\s\r\n\t]/ims', '/[\s\r\n\t]*:[\s\r\n\t][\s+\/]/ims', '/[\s\r\n\t]*,[\s\r\n\t]*?([^\s\r\n\t]\.[\s+\/])/ims', '/[\s\r\n\t]/ims', '/([\d\.]+)[\s\r\n\t]+(px|em|pt|%)/ims', '/([^\s\.]0)(px|em|pt|%|ex|mm|in|pc|vh|vw|vmin)/ims', '/\s+/'], ['}', ';$1', ',$1', '$1', '$1$2', '$1$2', ' '], $file);
} | [
"public",
"function",
"cssMinify",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"'file'",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"file",
",",
"$",
"type",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"cleanSpaces",
"(",... | Minify CSS.
@param (mixed) $file valid code.
@since 2.0.3
@return mixed | [
"Minify",
"CSS",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Minify.php#L112-L120 |
zestframework/Zest_Framework | src/Common/Minify.php | Minify.javascriptMinify | public function javascriptMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = preg_replace(["/\/\/(.*\s+)/", "/;+\}/"], ['', '}'], $file);
$file = $this->cleanSpaces($file);
$file = $this->removeComments($file);
return $file;
} | php | public function javascriptMinify($file, $type = 'file')
{
$file = $this->getFile($file, $type);
$file = preg_replace(["/\/\/(.*\s+)/", "/;+\}/"], ['', '}'], $file);
$file = $this->cleanSpaces($file);
$file = $this->removeComments($file);
return $file;
} | [
"public",
"function",
"javascriptMinify",
"(",
"$",
"file",
",",
"$",
"type",
"=",
"'file'",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"file",
",",
"$",
"type",
")",
";",
"$",
"file",
"=",
"preg_replace",
"(",
"[",
"\"/\\/... | Minify Js.
@param (mixed) $file valid code.
@since 2.0.3
@return mixed | [
"Minify",
"Js",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Minify.php#L131-L139 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.set | public function set(string $name, $value, $expire = 0, $path = null, $domain = null, bool $secure = false, bool $httponly = true)
{
$name = preg_match('/[=,; \t\r\n\013\014]/', $name) ? rand(1, 25) : $name;
if ($expire instanceof \DateTime) {
$expire = $expire->format('U');
} elseif (preg_match('~\D~', $expire)) {
$expire = strtotime($expire);
} else {
$expire = $expire;
if (false === $expire) {
throw new \InvalidArgumentException('The cookie expiration time is not valid.', 500);
}
}
[$path, $domain, $secure] = $this->getPathAndDomain($path, $domain, $secure);
return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
} | php | public function set(string $name, $value, $expire = 0, $path = null, $domain = null, bool $secure = false, bool $httponly = true)
{
$name = preg_match('/[=,; \t\r\n\013\014]/', $name) ? rand(1, 25) : $name;
if ($expire instanceof \DateTime) {
$expire = $expire->format('U');
} elseif (preg_match('~\D~', $expire)) {
$expire = strtotime($expire);
} else {
$expire = $expire;
if (false === $expire) {
throw new \InvalidArgumentException('The cookie expiration time is not valid.', 500);
}
}
[$path, $domain, $secure] = $this->getPathAndDomain($path, $domain, $secure);
return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"0",
",",
"$",
"path",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
",",
"bool",
"$",
"secure",
"=",
"false",
",",
"bool",
"$",
"httponly",
"=",... | Set the cookie value.
@param (string) $name Name of cookie.
@param (mixed) $value Value to store in cookie.
@param (expire) $expire TTL.
@param (string) $path Path.
@param (domain) $domain Domain.
@param (bool) $secure true | false.
@param (bool) $httponly true | false.
@since 1.0.0
@return bool | [
"Set",
"the",
"cookie",
"value",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L63-L79 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.setMultiple | public function setMultiple(array $array)
{
foreach ($array as $key) {
$this->set($key[0], $key[1], $key[2], $key[3], $key[4], $key[5], $key[6]);
}
return $this;
} | php | public function setMultiple(array $array)
{
foreach ($array as $key) {
$this->set($key[0], $key[1], $key[2], $key[3], $key[4], $key[5], $key[6]);
}
return $this;
} | [
"public",
"function",
"setMultiple",
"(",
"array",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
"[",
"0",
"]",
",",
"$",
"key",
"[",
"1",
"]",
",",
"$",
"key",
"[... | Set the multiple cookies value.
@param (array) $array valid array.
@since 3.0.0
@return object | [
"Set",
"the",
"multiple",
"cookies",
"value",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L124-L131 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.has | public function has($name)
{
if (isset($name) && !empty($name)) {
if (isset($_COOKIE[$name])) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function has($name)
{
if (isset($name) && !empty($name)) {
if (isset($_COOKIE[$name])) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
"&&",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
... | Determine if cookie set or not.
@param (string) $name of cookie
@since 1.0.0
@return bool | [
"Determine",
"if",
"cookie",
"set",
"or",
"not",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L142-L153 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.get | public function get($name, $default = null)
{
if (isset($name) && !empty($name)) {
if ($this->has($name)) {
return $_COOKIE[$name];
} else {
return $default;
}
} else {
return false;
}
} | php | public function get($name, $default = null)
{
if (isset($name) && !empty($name)) {
if ($this->has($name)) {
return $_COOKIE[$name];
} else {
return $default;
}
} else {
return false;
}
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
"&&",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
... | Get the cookie value.
@param (sring) $name of cookie
@param (mixed) $default default value if cookie is not exists
@since 1.0.0
@return mixed | [
"Get",
"the",
"cookie",
"value",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L165-L176 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.getMultiple | public function getMultiple($keys, $default = null)
{
$value = [];
foreach ($keys as $key) {
$this->has($key) ? $value[$key] = $this->get($key, $default) : null;
}
return $value;
} | php | public function getMultiple($keys, $default = null)
{
$value = [];
foreach ($keys as $key) {
$this->has($key) ? $value[$key] = $this->get($key, $default) : null;
}
return $value;
} | [
"public",
"function",
"getMultiple",
"(",
"$",
"keys",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
"?",
... | Get multiple values from cookie.
@param (array) $keys name
@param (mixed) $default default value if cookie is not exists
@since 3.0.0
@return array | [
"Get",
"multiple",
"values",
"from",
"cookie",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L188-L196 |
zestframework/Zest_Framework | src/Cookies/Cookies.php | Cookies.delete | public function delete($name, $path = null, $domain = null)
{
$this->set($name, null, -2628000, $path, $domain);
} | php | public function delete($name, $path = null, $domain = null)
{
$this->set($name, null, -2628000, $path, $domain);
} | [
"public",
"function",
"delete",
"(",
"$",
"name",
",",
"$",
"path",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"null",
",",
"-",
"2628000",
",",
"$",
"path",
",",
"$",
"domain",
")",... | Delete the cookie.
@param (string) $name of cookie
@since 1.0.0
@return bool | [
"Delete",
"the",
"cookie",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cookies/Cookies.php#L207-L210 |
zestframework/Zest_Framework | src/Cache/Adapter/Redis.php | Redis.getItemTtl | public function getItemTtl($key)
{
$data = $this->redis->get($key);
if ($data !== false) {
$data = json_decode($data, true);
if ((($data['ttl'] == 0) || ((time() - $data['start']) <= $data['ttl']))) {
$ttl = $data['ttl'];
} else {
$this->deleteItem($id);
}
} else {
$this->deleteItem($id);
}
return (isset($ttl)) ? $ttl : false;
} | php | public function getItemTtl($key)
{
$data = $this->redis->get($key);
if ($data !== false) {
$data = json_decode($data, true);
if ((($data['ttl'] == 0) || ((time() - $data['start']) <= $data['ttl']))) {
$ttl = $data['ttl'];
} else {
$this->deleteItem($id);
}
} else {
$this->deleteItem($id);
}
return (isset($ttl)) ? $ttl : false;
} | [
"public",
"function",
"getItemTtl",
"(",
"$",
"key",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"false",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"d... | Get the time-to-live for an item in cache.
@param (string) $key
@since 3.0.0
@return mixed | [
"Get",
"the",
"time",
"-",
"to",
"-",
"live",
"for",
"an",
"item",
"in",
"cache",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Redis.php#L86-L101 |
zestframework/Zest_Framework | src/Cache/Adapter/Redis.php | Redis.saveItem | public function saveItem($key, $value, $ttl = null)
{
$cache = [
'start' => time(),
'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl,
'value' => $value,
];
if ($cache['ttl'] != 0) {
$this->redis->set($key, json_encode($cache), $cache['ttl']);
} else {
$this->redis->set($key, json_encode($cache));
}
return $this;
} | php | public function saveItem($key, $value, $ttl = null)
{
$cache = [
'start' => time(),
'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl,
'value' => $value,
];
if ($cache['ttl'] != 0) {
$this->redis->set($key, json_encode($cache), $cache['ttl']);
} else {
$this->redis->set($key, json_encode($cache));
}
return $this;
} | [
"public",
"function",
"saveItem",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"cache",
"=",
"[",
"'start'",
"=>",
"time",
"(",
")",
",",
"'ttl'",
"=>",
"(",
"$",
"ttl",
"!==",
"null",
")",
"?",
"(",
"int",
... | Save an item to cache.
@param (string) $key
@param (mixed) $value
@param (int) $ttl
@since 3.0.0
@return object | [
"Save",
"an",
"item",
"to",
"cache",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Redis.php#L114-L128 |
zestframework/Zest_Framework | src/Cache/Adapter/Redis.php | Redis.getItem | public function getItem($key)
{
$data = $this->redis->get($key);
if ($data !== false) {
$data = json_decode($data, true);
if ((($data['ttl'] == 0) || ((time() - $data['start']) <= $data['ttl']))) {
$value = $data['value'];
} else {
$this->deleteItem($id);
}
} else {
$this->deleteItem($id);
}
return (isset($value)) ? $value : false;
} | php | public function getItem($key)
{
$data = $this->redis->get($key);
if ($data !== false) {
$data = json_decode($data, true);
if ((($data['ttl'] == 0) || ((time() - $data['start']) <= $data['ttl']))) {
$value = $data['value'];
} else {
$this->deleteItem($id);
}
} else {
$this->deleteItem($id);
}
return (isset($value)) ? $value : false;
} | [
"public",
"function",
"getItem",
"(",
"$",
"key",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"false",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"data... | Get value form the cache.
@param (string) $key
@since 3.0.0
@return mixed | [
"Get",
"value",
"form",
"the",
"cache",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Redis.php#L139-L154 |
zestframework/Zest_Framework | src/Cache/Adapter/Redis.php | Redis.destroy | public function destroy()
{
$this->redis->flushDb();
$this->close();
$this->redis = null;
return $this;
} | php | public function destroy()
{
$this->redis->flushDb();
$this->close();
$this->redis = null;
return $this;
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"$",
"this",
"->",
"redis",
"->",
"flushDb",
"(",
")",
";",
"$",
"this",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"redis",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Remove all caches.
@since 3.0.0
@return object | [
"Remove",
"all",
"caches",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Redis.php#L205-L212 |
zestframework/Zest_Framework | src/Time/Time.php | Time.timestampToGmt | public static function timestampToGmt($time = null)
{
$time = $time ?? time();
$dateTime = new \DateTime();
$dateTime->setTimestamp($time)->modify('+2 hours');
return $dateTime->format('d/m/Y H:i:s');
} | php | public static function timestampToGmt($time = null)
{
$time = $time ?? time();
$dateTime = new \DateTime();
$dateTime->setTimestamp($time)->modify('+2 hours');
return $dateTime->format('d/m/Y H:i:s');
} | [
"public",
"static",
"function",
"timestampToGmt",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"$",
"time",
"??",
"time",
"(",
")",
";",
"$",
"dateTime",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"dateTime",
"->",
"setTimestamp"... | Converts a timestamp to GMT.
@param int|null $time Unix timestamp
@since 3.0.0
@return string | [
"Converts",
"a",
"timestamp",
"to",
"GMT",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Time/Time.php#L80-L87 |
zestframework/Zest_Framework | src/Time/Time.php | Time.timestampToDate | private static function timestampToDate($time = null)
{
$time = $time ?? time();
$time = self::formatTime($time);
$dateTime = new \DateTime();
$dateTime->setTimestamp($time);
return $dateTime->format('d-m-Y H:i:s');
} | php | private static function timestampToDate($time = null)
{
$time = $time ?? time();
$time = self::formatTime($time);
$dateTime = new \DateTime();
$dateTime->setTimestamp($time);
return $dateTime->format('d-m-Y H:i:s');
} | [
"private",
"static",
"function",
"timestampToDate",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"time",
"=",
"$",
"time",
"??",
"time",
"(",
")",
";",
"$",
"time",
"=",
"self",
"::",
"formatTime",
"(",
"$",
"time",
")",
";",
"$",
"dateTime",
"=",... | Converts a timestamp to DateTime.
@param int|string $time Datetime, Timestamp or English textual datetime (http://php.net/manual/en/function.strtotime.php)
@since 3.0.0
@return string | [
"Converts",
"a",
"timestamp",
"to",
"DateTime",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Time/Time.php#L98-L106 |
zestframework/Zest_Framework | src/Time/Time.php | Time.ago | public static function ago($dateTime, $full = false)
{
$dateTime = self::timestampToDate($dateTime);
$now = new \DateTime();
$ago = new \DateTime($dateTime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = [
'y' => ':year',
'm' => ':month',
'w' => ':week',
'd' => ':day',
'h' => ':hour',
'i' => ':minute',
's' => ':second',
];
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k.' '.$v.($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) {
$string = array_slice($string, 0, 1);
}
return $string ? implode(', ', $string).' ' : ':just';
} | php | public static function ago($dateTime, $full = false)
{
$dateTime = self::timestampToDate($dateTime);
$now = new \DateTime();
$ago = new \DateTime($dateTime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = [
'y' => ':year',
'm' => ':month',
'w' => ':week',
'd' => ':day',
'h' => ':hour',
'i' => ':minute',
's' => ':second',
];
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k.' '.$v.($diff->$k > 1 ? 's' : '');
} else {
unset($string[$k]);
}
}
if (!$full) {
$string = array_slice($string, 0, 1);
}
return $string ? implode(', ', $string).' ' : ':just';
} | [
"public",
"static",
"function",
"ago",
"(",
"$",
"dateTime",
",",
"$",
"full",
"=",
"false",
")",
"{",
"$",
"dateTime",
"=",
"self",
"::",
"timestampToDate",
"(",
"$",
"dateTime",
")",
";",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"... | Converts the timestamp in to ago form.
@param int|string $time Datetime, Timestamp or English textual datetime (http://php.net/manual/en/function.strtotime.php)
@author https://github.com/peter279k (https://github.com/zestframework/Zest_Framework/pull/206).
@since 3.0.0
@return mixed | [
"Converts",
"the",
"timestamp",
"in",
"to",
"ago",
"form",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Time/Time.php#L119-L151 |
zestframework/Zest_Framework | src/Image/Identicon/Gd.php | Gd.genImage | public function genImage()
{
$this->image = imagecreatetruecolor($this->getPxRatio() * 5, $this->getPxRatio() * 5);
$bg = $this->getBgColor();
if (!empty($bg)) {
$background = imagecolorallocate($this->image, $bg[0], $bg[1], $bg[2]);
imagefill($this->image, 0, 0, $background);
} else {
$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
imagefill($this->image, 0, 0, $transparent);
imagesavealpha($this->image, true);
}
$color = $this->getColor();
$color = imagecolorallocate($this->image, $color[0], $color[1], $color[2]);
foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
foreach ($lineValue as $colKey => $colValue) {
if ($colValue) {
imagefilledrectangle($this->image, $colKey * $this->getPxRatio(), $lineKey * $this->getPxRatio(), ($colKey + 1) * $this->getPxRatio(), ($lineKey + 1) * $this->getPxRatio(), $color);
}
}
}
return $this->image;
} | php | public function genImage()
{
$this->image = imagecreatetruecolor($this->getPxRatio() * 5, $this->getPxRatio() * 5);
$bg = $this->getBgColor();
if (!empty($bg)) {
$background = imagecolorallocate($this->image, $bg[0], $bg[1], $bg[2]);
imagefill($this->image, 0, 0, $background);
} else {
$transparent = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
imagefill($this->image, 0, 0, $transparent);
imagesavealpha($this->image, true);
}
$color = $this->getColor();
$color = imagecolorallocate($this->image, $color[0], $color[1], $color[2]);
foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
foreach ($lineValue as $colKey => $colValue) {
if ($colValue) {
imagefilledrectangle($this->image, $colKey * $this->getPxRatio(), $lineKey * $this->getPxRatio(), ($colKey + 1) * $this->getPxRatio(), ($lineKey + 1) * $this->getPxRatio(), $color);
}
}
}
return $this->image;
} | [
"public",
"function",
"genImage",
"(",
")",
"{",
"$",
"this",
"->",
"image",
"=",
"imagecreatetruecolor",
"(",
"$",
"this",
"->",
"getPxRatio",
"(",
")",
"*",
"5",
",",
"$",
"this",
"->",
"getPxRatio",
"(",
")",
"*",
"5",
")",
";",
"$",
"bg",
"=",
... | Generate the iamge.
@since 3.0.0
@return resource | [
"Generate",
"the",
"iamge",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Gd.php#L37-L61 |
zestframework/Zest_Framework | src/Common/Sitemap/SitemapIndex.php | SitemapIndex.create | private function create($mode, $url, $lastMod = null):void
{
$lastMod = $lastMod ?: $this->lastMod;
$raw = str_replace([':url', ':lastmod'], [$url, $lastMod], $this->raw);
if ($mode === 'create') {
$fileH = new SitemapWriter($this->file, 'writeOnly');
$fileH->write(self::START.PHP_EOL);
$fileH->write($raw);
$fileH->write(PHP_EOL.self::END);
} elseif ($mode === 'append') {
$fileH = new SitemapWriter($this->file, 'readOnly');
$sitemapData = $fileH->read();
$fileH = new SitemapWriter($this->file, 'writeOverride');
$sitemapData = str_replace('</sitemapindex>', '', $sitemapData);
$sitemapData = $sitemapData.$raw;
$fileH->write($sitemapData);
$fileH->write(PHP_EOL.self::END);
}
$fileH->close();
} | php | private function create($mode, $url, $lastMod = null):void
{
$lastMod = $lastMod ?: $this->lastMod;
$raw = str_replace([':url', ':lastmod'], [$url, $lastMod], $this->raw);
if ($mode === 'create') {
$fileH = new SitemapWriter($this->file, 'writeOnly');
$fileH->write(self::START.PHP_EOL);
$fileH->write($raw);
$fileH->write(PHP_EOL.self::END);
} elseif ($mode === 'append') {
$fileH = new SitemapWriter($this->file, 'readOnly');
$sitemapData = $fileH->read();
$fileH = new SitemapWriter($this->file, 'writeOverride');
$sitemapData = str_replace('</sitemapindex>', '', $sitemapData);
$sitemapData = $sitemapData.$raw;
$fileH->write($sitemapData);
$fileH->write(PHP_EOL.self::END);
}
$fileH->close();
} | [
"private",
"function",
"create",
"(",
"$",
"mode",
",",
"$",
"url",
",",
"$",
"lastMod",
"=",
"null",
")",
":",
"void",
"{",
"$",
"lastMod",
"=",
"$",
"lastMod",
"?",
":",
"$",
"this",
"->",
"lastMod",
";",
"$",
"raw",
"=",
"str_replace",
"(",
"[... | Create the sitemap.
@param (siring) $mode Valid mode (for only access inside class)
@param (string) $url Valid url.
@param (string) $lastMod Last modify.
@since 3.0.0
@return bool | [
"Create",
"the",
"sitemap",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/SitemapIndex.php#L81-L100 |
zestframework/Zest_Framework | src/Common/Sitemap/SitemapIndex.php | SitemapIndex.addItem | public function addItem($url, $lastMod = null):void
{
if ($this->has($this->file)) {
$this->appendItem($url, $lastMod);
} else {
$this->create('create', $url, $lastMod);
}
} | php | public function addItem($url, $lastMod = null):void
{
if ($this->has($this->file)) {
$this->appendItem($url, $lastMod);
} else {
$this->create('create', $url, $lastMod);
}
} | [
"public",
"function",
"addItem",
"(",
"$",
"url",
",",
"$",
"lastMod",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"this",
"->",
"file",
")",
")",
"{",
"$",
"this",
"->",
"appendItem",
"(",
"$",
"url",
","... | Add item to sitemap.
@param (string) $url Valid url.
@param (string) $lastMod Last modify.
@since 3.0.0
@return void | [
"Add",
"item",
"to",
"sitemap",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/SitemapIndex.php#L112-L119 |
zestframework/Zest_Framework | src/Component/Router.php | Router.loadComponents | public static function loadComponents()
{
$com = new Component();
$file = new FileHandling();
$diskScan = array_diff(scandir(route()->com), ['..', '.']);
foreach ($diskScan as $scans) {
$configFile = route()->com.$scans.'/component.json';
if (file_exists($configFile)) {
$c = $file->open($configFile, 'readOnly')->read();
$file->close();
$config = json_decode($c, true);
if ($config['status'] === true) {
require_once route()->com.$scans.'/routes.php';
}
}
}
require_once 'dispatcher.php';
} | php | public static function loadComponents()
{
$com = new Component();
$file = new FileHandling();
$diskScan = array_diff(scandir(route()->com), ['..', '.']);
foreach ($diskScan as $scans) {
$configFile = route()->com.$scans.'/component.json';
if (file_exists($configFile)) {
$c = $file->open($configFile, 'readOnly')->read();
$file->close();
$config = json_decode($c, true);
if ($config['status'] === true) {
require_once route()->com.$scans.'/routes.php';
}
}
}
require_once 'dispatcher.php';
} | [
"public",
"static",
"function",
"loadComponents",
"(",
")",
"{",
"$",
"com",
"=",
"new",
"Component",
"(",
")",
";",
"$",
"file",
"=",
"new",
"FileHandling",
"(",
")",
";",
"$",
"diskScan",
"=",
"array_diff",
"(",
"scandir",
"(",
"route",
"(",
")",
"... | Load the components.
@since 1.9.7
@return void | [
"Load",
"the",
"components",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Component/Router.php#L30-L47 |
zestframework/Zest_Framework | src/Encryption/Adapter/OpenSslEncryption.php | OpenSslEncryption.encrypt | public function encrypt($data)
{
return base64_encode(openssl_encrypt($data, $this->cipher, $this->key, 0, $this->iv).'&&'.bin2hex($this->iv));
} | php | public function encrypt($data)
{
return base64_encode(openssl_encrypt($data, $this->cipher, $this->key, 0, $this->iv).'&&'.bin2hex($this->iv));
} | [
"public",
"function",
"encrypt",
"(",
"$",
"data",
")",
"{",
"return",
"base64_encode",
"(",
"openssl_encrypt",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"cipher",
",",
"$",
"this",
"->",
"key",
",",
"0",
",",
"$",
"this",
"->",
"iv",
")",
".",
"'&... | Encrypt the message.
@param $data => data to be encrypted
@since 1.0.0
@return token | [
"Encrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Adapter/OpenSslEncryption.php#L65-L68 |
zestframework/Zest_Framework | src/Encryption/Adapter/OpenSslEncryption.php | OpenSslEncryption.decrypt | public function decrypt($token)
{
$token = base64_decode($token);
list($token, $this->iv) = explode('&&', $token);
return openssl_decrypt($token, $this->cipher, $this->key, 0, hex2bin($this->iv));
} | php | public function decrypt($token)
{
$token = base64_decode($token);
list($token, $this->iv) = explode('&&', $token);
return openssl_decrypt($token, $this->cipher, $this->key, 0, hex2bin($this->iv));
} | [
"public",
"function",
"decrypt",
"(",
"$",
"token",
")",
"{",
"$",
"token",
"=",
"base64_decode",
"(",
"$",
"token",
")",
";",
"list",
"(",
"$",
"token",
",",
"$",
"this",
"->",
"iv",
")",
"=",
"explode",
"(",
"'&&'",
",",
"$",
"token",
")",
";",... | Decrypt the message.
@param $token => encrypted token
@since 1.0.0
@return mix-data | [
"Decrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Adapter/OpenSslEncryption.php#L79-L85 |
zestframework/Zest_Framework | src/Common/Maintenance.php | Maintenance.isMaintain | public function isMaintain()
{
if (file_exists(route()->root.'maintained')) {
return true;
} elseif (__config()->config->maintenance) {
return true;
} else {
return false;
}
} | php | public function isMaintain()
{
if (file_exists(route()->root.'maintained')) {
return true;
} elseif (__config()->config->maintenance) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"isMaintain",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"route",
"(",
")",
"->",
"root",
".",
"'maintained'",
")",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"__config",
"(",
")",
"->",
"config",
"->",
"maintenance",... | Check is the site maintaince mode is enable.
@since 2.0.3
@return bool | [
"Check",
"is",
"the",
"site",
"maintaince",
"mode",
"is",
"enable",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Maintenance.php#L28-L37 |
zestframework/Zest_Framework | src/Common/Maintenance.php | Maintenance.updataMaintenance | public function updataMaintenance(bool $status)
{
if ($status) {
if (!file_exists(route()->root.'maintained')) {
$fh = fopen(route()->root.'maintained', 'w');
fwrite($fh, 'maintained');
fclose($fh);
}
} elseif (!$status) {
if (file_exists(route()->root.'maintained')) {
unlink(route()->root.'maintained');
}
} else {
return false;
}
} | php | public function updataMaintenance(bool $status)
{
if ($status) {
if (!file_exists(route()->root.'maintained')) {
$fh = fopen(route()->root.'maintained', 'w');
fwrite($fh, 'maintained');
fclose($fh);
}
} elseif (!$status) {
if (file_exists(route()->root.'maintained')) {
unlink(route()->root.'maintained');
}
} else {
return false;
}
} | [
"public",
"function",
"updataMaintenance",
"(",
"bool",
"$",
"status",
")",
"{",
"if",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"route",
"(",
")",
"->",
"root",
".",
"'maintained'",
")",
")",
"{",
"$",
"fh",
"=",
"fopen",
"... | Upgrade the maintaince mode dynamically.
@param (bool) $status
@since 2.0.3
@return void | [
"Upgrade",
"the",
"maintaince",
"mode",
"dynamically",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Maintenance.php#L48-L63 |
zestframework/Zest_Framework | src/Auth/Verify.php | Verify.verify | public function verify($token)
{
$user = new User();
if ($token === 'NULL' || $user->isToken($token) !== true) {
Error::set(__printl('auth:error:token'), 'token');
}
if ($this->fail() !== true) {
if (!(new User())->isLogin()) {
$id = $user->getByWhere('token', $token)[0]['id'];
$email = $user->getByWhere('token', $token)[0]['email'];
$update = new Update();
$update->update(['token' => 'NULL'], $id);
$subject = __printl('auth:subject:verified');
$link = __config()->auth->verification_link.'/'.$token;
$html = __printl('auth:body:verified');
$html = str_replace(':email', $email, $html);
$email = new EmailHandler($subject, $html, $email);
Success::set(__config()->auth->success->verified);
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
}
} | php | public function verify($token)
{
$user = new User();
if ($token === 'NULL' || $user->isToken($token) !== true) {
Error::set(__printl('auth:error:token'), 'token');
}
if ($this->fail() !== true) {
if (!(new User())->isLogin()) {
$id = $user->getByWhere('token', $token)[0]['id'];
$email = $user->getByWhere('token', $token)[0]['email'];
$update = new Update();
$update->update(['token' => 'NULL'], $id);
$subject = __printl('auth:subject:verified');
$link = __config()->auth->verification_link.'/'.$token;
$html = __printl('auth:body:verified');
$html = str_replace(':email', $email, $html);
$email = new EmailHandler($subject, $html, $email);
Success::set(__config()->auth->success->verified);
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
}
} | [
"public",
"function",
"verify",
"(",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"if",
"(",
"$",
"token",
"===",
"'NULL'",
"||",
"$",
"user",
"->",
"isToken",
"(",
"$",
"token",
")",
"!==",
"true",
")",
"{",
"Error",
... | Verify the user base on token.
@param (mixed) $token token of user
@since 2.0.3
@return void | [
"Verify",
"the",
"user",
"base",
"on",
"token",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Verify.php#L30-L52 |
zestframework/Zest_Framework | src/Encryption/Encrypt.php | Encrypt.setAdapter | public static function setAdapter($adapter)
{
switch (strtolower($adapter)) {
case 'sodium':
$adapterSet = '\Zest\Encryption\Adapter\SodiumEncryption';
break;
case 'openssl':
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
default:
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
}
$key = __config()->encryption->key;
self::$adapter = new $adapterSet($key);
return __CLASS__;
} | php | public static function setAdapter($adapter)
{
switch (strtolower($adapter)) {
case 'sodium':
$adapterSet = '\Zest\Encryption\Adapter\SodiumEncryption';
break;
case 'openssl':
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
default:
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
}
$key = __config()->encryption->key;
self::$adapter = new $adapterSet($key);
return __CLASS__;
} | [
"public",
"static",
"function",
"setAdapter",
"(",
"$",
"adapter",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"adapter",
")",
")",
"{",
"case",
"'sodium'",
":",
"$",
"adapterSet",
"=",
"'\\Zest\\Encryption\\Adapter\\SodiumEncryption'",
";",
"break",
";",
... | Set the adapter.
@param (string) $adapter
@since 3.0.0
@return object | [
"Set",
"the",
"adapter",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Encrypt.php#L41-L58 |
zestframework/Zest_Framework | src/Encryption/Encrypt.php | Encrypt.encrypt | public static function encrypt($data, $adapter = null)
{
($adapter !== null) ? self::setAdapter($adapter) : self::setAdapter(__config()->encryption->driver);
return self::$adapter->encrypt($data);
} | php | public static function encrypt($data, $adapter = null)
{
($adapter !== null) ? self::setAdapter($adapter) : self::setAdapter(__config()->encryption->driver);
return self::$adapter->encrypt($data);
} | [
"public",
"static",
"function",
"encrypt",
"(",
"$",
"data",
",",
"$",
"adapter",
"=",
"null",
")",
"{",
"(",
"$",
"adapter",
"!==",
"null",
")",
"?",
"self",
"::",
"setAdapter",
"(",
"$",
"adapter",
")",
":",
"self",
"::",
"setAdapter",
"(",
"__conf... | Encrypt the message.
@param (mixed) $data data to be encrypted
@since 3.0.0
@return mixed | [
"Encrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Encrypt.php#L69-L74 |
zestframework/Zest_Framework | src/Encryption/Encrypt.php | Encrypt.decrypt | public static function decrypt($token, $adapter = null)
{
($adapter !== null) ? self::setAdapter($adapter) : self::setAdapter(__config()->encryption->driver);
return self::$adapter->decrypt($token);
} | php | public static function decrypt($token, $adapter = null)
{
($adapter !== null) ? self::setAdapter($adapter) : self::setAdapter(__config()->encryption->driver);
return self::$adapter->decrypt($token);
} | [
"public",
"static",
"function",
"decrypt",
"(",
"$",
"token",
",",
"$",
"adapter",
"=",
"null",
")",
"{",
"(",
"$",
"adapter",
"!==",
"null",
")",
"?",
"self",
"::",
"setAdapter",
"(",
"$",
"adapter",
")",
":",
"self",
"::",
"setAdapter",
"(",
"__con... | Decrypt the message.
@param (mixed) $token encrypted token
@since 3.0.0
@return mixed | [
"Decrypt",
"the",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Encrypt.php#L85-L90 |
zestframework/Zest_Framework | src/Auth/Error.php | Error.set | public static function set($error, $key = null)
{
if (isset($key)) {
static::$errors[$key] = $error;
} else {
static::$errors = $error;
}
} | php | public static function set($error, $key = null)
{
if (isset($key)) {
static::$errors[$key] = $error;
} else {
static::$errors = $error;
}
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"error",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"key",
")",
")",
"{",
"static",
"::",
"$",
"errors",
"[",
"$",
"key",
"]",
"=",
"$",
"error",
";",
"}",
"else",
"{... | Set the error msg.
@param (string) $error error msg
@param (string) optional $key key of error msg like username
@since 2.0.3
@return bool | [
"Set",
"the",
"error",
"msg",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Error.php#L40-L47 |
zestframework/Zest_Framework | src/Encryption/Encryption.php | Encryption.setAdapter | public function setAdapter($adapter)
{
switch (strtolower($adapter)) {
case 'sodium':
$adapterSet = '\Zest\Encryption\Adapter\SodiumEncryption';
break;
case 'openssl':
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
default:
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
}
$key = __config()->encryption->key;
$this->adapter = new $adapterSet($key);
return $this;
} | php | public function setAdapter($adapter)
{
switch (strtolower($adapter)) {
case 'sodium':
$adapterSet = '\Zest\Encryption\Adapter\SodiumEncryption';
break;
case 'openssl':
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
default:
$adapterSet = '\Zest\Encryption\Adapter\OpenSslEncryption';
break;
}
$key = __config()->encryption->key;
$this->adapter = new $adapterSet($key);
return $this;
} | [
"public",
"function",
"setAdapter",
"(",
"$",
"adapter",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"adapter",
")",
")",
"{",
"case",
"'sodium'",
":",
"$",
"adapterSet",
"=",
"'\\Zest\\Encryption\\Adapter\\SodiumEncryption'",
";",
"break",
";",
"case",
"... | Set the adapter.
@param (string) $adapter
@since 3.0.0
@return object | [
"Set",
"the",
"adapter",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Encryption/Encryption.php#L51-L68 |
zestframework/Zest_Framework | src/Zip/Zip.php | Zip.extract | public function extract($file, $target, $delete = false)
{
$zip = new \ZipArchive();
$x = $zip->open($file);
if ($x === true) {
$zip->extractTo($target);
$zip->close();
if ($delete === true) {
unlink($file);
}
return true;
}
} | php | public function extract($file, $target, $delete = false)
{
$zip = new \ZipArchive();
$x = $zip->open($file);
if ($x === true) {
$zip->extractTo($target);
$zip->close();
if ($delete === true) {
unlink($file);
}
return true;
}
} | [
"public",
"function",
"extract",
"(",
"$",
"file",
",",
"$",
"target",
",",
"$",
"delete",
"=",
"false",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"x",
"=",
"$",
"zip",
"->",
"open",
"(",
"$",
"file",
")",
";",
... | Open zip extract zip.
@param (string) $file file that you want uncompress/open
@param (string) $target where you extract file
@param (bool) $delete true delete zip file false not delete
@since 1.0.0
@return bool | [
"Open",
"zip",
"extract",
"zip",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Zip/Zip.php#L34-L47 |
zestframework/Zest_Framework | src/Validation/JsonRules.php | JsonRules.validate | public function validate($value)
{
if ($this->notBeEmpty($value)) {
$value = json_decode($value);
if ($value !== null) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function validate($value)
{
if ($this->notBeEmpty($value)) {
$value = json_decode($value);
if ($value !== null) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notBeEmpty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")... | Evaulate Json.
@param $value Value to be checked
@return bool | [
"Evaulate",
"Json",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/JsonRules.php#L26-L38 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.addBcc | public function addBcc($bcc)
{
if ($this->isValidEmail($bcc) === true) {
if (is_array($bcc, $this->bcc) === false) {
$this->bcc[] = $bcc;
}
}
return false;
} | php | public function addBcc($bcc)
{
if ($this->isValidEmail($bcc) === true) {
if (is_array($bcc, $this->bcc) === false) {
$this->bcc[] = $bcc;
}
}
return false;
} | [
"public",
"function",
"addBcc",
"(",
"$",
"bcc",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidEmail",
"(",
"$",
"bcc",
")",
"===",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"bcc",
",",
"$",
"this",
"->",
"bcc",
")",
"===",
"false",
... | For add a new BCC.
@param string $bcc
@since 1.9.0
@return bool | [
"For",
"add",
"a",
"new",
"BCC",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L134-L143 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.addCc | public function addCc($cc)
{
if ($this->isValidEmail($cc) === true) {
if (is_array($cc, $this->cc) === false) {
$this->cc[] = $cc;
}
}
return false;
} | php | public function addCc($cc)
{
if ($this->isValidEmail($cc) === true) {
if (is_array($cc, $this->cc) === false) {
$this->cc[] = $cc;
}
}
return false;
} | [
"public",
"function",
"addCc",
"(",
"$",
"cc",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidEmail",
"(",
"$",
"cc",
")",
"===",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"cc",
",",
"$",
"this",
"->",
"cc",
")",
"===",
"false",
")",
... | For adding a new cc.
@param string $cc
@since 1.9.0
@return bool | [
"For",
"adding",
"a",
"new",
"cc",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L154-L163 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.addReceiver | public function addReceiver($email)
{
if ($this->isValidEmail($email) === true) {
if (@is_array($email, $this->receivers) === false) {
$this->receivers[] = $email;
}
}
return false;
} | php | public function addReceiver($email)
{
if ($this->isValidEmail($email) === true) {
if (@is_array($email, $this->receivers) === false) {
$this->receivers[] = $email;
}
}
return false;
} | [
"public",
"function",
"addReceiver",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidEmail",
"(",
"$",
"email",
")",
"===",
"true",
")",
"{",
"if",
"(",
"@",
"is_array",
"(",
"$",
"email",
",",
"$",
"this",
"->",
"receivers",
")"... | For adding a receiver.
@param string $email
@since 1.9.0
@return bool | [
"For",
"adding",
"a",
"receiver",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L174-L183 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.prepareAttachment | public function prepareAttachment($attachment)
{
if ($this->isFile($attachment) !== true) {
return false;
}
//http://php.net/manual/en/class.finfo.php
$fileInfo = new \finfo(FILEINFO_MIME_TYPE);
$fileType = $fileInfo->file($attachment);
$file = fopen($attachment, 'r');
$fileContent = fread($file, filesize($attachment));
$fileContent = chunk_split(base64_encode($fileContent));
fclose($file);
$msgContent = 'Content-Type: '.$fileType.'; name='.basename($attachment)."\r\n";
$msgContent .= 'Content-Transfer-Encoding: base64'."\r\n";
$msgContent .= 'Content-ID: <'.basename($attachment).'>'."\r\n";
$msgContent .= "\r\n".$fileContent."\r\n\r\n";
return $msgContent;
} | php | public function prepareAttachment($attachment)
{
if ($this->isFile($attachment) !== true) {
return false;
}
//http://php.net/manual/en/class.finfo.php
$fileInfo = new \finfo(FILEINFO_MIME_TYPE);
$fileType = $fileInfo->file($attachment);
$file = fopen($attachment, 'r');
$fileContent = fread($file, filesize($attachment));
$fileContent = chunk_split(base64_encode($fileContent));
fclose($file);
$msgContent = 'Content-Type: '.$fileType.'; name='.basename($attachment)."\r\n";
$msgContent .= 'Content-Transfer-Encoding: base64'."\r\n";
$msgContent .= 'Content-ID: <'.basename($attachment).'>'."\r\n";
$msgContent .= "\r\n".$fileContent."\r\n\r\n";
return $msgContent;
} | [
"public",
"function",
"prepareAttachment",
"(",
"$",
"attachment",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"attachment",
")",
"!==",
"true",
")",
"{",
"return",
"false",
";",
"}",
"//http://php.net/manual/en/class.finfo.php",
"$",
"fileInfo... | For preparing an attachment to send with mail.
@since 1.9.0
@return mix-data | [
"For",
"preparing",
"an",
"attachment",
"to",
"send",
"with",
"mail",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L192-L210 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.send | public function send()
{
//Check if a sender is available.
if (empty(trim($this->sender))) {
return false;
}
if ((is_array($this->receivers) === false) || (count($this->receivers) < 1)) {
return false;
}
$receivers = implode(',', $this->receivers);
if (!empty(trim($this->replyTo))) {
$headers[] = 'Reply-To: '.$this->replyTo;
} else {
$headers[] = 'Reply-To: '.$this->sender;
}
if ((is_array($this->bcc) === true) && (count($this->bcc) > 0)) {
$headers[] = 'Bcc: '.implode(',', $this->bcc);
}
if ((is_array($this->cc) === true) && (count($this->cc) > 0)) {
$headers[] = 'Cc: '.implode(',', $this->cc);
}
//Generate boundaries for mail content areas.
$boundaryMessage = md5(rand().'message');
$boundaryContent = md5(rand().'content');
//Set the header informations of the mail.
$headers = [];
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'X-Mailer: PHP/'.phpversion();
$headers[] = 'Date: '.date('r', $_SERVER['REQUEST_TIME']);
$headers[] = 'X-Originating-IP: '.$_SERVER['SERVER_ADDR'];
$headers[] = 'Content-Type: multipart/related;boundary='.$boundaryMessage;
$headers[] = 'Content-Transfer-Encoding: 8bit';
$headers[] = 'From: '.$this->sender;
$headers[] = 'Return-Path: '.$this->sender;
//Start to generate the content of the mail.
$msgContent = "\r\n".'--'.$boundaryMessage."\r\n";
$msgContent .= 'Content-Type: multipart/alternative; boundary='.$boundaryContent."\r\n";
if (!empty(trim($this->contentPlain))) {
$msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
$msgContent .= 'Content-Type: text/plain; charset=ISO-8859-1'."\r\n";
$msgContent .= "\r\n".$this->contentPlain."\r\n";
}
if (!empty(trim($this->contentHTML))) {
$msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
$msgContent .= 'Content-Type: text/html; charset=ISO-8859-1'."\r\n";
$msgContent .= "\r\n".$this->contentHTML."\r\n";
}
//Close the message area of the mail.
$msgContent .= "\r\n".'--'.$boundaryContent.'--'."\r\n";
foreach ($this->attachments as $attachment) {
$attachmentContent = $this->prepareAttachment($attachment);
if ($attachmentContent !== false) {
$msgContent .= "\r\n".'--'.$boundaryMessage."\r\n";
$msgContent .= $attachmentContent;
}
}
//Close the area of the whole mail content.
$msgContent .= "\r\n".'--'.$boundaryMessage.'--'."\r\n";
if (!isset($this->smtp['status']) || $this->smtp['status'] === false) {
$return = mail($receivers, $this->subject, $msgContent, implode("\r\n", $headers), $this->addparams);
} else {
$return = $this->sendSMTP($receivers, $this->sender, $msgContent);
}
return $return;
} | php | public function send()
{
//Check if a sender is available.
if (empty(trim($this->sender))) {
return false;
}
if ((is_array($this->receivers) === false) || (count($this->receivers) < 1)) {
return false;
}
$receivers = implode(',', $this->receivers);
if (!empty(trim($this->replyTo))) {
$headers[] = 'Reply-To: '.$this->replyTo;
} else {
$headers[] = 'Reply-To: '.$this->sender;
}
if ((is_array($this->bcc) === true) && (count($this->bcc) > 0)) {
$headers[] = 'Bcc: '.implode(',', $this->bcc);
}
if ((is_array($this->cc) === true) && (count($this->cc) > 0)) {
$headers[] = 'Cc: '.implode(',', $this->cc);
}
//Generate boundaries for mail content areas.
$boundaryMessage = md5(rand().'message');
$boundaryContent = md5(rand().'content');
//Set the header informations of the mail.
$headers = [];
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'X-Mailer: PHP/'.phpversion();
$headers[] = 'Date: '.date('r', $_SERVER['REQUEST_TIME']);
$headers[] = 'X-Originating-IP: '.$_SERVER['SERVER_ADDR'];
$headers[] = 'Content-Type: multipart/related;boundary='.$boundaryMessage;
$headers[] = 'Content-Transfer-Encoding: 8bit';
$headers[] = 'From: '.$this->sender;
$headers[] = 'Return-Path: '.$this->sender;
//Start to generate the content of the mail.
$msgContent = "\r\n".'--'.$boundaryMessage."\r\n";
$msgContent .= 'Content-Type: multipart/alternative; boundary='.$boundaryContent."\r\n";
if (!empty(trim($this->contentPlain))) {
$msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
$msgContent .= 'Content-Type: text/plain; charset=ISO-8859-1'."\r\n";
$msgContent .= "\r\n".$this->contentPlain."\r\n";
}
if (!empty(trim($this->contentHTML))) {
$msgContent .= "\r\n".'--'.$boundaryContent."\r\n";
$msgContent .= 'Content-Type: text/html; charset=ISO-8859-1'."\r\n";
$msgContent .= "\r\n".$this->contentHTML."\r\n";
}
//Close the message area of the mail.
$msgContent .= "\r\n".'--'.$boundaryContent.'--'."\r\n";
foreach ($this->attachments as $attachment) {
$attachmentContent = $this->prepareAttachment($attachment);
if ($attachmentContent !== false) {
$msgContent .= "\r\n".'--'.$boundaryMessage."\r\n";
$msgContent .= $attachmentContent;
}
}
//Close the area of the whole mail content.
$msgContent .= "\r\n".'--'.$boundaryMessage.'--'."\r\n";
if (!isset($this->smtp['status']) || $this->smtp['status'] === false) {
$return = mail($receivers, $this->subject, $msgContent, implode("\r\n", $headers), $this->addparams);
} else {
$return = $this->sendSMTP($receivers, $this->sender, $msgContent);
}
return $return;
} | [
"public",
"function",
"send",
"(",
")",
"{",
"//Check if a sender is available.",
"if",
"(",
"empty",
"(",
"trim",
"(",
"$",
"this",
"->",
"sender",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"is_array",
"(",
"$",
"this",
"->",
... | For send the mail.
@since 1.9.0
@return boolean. | [
"For",
"send",
"the",
"mail",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L219-L284 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.isValidEmail | public function isValidEmail($email)
{
if (filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
return true;
}
if (filter_var($email, FILTER_SANITIZE_EMAIL) !== false) {
return true;
} else {
return false;
}
} | php | public function isValidEmail($email)
{
if (filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
return true;
}
if (filter_var($email, FILTER_SANITIZE_EMAIL) !== false) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"isValidEmail",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FILTER_VALIDATE_EMAIL",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"filter_var",
"(",
"$",
"email",
",",
"FI... | Check is email is valid.
@param string $email
@since 1.9.0
@return bool | [
"Check",
"is",
"email",
"is",
"valid",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L295-L305 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.isSMTP | public function isSMTP(bool $status = false)
{
if ($status === true) {
$this->smtp['status'] = $status;
} else {
$this->smtp['status'] = $status;
}
} | php | public function isSMTP(bool $status = false)
{
if ($status === true) {
$this->smtp['status'] = $status;
} else {
$this->smtp['status'] = $status;
}
} | [
"public",
"function",
"isSMTP",
"(",
"bool",
"$",
"status",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"status",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"smtp",
"[",
"'status'",
"]",
"=",
"$",
"status",
";",
"}",
"else",
"{",
"$",
"this",
"->",
... | Set SMPT status.
@param $status
@since 1.9.0
@return bool | [
"Set",
"SMPT",
"status",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L316-L323 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.sendSMTP | public function sendSMTP($to, $from, $message)
{
$host = __config()->email->smtp_host;
$user = __config()->email->smtp_user;
$pass = __config()->email->smtp_pass;
$port = __config()->email->smtp_port;
if ($h = fsockopen($host, $port)) {
$data = [
0,
"EHLO $host",
'AUTH LOGIN',
base64_encode($user),
base64_encode($pass),
"MAIL FROM: <$from>",
"RCPT TO: <$to>",
'DATA',
$message,
];
foreach ($data as $c) {
$c && fwrite($h, "$c\r\n");
while (substr(fgets($h, 256), 3, 1) != ' ') {
}
}
fwrite($h, "QUIT\r\n");
return fclose($h);
}
} | php | public function sendSMTP($to, $from, $message)
{
$host = __config()->email->smtp_host;
$user = __config()->email->smtp_user;
$pass = __config()->email->smtp_pass;
$port = __config()->email->smtp_port;
if ($h = fsockopen($host, $port)) {
$data = [
0,
"EHLO $host",
'AUTH LOGIN',
base64_encode($user),
base64_encode($pass),
"MAIL FROM: <$from>",
"RCPT TO: <$to>",
'DATA',
$message,
];
foreach ($data as $c) {
$c && fwrite($h, "$c\r\n");
while (substr(fgets($h, 256), 3, 1) != ' ') {
}
}
fwrite($h, "QUIT\r\n");
return fclose($h);
}
} | [
"public",
"function",
"sendSMTP",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"message",
")",
"{",
"$",
"host",
"=",
"__config",
"(",
")",
"->",
"email",
"->",
"smtp_host",
";",
"$",
"user",
"=",
"__config",
"(",
")",
"->",
"email",
"->",
"smtp_use... | Send mail over SMTP.
@param $to sender email
$from from email
$message message to be send
@since 1.9.0
@return bool | [
"Send",
"mail",
"over",
"SMTP",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L336-L363 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.setReplyTo | public function setReplyTo($email)
{
if ($this->isValidEmail($email) === true) {
$this->reply_to = $email;
} else {
return false;
}
} | php | public function setReplyTo($email)
{
if ($this->isValidEmail($email) === true) {
$this->reply_to = $email;
} else {
return false;
}
} | [
"public",
"function",
"setReplyTo",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidEmail",
"(",
"$",
"email",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"reply_to",
"=",
"$",
"email",
";",
"}",
"else",
"{",
"return",
"fals... | For set reply_to in mail.
@param string $subject The subject of the mail.
@since 1.9.0
@return bool | [
"For",
"set",
"reply_to",
"in",
"mail",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L418-L425 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.setSender | public function setSender($email)
{
if ($this->isValidEmail($email) === true) {
$this->sender = $email;
} else {
return false;
}
} | php | public function setSender($email)
{
if ($this->isValidEmail($email) === true) {
$this->sender = $email;
} else {
return false;
}
} | [
"public",
"function",
"setSender",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidEmail",
"(",
"$",
"email",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"sender",
"=",
"$",
"email",
";",
"}",
"else",
"{",
"return",
"false",... | For set sender in mail.
@param string $subject The subject of the mail.
@since 1.9.0
@return bool | [
"For",
"set",
"sender",
"in",
"mail",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L436-L443 |
zestframework/Zest_Framework | src/Mail/Mail.php | Mail.clear | public function clear()
{
unset($this->cc);
unset($this->bcc);
unset($this->receivers);
unset($this->attachments);
unset($this->contentHTML);
unset($this->contentPlain);
} | php | public function clear()
{
unset($this->cc);
unset($this->bcc);
unset($this->receivers);
unset($this->attachments);
unset($this->contentHTML);
unset($this->contentPlain);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"cc",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"bcc",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"receivers",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"attachments... | Clear all the information.
@since 1.9.0
@return void | [
"Clear",
"all",
"the",
"information",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Mail/Mail.php#L484-L492 |
zestframework/Zest_Framework | src/Auth/Signup.php | Signup.signup | public function signup($username, $email, $password, $params)
{
$rules = [
'username' => ['required' => true],
'email' => ['required' => true, 'email' => true],
'password' => ['required' => true],
];
$inputs = [
'username' => $username,
'email' => $email,
'password' => $password,
];
$requireValidate = new Validation($inputs, $rules);
if ($requireValidate->fail()) {
Error::set($requireValidate->error()->get());
}
$uniqueUsername = new Validation(['field'=> 'username', 'value'=>$username], __config()->auth->db_table, 'database');
if ($uniqueUsername->fail()) {
Error::set($uniqueUsername->error()->get());
}
$uniqueEmail = new Validation(['field'=> 'email', 'value'=>$email], __config()->auth->db_table, 'database');
if ($uniqueEmail->fail()) {
Error::set($uniqueEmail->error()->get());
}
if (is_array($params)) {
foreach (array_keys($params) as $key => $value) {
$paramsRules = [$value => ['required' => true]];
}
$paramsValidate = new Validation($params, $paramsRules);
if ($paramsValidate->fail()) {
Error::set($paramsValidate->error()->get());
}
if (isset($params['passConfirm'])) {
if ($password !== $params['passConfirm']) {
Error::set(__printl('auth:error:password:confirm'), 'password');
}
}
}
if (__config()->auth->sticky_password) {
if (!(new PasswordManipulation())->isValid($password)) {
Error::set(__printl('auth:error:password:sticky'), 'password');
}
}
if (!(new User())->isLogin()) {
if ($this->fail() !== true) {
$salts = (new Site())::salts(12);
$password_hash = Hash::make($password);
if (__config()->auth->is_verify_email) {
$token = (new Site())::salts(8);
} else {
$token = 'NULL';
}
$param = [
'username' => $username,
'email' => $email,
'password' => $password_hash,
'salts' => $salts,
'token' => $token,
];
$fields = [
'db_name' => __config()->auth->db_name,
'table' => __config()->auth->db_table,
];
unset($params['passConfirm']);
$data = ['columns' => array_merge($param, $params)];
$values = array_merge($fields, $data);
$db = new DB();
Success::set($db->db()->insert($values));
$db->db()->close();
if (__config()->auth->is_verify_email === true) {
$subject = __printl('auth:subject:need:verify');
$link = site_base_url().__config()->auth->verification_link.'/'.$token;
$html = __printl('auth:body:need:verify');
$html = str_replace(':email', $email, $html);
$html = str_replace(':link', $link, $html);
(new EmailHandler($subject, $html, $email));
}
}
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
} | php | public function signup($username, $email, $password, $params)
{
$rules = [
'username' => ['required' => true],
'email' => ['required' => true, 'email' => true],
'password' => ['required' => true],
];
$inputs = [
'username' => $username,
'email' => $email,
'password' => $password,
];
$requireValidate = new Validation($inputs, $rules);
if ($requireValidate->fail()) {
Error::set($requireValidate->error()->get());
}
$uniqueUsername = new Validation(['field'=> 'username', 'value'=>$username], __config()->auth->db_table, 'database');
if ($uniqueUsername->fail()) {
Error::set($uniqueUsername->error()->get());
}
$uniqueEmail = new Validation(['field'=> 'email', 'value'=>$email], __config()->auth->db_table, 'database');
if ($uniqueEmail->fail()) {
Error::set($uniqueEmail->error()->get());
}
if (is_array($params)) {
foreach (array_keys($params) as $key => $value) {
$paramsRules = [$value => ['required' => true]];
}
$paramsValidate = new Validation($params, $paramsRules);
if ($paramsValidate->fail()) {
Error::set($paramsValidate->error()->get());
}
if (isset($params['passConfirm'])) {
if ($password !== $params['passConfirm']) {
Error::set(__printl('auth:error:password:confirm'), 'password');
}
}
}
if (__config()->auth->sticky_password) {
if (!(new PasswordManipulation())->isValid($password)) {
Error::set(__printl('auth:error:password:sticky'), 'password');
}
}
if (!(new User())->isLogin()) {
if ($this->fail() !== true) {
$salts = (new Site())::salts(12);
$password_hash = Hash::make($password);
if (__config()->auth->is_verify_email) {
$token = (new Site())::salts(8);
} else {
$token = 'NULL';
}
$param = [
'username' => $username,
'email' => $email,
'password' => $password_hash,
'salts' => $salts,
'token' => $token,
];
$fields = [
'db_name' => __config()->auth->db_name,
'table' => __config()->auth->db_table,
];
unset($params['passConfirm']);
$data = ['columns' => array_merge($param, $params)];
$values = array_merge($fields, $data);
$db = new DB();
Success::set($db->db()->insert($values));
$db->db()->close();
if (__config()->auth->is_verify_email === true) {
$subject = __printl('auth:subject:need:verify');
$link = site_base_url().__config()->auth->verification_link.'/'.$token;
$html = __printl('auth:body:need:verify');
$html = str_replace(':email', $email, $html);
$html = str_replace(':link', $link, $html);
(new EmailHandler($subject, $html, $email));
}
}
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
} | [
"public",
"function",
"signup",
"(",
"$",
"username",
",",
"$",
"email",
",",
"$",
"password",
",",
"$",
"params",
")",
"{",
"$",
"rules",
"=",
"[",
"'username'",
"=>",
"[",
"'required'",
"=>",
"true",
"]",
",",
"'email'",
"=>",
"[",
"'required'",
"=... | Signup the users.
@param (mixed) $username username of user
@param (mixed) $email email of user
@param (mixed) $password password of users
@param (array) $params extra field like [name => value] array
@since 2.0.3
@return bool | [
"Signup",
"the",
"users",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Signup.php#L48-L129 |
zestframework/Zest_Framework | src/SystemMessage/SystemMessage.php | SystemMessage.add | public function add($params)
{
if (is_array($params)) {
if (!empty($params['msg'])) {
if (isset($params['type']) && !empty($params['type'])) {
$this->type($params['type']);
} else {
$this->type = 'light';
}
Session::set('sys_msg', ['msg'=>$params['msg'], 'type'=>$this->type]);
return true;
}
} else {
return false;
}
} | php | public function add($params)
{
if (is_array($params)) {
if (!empty($params['msg'])) {
if (isset($params['type']) && !empty($params['type'])) {
$this->type($params['type']);
} else {
$this->type = 'light';
}
Session::set('sys_msg', ['msg'=>$params['msg'], 'type'=>$this->type]);
return true;
}
} else {
return false;
}
} | [
"public",
"function",
"add",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'msg'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"... | Add the system message.
@param $params['msg'] => message to be store
$params['type'] => alert type
@since 1.0.0
@return bool | [
"Add",
"the",
"system",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/SystemMessage/SystemMessage.php#L43-L59 |
zestframework/Zest_Framework | src/SystemMessage/SystemMessage.php | SystemMessage.type | protected function type($type)
{
$type = strtolower($type);
switch ($type) {
case 'success':
$type = 'success';
break;
case 'error':
$type = 'danger';
break;
case 'information':
$type = 'info';
break;
case 'warning':
$type = 'warning';
break;
case 'primary':
$type = 'primary';
break;
case 'secondary':
$type = 'secondary';
break;
case 'dark':
$type = 'Dark';
break;
default:
$type = 'light';
break;
}
$this->type = $type;
} | php | protected function type($type)
{
$type = strtolower($type);
switch ($type) {
case 'success':
$type = 'success';
break;
case 'error':
$type = 'danger';
break;
case 'information':
$type = 'info';
break;
case 'warning':
$type = 'warning';
break;
case 'primary':
$type = 'primary';
break;
case 'secondary':
$type = 'secondary';
break;
case 'dark':
$type = 'Dark';
break;
default:
$type = 'light';
break;
}
$this->type = $type;
} | [
"protected",
"function",
"type",
"(",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'success'",
":",
"$",
"type",
"=",
"'success'",
";",
"break",
";",
"case",
"'err... | Set the type of message.
@param $type => alert type
@since 1.0.0
@return void | [
"Set",
"the",
"type",
"of",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/SystemMessage/SystemMessage.php#L70-L100 |
zestframework/Zest_Framework | src/SystemMessage/SystemMessage.php | SystemMessage.view | public function view()
{
$sys_msg = Session::get('sys_msg');
$msg = (isset($sys_msg['msg'])) ? $sys_msg['msg'] : null;
$type = (isset($sys_msg['type'])) ? $sys_msg['type'] : null;
if (isset($msg) && isset($type)) {
$msg = "<div class='alert alert-".$type."'>".'<a href="#" class="close" data-dismiss="alert">×</a>'.$msg.'</div>';
$msg_data[] = $msg;
}
if (isset($msg_data)) {
$data = implode('', $msg_data);
Session::delete('sys_msg');
//unset($_SESSION['sys_msg']);
return $data;
}
} | php | public function view()
{
$sys_msg = Session::get('sys_msg');
$msg = (isset($sys_msg['msg'])) ? $sys_msg['msg'] : null;
$type = (isset($sys_msg['type'])) ? $sys_msg['type'] : null;
if (isset($msg) && isset($type)) {
$msg = "<div class='alert alert-".$type."'>".'<a href="#" class="close" data-dismiss="alert">×</a>'.$msg.'</div>';
$msg_data[] = $msg;
}
if (isset($msg_data)) {
$data = implode('', $msg_data);
Session::delete('sys_msg');
//unset($_SESSION['sys_msg']);
return $data;
}
} | [
"public",
"function",
"view",
"(",
")",
"{",
"$",
"sys_msg",
"=",
"Session",
"::",
"get",
"(",
"'sys_msg'",
")",
";",
"$",
"msg",
"=",
"(",
"isset",
"(",
"$",
"sys_msg",
"[",
"'msg'",
"]",
")",
")",
"?",
"$",
"sys_msg",
"[",
"'msg'",
"]",
":",
... | View the system message.
@since 1.0.0
@return string | [
"View",
"the",
"system",
"message",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/SystemMessage/SystemMessage.php#L109-L125 |
zestframework/Zest_Framework | src/Validation/Handler.php | Handler.pushMsgs | public static function pushMsgs()
{
static::$msgs = [
'string' => __printl('string:validation'),
'required' => __printl('required:validation'),
'int' => __printl('int:validation'),
'float' => __printl('float:validation'),
'email' => __printl('email:validation'),
'ip' => __printl('ip:validation'),
'ipv6' => __printl('ipv6:validation'),
'alpha' => __printl('alpha:validation'),
'subnet' => __printl('subnet:validation'),
'validate' => __printl('validate:validation'),
'unique' => __printl('unique:validation'),
];
} | php | public static function pushMsgs()
{
static::$msgs = [
'string' => __printl('string:validation'),
'required' => __printl('required:validation'),
'int' => __printl('int:validation'),
'float' => __printl('float:validation'),
'email' => __printl('email:validation'),
'ip' => __printl('ip:validation'),
'ipv6' => __printl('ipv6:validation'),
'alpha' => __printl('alpha:validation'),
'subnet' => __printl('subnet:validation'),
'validate' => __printl('validate:validation'),
'unique' => __printl('unique:validation'),
];
} | [
"public",
"static",
"function",
"pushMsgs",
"(",
")",
"{",
"static",
"::",
"$",
"msgs",
"=",
"[",
"'string'",
"=>",
"__printl",
"(",
"'string:validation'",
")",
",",
"'required'",
"=>",
"__printl",
"(",
"'required:validation'",
")",
",",
"'int'",
"=>",
"__pr... | Push the messages.
@return void | [
"Push",
"the",
"messages",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/Handler.php#L33-L48 |
zestframework/Zest_Framework | src/UserInfo/UserInfo.php | UserInfo.operatingSystem | public function operatingSystem()
{
$UserAgent = self::agent();
if (preg_match_all('/windows/i', $UserAgent)) {
$PlatForm = 'Windows';
} elseif (preg_match_all('/linux/i', $UserAgent)) {
$PlatForm = 'Linux';
} elseif (preg_match('/macintosh|mac os x/i', $UserAgent)) {
$PlatForm = 'Macintosh';
} elseif (preg_match_all('/Android/i', $UserAgent)) {
$PlatForm = 'Android';
} elseif (preg_match_all('/iPhone/i', $UserAgent)) {
$PlatForm = 'IOS';
} elseif (preg_match_all('/ubuntu/i', $UserAgent)) {
$PlatForm = 'Ubuntu';
} else {
$PlatForm = 'unknown';
}
return $PlatForm;
} | php | public function operatingSystem()
{
$UserAgent = self::agent();
if (preg_match_all('/windows/i', $UserAgent)) {
$PlatForm = 'Windows';
} elseif (preg_match_all('/linux/i', $UserAgent)) {
$PlatForm = 'Linux';
} elseif (preg_match('/macintosh|mac os x/i', $UserAgent)) {
$PlatForm = 'Macintosh';
} elseif (preg_match_all('/Android/i', $UserAgent)) {
$PlatForm = 'Android';
} elseif (preg_match_all('/iPhone/i', $UserAgent)) {
$PlatForm = 'IOS';
} elseif (preg_match_all('/ubuntu/i', $UserAgent)) {
$PlatForm = 'Ubuntu';
} else {
$PlatForm = 'unknown';
}
return $PlatForm;
} | [
"public",
"function",
"operatingSystem",
"(",
")",
"{",
"$",
"UserAgent",
"=",
"self",
"::",
"agent",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/windows/i'",
",",
"$",
"UserAgent",
")",
")",
"{",
"$",
"PlatForm",
"=",
"'Windows'",
";",
"}",
"e... | Get OperatingSystem name.
@since 1.0.0
@return void | [
"Get",
"OperatingSystem",
"name",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/UserInfo/UserInfo.php#L40-L60 |
zestframework/Zest_Framework | src/UserInfo/UserInfo.php | UserInfo.browser | public function browser()
{
$UserAgent = self::agent();
if (preg_match_all('/Edge/i', $UserAgent)) {
$Browser = 'Microsoft Edge';
$B_Agent = 'Edge';
} elseif (preg_match_all('/MSIE/i', $UserAgent)) {
$Browser = 'Mozilla Firefox';
$B_Agent = 'Firefox';
} elseif (preg_match_all('/OPR/i', $UserAgent)) {
$Browser = 'Opera';
$B_Agent = 'Opera';
} elseif (preg_match_all('/Opera/i', $UserAgent)) {
$Browser = 'Opera';
$B_Agent = 'Opera';
} elseif (preg_match_all('/Chrome/i', $UserAgent)) {
$Browser = 'Google Chrome';
$B_Agent = 'Chrome';
} elseif (preg_match_all('/Safari/i', $UserAgent)) {
$Browser = 'Apple Safari';
$B_Agent = 'Safari';
} elseif (preg_match_all('/firefox/i', $UserAgent)) {
$Browser = 'Mozilla Firefox';
$B_Agent = 'Firefox';
} else {
$Browser = null;
$B_Agent = null;
}
return [
'browser' => $Browser,
'agent' => $B_Agent,
];
} | php | public function browser()
{
$UserAgent = self::agent();
if (preg_match_all('/Edge/i', $UserAgent)) {
$Browser = 'Microsoft Edge';
$B_Agent = 'Edge';
} elseif (preg_match_all('/MSIE/i', $UserAgent)) {
$Browser = 'Mozilla Firefox';
$B_Agent = 'Firefox';
} elseif (preg_match_all('/OPR/i', $UserAgent)) {
$Browser = 'Opera';
$B_Agent = 'Opera';
} elseif (preg_match_all('/Opera/i', $UserAgent)) {
$Browser = 'Opera';
$B_Agent = 'Opera';
} elseif (preg_match_all('/Chrome/i', $UserAgent)) {
$Browser = 'Google Chrome';
$B_Agent = 'Chrome';
} elseif (preg_match_all('/Safari/i', $UserAgent)) {
$Browser = 'Apple Safari';
$B_Agent = 'Safari';
} elseif (preg_match_all('/firefox/i', $UserAgent)) {
$Browser = 'Mozilla Firefox';
$B_Agent = 'Firefox';
} else {
$Browser = null;
$B_Agent = null;
}
return [
'browser' => $Browser,
'agent' => $B_Agent,
];
} | [
"public",
"function",
"browser",
"(",
")",
"{",
"$",
"UserAgent",
"=",
"self",
"::",
"agent",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/Edge/i'",
",",
"$",
"UserAgent",
")",
")",
"{",
"$",
"Browser",
"=",
"'Microsoft Edge'",
";",
"$",
"B_Agen... | Get Browser Name.
@since 1.0.0
@return void | [
"Get",
"Browser",
"Name",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/UserInfo/UserInfo.php#L69-L102 |
zestframework/Zest_Framework | src/UserInfo/UserInfo.php | UserInfo.oSVersion | public function oSVersion()
{
$UserAgent = self::agent();
if (preg_match_all('/windows nt 10/i', $UserAgent)) {
$OsVersion = 'Windows 10';
} elseif (preg_match_all('/windows nt 6.3/i', $UserAgent)) {
$OsVersion = 'Windows 8.1';
} elseif (preg_match_all('/windows nt 6.2/i', $UserAgent)) {
$OsVersion = 'Windows 8';
} elseif (preg_match_all('/windows nt 6.1/i', $UserAgent)) {
$OsVersion = 'Windows 7';
} elseif (preg_match_all('/windows nt 6.0/i', $UserAgent)) {
$OsVersion = 'Windows Vista';
} elseif (preg_match_all('/windows nt 5.1/i', $UserAgent)) {
$OsVersion = 'Windows Xp';
} elseif (preg_match_all('/windows xp/i', $UserAgent)) {
$OsVersion = 'Windows Xp';
} elseif (preg_match_all('/windows me/i', $UserAgent)) {
$OsVersion = 'Windows Me';
} elseif (preg_match_all('/win98/i', $UserAgent)) {
$OsVersion = 'Windows 98';
} elseif (preg_match_all('/win95/i', $UserAgent)) {
$OsVersion = 'Windows 95';
} elseif (preg_match_all('/Windows Phone +[0-9]/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/Android +[0-9]/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/Linux +x[0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/mac os x [0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/os [0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
}
return isset($OsVersion) ? $OsVersion : false;
} | php | public function oSVersion()
{
$UserAgent = self::agent();
if (preg_match_all('/windows nt 10/i', $UserAgent)) {
$OsVersion = 'Windows 10';
} elseif (preg_match_all('/windows nt 6.3/i', $UserAgent)) {
$OsVersion = 'Windows 8.1';
} elseif (preg_match_all('/windows nt 6.2/i', $UserAgent)) {
$OsVersion = 'Windows 8';
} elseif (preg_match_all('/windows nt 6.1/i', $UserAgent)) {
$OsVersion = 'Windows 7';
} elseif (preg_match_all('/windows nt 6.0/i', $UserAgent)) {
$OsVersion = 'Windows Vista';
} elseif (preg_match_all('/windows nt 5.1/i', $UserAgent)) {
$OsVersion = 'Windows Xp';
} elseif (preg_match_all('/windows xp/i', $UserAgent)) {
$OsVersion = 'Windows Xp';
} elseif (preg_match_all('/windows me/i', $UserAgent)) {
$OsVersion = 'Windows Me';
} elseif (preg_match_all('/win98/i', $UserAgent)) {
$OsVersion = 'Windows 98';
} elseif (preg_match_all('/win95/i', $UserAgent)) {
$OsVersion = 'Windows 95';
} elseif (preg_match_all('/Windows Phone +[0-9]/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/Android +[0-9]/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/Linux +x[0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/mac os x [0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
} elseif (preg_match_all('/os [0-9]+/i', $UserAgent, $match)) {
$OsVersion = $match;
}
return isset($OsVersion) ? $OsVersion : false;
} | [
"public",
"function",
"oSVersion",
"(",
")",
"{",
"$",
"UserAgent",
"=",
"self",
"::",
"agent",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'/windows nt 10/i'",
",",
"$",
"UserAgent",
")",
")",
"{",
"$",
"OsVersion",
"=",
"'Windows 10'",
";",
"}",
... | Get Os version.
@since 1.0.0
@return void | [
"Get",
"Os",
"version",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/UserInfo/UserInfo.php#L111-L147 |
zestframework/Zest_Framework | src/UserInfo/UserInfo.php | UserInfo.browserVersion | public function browserVersion()
{
$UserAgent = self::agent();
$B_Agent = self::Browser()['agent'];
if ($B_Agent !== null) {
$known = ['Version', $B_Agent, 'other'];
$pattern = '#(?<browser>'.implode('|', $known).
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $UserAgent, $matches)) {
}
$i = count($matches['browser']);
if ($i != 1) {
if (strripos($UserAgent, 'Version') < strripos($UserAgent, $B_Agent)) {
$Version = $matches['version'][0];
} else {
$Version = $matches['version'][0];
}
} else {
$Version = $matches['version'][0];
}
}
return $Version;
} | php | public function browserVersion()
{
$UserAgent = self::agent();
$B_Agent = self::Browser()['agent'];
if ($B_Agent !== null) {
$known = ['Version', $B_Agent, 'other'];
$pattern = '#(?<browser>'.implode('|', $known).
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $UserAgent, $matches)) {
}
$i = count($matches['browser']);
if ($i != 1) {
if (strripos($UserAgent, 'Version') < strripos($UserAgent, $B_Agent)) {
$Version = $matches['version'][0];
} else {
$Version = $matches['version'][0];
}
} else {
$Version = $matches['version'][0];
}
}
return $Version;
} | [
"public",
"function",
"browserVersion",
"(",
")",
"{",
"$",
"UserAgent",
"=",
"self",
"::",
"agent",
"(",
")",
";",
"$",
"B_Agent",
"=",
"self",
"::",
"Browser",
"(",
")",
"[",
"'agent'",
"]",
";",
"if",
"(",
"$",
"B_Agent",
"!==",
"null",
")",
"{"... | Get Browser version.
@since 1.0.0
@return void | [
"Get",
"Browser",
"version",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/UserInfo/UserInfo.php#L156-L179 |
zestframework/Zest_Framework | src/UserInfo/UserInfo.php | UserInfo.ip | public function ip()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip_add = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWADED_FOR'])) {
$ip_add = $_SERVER['HTTP_X_FORWADED_FOR'];
} else {
$ip_add = $_SERVER['REMOTE_ADDR'];
}
return $ip_add;
} | php | public function ip()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip_add = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWADED_FOR'])) {
$ip_add = $_SERVER['HTTP_X_FORWADED_FOR'];
} else {
$ip_add = $_SERVER['REMOTE_ADDR'];
}
return $ip_add;
} | [
"public",
"function",
"ip",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
")",
")",
"{",
"$",
"ip_add",
"=",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",... | Get The user ip.
@since 1.0.0
@return void | [
"Get",
"The",
"user",
"ip",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/UserInfo/UserInfo.php#L188-L199 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.setUri | public function setUri($scheme, $host, $port = null, $path = '/', $query = '', $fragment = '', $user = '', $password = '')
{
$this->scheme = $this->filterScheme($scheme);
$this->host = $host;
$this->port = $this->filterPort($port);
$this->path = empty($path) ? '/' : $this->filterQuery($path);
$this->query = $this->filterQuery($query);
$this->fragment = $this->filterQuery($fragment);
$this->user = $user;
$this->password = $password;
return $this;
} | php | public function setUri($scheme, $host, $port = null, $path = '/', $query = '', $fragment = '', $user = '', $password = '')
{
$this->scheme = $this->filterScheme($scheme);
$this->host = $host;
$this->port = $this->filterPort($port);
$this->path = empty($path) ? '/' : $this->filterQuery($path);
$this->query = $this->filterQuery($query);
$this->fragment = $this->filterQuery($fragment);
$this->user = $user;
$this->password = $password;
return $this;
} | [
"public",
"function",
"setUri",
"(",
"$",
"scheme",
",",
"$",
"host",
",",
"$",
"port",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"query",
"=",
"''",
",",
"$",
"fragment",
"=",
"''",
",",
"$",
"user",
"=",
"''",
",",
"$",
"password",... | Set the Uri.
@param (string) $url valid url
(string) $host valid host
(int) $port valid port number
(string) $path valid path
(string) $query query URI
(string) $fragment fragment
(string) $user username
(string) $password password
@since 3.0.0
@return object | [
"Set",
"the",
"Uri",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L42-L54 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.createFormUrl | public function createFormUrl($url)
{
$urlParts = parse_url($url);
$scheme = isset($urlParts['scheme']) ? $urlParts['scheme'] : '';
$user = isset($urlParts['user']) ? $urlParts['user'] : '';
$password = isset($urlParts['pass']) ? $urlParts['pass'] : '';
$host = isset($urlParts['host']) ? $urlParts['host'] : '';
$port = isset($urlParts['port']) ? $urlParts['port'] : null;
$path = isset($urlParts['path']) ? $urlParts['path'] : '';
$query = isset($urlParts['query']) ? $urlParts['query'] : '';
$fragment = isset($urlParts['fragment']) ? $urlParts['fragment'] : '';
$this->setUri($scheme, $host, $port, $path, $query, $fragment, $user, $password);
return $this;
} | php | public function createFormUrl($url)
{
$urlParts = parse_url($url);
$scheme = isset($urlParts['scheme']) ? $urlParts['scheme'] : '';
$user = isset($urlParts['user']) ? $urlParts['user'] : '';
$password = isset($urlParts['pass']) ? $urlParts['pass'] : '';
$host = isset($urlParts['host']) ? $urlParts['host'] : '';
$port = isset($urlParts['port']) ? $urlParts['port'] : null;
$path = isset($urlParts['path']) ? $urlParts['path'] : '';
$query = isset($urlParts['query']) ? $urlParts['query'] : '';
$fragment = isset($urlParts['fragment']) ? $urlParts['fragment'] : '';
$this->setUri($scheme, $host, $port, $path, $query, $fragment, $user, $password);
return $this;
} | [
"public",
"function",
"createFormUrl",
"(",
"$",
"url",
")",
"{",
"$",
"urlParts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"scheme",
"=",
"isset",
"(",
"$",
"urlParts",
"[",
"'scheme'",
"]",
")",
"?",
"$",
"urlParts",
"[",
"'scheme'",
"]",
... | Get the scheme component of the URL.
@param (string) $url valid url
@since 3.0.0
@return object | [
"Get",
"the",
"scheme",
"component",
"of",
"the",
"URL",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L65-L81 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.filterScheme | public function filterScheme($scheme)
{
$valids = [
'' => true,
'http' => true,
'https' => true,
];
$scheme = str_replace('://', '', strtolower((string) $scheme));
if (!isset($valids[$scheme])) {
throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
}
return $scheme;
} | php | public function filterScheme($scheme)
{
$valids = [
'' => true,
'http' => true,
'https' => true,
];
$scheme = str_replace('://', '', strtolower((string) $scheme));
if (!isset($valids[$scheme])) {
throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
}
return $scheme;
} | [
"public",
"function",
"filterScheme",
"(",
"$",
"scheme",
")",
"{",
"$",
"valids",
"=",
"[",
"''",
"=>",
"true",
",",
"'http'",
"=>",
"true",
",",
"'https'",
"=>",
"true",
",",
"]",
";",
"$",
"scheme",
"=",
"str_replace",
"(",
"'://'",
",",
"''",
"... | Filter the url scheme component.
@param (string) $scheme valid scheme
@since 3.0.0
@return string | [
"Filter",
"the",
"url",
"scheme",
"component",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L92-L105 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.getAuthority | public function getAuthority()
{
return ($this->getUserInfo() !== '') ? $this->getUserInfo().
'@' : ''.$this->getHost().($this->getPort() !== '') ? ':'.$this->getPort() : '';
} | php | public function getAuthority()
{
return ($this->getUserInfo() !== '') ? $this->getUserInfo().
'@' : ''.$this->getHost().($this->getPort() !== '') ? ':'.$this->getPort() : '';
} | [
"public",
"function",
"getAuthority",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
"!==",
"''",
")",
"?",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
".",
"'@'",
":",
"''",
".",
"$",
"this",
"->",
"getHost",
"(",
")",
... | Get the authority component of the URL.
@since 3.0.0
@return string | [
"Get",
"the",
"authority",
"component",
"of",
"the",
"URL",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L170-L174 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.withUserInfo | public function withUserInfo($user, $password = null)
{
$this->user = $user;
$this->password = $password;
return $this;
} | php | public function withUserInfo($user, $password = null)
{
$this->user = $user;
$this->password = $password;
return $this;
} | [
"public",
"function",
"withUserInfo",
"(",
"$",
"user",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"password",
";",
"return",
"$",
"this",
";",
"}"
] | Return an instance with the specified user information.
@param (string) $user username
(string) $password password
@since 3.0.0
@return object | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"user",
"information",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L270-L276 |
zestframework/Zest_Framework | src/http/Uri.php | Uri.withPath | public function withPath($path)
{
// if the path is absolute, then clear basePath
if (substr($path, 0, 1) == '/') {
$clone->basePath = '';
}
$this->path = $this->filterQuery($path);
return $this;
} | php | public function withPath($path)
{
// if the path is absolute, then clear basePath
if (substr($path, 0, 1) == '/') {
$clone->basePath = '';
}
$this->path = $this->filterQuery($path);
return $this;
} | [
"public",
"function",
"withPath",
"(",
"$",
"path",
")",
"{",
"// if the path is absolute, then clear basePath",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"clone",
"->",
"basePath",
"=",
"''",
";",
"}",
... | Return an instance with the specified path.
@param (string) $path valid path
@since 3.0.0
@return object | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"path",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Uri.php#L303-L312 |
zestframework/Zest_Framework | src/Component/Component.php | Component.dispatch | public function dispatch(Request $request)
{
$url = $request->getQueryString();
$url = $this->RemoveQueryString($url, new Request());
if ($this->match($url)) {
(isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null;
if (!isset($this->params['callable'])) {
$controller = $this->params['controller'];
$controller = $this->convertToStudlyCaps($controller);
$controller = $this->getNamespace().$controller;
if (class_exists($controller)) {
(isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null;
$controller_object = new $controller($this->params, $this->getInput(new Input()));
$action = $this->params['action'];
$action = $this->convertToCamelCase($action);
if (preg_match('/action$/i', $action) == 0) {
$controller_object->$action();
(isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null;
} else {
throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method");
}
} else {
throw new \Exception("Controller class $controller not found");
}
} else {
(is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null;
call_user_func($this->params['callable'], $this->params);
(is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null;
}
} else {
View::view('errors/404', [], true, [], 404);
}
} | php | public function dispatch(Request $request)
{
$url = $request->getQueryString();
$url = $this->RemoveQueryString($url, new Request());
if ($this->match($url)) {
(isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null;
if (!isset($this->params['callable'])) {
$controller = $this->params['controller'];
$controller = $this->convertToStudlyCaps($controller);
$controller = $this->getNamespace().$controller;
if (class_exists($controller)) {
(isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null;
$controller_object = new $controller($this->params, $this->getInput(new Input()));
$action = $this->params['action'];
$action = $this->convertToCamelCase($action);
if (preg_match('/action$/i', $action) == 0) {
$controller_object->$action();
(isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null;
} else {
throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method");
}
} else {
throw new \Exception("Controller class $controller not found");
}
} else {
(is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null;
call_user_func($this->params['callable'], $this->params);
(is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null;
}
} else {
View::view('errors/404', [], true, [], 404);
}
} | [
"public",
"function",
"dispatch",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"url",
"=",
"$",
"request",
"->",
"getQueryString",
"(",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"RemoveQueryString",
"(",
"$",
"url",
",",
"new",
"Request",
"(",
... | Dispatch the route, creating the controller object and running the
action method.
@param string $url The route URL
@since 3.0.0
@return void | [
"Dispatch",
"the",
"route",
"creating",
"the",
"controller",
"object",
"and",
"running",
"the",
"action",
"method",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Component/Component.php#L36-L68 |
zestframework/Zest_Framework | src/Auth/Reset.php | Reset.reset | public function reset($email)
{
$rules = [
'email' => ['required' => true, 'email' => true],
];
$input = [
'email' => $email,
];
$requireValidate = new Validation($input, $rules);
if ($requireValidate->fail()) {
Error::set($requireValidate->error()->get());
}
$user = new User();
if (!$user->isEmail($email)) {
Error::set(__config()->auth->errors->email_not_exist, 'username');
}
if (!$user->isLogin()) {
if ($this->fail() !== true) {
$id = $user->getByWhere('email', $email)[0]['id'];
$resetToken = (new Site())::salts(8);
$update = new Update();
$update->update(['resetToken' => $resetToken], $id);
$link = site_base_url().__config()->auth->reset_password_link.$resetToken;
$subject = __printl('auth:subject:reset');
$link = site_base_url().__config()->auth->reset_password_link.'/'.$token;
$html = __printl('auth:body:reset');
$html = str_replace(':email', $email, $html);
$html = str_replace(':link', $link, $html);
(new EmailHandler($subject, $html, $email));
Success::set(__printl('auth:success:reset'));
}
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
} | php | public function reset($email)
{
$rules = [
'email' => ['required' => true, 'email' => true],
];
$input = [
'email' => $email,
];
$requireValidate = new Validation($input, $rules);
if ($requireValidate->fail()) {
Error::set($requireValidate->error()->get());
}
$user = new User();
if (!$user->isEmail($email)) {
Error::set(__config()->auth->errors->email_not_exist, 'username');
}
if (!$user->isLogin()) {
if ($this->fail() !== true) {
$id = $user->getByWhere('email', $email)[0]['id'];
$resetToken = (new Site())::salts(8);
$update = new Update();
$update->update(['resetToken' => $resetToken], $id);
$link = site_base_url().__config()->auth->reset_password_link.$resetToken;
$subject = __printl('auth:subject:reset');
$link = site_base_url().__config()->auth->reset_password_link.'/'.$token;
$html = __printl('auth:body:reset');
$html = str_replace(':email', $email, $html);
$html = str_replace(':link', $link, $html);
(new EmailHandler($subject, $html, $email));
Success::set(__printl('auth:success:reset'));
}
} else {
Error::set(__printl('auth:error:already:login'), 'login');
}
} | [
"public",
"function",
"reset",
"(",
"$",
"email",
")",
"{",
"$",
"rules",
"=",
"[",
"'email'",
"=>",
"[",
"'required'",
"=>",
"true",
",",
"'email'",
"=>",
"true",
"]",
",",
"]",
";",
"$",
"input",
"=",
"[",
"'email'",
"=>",
"$",
"email",
",",
"]... | Add the reset password request.
@param (string) $email email of user
@since 2.0.3
@return void | [
"Add",
"the",
"reset",
"password",
"request",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Reset.php#L42-L76 |
zestframework/Zest_Framework | src/Auth/Reset.php | Reset.resetUpdate | public function resetUpdate($token)
{
$user = new User();
if ($token === 'NULL' || $user->isResetToken($token) !== true) {
Error::set(__printl('auth:error:token'), 'token');
}
if ($this->fail() !== true) {
Success::set(true);
}
} | php | public function resetUpdate($token)
{
$user = new User();
if ($token === 'NULL' || $user->isResetToken($token) !== true) {
Error::set(__printl('auth:error:token'), 'token');
}
if ($this->fail() !== true) {
Success::set(true);
}
} | [
"public",
"function",
"resetUpdate",
"(",
"$",
"token",
")",
"{",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"if",
"(",
"$",
"token",
"===",
"'NULL'",
"||",
"$",
"user",
"->",
"isResetToken",
"(",
"$",
"token",
")",
"!==",
"true",
")",
"{",
... | check token is exists or not.
@param (mixed) $token token of user
@since 2.0.3
@return void | [
"check",
"token",
"is",
"exists",
"or",
"not",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Reset.php#L87-L96 |
zestframework/Zest_Framework | src/Site/Site.php | Site.siteUrl | public static function siteUrl()
{
$base_url = self::requestInstance()->getDeterminedScheme().'://'.self::requestInstance()->getServerName().':'.self::requestInstance()->getServerPort().self::getUri();
return $base_url;
} | php | public static function siteUrl()
{
$base_url = self::requestInstance()->getDeterminedScheme().'://'.self::requestInstance()->getServerName().':'.self::requestInstance()->getServerPort().self::getUri();
return $base_url;
} | [
"public",
"static",
"function",
"siteUrl",
"(",
")",
"{",
"$",
"base_url",
"=",
"self",
"::",
"requestInstance",
"(",
")",
"->",
"getDeterminedScheme",
"(",
")",
".",
"'://'",
".",
"self",
"::",
"requestInstance",
"(",
")",
"->",
"getServerName",
"(",
")",... | Return site URL.
@since 1.0.0
@return string | [
"Return",
"site",
"URL",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L43-L48 |
zestframework/Zest_Framework | src/Site/Site.php | Site.siteBaseUrl | public static function siteBaseUrl()
{
$base_url = self::requestInstance()->getDeterminedScheme().'://'.self::requestInstance()->getServerName().':'.self::requestInstance()->getServerPort().self::getBase();
return $base_url;
} | php | public static function siteBaseUrl()
{
$base_url = self::requestInstance()->getDeterminedScheme().'://'.self::requestInstance()->getServerName().':'.self::requestInstance()->getServerPort().self::getBase();
return $base_url;
} | [
"public",
"static",
"function",
"siteBaseUrl",
"(",
")",
"{",
"$",
"base_url",
"=",
"self",
"::",
"requestInstance",
"(",
")",
"->",
"getDeterminedScheme",
"(",
")",
".",
"'://'",
".",
"self",
"::",
"requestInstance",
"(",
")",
"->",
"getServerName",
"(",
... | Return site base URL.
@since 1.0.0
@return string | [
"Return",
"site",
"base",
"URL",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L57-L62 |
zestframework/Zest_Framework | src/Site/Site.php | Site.redirect | public static function redirect($url = null)
{
if ($url === null or empty($url)) {
$base_url = self::siteBaseUrl();
} elseif ($url === 'self') {
$base_url = self::siteUrl();
} elseif ($url === 'prev') {
$base_url = self::previous();
} else {
$base_url = $url;
}
ob_start();
(new Redirect($base_url, 200));
} | php | public static function redirect($url = null)
{
if ($url === null or empty($url)) {
$base_url = self::siteBaseUrl();
} elseif ($url === 'self') {
$base_url = self::siteUrl();
} elseif ($url === 'prev') {
$base_url = self::previous();
} else {
$base_url = $url;
}
ob_start();
(new Redirect($base_url, 200));
} | [
"public",
"static",
"function",
"redirect",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
"or",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"base_url",
"=",
"self",
"::",
"siteBaseUrl",
"(",
")",
";",
"}",
"elsei... | Redirect to another page.
@param (string) $url url to be redirected.
@since 1.0.0
@return void | [
"Redirect",
"to",
"another",
"page",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L111-L124 |
zestframework/Zest_Framework | src/Site/Site.php | Site.segmentUrl | public static function segmentUrl($url = null)
{
if (!is_null($url) && !empty($url)) {
$url = $url;
} else {
$url = self::requestInstance()->getRequestUrl();
}
return explode('/', trim($url, '/'));
} | php | public static function segmentUrl($url = null)
{
if (!is_null($url) && !empty($url)) {
$url = $url;
} else {
$url = self::requestInstance()->getRequestUrl();
}
return explode('/', trim($url, '/'));
} | [
"public",
"static",
"function",
"segmentUrl",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"url",
")",
"&&",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"$",
"url",
";",
"}",
"else",
"{",
"$"... | Get all URL parts based on a / seperator.
@param (string) $url URI to segment.
@since 1.0.0
@return string | [
"Get",
"all",
"URL",
"parts",
"based",
"on",
"a",
"/",
"seperator",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L147-L156 |
zestframework/Zest_Framework | src/Site/Site.php | Site.getFirstSegment | public static function getFirstSegment($segments)
{
if (is_array($segments)) {
$vars = $segments;
} else {
$vars = self::segmentUrl($segments);
}
return current($vars);
} | php | public static function getFirstSegment($segments)
{
if (is_array($segments)) {
$vars = $segments;
} else {
$vars = self::segmentUrl($segments);
}
return current($vars);
} | [
"public",
"static",
"function",
"getFirstSegment",
"(",
"$",
"segments",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"segments",
")",
")",
"{",
"$",
"vars",
"=",
"$",
"segments",
";",
"}",
"else",
"{",
"$",
"vars",
"=",
"self",
"::",
"segmentUrl",
"("... | Get first item segment.
@param (mixed) $segments Url segments.
@since 1.0.0
@return string | [
"Get",
"first",
"item",
"segment",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L167-L176 |
zestframework/Zest_Framework | src/Site/Site.php | Site.setLastSegment | public static function setLastSegment($segments)
{
if (is_array($segments)) {
$vars = $segments;
} else {
$vars = self::segmentUrl($segments);
}
return end($vars);
} | php | public static function setLastSegment($segments)
{
if (is_array($segments)) {
$vars = $segments;
} else {
$vars = self::segmentUrl($segments);
}
return end($vars);
} | [
"public",
"static",
"function",
"setLastSegment",
"(",
"$",
"segments",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"segments",
")",
")",
"{",
"$",
"vars",
"=",
"$",
"segments",
";",
"}",
"else",
"{",
"$",
"vars",
"=",
"self",
"::",
"segmentUrl",
"(",... | Get last item segment.
@param (mixed) $segments Url segments.
@since 1.0.0
@return string | [
"Get",
"last",
"item",
"segment",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L187-L196 |
zestframework/Zest_Framework | src/Site/Site.php | Site.salts | public static function salts($length)
{
$chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$stringlength = count($chars); //Used Count because its array now
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $chars[rand(0, $stringlength - 1)];
}
return $randomString;
} | php | public static function salts($length)
{
$chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$stringlength = count($chars); //Used Count because its array now
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $chars[rand(0, $stringlength - 1)];
}
return $randomString;
} | [
"public",
"static",
"function",
"salts",
"(",
"$",
"length",
")",
"{",
"$",
"chars",
"=",
"array_merge",
"(",
"range",
"(",
"0",
",",
"9",
")",
",",
"range",
"(",
"'a'",
",",
"'z'",
")",
",",
"range",
"(",
"'A'",
",",
"'Z'",
")",
")",
";",
"$",... | generate salts for files.
@param (int) $length Length of salts.
@since 1.0.0
@return string | [
"generate",
"salts",
"for",
"files",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Site/Site.php#L207-L217 |
zestframework/Zest_Framework | src/Auth/User.php | User.getAll | public function getAll()
{
$db = new DB();
$result = $db->db()->select(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table]);
$db->db()->close();
return $result;
} | php | public function getAll()
{
$db = new DB();
$result = $db->db()->select(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table]);
$db->db()->close();
return $result;
} | [
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"db",
"=",
"new",
"DB",
"(",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"db",
"(",
")",
"->",
"select",
"(",
"[",
"'db_name'",
"=>",
"__config",
"(",
")",
"->",
"auth",
"->",
"db_name",
",... | Get all the users.
@since 2.0.3
@return array | [
"Get",
"all",
"the",
"users",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/User.php#L34-L41 |
zestframework/Zest_Framework | src/Auth/User.php | User.getByWhere | public function getByWhere($where, $value)
{
$db = new DB();
$result = $db->db()->select(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table, 'wheres'=>["{$where} ="."'{$value}'"]]);
$db->db()->close();
return $result;
} | php | public function getByWhere($where, $value)
{
$db = new DB();
$result = $db->db()->select(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table, 'wheres'=>["{$where} ="."'{$value}'"]]);
$db->db()->close();
return $result;
} | [
"public",
"function",
"getByWhere",
"(",
"$",
"where",
",",
"$",
"value",
")",
"{",
"$",
"db",
"=",
"new",
"DB",
"(",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"db",
"(",
")",
"->",
"select",
"(",
"[",
"'db_name'",
"=>",
"__config",
"(",
"... | Get users using specific field.
@param (string) $where field of user e.g username
@param (string) $value value fo field like , usr01
@since 2.0.3
@return bool | [
"Get",
"users",
"using",
"specific",
"field",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/User.php#L53-L60 |
zestframework/Zest_Framework | src/Auth/User.php | User.delete | public function delete($id)
{
$db = new DB();
$result = $db->db()->delete(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table, 'wheres'=>['id ='."'{$id}'"]]);
$db->db()->close();
return $result;
} | php | public function delete($id)
{
$db = new DB();
$result = $db->db()->delete(['db_name'=>__config()->auth->db_name, 'table'=>__config()->auth->db_table, 'wheres'=>['id ='."'{$id}'"]]);
$db->db()->close();
return $result;
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"db",
"=",
"new",
"DB",
"(",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"db",
"(",
")",
"->",
"delete",
"(",
"[",
"'db_name'",
"=>",
"__config",
"(",
")",
"->",
"auth",
"->",
... | Delete user by id.
@param $id id or guide of user
@since 3.0.0
@return bool | [
"Delete",
"user",
"by",
"id",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/User.php#L71-L78 |
zestframework/Zest_Framework | src/Auth/User.php | User.logout | public function logout()
{
$request = new Request();
(new Cookies())->delete('user', '/', $request->getServerName());
session_regenerate_id(); //Avoid session hijacking
return Session::delete('user');
} | php | public function logout()
{
$request = new Request();
(new Cookies())->delete('user', '/', $request->getServerName());
session_regenerate_id(); //Avoid session hijacking
return Session::delete('user');
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"(",
"new",
"Cookies",
"(",
")",
")",
"->",
"delete",
"(",
"'user'",
",",
"'/'",
",",
"$",
"request",
"->",
"getServerName",
"(",
")",
")",
";",
... | Logout the user.
@since 2.0.3
@return bool | [
"Logout",
"the",
"user",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/User.php#L198-L205 |
zestframework/Zest_Framework | src/Hashing/Hash.php | Hash.self | public static function self($verify = false)
{
$driver = __config()->hashing->driver;
if ($driver === 'bcrypt') {
self::$driver = new BcryptHashing(['cost' => __config()->hashing->bcrypt->cost]);
} elseif ($driver === 'argon2i') {
self::$driver = new ArgonHashing([
'memory' => __config()->hashing->argon->memory,
'time' => __config()->hashing->argon->time,
'threads' => __config()->hashing->argon->threads,
'verify' => $verify,
]);
} elseif ($driver === 'argon2id') {
self::$driver = new Argon2IdHashing([
'memory' => __config()->hashing->argon->memory,
'time' => __config()->hashing->argon->time,
'threads' => __config()->hashing->argon->threads,
'verify' => $verify,
]);
} else {
throw new \Exception('We\'re sorry, The hashing driver '.$driver.' not supported.', 500);
}
} | php | public static function self($verify = false)
{
$driver = __config()->hashing->driver;
if ($driver === 'bcrypt') {
self::$driver = new BcryptHashing(['cost' => __config()->hashing->bcrypt->cost]);
} elseif ($driver === 'argon2i') {
self::$driver = new ArgonHashing([
'memory' => __config()->hashing->argon->memory,
'time' => __config()->hashing->argon->time,
'threads' => __config()->hashing->argon->threads,
'verify' => $verify,
]);
} elseif ($driver === 'argon2id') {
self::$driver = new Argon2IdHashing([
'memory' => __config()->hashing->argon->memory,
'time' => __config()->hashing->argon->time,
'threads' => __config()->hashing->argon->threads,
'verify' => $verify,
]);
} else {
throw new \Exception('We\'re sorry, The hashing driver '.$driver.' not supported.', 500);
}
} | [
"public",
"static",
"function",
"self",
"(",
"$",
"verify",
"=",
"false",
")",
"{",
"$",
"driver",
"=",
"__config",
"(",
")",
"->",
"hashing",
"->",
"driver",
";",
"if",
"(",
"$",
"driver",
"===",
"'bcrypt'",
")",
"{",
"self",
"::",
"$",
"driver",
... | __construct.
@since 3.0.0 | [
"__construct",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/Hash.php#L35-L57 |
zestframework/Zest_Framework | src/Hashing/Hash.php | Hash.make | public static function make($original, $options = null, $verify = false)
{
self::self($verify);
return self::$driver->make($original, $options);
} | php | public static function make($original, $options = null, $verify = false)
{
self::self($verify);
return self::$driver->make($original, $options);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"original",
",",
"$",
"options",
"=",
"null",
",",
"$",
"verify",
"=",
"false",
")",
"{",
"self",
"::",
"self",
"(",
"$",
"verify",
")",
";",
"return",
"self",
"::",
"$",
"driver",
"->",
"make",
"("... | Generate the hash.
@param (string) $original
@param (array) optional $options
@since 3.0.0
@return string | [
"Generate",
"the",
"hash",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/Hash.php#L69-L74 |
zestframework/Zest_Framework | src/Hashing/Hash.php | Hash.verify | public static function verify($original, $hash, $verify = false)
{
self::self($verify);
return self::$driver->verify($original, $hash);
} | php | public static function verify($original, $hash, $verify = false)
{
self::self($verify);
return self::$driver->verify($original, $hash);
} | [
"public",
"static",
"function",
"verify",
"(",
"$",
"original",
",",
"$",
"hash",
",",
"$",
"verify",
"=",
"false",
")",
"{",
"self",
"::",
"self",
"(",
"$",
"verify",
")",
";",
"return",
"self",
"::",
"$",
"driver",
"->",
"verify",
"(",
"$",
"orig... | Verify the hash.
@param (string) $original
@param (string) $hash
@since 3.0.0
@return string | [
"Verify",
"the",
"hash",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/Hash.php#L86-L91 |
zestframework/Zest_Framework | src/Hashing/Hash.php | Hash.needsRehash | public static function needsRehash($hash, $options = null, $verify = false)
{
self::self($verify);
return self::$driver->needsRehash($hash, $options);
} | php | public static function needsRehash($hash, $options = null, $verify = false)
{
self::self($verify);
return self::$driver->needsRehash($hash, $options);
} | [
"public",
"static",
"function",
"needsRehash",
"(",
"$",
"hash",
",",
"$",
"options",
"=",
"null",
",",
"$",
"verify",
"=",
"false",
")",
"{",
"self",
"::",
"self",
"(",
"$",
"verify",
")",
";",
"return",
"self",
"::",
"$",
"driver",
"->",
"needsReha... | Check if the given hash has been hashed using the given options.
@param (string) $hash
@param (array) optional $options
@since 3.0.0
@return bool | [
"Check",
"if",
"the",
"given",
"hash",
"has",
"been",
"hashed",
"using",
"the",
"given",
"options",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/Hash.php#L103-L108 |
zestframework/Zest_Framework | src/Validation/InputRules.php | InputRules.int | public function int($value)
{
if ($this->notBeEmpty($value)) {
if (is_int($value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function int($value)
{
if ($this->notBeEmpty($value)) {
if (is_int($value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"int",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notBeEmpty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"f... | Evaulate int.
@param $value Value to be checked
@return bool | [
"Evaulate",
"int",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/InputRules.php#L38-L49 |
zestframework/Zest_Framework | src/Validation/InputRules.php | InputRules.float | public function float($value)
{
if ($this->notBeEmpty($value)) {
if (is_float($value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function float($value)
{
if ($this->notBeEmpty($value)) {
if (is_float($value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"float",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notBeEmpty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
... | Evaulate float.
@param $value Value to be checked
@return bool | [
"Evaulate",
"float",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/InputRules.php#L58-L69 |
zestframework/Zest_Framework | src/Validation/InputRules.php | InputRules.string | public function string($value)
{
if ($this->notBeEmpty($value)) {
if (is_string($value) && preg_match('/[A-Za-z]+/i', $value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function string($value)
{
if ($this->notBeEmpty($value)) {
if (is_string($value) && preg_match('/[A-Za-z]+/i', $value)) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"string",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notBeEmpty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"preg_match",
"(",
"'/[A-Za-z]+/i'",
",",
"$",
"value",
... | Evaulate string.
@param $value Value to be checked
@return bool | [
"Evaulate",
"string",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/InputRules.php#L78-L89 |
zestframework/Zest_Framework | src/Validation/InputRules.php | InputRules.email | public function email($value)
{
if ($this->notBeEmpty($value)) {
if (filter_var($value, FILTER_VALIDATE_EMAIL) !== false) {
return true;
} else {
return false;
}
} else {
return false;
}
} | php | public function email($value)
{
if ($this->notBeEmpty($value)) {
if (filter_var($value, FILTER_VALIDATE_EMAIL) !== false) {
return true;
} else {
return false;
}
} else {
return false;
}
} | [
"public",
"function",
"email",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notBeEmpty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_EMAIL",
")",
"!==",
"false",
")",
"{",
"return... | Evaulate email.
@param $value Value to be checked
@return bool | [
"Evaulate",
"email",
"."
] | train | https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/InputRules.php#L98-L109 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.