ArticleRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 26
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A searchArticle() 0 8 1
A save() 0 4 1
A getArticles() 0 5 1
1
<?php
2
3
4
namespace App\Project\Infrastructure\Article;
5
6
use App\Project\App\Support\AppEntityRepository;
7
use App\Project\Domain\Article\Entity\Article;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class ArticleRepository extends AppEntityRepository
11
{
12
13
    public function getArticles()
14
    {
15
        $qb = $this->createQueryBuilder('a');
16
17
        return $qb->getQuery();
18
    }
19
20
    public function searchArticle(Request $request)
21
    {
22
        $qb = $this->createQueryBuilder('a')
23
            ->where('a.title LIKE :query')
24
            ->orWhere('a.body LIKE :query')
25
            ->setParameter('query', "%{$request->get('query')}%");
26
27
        return $qb->getQuery()->getResult();
28
    }
29
30
31
32
    public function save(Article $article)
33
    {
34
        $this->_em->persist($article);
35
        $this->_em->flush();
36
    }
37
}