Completed
Push — master ( 8ffdf8...f67228 )
by Matthew
08:43
created

SaveableTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 19
ccs 4
cts 6
cp 0.6667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSaveable() 0 10 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 37
    protected function validateSaveable(\Dtc\QueueBundle\Model\Job $job)
18
    {
19 37
        if (null !== $job->getPriority() && !isset($this->maxPriority)) {
20
            throw new PriorityException('This queue does not support priorities');
21
        }
22
23 37
        if (!$job instanceof RetryableJob) {
24
            throw new ClassNotSubclassException('Job needs to be instance of '.RetryableJob::class);
25
        }
26 37
    }
27
}
28