Completed
Push — master ( 27b2e7...418156 )
by Christophe
09:36 queued 06:43
created

RadioHitRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSimilar() 0 8 1
1
<?php
2
3
namespace AudioCoreEntity\Repository;
4
5
use AudioCoreEntity\Entity\RadioHit;
6
use Doctrine\ORM\EntityRepository;
7
8
/**
9
 * RadioHitRepository
10
 *
11
 * This class was generated by the Doctrine ORM. Add your own custom
12
 * repository methods below.
13
 */
14
class RadioHitRepository extends EntityRepository
15
{
16
    /**
17
     * @param $minSimilarity
18
     * @param $artist
19
     * @param $title
20
     * @return RadioHit[]
21
     */
22
    public function getSimilar($artist, $title, $minSimilarity = 51)
23
    {
24
        $query = $this->_em->createQuery('SELECT r FROM RadioHit r WHERE LEVENSHTEIN_RATIO(CONCAT(r.artist, \' \', title), :artistTitle) > :minSimilarity');
25
        $query->setParameter('artistTitle', sprintf('%s %s', $artist, $title));
26
        $query->setParameter('minSimilarity', $minSimilarity);
27
28
        return $query->getResult();
29
    }
30
}
31