GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — user-entity ( e96cee...7b48d2 )
by Luis Ramón
02:43
created

AgreementRepository::getRealFromDate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
7
class AgreementRepository extends EntityRepository
8
{
9
    public function countHours(Agreement $agreement)
10
    {
11
        return $this->getEntityManager()
12
            ->createQuery('SELECT SUM(w.hours) FROM AppBundle:Workday w INNER JOIN w.agreement a WHERE w.agreement = :agreement')
13
            ->setParameter('agreement', $agreement)
14
            ->getSingleScalarResult();
15
    }
16
17 View Code Duplication
    public function getRealFromDate(Agreement $agreement)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $date = $this->getEntityManager()
20
            ->createQuery('SELECT MIN(w.date) FROM AppBundle:Workday w INNER JOIN w.agreement a WHERE w.agreement = :agreement')
21
            ->setParameter('agreement', $agreement)
22
            ->getSingleScalarResult();
23
24
        return null === $date ?: new \DateTime($date);
25
    }
26
27 View Code Duplication
    public function getRealToDate(Agreement $agreement)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $date = $this->getEntityManager()
30
            ->createQuery('SELECT MAX(w.date) FROM AppBundle:Workday w INNER JOIN w.agreement a WHERE w.agreement = :agreement')
31
            ->setParameter('agreement', $agreement)
32
            ->getSingleScalarResult();
33
34
        return null === $date ?: new \DateTime($date);
35
    }
36
37
    public function getActivitiesStats(Agreement $agreement)
38
    {
39
        $activities = $agreement->getActivities();
40
41
        $result = $this->getEntityManager()
42
            ->createQuery('SELECT a, SUM(t.hours), COUNT(a) FROM AppBundle:Activity a INNER JOIN AppBundle:Tracking t WITH t.activity = a.id INNER JOIN t.workday w WHERE w.agreement = :agreement AND a.id IN (:activities) GROUP BY a.id')
43
            ->setParameter('agreement', $agreement)
44
            ->setParameter('activities', $activities)
45
            ->getResult();
46
47
        return $result;
48
    }
49
50
    public function delete(Agreement $agreement)
51
    {
52
        // borrar informe si estaba cumplimentado
53
        if ($agreement->getReport()) {
54
            $this->getEntityManager()->remove($agreement->getReport());
55
        }
56
57
        // borrar calendario
58
        foreach ($agreement->getWorkdays() as $workday) {
59
            $this->getEntityManager()->remove($workday);
60
        }
61
62
        // borrar actividades de plan de formación individualizado
63
        $agreement->getActivities()->clear();
64
65
        // borrar acuerdo
66
        $this->getEntityManager()->remove($agreement);
67
    }
68
}
69