ThrowInconsistency   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 21
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B detectAnnotationErrorThrow() 0 13 5
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
9
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
 * THE SOFTWARE.
12
 *
13
 * This software consists of voluntary contributions made by many individuals
14
 * and is licensed under the MIT license.
15
 *
16
 * Copyright (c) 2018 Yuuki Takezawa
17
 */
18
19
namespace Ytake\Lom\Exception;
20
21
use Ytake\Lom\Meta\AllArgsConstructor;
22
use Ytake\Lom\Meta\Data;
23
use Ytake\Lom\Meta\NoArgsConstructor;
24
use Ytake\Lom\Meta\Value;
25
26
/**
27
 * Class ThrowInconsistency.
28
 *
29
 * @author yuuki.takezawa<[email protected]>
30
 */
31
class ThrowInconsistency implements Throwable
32
{
33
    /**
34
     * @param array $annotations
35
     *
36
     * @throw InconsistencyException
37
     */
38
    public function detectAnnotationErrorThrow(array $annotations): void
39
    {
40
        if (array_key_exists(NoArgsConstructor::class, $annotations)
41
            && array_key_exists(AllArgsConstructor::class, $annotations)
42
        ) {
43
            throw new InconsistencyException();
44
        }
45
        if (array_key_exists(Data::class, $annotations)
46
            && array_key_exists(Value::class, $annotations)
47
        ) {
48
            throw new InconsistencyException();
49
        }
50
    }
51
}
52