MarioBlazek /
Toggable
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Marek\Toggable\Hydrator\Strategy; |
||
| 4 | |||
| 5 | use Marek\Toggable\API\Toggl\Values\User\BlogPost; |
||
| 6 | use Marek\Toggable\Hydrator\StrategyInterface; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class BlogPostStrategy |
||
| 10 | * @package Marek\Toggable\Hydrator\Strategy |
||
| 11 | */ |
||
| 12 | class BlogPostStrategy implements StrategyInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * {@inheritdoc} |
||
| 16 | */ |
||
| 17 | 3 | public function hydrate($value) |
|
| 18 | { |
||
| 19 | 3 | if (is_array($value)) { |
|
| 20 | 2 | $value = new BlogPost($value); |
|
| 21 | } |
||
| 22 | |||
| 23 | 3 | return $value; |
|
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | 3 | public function extract($value) |
|
| 30 | { |
||
| 31 | 3 | if ($value instanceof BlogPost) { |
|
| 32 | $value = array( |
||
| 33 | 2 | 'title' => $value->title, |
|
| 34 | 2 | 'url' => $value->url, |
|
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | 3 | return $value; |
|
|
0 ignored issues
–
show
Bug
Compatibility
introduced
by
Loading history...
|
|||
| 39 | } |
||
| 40 | } |
||
| 41 |