Test Failed
Push — master ( 690100...f55788 )
by Kirill
09:19
created

TypeHint::withModifiers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\IR;
11
12
/**
13
 * Class TypeHint
14
 */
15
class TypeHint implements TypeHintInterface
16
{
17
    /**
18
     * @var int
19
     */
20
    private $modifiers = 0;
21
22
    /**
23
     * @param int ...$values
24
     * @return self|$this
25
     */
26
    public function withModifiers(int ...$values): self
27
    {
28
        foreach ($values as $value) {
29
            $this->modifiers |= $value;
30
        }
31
32
        return $this;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function isNonNull(): bool
39
    {
40
        return (bool)($this->modifiers & static::IS_NOT_NULL);
41
    }
42
43
    /**
44
     * @return bool
45
     */
46
    public function isList(): bool
47
    {
48
        return (bool)($this->modifiers & static::IS_LIST);
49
    }
50
51
    /**
52
     * @return bool
53
     */
54
    public function isListOfNonNulls(): bool
55
    {
56
        return (bool)($this->modifiers & static::IS_LIST_OF_NOT_NULL);
57
    }
58
59
    /**
60
     * @return int
61
     */
62
    public function getModifiers(): int
63
    {
64
        return $this->modifiers;
65
    }
66
}
67