ValidateEntities::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.576

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
ccs 3
cts 5
cp 0.6
crap 3.576
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Schema\Generator;
6
7
use Cycle\Schema\Exception\EntityException;
8
use Cycle\Schema\GeneratorInterface;
9
use Cycle\Schema\Registry;
10
11
final class ValidateEntities implements GeneratorInterface
12
{
13
    /**
14
     *
15
     * @throws EntityException
16
     *
17
     */
18
    public function run(Registry $registry): Registry
19
    {
20 16
        foreach ($registry->getIterator() as $entity) {
21
            if (count($entity->getFields()) === 0) {
22 16
                throw new EntityException(
23 16
                    "Entity `{$entity->getRole()}` is empty",
24
                );
25
            }
26
        }
27
28
        return $registry;
29
    }
30
}
31