GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#68)
by Bidesh
04:41
created

MarathonApiClient::updatingJob()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Chapi\Component\RemoteClients;
4
5
6
use Chapi\Component\Http\HttpClientInterface;
7
use Chapi\Entity\Chronos\ChronosJobEntity;
8
use Chapi\Entity\JobEntityInterface;
9
use Symfony\Component\Config\Definition\Exception\Exception;
10
11
class MarathonApiClient implements ApiClientInterface
12
{
13
14
    /** @var HttpClientInterface  */
15
    private $oHttpClient;
16
17 6
    public function __construct(
18
        HttpClientInterface $oHttpClient
19
    )
20
    {
21 6
        $this->oHttpClient = $oHttpClient;
22 6
    }
23
24
    /**
25
     * @link: https://mesos.github.io/chronos/docs/api.html#listing-jobs
26
     * @return array
27
     */
28 1
    public function listingJobs()
29
    {
30 1
        $oResponse = $this->oHttpClient->get('/v2/apps');
31 1
        if (200 == $oResponse->getStatusCode())
32 1
        {
33 1
            return $oResponse->json();
34
        }
35
36
        return [];
37
    }
38
39
    /**
40
     * @param JobEntityInterface $oJobEntity
41
     * @return bool
42
     */
43 1 View Code Duplication
    public function addingJob(JobEntityInterface $oJobEntity)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 1
        $_sTargetEndpoint = '/v2/apps';
46
47 1
        $_oResponse = $this->oHttpClient->postJsonData($_sTargetEndpoint, $oJobEntity);
48 1
        return ($_oResponse->getStatusCode() == 201);
49
    }
50
51
    /**
52
     * @param JobEntityInterface|ChronosJobEntity $oJobEntity
53
     * @return bool
54
     */
55 1 View Code Duplication
    public function updatingJob(JobEntityInterface $oJobEntity)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57 1
        $_sTargetEndpoint = '/v2/apps';
58
59 1
        $_oResponse = $this->oHttpClient->putJsonData($_sTargetEndpoint, $oJobEntity);
60 1
        return ($_oResponse->getStatusCode() == 200);
61
    }
62
63
    /**
64
     * @param string $sJobName
65
     * @return bool
66
     */
67 1
    public function removeJob($sJobName)
68
    {
69 1
        $_sTargetEndpoint = '/v2/apps/'.$sJobName;
70
71 1
        $_oResponse = $this->oHttpClient->delete($_sTargetEndpoint);
72 1
        return ($_oResponse->getStatusCode() == 200);
73
    }
74
75
    /**
76
     * @param string $sJobName
77
     * @return array
78
     */
79
    public function getJobStats($sJobName)
80
    {
81
        return [];
82
    }
83
84
    /**
85
     * Returns true if the client can be connected to.
86
     * @return bool
87
     */
88 2
    public function ping()
89
    {
90
        try {
91 2
            $this->oHttpClient->get('/v2/info');
92 2
        } catch (\Exception $e)
93
        {
94 1
            return false;
95
        }
96 1
        return true;
97
    }
98
}