Passed
Push — master ( 7c3afb...bf6fcb )
by Derek Stephen
09:16 queued 07:47
created

CountryFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 1
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Del\Factory;
4
5
use Del\Entity\Country;
6
use Del\Repository\CountryRepository;
7
8
class CountryFactory
9
{
10
    private CountryRepository $countryRepository;
11 1
    private function __construct(){}
12
    private function __clone(){}
13
14 3
    public static function generate(string $id): Country
15
    {
16 3
        static $inst = null;
17
18 3
        if ($inst === null) {
19 1
            $inst = new CountryFactory();
20 1
            $inst->countryRepository = new CountryRepository();
21
        }
22
23 3
        return $inst->countryRepository->findCountryByIsoCode($id);
24
    }
25
26
    public function setCountryRepository(CountryRepository $countryRepository): void
27
    {
28
        $this->countryRepository = $countryRepository;
29
    }
30
}
31