LinkRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 26
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneByUrl() 0 8 1
A getOrCreateLink() 0 10 2
1
<?php
2
3
namespace AppBundle\Entity\Repository;
4
5
use AppBundle\Entity\Infrasctucture\AbstractRepository;
6
use AppBundle\Entity\Link;
7
8
/** {@inheritDoc} */
9
class LinkRepository extends AbstractRepository
10
{
11
12
    /**
13
     * @return Link|object|null
14
     */
15 1
    public function findOneByUrl(string $linkUrl)
16
    {
17 1
        return $this->findOneBy(
18
            [
19 1
                'url' => $linkUrl,
20
            ]
21
        );
22
    }
23
24 1
    public function getOrCreateLink(string $url, string $description = null): Link
25
    {
26 1
        $link = $this->findOneByUrl($url);
27
28 1
        if (!$link) {
29 1
            $link = new Link($url, $description);
30
        }
31
32 1
        return $link;
33
    }
34
}
35