UrlAliasRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
eloc 12
c 5
b 1
f 1
dl 0
loc 34
ccs 0
cts 21
cp 0
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneByPublicUrl() 0 7 2
A findAllByInternalUrl() 0 5 1
A findOneByInternalUrl() 0 7 2
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
namespace Zicht\Bundle\UrlBundle\Entity\Repository;
7
8
use Doctrine\ORM\EntityRepository;
9
use Zicht\Bundle\UrlBundle\Aliasing\UrlAliasRepositoryInterface;
10
use Zicht\Bundle\UrlBundle\Entity\UrlAlias;
11
12
/**
13
 * Default repository implementation for url aliases
14
 */
15
class UrlAliasRepository extends EntityRepository implements UrlAliasRepositoryInterface
16
{
17
    /**
18
     * @{inheritDoc}
19
     */
20
    public function findOneByPublicUrl($publicUrl, $mode = UrlAlias::REWRITE)
21
    {
22
        $where = ['public_url' => $publicUrl];
23
        if (null !== $mode) {
24
            $where['mode']= $mode;
25
        }
26
        return $this->findOneBy($where, ['id' => 'ASC']);
27
    }
28
29
    /**
30
     * @{inheritDoc}
31
     */
32
    public function findOneByInternalUrl($internalUrl, $mode = UrlAlias::REWRITE)
33
    {
34
        $where = ['internal_url' => $internalUrl];
35
        if (null !== $mode) {
36
            $where['mode']= $mode;
37
        }
38
        return $this->findOneBy($where, ['id' => 'ASC']);
39
    }
40
41
    /**
42
     * @{inheritDoc}
43
     */
44
    public function findAllByInternalUrl($internalUrl)
45
    {
46
        return $this->findBy(
47
            ['internal_url' => $internalUrl],
48
            ['id' => 'ASC']
49
        );
50
    }
51
}
52