InvalidFeedItem::withSubject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Feed\Exceptions;
4
5
use Exception;
6
use Spatie\Feed\FeedItem;
7
8
class InvalidFeedItem extends Exception
9
{
10
    /** @var \Spatie\Feed\FeedItem|null */
11
    public $subject;
12
13
    public static function notFeedable($subject)
14
    {
15
        return (new static('Object doesn\'t implement `Spatie\Feed\Feedable`'))->withSubject($subject);
0 ignored issues
show
Unused Code introduced by
The call to InvalidFeedItem::withSubject() has too many arguments starting with $subject.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
16
    }
17
18
    public static function notAFeedItem($subject)
19
    {
20
        return (new static('`toFeedItem` should return an instance of `Spatie\Feed\Feedable`'))->withSubject($subject);
0 ignored issues
show
Unused Code introduced by
The call to InvalidFeedItem::withSubject() has too many arguments starting with $subject.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
21
    }
22
23
    public static function missingField(FeedItem $subject, $field)
24
    {
25
        return (new static("Field `{$field}` is required"))->withSubject($subject);
0 ignored issues
show
Unused Code introduced by
The call to InvalidFeedItem::withSubject() has too many arguments starting with $subject.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
26
    }
27
28
    protected function withSubject()
29
    {
30
        $this->subject;
31
32
        return $this;
33
    }
34
}
35