1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-11 08:24:02 +02:00

implemented "digit" type

This commit is contained in:
Oliver Vogel
2014-07-26 10:16:11 +02:00
parent 5b50e7b506
commit adc7881840
20 changed files with 38 additions and 38 deletions

View File

@@ -15,10 +15,10 @@ class CropCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->required()->value(); $height = $this->argument(1)->type('digit')->required()->value();
$x = $this->argument(2)->type('integer')->value(); $x = $this->argument(2)->type('digit')->value();
$y = $this->argument(3)->type('integer')->value(); $y = $this->argument(3)->type('digit')->value();
if (is_null($width) || is_null($height)) { if (is_null($width) || is_null($height)) {
throw new \Intervention\Image\Exception\InvalidArgumentException( throw new \Intervention\Image\Exception\InvalidArgumentException(

View File

@@ -16,8 +16,8 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand
public function execute($image) public function execute($image)
{ {
$filling = $this->argument(0)->value(); $filling = $this->argument(0)->value();
$x = $this->argument(1)->type('integer')->value(); $x = $this->argument(1)->type('digit')->value();
$y = $this->argument(2)->type('integer')->value(); $y = $this->argument(2)->type('digit')->value();
$width = $image->getWidth(); $width = $image->getWidth();
$height = $image->getHeight(); $height = $image->getHeight();

View File

@@ -15,8 +15,8 @@ class FitCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->value($width); $height = $this->argument(1)->type('digit')->value($width);
// calculate size // calculate size
$fitted = $image->getSize()->fit(new Size($width, $height)); $fitted = $image->getSize()->fit(new Size($width, $height));

View File

@@ -12,7 +12,7 @@ class HeightenCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$height = $this->argument(0)->type('integer')->required()->value(); $height = $this->argument(0)->type('digit')->required()->value();
$this->arguments[0] = null; $this->arguments[0] = null;
$this->arguments[1] = $height; $this->arguments[1] = $height;

View File

@@ -14,8 +14,8 @@ class InsertCommand extends \Intervention\Image\Commands\AbstractCommand
{ {
$source = $this->argument(0)->required()->value(); $source = $this->argument(0)->required()->value();
$position = $this->argument(1)->type('string')->value(); $position = $this->argument(1)->type('string')->value();
$x = $this->argument(2)->type('integer')->value(0); $x = $this->argument(2)->type('digit')->value(0);
$y = $this->argument(3)->type('integer')->value(0); $y = $this->argument(3)->type('digit')->value(0);
// build watermark // build watermark
$watermark = $image->getDriver()->init($source); $watermark = $image->getDriver()->init($source);

View File

@@ -14,8 +14,8 @@ class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$x = $this->argument(0)->type('integer')->required()->value(); $x = $this->argument(0)->type('digit')->required()->value();
$y = $this->argument(1)->type('integer')->required()->value(); $y = $this->argument(1)->type('digit')->required()->value();
$format = $this->argument(2)->type('string')->value('array'); $format = $this->argument(2)->type('string')->value('array');
// pick color // pick color

View File

@@ -16,8 +16,8 @@ class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
{ {
$color = $this->argument(0)->required()->value(); $color = $this->argument(0)->required()->value();
$color = new Color($color); $color = new Color($color);
$x = $this->argument(1)->type('integer')->required()->value(); $x = $this->argument(1)->type('digit')->required()->value();
$y = $this->argument(2)->type('integer')->required()->value(); $y = $this->argument(2)->type('digit')->required()->value();
return imagesetpixel($image->getCore(), $x, $y, $color->getInt()); return imagesetpixel($image->getCore(), $x, $y, $color->getInt());
} }

View File

@@ -12,7 +12,7 @@ class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$size = $this->argument(0)->type('integer')->value(10); $size = $this->argument(0)->type('digit')->value(10);
return imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $size, true); return imagefilter($image->getCore(), IMG_FILTER_PIXELATE, $size, true);
} }

View File

@@ -15,8 +15,8 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->required()->value(); $height = $this->argument(1)->type('digit')->required()->value();
$anchor = $this->argument(2)->value('center'); $anchor = $this->argument(2)->value('center');
$relative = $this->argument(3)->type('boolean')->value(); $relative = $this->argument(3)->type('boolean')->value();
$bgcolor = $this->argument(4)->value(); $bgcolor = $this->argument(4)->value();

View File

@@ -12,7 +12,7 @@ class WidenCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$this->arguments[0] = $width; $this->arguments[0] = $width;
$this->arguments[1] = null; $this->arguments[1] = null;

View File

@@ -15,10 +15,10 @@ class CropCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->required()->value(); $height = $this->argument(1)->type('digit')->required()->value();
$x = $this->argument(2)->type('integer')->value(); $x = $this->argument(2)->type('digit')->value();
$y = $this->argument(3)->type('integer')->value(); $y = $this->argument(3)->type('digit')->value();
if (is_null($width) || is_null($height)) { if (is_null($width) || is_null($height)) {
throw new \Intervention\Image\Exception\InvalidArgumentException( throw new \Intervention\Image\Exception\InvalidArgumentException(

View File

@@ -17,8 +17,8 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand
public function execute($image) public function execute($image)
{ {
$filling = $this->argument(0)->value(); $filling = $this->argument(0)->value();
$x = $this->argument(1)->type('integer')->value(); $x = $this->argument(1)->type('digit')->value();
$y = $this->argument(2)->type('integer')->value(); $y = $this->argument(2)->type('digit')->value();
$imagick = $image->getCore(); $imagick = $image->getCore();

View File

@@ -14,8 +14,8 @@ class FitCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->value($width); $height = $this->argument(1)->type('digit')->value($width);
// calculate size // calculate size
$fitted = $image->getSize()->fit(new Size($width, $height)); $fitted = $image->getSize()->fit(new Size($width, $height));

View File

@@ -12,7 +12,7 @@ class HeightenCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$height = $this->argument(0)->type('integer')->required()->value(); $height = $this->argument(0)->type('digit')->required()->value();
$this->arguments[0] = null; $this->arguments[0] = null;
$this->arguments[1] = $height; $this->arguments[1] = $height;

View File

@@ -14,8 +14,8 @@ class InsertCommand extends \Intervention\Image\Commands\AbstractCommand
{ {
$source = $this->argument(0)->required()->value(); $source = $this->argument(0)->required()->value();
$position = $this->argument(1)->type('string')->value(); $position = $this->argument(1)->type('string')->value();
$x = $this->argument(2)->type('integer')->value(0); $x = $this->argument(2)->type('digit')->value(0);
$y = $this->argument(3)->type('integer')->value(0); $y = $this->argument(3)->type('digit')->value(0);
// build watermark // build watermark
$watermark = $image->getDriver()->init($source); $watermark = $image->getDriver()->init($source);

View File

@@ -14,8 +14,8 @@ class PickColorCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$x = $this->argument(0)->type('integer')->required()->value(); $x = $this->argument(0)->type('digit')->required()->value();
$y = $this->argument(1)->type('integer')->required()->value(); $y = $this->argument(1)->type('digit')->required()->value();
$format = $this->argument(2)->type('string')->value('array'); $format = $this->argument(2)->type('string')->value('array');
// pick color // pick color

View File

@@ -16,8 +16,8 @@ class PixelCommand extends \Intervention\Image\Commands\AbstractCommand
{ {
$color = $this->argument(0)->required()->value(); $color = $this->argument(0)->required()->value();
$color = new Color($color); $color = new Color($color);
$x = $this->argument(1)->type('integer')->required()->value(); $x = $this->argument(1)->type('digit')->required()->value();
$y = $this->argument(2)->type('integer')->required()->value(); $y = $this->argument(2)->type('digit')->required()->value();
// prepare pixel // prepare pixel
$draw = new \ImagickDraw; $draw = new \ImagickDraw;

View File

@@ -12,7 +12,7 @@ class PixelateCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$size = $this->argument(0)->type('integer')->value(10); $size = $this->argument(0)->type('digit')->value(10);
$width = $image->getWidth(); $width = $image->getWidth();
$height = $image->getHeight(); $height = $image->getHeight();

View File

@@ -12,8 +12,8 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$height = $this->argument(1)->type('integer')->required()->value(); $height = $this->argument(1)->type('digit')->required()->value();
$anchor = $this->argument(2)->value('center'); $anchor = $this->argument(2)->value('center');
$relative = $this->argument(3)->type('boolean')->value(); $relative = $this->argument(3)->type('boolean')->value();
$bgcolor = $this->argument(4)->value(); $bgcolor = $this->argument(4)->value();

View File

@@ -12,7 +12,7 @@ class WidenCommand extends ResizeCommand
*/ */
public function execute($image) public function execute($image)
{ {
$width = $this->argument(0)->type('integer')->required()->value(); $width = $this->argument(0)->type('digit')->required()->value();
$this->arguments[0] = $width; $this->arguments[0] = $width;
$this->arguments[1] = null; $this->arguments[1] = null;