Passed
Push — master ( ce47d9...c1ea42 )
by David
38s
created

TdbmFluidJunctionTableGraphqlOptions::failWith()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
4
namespace TheCodingMachine\FluidSchema;
5
6
7
use function addslashes;
8
use function var_export;
9
10
class TdbmFluidJunctionTableGraphqlOptions
11
{
12
    /**
13
     * @var TdbmFluidJunctionTableOptions
14
     */
15
    private $tdbmFluidJunctionTableOptions;
16
    /**
17
     * @var TdbmFluidTable
18
     */
19
    private $tdbmFluidTable;
20
21
    public function __construct(TdbmFluidJunctionTableOptions $tdbmFluidJunctionTableOptions, TdbmFluidTable $tdbmFluidTable)
22
    {
23
        $this->tdbmFluidJunctionTableOptions = $tdbmFluidJunctionTableOptions;
24
        $this->tdbmFluidTable = $tdbmFluidTable;
25
    }
26
27
    public function logged(bool $mustBeLogged = true): self
28
    {
29
        if ($mustBeLogged) {
30
            $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Logged');
31
        } else {
32
            $this->removeAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Logged');
33
        }
34
        return $this;
35
    }
36
37
    public function right(string $rightName): self
38
    {
39
        $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\Right', '(name="'.addslashes($rightName).'")');
40
        return $this;
41
    }
42
43
    public function failWith($value): self
44
    {
45
        $this->addAnnotation('TheCodingMachine\\GraphQLite\\Annotations\\FailWith', '('.var_export($value, true).')');
46
        return $this;
47
    }
48
49
    public function addAnnotation(string $annotation, string $content = '', bool $replaceExisting = true): self
50
    {
51
        $this->tdbmFluidTable->addAnnotation($annotation, $content, $replaceExisting);
52
        return $this;
53
    }
54
55
    public function removeAnnotation(string $annotation): self
56
    {
57
        $this->tdbmFluidTable->removeAnnotation($annotation);
58
        return $this;
59
    }
60
61
    public function endGraphql(): TdbmFluidJunctionTableOptions
62
    {
63
        return $this->tdbmFluidJunctionTableOptions;
64
    }
65
}
66