StackOverflowWebPageSource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getResults() 0 13 3
A __construct() 0 5 1
1
<?php
2
3
namespace Coco\SourceWatcher\Vendors\StackOverflow;
4
5
use Coco\SourceWatcher\Core\SourceWatcherException;
6
use Coco\SourceWatcher\Watcher\Source\WebPageSource;
7
8
/**
9
 * Class StackOverflowWebPageSource
10
 *
11
 * @package Coco\SourceWatcher\Vendors\StackOverflow
12
 */
13
class StackOverflowWebPageSource extends WebPageSource
14
{
15
    public function __construct ( string $url )
16
    {
17
        parent::__construct( $url );
18
19
        $this->handler = new StackOverflowWebPageHandler( $url );
20
    }
21
22
    /**
23
     * Function that returns the results from the given StackOverflow URL.
24
     *
25
     * @return array
26
     * @throws SourceWatcherException
27
     */
28
    public function getResults () : array
29
    {
30
        if ( $this->url != $this->handler->getUrl() ) {
31
            $this->handler = new StackOverflowWebPageHandler( $this->url );
32
        }
33
34
        try {
35
            $this->handler->read();
36
        } catch ( SourceWatcherException $e ) {
37
            throw new SourceWatcherException( "Something went wrong trying to read the results", $e->getCode(), $e );
38
        }
39
40
        return $this->handler->getResults();
0 ignored issues
show
introduced by
The method getResults() does not exist on Coco\SourceWatcher\Watcher\Handler\WebPageHandler. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        return $this->handler->/** @scrutinizer ignore-call */ getResults();
Loading history...
41
    }
42
}
43