Completed
Pull Request — master (#45)
by Jose Manuel
02:24
created

AbstractObject::has()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Softonic\GraphQL\DataObjects;
4
5
use JsonSerializable;
6
use Softonic\GraphQL\DataObjects\Interfaces\DataObject;
7
8
abstract class AbstractObject implements JsonSerializable, DataObject
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $arguments;
14
15 144
    public function __construct(array $arguments = [])
16
    {
17 144
        $this->arguments = $arguments;
18 144
    }
19
20 28
    public function toArray(): array
21
    {
22 28
        $item = [];
23 28
        foreach ($this->arguments as $key => $value) {
24 28
            $item[$key] = $value instanceof JsonSerializable ? $value->toArray() : $value;
0 ignored issues
show
Bug introduced by
The class JsonSerializable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
25
        }
26
27 28
        return $item;
28
    }
29
30
    abstract public function has(string $key): bool;
31
}
32