Completed
Push — master ( cbfed7...c39fb6 )
by Rafael
05:06
created

MetaAwareTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 70
ccs 12
cts 15
cp 0.8
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hasMeta() 0 3 1
A getMetas() 0 3 1
A setMeta() 0 5 1
A setMetas() 0 5 1
A removeMeta() 0 5 1
A getMeta() 0 3 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Definition\Traits;
12
13
use Ynlo\GraphQLBundle\Definition\MetaAwareInterface;
14
15
/**
16
 * Class MetaAwareTrait
17
 */
18
trait MetaAwareTrait
19
{
20
    /**
21
     * @var array
22
     */
23
    protected $metas = [];
24
25
    /**
26
     * @return array
27
     */
28 1
    public function getMetas(): array
29
    {
30 1
        return $this->metas;
31
    }
32
33
    /**
34
     * @param string $key
35
     *
36
     * @return mixed
37
     */
38 10
    public function getMeta(string $key)
39
    {
40 10
        return $this->metas[$key];
41
    }
42
43
    /**
44
     * @param string $key
45
     *
46
     * @return bool
47
     */
48 10
    public function hasMeta(string $key): bool
49
    {
50 10
        return array_key_exists($key, $this->metas);
51
    }
52
53
    /**
54
     * @param array $metas
55
     *
56
     * @return MetaAwareInterface
57
     */
58 1
    public function setMetas(array $metas): MetaAwareInterface
59
    {
60 1
        $this->metas = $metas;
61
62 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...n\Traits\MetaAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Definition\MetaAwareInterface.
Loading history...
63
    }
64
65
    /**
66
     * @param string $key
67
     * @param mixed  $value
68
     *
69
     * @return MetaAwareInterface
70
     */
71 1
    public function setMeta(string $key, $value): MetaAwareInterface
72
    {
73 1
        $this->metas[$key] = $value;
74
75 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...n\Traits\MetaAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Definition\MetaAwareInterface.
Loading history...
76
    }
77
78
    /**
79
     * @param string $key
80
     *
81
     * @return MetaAwareInterface
82
     */
83
    public function removeMeta(string $key): MetaAwareInterface
84
    {
85
        unset($this->metas[$key]);
86
87
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Ynlo\GraphQLBundle\Defin...n\Traits\MetaAwareTrait which is incompatible with the type-hinted return Ynlo\GraphQLBundle\Definition\MetaAwareInterface.
Loading history...
88
    }
89
}
90