Completed
Push — master ( a682ba...4851b3 )
by Paweł
40:50
created

ArticleRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 45
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneBySlug() 0 6 1
A findAllArticles() 0 4 1
A getByCriteria() 0 8 1
A getQueryForRouteArticles() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Content Bundle.
7
 *
8
 * Copyright 2016 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2016 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\ContentBundle\Doctrine\ORM;
18
19
use Doctrine\ORM\QueryBuilder;
20
use SWP\Component\Common\Criteria\Criteria;
21
use SWP\Bundle\ContentBundle\Doctrine\ArticleRepositoryInterface;
22
use SWP\Bundle\ContentBundle\Model\ArticleInterface;
23
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
24
25
class ArticleRepository extends EntityRepository implements ArticleRepositoryInterface
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30 17
    public function findOneBySlug($slug)
31
    {
32 17
        return $this->findOneBy([
33 17
            'slug' => $slug,
34
        ]);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function findAllArticles()
41
    {
42
        throw new \Exception('Not implemented');
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 20
    public function getByCriteria(Criteria $criteria, array $sorting): QueryBuilder
49
    {
50 20
        $qb = $this->getQueryByCriteria($criteria, $sorting, 'a');
51 20
        $qb->andWhere('a.status = :status')
52 20
            ->setParameter('status', $criteria->get('status', ArticleInterface::STATUS_PUBLISHED));
53
54 20
        return $qb;
55
    }
56
57
    /**
58
     * @param string $identifier
59
     * @param array  $order
60
     *
61
     * @return SqlQuery
62
     *
63
     * @throws \Exception
64
     */
65
    public function getQueryForRouteArticles(string $identifier, array $order = []) : SqlQuery
66
    {
67
        throw new \Exception('Not implemented');
68
    }
69
}
70