Completed
Push — sidebaracl ( 7a112d...7c3e4a )
by Andreas
04:38
created

FeedParser_File::headers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Class used to parse RSS and ATOM feeds
4
 *
5
 * @author Andreas Gohr <[email protected]>
6
 */
7
8
if(!defined('DOKU_INC')) die('meh.');
9
10
/**
11
 * We override some methods of the original SimplePie class here
12
 */
13
class FeedParser extends SimplePie {
14
15
    /**
16
     * Constructor. Set some defaults
17
     */
18
    function __construct(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
19
        parent::__construct();
20
        $this->enable_cache(false);
21
        $this->set_file_class('FeedParser_File');
22
    }
23
24
    /**
25
     * Backward compatibility for older plugins
26
     */
27
    function feed_url($url){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
        $this->set_feed_url($url);
29
    }
30
}
31
32
/**
33
 * Fetch an URL using our own HTTPClient
34
 *
35
 * Replaces SimplePie's own class
36
 */
37
class FeedParser_File extends SimplePie_File {
38
    var $http;
39
    var $useragent;
40
    var $success = true;
41
    var $headers = array();
42
    var $body;
43
    var $error;
44
45
    /**
46
     * Inititializes the HTTPClient
47
     *
48
     * We ignore all given parameters - they are set in DokuHTTPClient
49
     */
50
    function __construct($url, $timeout=10, $redirects=5,
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
                         $headers=null, $useragent=null, $force_fsockopen=false) {
52
        $this->http    = new DokuHTTPClient();
53
        $this->success = $this->http->sendRequest($url);
54
55
        $this->headers = $this->http->resp_headers;
0 ignored issues
show
Bug introduced by
The property resp_headers cannot be accessed from this context as it is declared private in class HTTPClient.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
56
        $this->body    = $this->http->resp_body;
0 ignored issues
show
Bug introduced by
The property resp_body cannot be accessed from this context as it is declared private in class HTTPClient.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
57
        $this->error   = $this->http->error;
0 ignored issues
show
Bug introduced by
The property error cannot be accessed from this context as it is declared private in class HTTPClient.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
58
59
        $this->method  = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
60
61
        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...
62
    }
63
64
    function headers(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
65
        return $this->headers;
66
    }
67
68
    function body(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
69
        return $this->body;
70
    }
71
72
    function close(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
73
        return true;
74
    }
75
76
}
77