Passed
Push — master ( 7b7e33...6ff579 )
by Tomasz
04:38
created

DomainRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 16
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A getById() 0 8 2
1
<?php
2
/**
3
 * Copyright
4
 */
5
namespace Helpers\Repository;
6
7
8
use Hexarchium\CoreDomain\Model\Domain\DomainId;
9
use Hexarchium\CoreDomain\Model\Domain\Entity\Domain;
10
use Hexarchium\CoreDomain\Model\Domain\Exception\DomainNotFoundException;
11
use Hexarchium\CoreDomain\Model\Domain\Repository\DomainRepositoryInterface;
12
13
class DomainRepository extends \ArrayObject implements DomainRepositoryInterface
14
{
15
    public function add(Domain $domain)
16
    {
17
        $this->offsetSet($domain->getId()->getId(), $domain);
18
    }
19
20
    public function getById(DomainId $domainId): Domain
21
    {
22
        if (!$this->offsetExists($domainId->getId())) {
23
            throw new DomainNotFoundException(sprintf("Domain with id '%s' not found", $domainId->getId()));
24
        }
25
26
        return $this->offsetGet($domainId->getId());
27
    }
28
}