FcheckLogicValidator::validate()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 3
rs 10
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