Passed
Push — 1.11.x ( b4ce57...e435f5 )
by Julito
09:28
created

RecordingRepository::getPeriodRecordings()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 6
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 11
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\Zoom;
6
7
use Chamilo\ClassificationBundle\Entity\Collection;
8
use Chamilo\UserBundle\Entity\User;
9
use DateTime;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\ORM\EntityRepository;
12
13
/**
14
 * Class RecordingRepository.
15
 */
16
class RecordingRepository extends EntityRepository
17
{
18
    public function getPeriodRecordings($startDate, $endDate)
19
    {
20
        $matching = [];
21
        $all = $this->findAll();
22
        foreach ($all as $candidate) {
23
            if ($candidate->startDateTime >= $startDate && $candidate->startDateTime <= $endDate) {
24
                $matching[] = $candidate;
25
            }
26
        }
27
28
        return $matching;
29
    }
30
31
    /**
32
     * Returns a user's meeting recordings.
33
     *
34
     * @param User $user
35
     *
36
     * @return ArrayCollection|Collection|Recording[]
37
     */
38
    /*public function userRecordings($user)
39
    {
40
        return $this->matching(
41
            Criteria::create()->where(
42
                Criteria::expr()->in(
43
                    'meeting',
44
                    $this->getEntityManager()->getRepository(Meeting::class)->userMeetings($user)->toArray()
45
                )
46
            )
47
        );
48
    }*/
49
50
    /**
51
     * @param DateTime $start
52
     * @param DateTime $end
53
     * @param User     $user
54
     *
55
     * @return ArrayCollection|Recording[]
56
     */
57
    /*public function getPeriodUserRecordings($start, $end, $user = null)
58
    {
59
        return $this->userRecordings($user)->filter(
60
            function ($meeting) use ($start, $end) {
61
                return $meeting->startDateTime >= $start && $meeting->startDateTime <= $end;
62
            }
63
        );
64
    }*/
65
}
66