Lines 0.00% 0 / 3
Functions and Methods 0.00% 0 / 3
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
DomainModelCollection 0.00% 0 / 3 0.00% 0 / 3 12 0.00% 0 / 1
 havingEntities 0.00% 0 / 1 0.00% 0 / 1 2
 havingServices 0.00% 0 / 1 0.00% 0 / 1 2
 countAttributes 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Codegen\Model\Collection;
6
7use Stewart\Codegen\Model\DomainModel;
8use Stewart\Contracts\Collection\ListCollection;
9
10/** @extends ListCollection<DomainModel> */
11final readonly class DomainModelCollection extends ListCollection
12{
13    public function havingEntities(): self
14    {
15        return $this->filter(static fn(DomainModel $domain): bool => $domain->hasEntities());
16    }
17
18    public function havingServices(): self
19    {
20        return $this->filter(static fn(DomainModel $domain): bool => $domain->hasServices());
21    }
22
23    public function countAttributes(): int
24    {
25        return array_sum($this->mapToList(static fn(DomainModel $domain): int => \count($domain->attributes)));
26    }
27}