Passed
Push — master ( a8b983...5b3176 )
by Adrien
10:48
created

ConfigurationRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 14
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOrCreate() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Repository;
6
7
use Application\Model\Configuration;
8
9
class ConfigurationRepository extends AbstractRepository
10
{
11
    /**
12
     * Get or create the configuration for the given key
13
     */
14
    public function getOrCreate(string $key): Configuration
15
    {
16
        $configuration = $this->findOneByKey($key);
17
        if (!$configuration) {
18
            $configuration = new Configuration($key);
19
            $this->getEntityManager()->persist($configuration);
20
        }
21
22
        return $configuration;
23
    }
24
}
25