FcheckLogicValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 4 3
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[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
namespace FlexPHP\Schema\Validators\Logics;
11
12
use FlexPHP\Schema\Exception\InvalidSchemaAttributeException;
13
use FlexPHP\Schema\SchemaAttributeInterface;
14
use FlexPHP\Schema\Validations\ValidationInterface;
15
16
class FcheckLogicValidator implements ValidationInterface
17
{
18
    private SchemaAttributeInterface $property;
19
20 183
    public function __construct(SchemaAttributeInterface $property)
21
    {
22 183
        $this->property = $property;
23 183
    }
24
25 183
    public function validate(): void
26
    {
27 183
        if ($this->property->fkcheck() && !$this->property->isFk()) {
28 1
            throw new InvalidSchemaAttributeException('Only property with Foreing Key allow fkcheck option');
29
        }
30 182
    }
31
}
32