Passed
Pull Request — master (#141)
by Christoffer
02:56
created

DeprecationTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setDeprecationReason() 0 8 2
A getDeprecationReason() 0 3 1
A getIsDeprecated() 0 3 1
1
<?php
2
3
namespace Digia\GraphQL\Type\Definition;
4
5
trait DeprecationTrait
6
{
7
    /**
8
     * @var string|null
9
     */
10
    protected $deprecationReason;
11
12
    /**
13
     * @var bool
14
     */
15
    protected $isDeprecated = false;
16
17
    /**
18
     * @return null|string
19
     */
20
    public function getDeprecationReason(): ?string
21
    {
22
        return $this->deprecationReason;
23
    }
24
25
    /**
26
     * @return bool
27
     */
28
    public function getIsDeprecated(): bool
29
    {
30
        return $this->isDeprecated;
31
    }
32
33
    /**
34
     * @param null|string $deprecationReason
35
     * @return $this
36
     */
37
    protected function setDeprecationReason(?string $deprecationReason)
38
    {
39
        if (null !== $deprecationReason) {
40
            $this->isDeprecated = true;
41
        }
42
43
        $this->deprecationReason = $deprecationReason;
44
        return $this;
45
    }
46
}
47