Completed
Pull Request — master (#2)
by David
02:02
created

TdbmFluidJunctionTableGraphqlOptions   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A logged() 0 9 2
A right() 0 5 1
A failWith() 0 5 1
A addAnnotation() 0 5 1
A removeAnnotation() 0 5 1
A endGraphql() 0 4 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