Completed
Push — master ( 4100f7...88d4d7 )
by
unknown
37:35
created

TestJobContract::reserved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SfCod\QueueBundle\Tests\Data;
4
5
use SfCod\QueueBundle\Base\JobInterface;
6
use SfCod\QueueBundle\Job\JobContract;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
8
9
/**
10
 * Test job
11
 *
12
 * Class TestJob
13
 *
14
 * @author Virchenko Maksim <[email protected]>
15
 *
16
 * @package SfCod\QueueBundle\Tests
17
 */
18
class TestJobContract extends JobContract
19
{
20
    /**
21
     * @var ContainerInterface
22
     */
23
    private $_container;
24
25
    /**
26
     * Get the job identifier.
27
     *
28
     * @return string
29
     */
30
    public function getJobId(): string
31
    {
32
        return uniqid();
33
    }
34
35
    /**
36
     * TestJob constructor.
37
     *
38
     * @param ContainerInterface $container
39
     */
40
    public function __construct(ContainerInterface $container)
41
    {
42
        $this->_container = $container;
43
    }
44
45
    /**
46
     * Get container instance
47
     *
48
     * @return ContainerInterface
49
     */
50
    public function getContainer()
51
    {
52
        return $this->_container;
53
    }
54
55
    /**
56
     * Delete job
57
     *
58
     * @throws SuccessJobException
59
     */
60
    public function delete()
61
    {
62
        throw new SuccessJobException('Job was deleted.');
63
    }
64
65
    /**
66
     * Get the raw body of the job.
67
     *
68
     * @return string
69
     */
70
    public function getRawBody(): string
71
    {
72
        return '';
73
    }
74
75
    /**
76
     * Resolve the given class
77
     *
78
     * @param string $class
79
     *
80
     * @return JobInterface
81
     */
82
    protected function resolve(string $class): JobInterface
83
    {
84
        return $this->_container->get($class);
85
    }
86
87
    /**
88
     * Get is job reserved
89
     *
90
     * @return bool
91
     */
92
    public function reserved(): bool
93
    {
94
        return false;
95
    }
96
97
    /**
98
     * Get the number of times the job has been attempted.
99
     *
100
     * @return int
101
     */
102
    public function attempts(): int
103
    {
104
        return 1;
105
    }
106
}
107