DateTime
6 months ago
Number
6 months ago
String
1 month ago
BooleanValueObject.php
6 months ago
Discount.php
6 months ago
DiscountFixedValue.php
2 months ago
DiscountPercentageValue.php
6 months ago
Duration.php
7 years ago
Gender.php
1 year ago
GeoTag.php
7 years ago
Json.php
6 months ago
Picture.php
1 year ago
PositiveDuration.php
7 years ago
Priority.php
6 months ago
Recurring.php
4 years ago
Picture.php
80 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Domain\ValueObjects; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 6 | |
| 7 | /** |
| 8 | * Class Picture |
| 9 | * |
| 10 | * @package AmeliaBooking\Domain\ValueObjects |
| 11 | */ |
| 12 | final class Picture |
| 13 | { |
| 14 | public const MAX_LENGTH = 767; |
| 15 | |
| 16 | /** |
| 17 | * @var string |
| 18 | */ |
| 19 | private $pathToFull; |
| 20 | |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | private $pathToThumb; |
| 25 | |
| 26 | /** |
| 27 | * Name constructor. |
| 28 | * |
| 29 | * @param string $pathToFull |
| 30 | * @param string $pathToThumb |
| 31 | * |
| 32 | * @throws InvalidArgumentException |
| 33 | */ |
| 34 | public function __construct($pathToFull, $pathToThumb) |
| 35 | { |
| 36 | if (empty($pathToFull)) { |
| 37 | throw new InvalidArgumentException("Path to full can't be empty"); |
| 38 | } |
| 39 | |
| 40 | if (strlen($pathToFull) > static::MAX_LENGTH) { |
| 41 | throw new InvalidArgumentException( |
| 42 | "Path to full \"{$pathToFull}\" must be less than " . static::MAX_LENGTH . ' chars' |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | if (empty($pathToThumb)) { |
| 47 | throw new InvalidArgumentException("Path to thumb can't be empty"); |
| 48 | } |
| 49 | |
| 50 | if (strlen($pathToThumb) > static::MAX_LENGTH) { |
| 51 | throw new InvalidArgumentException( |
| 52 | "Path to thumb string length \"{$pathToThumb}\" must be less than " . static::MAX_LENGTH . ' chars' |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | $this->pathToFull = $pathToFull; |
| 57 | $this->pathToThumb = $pathToThumb; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Return the Full path |
| 62 | * |
| 63 | * @return string |
| 64 | */ |
| 65 | public function getFullPath() |
| 66 | { |
| 67 | return $this->pathToFull; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Return the Thumb path |
| 72 | * |
| 73 | * @return string |
| 74 | */ |
| 75 | public function getThumbPath() |
| 76 | { |
| 77 | return $this->pathToThumb; |
| 78 | } |
| 79 | } |
| 80 |