GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Holiday   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 24
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A is() 0 4 1
1
<?php
2
3
namespace COG\ChronoShifter\Evaluator;
4
5
use COG\ChronoShifter\HolidayProvider\HolidayProvider;
6
7
/**
8
 * @author Kristjan Siimson <[email protected]>
9
 * @package Evaluator\Domain
10
 */
11
class Holiday implements Evaluator
12
{
13
    /**
14
     * @var HolidayProvider
15
     */
16
    private $holidayProvider;
17
18
    /**
19
     * @param HolidayProvider $holidayProvider
20
     */
21 33
    public function __construct(HolidayProvider $holidayProvider)
22
    {
23 33
        $this->holidayProvider = $holidayProvider;
24 33
    }
25
26
    /**
27
     * @param string $date
28
     * @return bool
29
     */
30 31
    public function is($date)
31
    {
32 31
        return $this->holidayProvider->isHoliday($date);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->holidayProvider->isHoliday($date); (boolean) is incompatible with the return type declared by the interface COG\ChronoShifter\Evaluator\Evaluator::is of type integer.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
33
    }
34
}
35