Completed
Push — psr2 ( 963c69...e24a74 )
by Andreas
02:58
created

FeedParserFile   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 1
A headers() 0 4 1
A body() 0 4 1
A close() 0 4 1
1
<?php
2
3
namespace dokuwiki;
4
5
/**
6
 * Fetch an URL using our own HTTPClient
7
 *
8
 * Replaces SimplePie's own class
9
 */
10
class FeedParserFile extends \SimplePie_File
11
{
12
    protected $http;
13
    /** @noinspection PhpMissingParentConstructorInspection */
14
15
    /**
16
     * Inititializes the HTTPClient
17
     *
18
     * We ignore all given parameters - they are set in DokuHTTPClient
19
     *
20
     * @inheritdoc
21
     */
22
    public function __construct(
23
        $url,
24
        $timeout = 10,
25
        $redirects = 5,
26
        $headers = null,
27
        $useragent = null,
28
        $force_fsockopen = false,
29
        $curl_options = array()
30
    ) {
31
        $this->http = new \DokuHTTPClient();
32
        $this->success = $this->http->sendRequest($url);
33
34
        $this->headers = $this->http->resp_headers;
35
        $this->body = $this->http->resp_body;
36
        $this->error = $this->http->error;
37
38
        $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
39
40
        return $this->success;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
41
    }
42
43
    /** @inheritdoc */
44
    public function headers()
45
    {
46
        return $this->headers;
47
    }
48
49
    /** @inheritdoc */
50
    public function body()
51
    {
52
        return $this->body;
53
    }
54
55
    /** @inheritdoc */
56
    public function close()
57
    {
58
        return true;
59
    }
60
}
61