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.
Completed
Push — develop ( 5bcd3c...9a7c30 )
by Tom Van
28s
created

Iptc::getHeadline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Iptc: A container class for IPTC data
4
 *
5
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
8
 * @category    PHPExif
9
 * @package     Common
10
 */
11
12
namespace PHPExif\Common\Data;
13
14
use PHPExif\Common\Data\ValueObject\Caption;
15
use PHPExif\Common\Data\ValueObject\Copyright;
16
use PHPExif\Common\Data\ValueObject\Credit;
17
use PHPExif\Common\Data\ValueObject\Headline;
18
19
/**
20
 * Iptc class
21
 *
22
 * Container for IPTC data
23
 *
24
 * @category    PHPExif
25
 * @package     Common
26
 */
27
class Iptc implements IptcInterface
28
{
29
    /**
30
     * @var Caption
31
     */
32
    protected $caption;
33
34
    /**
35
     * @var Copyright
36
     */
37
    protected $copyright;
38
39
    /**
40
     * @var Credit
41
     */
42
    protected $credit;
43
44
    /**
45
     * @var Headline
46
     */
47
    protected $headline;
48
49
    /**
50
     * Contains the mapping of names to IPTC field numbers
51
     *
52
     * @var array
53
     */
54
    public static $iptcMapping = array(
55
        'caption'   => '2#120',
56
        'copyright' => '2#116',
57
        'credit'    => '2#110',
58
        'headline'  => '2#105',
59
        'jobtitle'  => '2#085',
60
        'keywords'  => '2#025',
61
        'source'    => '2#115',
62
        'title'     => '2#005',
63
    );
64
65
    /**
66
     * {@inheritDoc}
67
     */
68
    public function getHeadline()
69
    {
70
        return $this->headline;
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76
    public function withHeadline(Headline $headline)
77
    {
78
        $new = clone $this;
79
        $new->headline = $headline;
80
81
        return $new;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $new; (PHPExif\Common\Data\Iptc) is incompatible with the return type declared by the interface PHPExif\Common\Data\IptcInterface::withHeadline of type PHPExif\Common\Data\ExifInterface.

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...
82
    }
83
84
    /**
85
     * {@inheritDoc}
86
     */
87
    public function getCredit()
88
    {
89
        return $this->credit;
90
    }
91
92
    /**
93
     * {@inheritDoc}
94
     */
95
    public function withCredit(Credit $credit)
96
    {
97
        $new = clone $this;
98
        $new->credit = $credit;
99
100
        return $new;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $new; (PHPExif\Common\Data\Iptc) is incompatible with the return type declared by the interface PHPExif\Common\Data\IptcInterface::withCredit of type PHPExif\Common\Data\ExifInterface.

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...
101
    }
102
103
    /**
104
     * {@inheritDoc}
105
     */
106
    public function getCopyright()
107
    {
108
        return $this->copyright;
109
    }
110
111
    /**
112
     * {@inheritDoc}
113
     */
114
    public function withCopyright(Copyright $copyright)
115
    {
116
        $new = clone $this;
117
        $new->copyright = $copyright;
118
119
        return $new;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $new; (PHPExif\Common\Data\Iptc) is incompatible with the return type declared by the interface PHPExif\Common\Data\IptcInterface::withCopyright of type PHPExif\Common\Data\ExifInterface.

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...
120
    }
121
122
    /**
123
     * {@inheritDoc}
124
     */
125
    public function getCaption()
126
    {
127
        return $this->caption;
128
    }
129
130
    /**
131
     * {@inheritDoc}
132
     */
133
    public function withCaption(Caption $caption)
134
    {
135
        $new = clone $this;
136
        $new->caption = $caption;
137
138
        return $new;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $new; (PHPExif\Common\Data\Iptc) is incompatible with the return type declared by the interface PHPExif\Common\Data\IptcInterface::withCaption of type PHPExif\Common\Data\ExifInterface.

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...
139
    }
140
}
141