Completed
Push — master ( c91fb3...77e88f )
by Ariel
05:48
created

VacancyFinder   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 59
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A forServiceAndDateTime() 0 6 1
A forDateTime() 0 10 3
A forService() 0 10 3
A find() 0 4 1
A filtered() 0 8 2
1
<?php
2
3
namespace Timegridio\Concierge\Calendar;
4
5
class VacancyFinder extends Calendar
6
{
7
    protected $service = null;
8
9
    protected $datetime = null;
10
11
    protected $timezone = null;
12
13
    protected $vacancies = null;
14
15
    protected $find = null;
16
17
    /////////////////////
18
    // Vacancy Queries //
19
    /////////////////////
20
21
    public function forServiceAndDateTime($service, $datetime = null, $timezone = null)
0 ignored issues
show
Unused Code introduced by
The parameter $timezone is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $this->find = $this->filtered()->forDateTime($datetime)->forService($service->id);
24
25
        return $this;
26
    }
27
28
    public function forDateTime($datetime = null, $timezone = null)
0 ignored issues
show
Unused Code introduced by
The parameter $timezone is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30
        if ($datetime === null && $this->datetime !== null) {
31
            $datetime = $this->datetime;
32
        }
33
34
        $this->find = $this->filtered()->forDateTime($datetime);
35
36
        return $this;
37
    }
38
39
    public function forService($service)
40
    {
41
        if ($service === null && $this->service !== null) {
42
            $service = $this->service;
43
        }
44
45
        $this->find = $this->filtered()->forService($service->id);
46
47
        return $this;
48
    }
49
50
    public function find()
51
    {
52
        return $this->filtered()->first();
53
    }
54
55
    public function filtered()
56
    {
57
        if ($this->find === null) {
58
            $this->find = $this->business->vacancies();
59
        }
60
61
        return $this->find;
62
    }
63
}
64