-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sunrise-php/release/v1.4.0
v1.4.0
- Loading branch information
Showing
4 changed files
with
216 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Fenric <anatoly@fenric.ru> | ||
* @copyright Copyright (c) 2021, Anatoly Fenric | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
namespace Sunrise\Hydrator; | ||
|
||
/** | ||
* Import classes | ||
*/ | ||
use ArrayAccess; | ||
use JsonSerializable; | ||
|
||
/** | ||
* Import functions | ||
*/ | ||
use function array_key_exists; | ||
|
||
/** | ||
* Json | ||
*/ | ||
class Json implements ArrayAccess, JsonSerializable | ||
{ | ||
protected array $data; | ||
|
||
/** | ||
* Constructor of the class | ||
*/ | ||
public function __construct(array $data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetExists($offset) : bool | ||
{ | ||
return array_key_exists($offset, $this->data); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetGet($offset) | ||
{ | ||
return $this->data[$offset] ?? null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetSet($offset, $value) : void | ||
{ | ||
$this->data[$offset] = $value; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function offsetUnset($offset) : void | ||
{ | ||
unset($this->data[$offset]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function jsonSerialize() : array | ||
{ | ||
return $this->data; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator\Tests\Fixture; | ||
|
||
use Sunrise\Hydrator\HydrableObjectInterface; | ||
use Sunrise\Hydrator\Json; | ||
|
||
final class TestJsonTypeDto implements HydrableObjectInterface | ||
{ | ||
public Json $json; | ||
} |
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