Passed
Push — master ( f67228...ea1bad )
by Matthew
08:44
created

SaveableTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSaveable() 0 8 4
1
<?php
2
3
namespace Dtc\QueueBundle\Manager;
4
5
use Dtc\QueueBundle\Exception\ClassNotSubclassException;
6
use Dtc\QueueBundle\Exception\PriorityException;
7
use Dtc\QueueBundle\Model\RetryableJob;
8
9
trait SaveableTrait
10
{
11
    /**
12
     * @param \Dtc\QueueBundle\Model\Job $job
13
     *
14
     * @throws PriorityException
15
     * @throws ClassNotSubclassException
16
     */
17 38
    protected function validateSaveable(\Dtc\QueueBundle\Model\Job $job)
18
    {
19 38
        if (null !== $job->getPriority() && !isset($this->maxPriority)) {
20 1
            throw new PriorityException('This queue does not support priorities');
21
        }
22
23 38
        if (!$job instanceof RetryableJob) {
24 1
            throw new ClassNotSubclassException('Job needs to be instance of '.RetryableJob::class);
25
        }
26 37
    }
27
}
28