NewsResource   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 6 1
A getLatestNews() 0 6 1
A getNewstickers() 0 6 1
1
<?php
2
3
namespace Igorsgm\TibiaDataApi\Resources;
4
5
use Igorsgm\TibiaDataApi\Response\NewslistResponse;
6
use Igorsgm\TibiaDataApi\Response\NewsResponse;
7
8
/**
9
 * @see https://tibiadata.com/doc-api-v2/news/
10
 */
11
class NewsResource extends AbstractResource
12
{
13
    /**
14
     * @param integer $id
15
     * @return NewsResponse
16
     * @throws \GuzzleHttp\Exception\GuzzleException
17
     * @throws \Igorsgm\TibiaDataApi\Exceptions\NotFoundException
18
     * @throws \Igorsgm\TibiaDataApi\Exceptions\ImmutableException
19
     */
20
    public function get($id)
21
    {
22
        $response = $this->sendRequest('GET', "news/{$id}.json");
23
24
        return new NewsResponse($response);
25
    }
26
27
    /**
28
     * @return NewslistResponse
29
     * @throws \GuzzleHttp\Exception\GuzzleException
30
     * @throws \Igorsgm\TibiaDataApi\Exceptions\ImmutableException
31
     */
32
    public function getLatestNews()
33
    {
34
        $response = $this->sendRequest('GET', "latestnews.json");
35
36
        return new NewslistResponse($response);
37
    }
38
39
    /**
40
     * @return NewslistResponse
41
     * @throws \GuzzleHttp\Exception\GuzzleException
42
     * @throws \Igorsgm\TibiaDataApi\Exceptions\ImmutableException
43
     */
44
    public function getNewstickers()
45
    {
46
        $response = $this->sendRequest('GET', "newstickers.json");
47
48
        return new NewslistResponse($response);
49
    }
50
}
51