-
Notifications
You must be signed in to change notification settings - Fork 3
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
23 changed files
with
424 additions
and
439 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
35 changes: 35 additions & 0 deletions
35
src/EventSystem/NormalizedValueToRawValue/Event/NormalizedValueToRawValueEvent.php
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,35 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\NormalizedValueToRawValue\Event; | ||
|
||
use App\Contract\EventInterface; | ||
use App\Trait\StoppableEventTrait; | ||
|
||
class NormalizedValueToRawValueEvent implements EventInterface | ||
{ | ||
use StoppableEventTrait; | ||
|
||
private mixed $rawValue; | ||
|
||
public function __construct( | ||
private readonly mixed $normalizedValue | ||
) { | ||
} | ||
|
||
public function getNormalizedValue(): mixed | ||
{ | ||
return $this->normalizedValue; | ||
} | ||
|
||
public function getRawValue(): mixed | ||
{ | ||
return $this->rawValue; | ||
} | ||
|
||
public function setRawValue(mixed $rawValue): self | ||
{ | ||
$this->rawValue = $rawValue; | ||
|
||
return $this; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ormalizedValueToRawValue/EventListener/DateTimeNormalizedValueToRawValueEventListener.php
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,18 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\NormalizedValueToRawValue\EventListener; | ||
|
||
use App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent; | ||
|
||
class DateTimeNormalizedValueToRawValueEventListener | ||
{ | ||
public function onNormalizedValueToRawValueEvent(NormalizedValueToRawValueEvent $event): void | ||
{ | ||
$normalizedValue = $event->getNormalizedValue(); | ||
if (!($normalizedValue instanceof \DateTime)) { | ||
return; | ||
} | ||
$event->setRawValue($normalizedValue->format(\DateTime::ATOM)); | ||
$event->stopPropagation(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...NormalizedValueToRawValue/EventListener/GenericNormalizedValueToRawValueEventListener.php
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,24 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\NormalizedValueToRawValue\EventListener; | ||
|
||
use App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent; | ||
|
||
class GenericNormalizedValueToRawValueEventListener | ||
{ | ||
public function onNormalizedValueToRawValueEvent(NormalizedValueToRawValueEvent $event): void | ||
{ | ||
$normalizedValue = $event->getNormalizedValue(); | ||
if ( | ||
is_array($normalizedValue) | ||
// is_object($normalizedValue) || | ||
|| is_numeric($normalizedValue) | ||
|| is_bool($normalizedValue) | ||
|| is_string($normalizedValue) | ||
|| is_null($normalizedValue) | ||
) { | ||
$event->setRawValue($normalizedValue); | ||
$event->stopPropagation(); | ||
} | ||
} | ||
} |
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,19 @@ | ||
services: | ||
|
||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
|
||
App\EventSystem\NormalizedValueToRawValue\EventListener\DateTimeNormalizedValueToRawValueEventListener: | ||
tags: | ||
- name: kernel.event_listener | ||
event: 'App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent' | ||
method: 'onNormalizedValueToRawValueEvent' | ||
priority: 16 | ||
|
||
App\EventSystem\NormalizedValueToRawValue\EventListener\GenericNormalizedValueToRawValueEventListener: | ||
tags: | ||
- name: kernel.event_listener | ||
event: 'App\EventSystem\NormalizedValueToRawValue\Event\NormalizedValueToRawValueEvent' | ||
method: 'onNormalizedValueToRawValueEvent' | ||
priority: 0 |
35 changes: 35 additions & 0 deletions
35
src/EventSystem/RawValueToNormalizedValue/Event/RawValueToNormalizedValueEvent.php
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,35 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\RawValueToNormalizedValue\Event; | ||
|
||
use App\Contract\EventInterface; | ||
use App\Trait\StoppableEventTrait; | ||
|
||
class RawValueToNormalizedValueEvent implements EventInterface | ||
{ | ||
use StoppableEventTrait; | ||
|
||
private mixed $normalizedValue; | ||
|
||
public function __construct( | ||
private readonly mixed $rawValue | ||
) { | ||
} | ||
|
||
public function getRawValue(): mixed | ||
{ | ||
return $this->rawValue; | ||
} | ||
|
||
public function getNormalizedValue(): mixed | ||
{ | ||
return $this->normalizedValue; | ||
} | ||
|
||
public function setNormalizedValue(mixed $normalizedValue): self | ||
{ | ||
$this->normalizedValue = $normalizedValue; | ||
|
||
return $this; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...awValueToNormalizedValue/EventListener/DateTimeRawValueToNormalizedValueEventListener.php
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,28 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\RawValueToNormalizedValue\EventListener; | ||
|
||
use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; | ||
|
||
class DateTimeRawValueToNormalizedValueEventListener | ||
{ | ||
public function onRawValueToNormalizedValueEvent(RawValueToNormalizedValueEvent $event): void | ||
{ | ||
$rawValue = $event->getRawValue(); | ||
if (!is_string($rawValue)) { | ||
return; | ||
} | ||
if ( | ||
strlen($rawValue) < 22 | ||
|| strlen($rawValue) > 25 | ||
) { | ||
return; | ||
} | ||
$possibleDate = \DateTime::createFromFormat(\DateTime::ATOM, $rawValue); | ||
if (false === $possibleDate) { | ||
return; | ||
} | ||
$event->setNormalizedValue($possibleDate); | ||
$event->stopPropagation(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...RawValueToNormalizedValue/EventListener/GenericRawValueToNormalizedValueEventListener.php
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,24 @@ | ||
<?php | ||
|
||
namespace App\EventSystem\RawValueToNormalizedValue\EventListener; | ||
|
||
use App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent; | ||
|
||
class GenericRawValueToNormalizedValueEventListener | ||
{ | ||
public function onRawValueToNormalizedValueEvent(RawValueToNormalizedValueEvent $event): void | ||
{ | ||
$rawValue = $event->getRawValue(); | ||
if ( | ||
is_array($rawValue) | ||
// is_object($rawValue) || | ||
|| is_numeric($rawValue) | ||
|| is_bool($rawValue) | ||
|| is_string($rawValue) | ||
|| is_null($rawValue) | ||
) { | ||
$event->setNormalizedValue($rawValue); | ||
$event->stopPropagation(); | ||
} | ||
} | ||
} |
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,19 @@ | ||
services: | ||
|
||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
|
||
App\EventSystem\RawValueToNormalizedValue\EventListener\DateTimeRawValueToNormalizedValueEventListener: | ||
tags: | ||
- name: kernel.event_listener | ||
event: 'App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent' | ||
method: 'onRawValueToNormalizedValueEvent' | ||
priority: 16 | ||
|
||
App\EventSystem\RawValueToNormalizedValue\EventListener\GenericRawValueToNormalizedValueEventListener: | ||
tags: | ||
- name: kernel.event_listener | ||
event: 'App\EventSystem\RawValueToNormalizedValue\Event\RawValueToNormalizedValueEvent' | ||
method: 'onRawValueToNormalizedValueEvent' | ||
priority: 0 |
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
tests/UnitTests/EventListener/ElementToRawEventListenerTest.php
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
tests/UnitTests/EventListener/GenericPropertyElementDefragmentizeEventListenerTest.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.