Skip to content

Commit 63f5269

Browse files
committed
BoolValue, IntegerValue, StringValue and NullValue
- as prepared implemented strict value objects - still preferable to extend these and add your specific validation and name to differentiate values in your application
1 parent 55956ca commit 63f5269

5 files changed

Lines changed: 113 additions & 1 deletion

File tree

src/Entity/Value/BoolValue.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\Elastic\Entity\Value;
4+
5+
6+
class BoolValue implements \Spameri\Elastic\Entity\IValue
7+
{
8+
9+
/**
10+
* @var bool
11+
*/
12+
private $value;
13+
14+
15+
public function __construct(
16+
bool $value
17+
)
18+
{
19+
$this->value = $value;
20+
}
21+
22+
23+
public function value(): bool
24+
{
25+
return $this->value;
26+
}
27+
28+
}

src/Entity/Value/IntegerValue.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\Elastic\Entity\Value;
4+
5+
6+
class IntegerValue implements \Spameri\Elastic\Entity\IValue
7+
{
8+
9+
/**
10+
* @var int
11+
*/
12+
private $value;
13+
14+
15+
public function __construct(
16+
int $value
17+
)
18+
{
19+
$this->value = $value;
20+
}
21+
22+
23+
public function value(): int
24+
{
25+
return $this->value;
26+
}
27+
28+
}

src/Entity/Value/NullValue.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\Elastic\Entity\Value;
4+
5+
6+
class NullValue implements \Spameri\Elastic\Entity\IValue
7+
{
8+
9+
/**
10+
* @var NULL
11+
*/
12+
private $value;
13+
14+
15+
public function __construct()
16+
{
17+
}
18+
19+
20+
/**
21+
* @return NULL
22+
*/
23+
public function value()
24+
{
25+
return $this->value;
26+
}
27+
28+
}

src/Entity/Value/StringValue.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Spameri\Elastic\Entity\Value;
4+
5+
6+
class StringValue implements \Spameri\Elastic\Entity\IValue
7+
{
8+
9+
/**
10+
* @var string
11+
*/
12+
private $value;
13+
14+
15+
public function __construct(
16+
string $value
17+
)
18+
{
19+
$this->value = $value;
20+
}
21+
22+
23+
public function value(): string
24+
{
25+
return $this->value;
26+
}
27+
28+
}

src/Model/Insert/PrepareEntityArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function iterateVariables(
7676

7777
} elseif ($property instanceof \Spameri\Elastic\Entity\IValueCollection) {
7878
$preparedArray[$key] = [];
79-
/** @var $value \Spameri\Elastic\Entity\IValue */
79+
/** @var \Spameri\Elastic\Entity\IValue $value */
8080
/** @var \Spameri\Elastic\Entity\IValueCollection $property */
8181
foreach ($property as $value) {
8282
if ($value instanceof \Spameri\Elastic\Entity\IValue) {

0 commit comments

Comments
 (0)