PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / league / container / src / Argument / LiteralArgument.php

LiteralArgument.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, at vendor/league/container/src/Argument/LiteralArgument.php

49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Imagify\Dependencies\League\Container\Argument;
6
7 use InvalidArgumentException;
8
9 class LiteralArgument implements LiteralArgumentInterface
10 {
11 public const TYPE_ARRAY = 'array';
12 public const TYPE_BOOL = 'boolean';
13 public const TYPE_BOOLEAN = 'boolean';
14 public const TYPE_CALLABLE = 'callable';
15 public const TYPE_DOUBLE = 'double';
16 public const TYPE_FLOAT = 'double';
17 public const TYPE_INT = 'integer';
18 public const TYPE_INTEGER = 'integer';
19 public const TYPE_OBJECT = 'object';
20 public const TYPE_STRING = 'string';
21
22 /**
23 * @var mixed
24 */
25 protected $value;
26
27 public function __construct($value, ?string $type = null)
28 {
29 if (
30 null === $type
31 || ($type === self::TYPE_CALLABLE && is_callable($value))
32 || ($type === self::TYPE_OBJECT && is_object($value))
33 || gettype($value) === $type
34 ) {
35 $this->value = $value;
36 } else {
37 throw new InvalidArgumentException('Incorrect type for value.');
38 }
39 }
40
41 /**
42 * {@inheritdoc}
43 */
44 public function getValue()
45 {
46 return $this->value;
47 }
48 }
49