Completed
Pull Request — master (#2)
by
unknown
38:19
created

JobQueue::connect()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 2
nop 0
1
<?php
2
3
namespace SfCod\QueueBundle\Service;
4
5
use SfCod\QueueBundle\Base\JobQueueInterface;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8
/**
9
 * JobQueue service
10
 *
11
 * @author Virchenko Maksim <[email protected]>
12
 * @author Orlov Alexey <[email protected]>
13
 */
14
class JobQueue implements JobQueueInterface
15
{
16
    /**
17
     * QueueManager instance
18
     *
19
     * @var QueueManager
20
     */
21
    protected $manager;
22
23
    /**
24
     * JobQueue constructor.
25
     *
26
     * @param ContainerInterface $container
0 ignored issues
show
Bug introduced by
There is no parameter named $container. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
27
     * @param array $connections
0 ignored issues
show
Bug introduced by
There is no parameter named $connections. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
28
     *
29
     * @internal param array $config
30
     */
31
    public function __construct(QueueManager $manager)
32
    {
33
        $this->manager = $manager;
34
    }
35
36
    /**
37
     * Push new job to queue
38
     *
39
     * @author Virchenko Maksim <[email protected]>
40
     *
41
     * @param string $job
42
     * @param array $data
43
     * @param string $queue
44
     * @param string $connection
45
     *
46
     * @return mixed
47
     */
48
    public function push(string $job, array $data = [], string $queue = 'default', string $connection = 'default')
49
    {
50
        return $this->manager->push($job, $data, $queue, $connection);
0 ignored issues
show
Documentation Bug introduced by
The method push does not exist on object<SfCod\QueueBundle\Service\QueueManager>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
51
    }
52
53
    /**
54
     * Push new job to queue if this job is not exist
55
     *
56
     * @author Virchenko Maksim <[email protected]>
57
     *
58
     * @param string $job
59
     * @param array $data
60
     * @param string $queue
61
     * @param string $connection
62
     *
63
     * @return mixed
64
     */
65
    public function pushUnique(string $job, array $data = [], string $queue = 'default', string $connection = 'default')
66
    {
67
        if (false === $this->manager->connection($connection)->exists($job, $data, $queue)) {
68
            return $this->manager->push($job, $data, $queue, $connection);
0 ignored issues
show
Documentation Bug introduced by
The method push does not exist on object<SfCod\QueueBundle\Service\QueueManager>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
69
        }
70
71
        return null;
72
    }
73
74
    /**
75
     * Push a new an array of jobs onto the queue.
76
     *
77
     * @param array $jobs
78
     * @param mixed $data
79
     * @param string $queue
80
     * @param string $connection
81
     *
82
     * @return mixed
83
     */
84
    public function bulk(array $jobs, array $data = [], string $queue = 'default', string $connection = 'default')
85
    {
86
        return $this->manager->bulk($jobs, $data, $queue, $connection);
0 ignored issues
show
Documentation Bug introduced by
The method bulk does not exist on object<SfCod\QueueBundle\Service\QueueManager>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
87
    }
88
89
    /**
90
     * Push a new job onto the queue after a delay.
91
     *
92
     * @param \DateTime|int $delay
93
     * @param string $job
94
     * @param mixed $data
95
     * @param string $queue
96
     * @param string $connection
97
     *
98
     * @return mixed
99
     */
100
    public function later(int $delay, string $job, array $data = [], string $queue = 'default', string $connection = 'default')
101
    {
102
        return $this->manager->later($delay, $job, $data, $queue, $connection);
0 ignored issues
show
Documentation Bug introduced by
The method later does not exist on object<SfCod\QueueBundle\Service\QueueManager>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
103
    }
104
105
    /**
106
     * Push a new job into the queue after a delay if job does not exist.
107
     *
108
     * @param \DateTime|int $delay
109
     * @param string $job
110
     * @param mixed $data
111
     * @param string $queue
112
     * @param string $connection
113
     *
114
     * @return mixed
115
     */
116
    public function laterUnique(int $delay, string $job, array $data = [], string $queue = 'default', string $connection = 'default')
117
    {
118
        if (false === $this->manager->connection($connection)->exists($job, $data, $queue)) {
119
            return $this->manager->later($delay, $job, $data, $queue, $connection);
0 ignored issues
show
Documentation Bug introduced by
The method later does not exist on object<SfCod\QueueBundle\Service\QueueManager>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
120
        }
121
122
        return null;
123
    }
124
}
125