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

DateslotCalendar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 41.38 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 13 1
A prepare() 12 12 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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