Jobs   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 50
loc 50
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A get() 4 4 1
A convertToResource() 5 5 1
A urlBase() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Scriptotek\Alma\Conf;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\PaginatedListGenerator;
7
use Scriptotek\Alma\Model\SimplePaginatedList;
8
use Scriptotek\Alma\Model\ReadOnlyArrayAccess;
9
use Scriptotek\Alma\Conf\Job;
10
11
/**
12
 * Iterable collection of Jobs.
13
 */
14 View Code Duplication
class Jobs extends SimplePaginatedList implements \ArrayAccess, \Countable, \Iterator
0 ignored issues
show
Duplication introduced by
This class 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...
15
{
16
    use ReadOnlyArrayAccess;
17
    use PaginatedListGenerator;
18
19
    /**
20
     * Job constructor.
21
     *
22
     * @param Client $client
23
     */
24
    public function __construct(Client $client)
25
    {
26
        parent::__construct($client, 'job');
27
    }
28
29
    /**
30
     * Get a single job by job_id.
31
     *
32
     * @param string $job_id
33
     *
34
     * @return Job
35
     */
36
    public function get($job_id)
37
    {
38
        return Job::make($this->client, $job_id);
39
    }
40
41
    /**
42
     * Convert a data element to a resource object.
43
     *
44
     * @param $data
45
     *
46
     * @return Job
47
     */
48
    protected function convertToResource($data)
49
    {
50
        return Job::make($this->client, $data->id)
51
            ->init($data);
52
    }
53
54
    /**
55
     * Generate the base URL for this resource.
56
     *
57
     * @return string
58
     */
59
    protected function urlBase()
60
    {
61
        return '/conf/jobs';
62
    }
63
}
64