Completed
Push — master ( ef29db...6cb927 )
by Ariel
06:10
created

DateslotCalendar::prepare()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 3
eloc 6
nc 4
nop 0
1
<?php
2
3
namespace Timegridio\Concierge\Calendar;
4
5
class DateslotCalendar extends VacancyCalendar
6
{
7
    public function find()
8
    {
9
        $this->prepare();
10
11
        $results = $this->vacancies->get();
0 ignored issues
show
Bug introduced by
The method get cannot be called on $this->vacancies (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
12
13
        $results = $results->reject(function ($vacancy) {
14
15
            return !$vacancy->hasRoom();
16
        });
17
18
        return $results;
19
    }
20
21 View Code Duplication
    protected function prepare()
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...
22
    {
23
        if ($this->service !== null) {
24
            $this->vacancies->forService($this->service);
0 ignored issues
show
Bug introduced by
The method forService cannot be called on $this->vacancies (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
25
        }
26
27
        if ($this->date !== null) {
28
            $this->vacancies->forDate($this->date());
0 ignored issues
show
Bug introduced by
The method forDate cannot be called on $this->vacancies (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
29
        }
30
31
        return $this;
32
    }
33
}
34