-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
653 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace M3O\Model\Id; | ||
|
||
|
||
use M3O\Model\AbstractModel; | ||
|
||
class GenerateOutput extends AbstractModel | ||
{ | ||
private string $id; | ||
private string $type; | ||
|
||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setId(string $id): GenerateOutput | ||
{ | ||
$this->id = $id; | ||
return $this; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function setType(string $type): GenerateOutput | ||
{ | ||
$this->type = $type; | ||
return $this; | ||
} | ||
|
||
public static function fromArray(array $array): GenerateOutput | ||
{ | ||
return (new GenerateOutput()) | ||
->setId((string) ($array['id'] ?? '')) | ||
->setType((string) ($array['type'] ?? '')); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'id' => $this->getId(), | ||
'type' => $this->getType() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace M3O\Model\Image; | ||
|
||
|
||
use M3O\Model\AbstractModel; | ||
|
||
class ConvertInput extends UploadInput | ||
{ | ||
private bool $outputURL; | ||
|
||
public function getOutputURL(): bool | ||
{ | ||
return $this->outputURL; | ||
} | ||
|
||
/** | ||
* @param bool $outputURL | ||
* @return static | ||
*/ | ||
public function setOutputURL(bool $outputURL) | ||
{ | ||
$this->outputURL = $outputURL; | ||
return $this; | ||
} | ||
|
||
public static function fromArray(array $array): ConvertInput | ||
{ | ||
return (new ConvertInput()) | ||
->setBase64((string) ($array['base64'] ?? '')) | ||
->setName((string) ($array['name'] ?? '')) | ||
->setOutputURL((bool) ($array['outputURL'] ?? false)) | ||
->setUrl((string) ($array['url'] ?? '')); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return parent::toArray() + ['outputURL' => $this->getOutputURL()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace M3O\Model\Image; | ||
|
||
|
||
use InvalidArgumentException; | ||
use M3O\Model\AbstractModel; | ||
|
||
class CropOptions extends AbstractModel | ||
{ | ||
public const ANCHOR_TOP = 'top'; | ||
public const ANCHOR_TOP_LEFT = 'top left'; | ||
public const ANCHOR_TOP_RIGHT = 'top right'; | ||
public const ANCHOR_LEFT = 'left'; | ||
public const ANCHOR_CENTER = 'center'; | ||
public const ANCHOR_RIGHT = 'right'; | ||
public const ANCHOR_BOTTOM_LEFT = 'bottom left'; | ||
public const ANCHOR_BOTTOM = 'bottom'; | ||
public const ANCHOR_BOTTOM_RIGHT = 'bottom right'; | ||
public const ANCHORS = [ | ||
self::ANCHOR_LEFT, | ||
self::ANCHOR_TOP_LEFT, | ||
self::ANCHOR_TOP_RIGHT, | ||
self::ANCHOR_LEFT, | ||
self::ANCHOR_CENTER, | ||
self::ANCHOR_RIGHT, | ||
self::ANCHOR_BOTTOM_LEFT, | ||
self::ANCHOR_BOTTOM, | ||
self::ANCHOR_BOTTOM_RIGHT | ||
]; | ||
|
||
private string $anchor; | ||
private int $width; | ||
private int $height; | ||
|
||
public function getWidth(): int | ||
{ | ||
return $this->width; | ||
} | ||
|
||
public function setWidth(int $width): CropOptions | ||
{ | ||
$this->width = $width; | ||
return $this; | ||
} | ||
|
||
public function getHeight(): int | ||
{ | ||
return $this->height; | ||
} | ||
|
||
public function setHeight(int $height): CropOptions | ||
{ | ||
$this->height = $height; | ||
return $this; | ||
} | ||
|
||
public function getAnchor(): string | ||
{ | ||
return $this->anchor; | ||
} | ||
|
||
public function setAnchor(string $anchor): CropOptions | ||
{ | ||
if (!in_array(strtolower(trim($anchor)), self::ANCHORS, true)) { | ||
throw new InvalidArgumentException('Invalid anchor'); | ||
} | ||
$this->anchor = $anchor; | ||
return $this; | ||
} | ||
|
||
public static function fromArray(array $array): CropOptions | ||
{ | ||
return (new CropOptions()) | ||
->setAnchor((string) ($array['anchor'] ?? self::ANCHOR_CENTER)) | ||
->setWidth((int) ($array['width'] ?? 0)) | ||
->setHeight((int) ($array['height'] ?? 0)); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'anchor' => $this->getAnchor(), | ||
'width' => $this->getWidth(), | ||
'height' => $this->getHeight() | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace M3O\Model\Image; | ||
|
||
|
||
use M3O\Model\AbstractModel; | ||
|
||
class Output extends AbstractModel | ||
{ | ||
private string $base64; | ||
private string $url; | ||
|
||
public function getBase64(): string | ||
{ | ||
return $this->base64; | ||
} | ||
|
||
public function setBase64(string $base64): Output | ||
{ | ||
$this->base64 = $base64; | ||
return $this; | ||
} | ||
|
||
public function getUrl(): string | ||
{ | ||
return $this->url; | ||
} | ||
|
||
public function setUrl(string $url): Output | ||
{ | ||
$this->url = $url; | ||
return $this; | ||
} | ||
|
||
public static function fromArray(array $array): Output | ||
{ | ||
return (new Output()) | ||
->setBase64((string) ($array['base64'] ?? '')) | ||
->setUrl((string) ($array['url'] ?? '')); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'base64' => $this->getBase64(), | ||
'url' => $this->getUrl() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace M3O\Model\Image; | ||
|
||
|
||
use M3O\Model\AbstractModel; | ||
|
||
class ResizeInput extends ConvertInput | ||
{ | ||
private CropOptions $cropOptions; | ||
private int $height; | ||
private int $width; | ||
|
||
public function getCropOptions(): CropOptions | ||
{ | ||
return $this->cropOptions; | ||
} | ||
|
||
public function setCropOptions(CropOptions $cropOptions): ResizeInput | ||
{ | ||
$this->cropOptions = $cropOptions; | ||
return $this; | ||
} | ||
|
||
public function getHeight(): int | ||
{ | ||
return $this->height; | ||
} | ||
|
||
public function setHeight(int $height): ResizeInput | ||
{ | ||
$this->height = $height; | ||
return $this; | ||
} | ||
|
||
public function getWidth(): int | ||
{ | ||
return $this->width; | ||
} | ||
|
||
public function setWidth(int $width): ResizeInput | ||
{ | ||
$this->width = $width; | ||
return $this; | ||
} | ||
|
||
public static function fromArray(array $array): ResizeInput | ||
{ | ||
return (new ResizeInput()) | ||
->setBase64((string)($array['base64'] ?? '')) | ||
->setName((string)($array['name'] ?? '')) | ||
->setOutputURL((bool)($array['outputURL'] ?? false)) | ||
->setUrl((string)($array['url'] ?? '')) | ||
->setCropOptions($array['cropOptions'] ?? null) | ||
->setHeight((int)($array['height'] ?? 0)) | ||
->setWidth((int)($array['width'] ?? 0)); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return parent::toArray() + [ | ||
'cropOptions' => $this->getCropOptions(), | ||
'height' => $this->getHeight(), | ||
'width' => $this->getWidth() | ||
]; | ||
} | ||
} |
Oops, something went wrong.