Skip to content

Commit

Permalink
Separated IJsonObject and IJsonMap interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lord-executor committed Jun 13, 2016
1 parent e8b9c9e commit 2136e23
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
10 changes: 10 additions & 0 deletions IJsonMap.php
@@ -0,0 +1,10 @@
<?php

namespace Lar\JsonApi;


interface IJsonMap extends IJsonObject
{
public function mapField($key, $extractorFn);
public function selectFields($names);
}
2 changes: 0 additions & 2 deletions IJsonObject.php
Expand Up @@ -5,7 +5,5 @@

interface IJsonObject
{
public function mapField($key, $extractorFn);
public function selectFields($names);
public function toArray();
}
2 changes: 1 addition & 1 deletion JsonFieldCollection.php
Expand Up @@ -5,7 +5,7 @@
use Exception;


class JsonFieldCollection implements IJsonObject
class JsonFieldCollection implements IJsonMap
{
private $map = [];

Expand Down
6 changes: 3 additions & 3 deletions JsonListCollection.php
Expand Up @@ -5,7 +5,7 @@
use Exception;


class JsonListCollection implements IJsonObject
class JsonListCollection implements IJsonMap
{
private $list;

Expand All @@ -18,7 +18,7 @@ public function mapField($key, $extractorFn)
{
foreach ($this->list as $value)
{
if ($value instanceof IJsonObject) {
if ($value instanceof IJsonMap) {
$value->mapField($key, $extractorFn);
}
}
Expand All @@ -30,7 +30,7 @@ public function selectFields($names)
{
foreach ($this->list as $value)
{
if ($value instanceof IJsonObject)
if ($value instanceof IJsonMap)
{
$value->selectFields($names);
}
Expand Down
1 change: 1 addition & 0 deletions jsonapi.php
Expand Up @@ -4,6 +4,7 @@
require_once(__DIR__ . '/StaticField.php');
require_once(__DIR__ . '/PageField.php');
require_once(__DIR__ . '/IJsonObject.php');
require_once(__DIR__ . '/IJsonMap.php');
require_once(__DIR__ . '/JsonListCollection.php');
require_once(__DIR__ . '/JsonFieldCollection.php');
require_once(__DIR__ . '/JsonApiAuth.php');
Expand Down

0 comments on commit 2136e23

Please sign in to comment.