1 | <?php |
||
27 | class Client { |
||
28 | |||
29 | /** |
||
30 | * The plugin's instance. |
||
31 | * |
||
32 | * @since 1.0.0 |
||
33 | * @access private |
||
34 | * @var Plugin $plugin This plugin's instance. |
||
35 | */ |
||
36 | private $plugin; |
||
37 | |||
38 | /** |
||
39 | * Root URL for Redmine. |
||
40 | * @access private |
||
41 | * @var string |
||
42 | */ |
||
43 | private $root_url = ''; |
||
44 | |||
45 | /** |
||
46 | * REST API key for Redmine. |
||
47 | * @var string |
||
48 | */ |
||
49 | private $api_key = ''; |
||
50 | |||
51 | /** |
||
52 | * Initialize the class and set its properties. |
||
53 | * |
||
54 | * @since 1.0.0 |
||
55 | * |
||
56 | * @param Plugin $plugin This plugin's instance. |
||
57 | */ |
||
58 | public function __construct( Plugin $plugin ) { |
||
64 | |||
65 | /** |
||
66 | * Fetch an issue. |
||
67 | * @param string $id Issue ID. |
||
68 | * @param array $options Request options. |
||
69 | * @param array $expires Cache TTL, in seconds (defaults to 3600). |
||
70 | * @return mixed Response data. |
||
71 | */ |
||
72 | public function get_issue( $id, $options = array(), $expires = 3600 ) { |
||
77 | |||
78 | /** |
||
79 | * Handle GET requests. |
||
80 | * @param string $resource Resource to fetch |
||
81 | * @param array $options Request options. |
||
82 | * @param array $expires Cache TTL, in seconds (defaults to 3600). |
||
83 | * @return mixed Response data. |
||
84 | */ |
||
85 | public function get( $url, $options = array(), $expires = 3600 ) { |
||
100 | |||
101 | /** |
||
102 | * Fetch the response body for a GET request. |
||
103 | * @param string $resource Resource to fetch |
||
104 | * @param array $options Request options. |
||
105 | * @return string Request body. |
||
106 | */ |
||
107 | public function get_body( $url, $options ) { |
||
119 | |||
120 | /** |
||
121 | * Add credentials to a set of request options. |
||
122 | * @param array $options Request options. |
||
123 | */ |
||
124 | private function add_credentials( $options = array() ) { |
||
133 | |||
134 | /** |
||
135 | * Get the configured Redmine API key. |
||
136 | * |
||
137 | * Looks for the user key first and falls back to the globally configured one. |
||
138 | * |
||
139 | * @return string Configured Redmine API key. |
||
140 | */ |
||
141 | private function get_api_key() { |
||
151 | |||
152 | } |
||
153 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: