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

RadioHitRepository::getSimilar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
crap 2
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