-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from tsantos84/2.0
Major Version 2.0
- Loading branch information
Showing
83 changed files
with
2,627 additions
and
282 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,12 @@ | ||
# Change Log | ||
|
||
## [1.1.1](https://github.com/tsantos84/serializer/tree/1.1.1) (2017-11-24) | ||
[Full Changelog](https://github.com/tsantos84/serializer/compare/1.1.0...1.1.1) | ||
|
||
## [1.1.0](https://github.com/tsantos84/serializer/tree/1.1.0) (2017-11-23) | ||
[Full Changelog](https://github.com/tsantos84/serializer/compare/1.0.0...1.1.0) | ||
|
||
## [1.0.0](https://github.com/tsantos84/serializer/tree/1.0.0) (2017-11-21) | ||
|
||
|
||
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* |
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
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
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
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,95 @@ | ||
<?php | ||
/** | ||
* This file is part of the TSantos Serializer package. | ||
* | ||
* (c) Tales Santos <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace TSantos\Serializer; | ||
|
||
/** | ||
* Trait ContextTrait | ||
* @package TSantos\Serializer | ||
*/ | ||
|
||
abstract class AbstractContext | ||
{ | ||
/** @var array */ | ||
private $groups = ['Default']; | ||
|
||
/** @var integer */ | ||
private $maxDepth; | ||
|
||
/** @var integer */ | ||
private $currentDepth; | ||
|
||
/** | ||
* @return self | ||
*/ | ||
public static function create(): self | ||
{ | ||
return new static(); | ||
} | ||
|
||
/** | ||
* @param array $groups | ||
* @return self | ||
*/ | ||
public function setGroups(array $groups): self | ||
{ | ||
$this->groups = $groups; | ||
return $this; | ||
} | ||
|
||
public function getGroups(): array | ||
{ | ||
return $this->groups; | ||
} | ||
|
||
/** | ||
* @param $maxDepth | ||
* @return self | ||
*/ | ||
public function setMaxDepth($maxDepth): self | ||
{ | ||
$this->maxDepth = $maxDepth; | ||
return $this; | ||
} | ||
|
||
public function start() | ||
{ | ||
if ($this->currentDepth > 0) { | ||
throw new \LogicException('The context cannot be restarted'); | ||
} | ||
|
||
$this->currentDepth = 0; | ||
} | ||
|
||
public function isStarted(): bool | ||
{ | ||
return null !== $this->currentDepth; | ||
} | ||
|
||
public function enter($object = null) | ||
{ | ||
$this->currentDepth++; | ||
} | ||
|
||
public function left() | ||
{ | ||
$this->currentDepth--; | ||
} | ||
|
||
public function isMaxDeepAchieve(): bool | ||
{ | ||
// infinite depth as the maxDepth wasn't provided | ||
if (null === $this->maxDepth) { | ||
return false; | ||
} | ||
|
||
return $this->currentDepth === $this->maxDepth; | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
/** | ||
* This file is part of the TSantos Serializer package. | ||
* | ||
* (c) Tales Santos <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace TSantos\Serializer; | ||
|
||
/** | ||
* Class SerializationContext | ||
* | ||
* @package Serializer | ||
* @author Tales Santos <[email protected]> | ||
*/ | ||
class DeserializationContext extends AbstractContext | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
private $target; | ||
|
||
/** | ||
* @return object | ||
*/ | ||
public function getTarget() | ||
{ | ||
return $this->target; | ||
} | ||
|
||
/** | ||
* @param object $target | ||
*/ | ||
public function setTarget($target): void | ||
{ | ||
if (!is_object($target)) { | ||
throw new \InvalidArgumentException('The $target should be an object, ' . gettype($target) . ' given'); | ||
} | ||
|
||
$this->target = $target; | ||
} | ||
} |
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
Oops, something went wrong.