Completed
Push — master ( 3e44d5...49b4bd )
by Rafael
06:52
created

Namespaces::__construct()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0
cc 4
nc 2
nop 1
crap 20
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\Annotation\Plugin;
12
13
/**
14
 * @Annotation
15
 */
16
class Namespaces extends PluginConfigAnnotation
17
{
18
    /**
19
     * Set custom namespace,
20
     * for example:
21
     *
22
     * billing/invoices
23
     *
24
     * @var string
25
     */
26
    public $namespace;
27
28
    /**
29
     * Name to use as alias for this operation.
30
     *
31
     * By default the same operation name is used,
32
     * but removing any suffix containing the node name,
33
     * example `AddPost` when is namespaced is converted to `add`
34
     * inside `posts` namespace. If you wat to use for example `create` instead
35
     * can set this as alias.
36
     *
37
     * @var bool
38
     */
39
    public $alias;
40
41
    /**
42
     * @var bool
43
     */
44
    public $enabled;
45
46
    /**
47
     * @var string
48
     */
49
    public $node;
50
51
    /**
52
     * @var string
53
     */
54
    public $bundle;
55
56
    public function __construct(array $config = [])
57
    {
58
        if (isset($config['value']) && \count($config) === 1 && \is_bool($config['value'])) {
59
            $config['enabled'] = $config['value'];
60
            unset($config['value']);
61
        }
62
        parent::__construct($config);
63
    }
64
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function getName(): string
70
    {
71
        return 'namespace';
72
    }
73
}
74