Test Setup Failed
Pull Request — master (#19)
by
unknown
01:55
created

Jobs::convertToResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 5
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Scriptotek\Alma\Conf;
4
5
use Scriptotek\Alma\Client;
6
use Scriptotek\Alma\Model\IterableCollection;
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 IterableCollection;
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