diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Query/Parameter.php')
-rw-r--r-- | vendor/doctrine/orm/src/Query/Parameter.php | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Query/Parameter.php b/vendor/doctrine/orm/src/Query/Parameter.php new file mode 100644 index 0000000..43eb7a4 --- /dev/null +++ b/vendor/doctrine/orm/src/Query/Parameter.php | |||
@@ -0,0 +1,89 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Query; | ||
6 | |||
7 | use function trim; | ||
8 | |||
9 | /** | ||
10 | * Defines a Query Parameter. | ||
11 | * | ||
12 | * @link www.doctrine-project.org | ||
13 | */ | ||
14 | class Parameter | ||
15 | { | ||
16 | /** | ||
17 | * Returns the internal representation of a parameter name. | ||
18 | */ | ||
19 | public static function normalizeName(int|string $name): string | ||
20 | { | ||
21 | return trim((string) $name, ':'); | ||
22 | } | ||
23 | |||
24 | /** | ||
25 | * The parameter name. | ||
26 | */ | ||
27 | private readonly string $name; | ||
28 | |||
29 | /** | ||
30 | * The parameter value. | ||
31 | */ | ||
32 | private mixed $value; | ||
33 | |||
34 | /** | ||
35 | * The parameter type. | ||
36 | */ | ||
37 | private mixed $type; | ||
38 | |||
39 | /** | ||
40 | * Whether the parameter type was explicitly specified or not | ||
41 | */ | ||
42 | private readonly bool $typeSpecified; | ||
43 | |||
44 | public function __construct(int|string $name, mixed $value, mixed $type = null) | ||
45 | { | ||
46 | $this->name = self::normalizeName($name); | ||
47 | $this->typeSpecified = $type !== null; | ||
48 | |||
49 | $this->setValue($value, $type); | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * Retrieves the Parameter name. | ||
54 | */ | ||
55 | public function getName(): string | ||
56 | { | ||
57 | return $this->name; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * Retrieves the Parameter value. | ||
62 | */ | ||
63 | public function getValue(): mixed | ||
64 | { | ||
65 | return $this->value; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * Retrieves the Parameter type. | ||
70 | */ | ||
71 | public function getType(): mixed | ||
72 | { | ||
73 | return $this->type; | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Defines the Parameter value. | ||
78 | */ | ||
79 | public function setValue(mixed $value, mixed $type = null): void | ||
80 | { | ||
81 | $this->value = $value; | ||
82 | $this->type = $type ?: ParameterTypeInferer::inferType($value); | ||
83 | } | ||
84 | |||
85 | public function typeWasSpecified(): bool | ||
86 | { | ||
87 | return $this->typeSpecified; | ||
88 | } | ||
89 | } | ||