FeedParserFile::headers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki;
4
5
use dokuwiki\HTTP\DokuHTTPClient;
6
7
/**
8
 * Fetch an URL using our own HTTPClient
9
 *
10
 * Replaces SimplePie's own class
11
 */
12
class FeedParserFile extends \SimplePie_File
13
{
14
    protected $http;
15
    /** @noinspection PhpMissingParentConstructorInspection */
16
17
    /**
18
     * Inititializes the HTTPClient
19
     *
20
     * We ignore all given parameters - they are set in DokuHTTPClient
21
     *
22
     * @inheritdoc
23
     */
24
    public function __construct(
25
        $url,
26
        $timeout = 10,
27
        $redirects = 5,
28
        $headers = null,
29
        $useragent = null,
30
        $force_fsockopen = false,
31
        $curl_options = array()
32
    ) {
33
        $this->http = new DokuHTTPClient();
34
        $this->success = $this->http->sendRequest($url);
35
36
        $this->headers = $this->http->resp_headers;
37
        $this->body = $this->http->resp_body;
38
        $this->error = $this->http->error;
39
40
        $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
41
42
        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...
43
    }
44
45
    /** @inheritdoc */
46
    public function headers()
47
    {
48
        return $this->headers;
49
    }
50
51
    /** @inheritdoc */
52
    public function body()
53
    {
54
        return $this->body;
55
    }
56
57
    /** @inheritdoc */
58
    public function close()
59
    {
60
        return true;
61
    }
62
}
63