UrlAliasRepository::findOneByInternalUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 4
c 1
b 1
f 0
nc 2
nop 2
dl 0
loc 7
ccs 0
cts 7
cp 0
crap 6
rs 10
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