ValidateEntities   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 11 3
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