Passed
Push — fix-phpbench-ci ( 32b959 )
by Michael
03:04
created

ClassWithClosure   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 38
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Doctrine\Tests\Annotations\Fixtures;
4
5
use Doctrine\Tests\Annotations\Fixtures\AnnotationTargetAll;
6
use Doctrine\Tests\Annotations\Fixtures\AnnotationTargetAnnotation;
7
8
/**
9
 * @AnnotationTargetAll("Foo")
10
 */
11
final class ClassWithClosure
12
{
13
14
    /**
15
     * @AnnotationTargetAll(@AnnotationTargetAnnotation)
16
     * @var string
17
     */
18
    public $value;
19
20
    /**
21
     * @AnnotationTargetAll(@AnnotationTargetAnnotation)
22
     *
23
     * @param   \Closure $callback
24
     * @return  \Closure
25
     */
26
    public function methodName(\Closure $callback)
27
    {
28
        return function() use ($callback) {
29
            return $callback;
30
        };
31
    }
32
33
    /**
34
     * @param   integer $year
35
     * @param   integer $month
36
     * @param   integer $day
37
     * @return  \Doctrine\Common\Collections\ArrayCollection
38
     */
39
    public function getEventsForDate($year, $month, $day){
40
        $extractEvents  = null; // check if date of item is inside day given
41
        $extractEvents  = $this->events->filter(function ($item) use ($year, $month, $day) {
42
            $leftDate   = new \DateTime($year.'-'.$month.'-'.$day.' 00:00');
43
            $rigthDate  = new \DateTime($year.'-'.$month.'-'.$day.' +1 day 00:00');
44
            return ( ( $leftDate <= $item->getDateStart() ) && ( $item->getDateStart() < $rigthDate ) );
45
46
            }
47
        );
48
        return $extractEvents;
49
    }
50
51
}
52