SongManager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PHPDish\DailySongPlugin\Service;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\EntityRepository;
7
8
class SongManager  implements SongManagerInterface
9
{
10
    /**
11
     * @var EntityManagerInterface
12
     */
13
    protected $entityManager;
14
15
    /**
16
     * @var EntityRepository
17
     */
18
    protected $songRepository;
19
20
    public function __construct(EntityManagerInterface $entityManager)
21
    {
22
        $this->entityManager = $entityManager;
23
        $this->songRepository = $entityManager->getRepository('PHPDishDailySongPlugin:Song');
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getLatestSong()
30
    {
31
        return $this->songRepository->findOneBy(['enabled' => true], [
32
            'createdAt' => 'desc',
33
        ]);
34
    }
35
}