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

SaveableTrait::validateSaveable()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 3
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 4
rs 9.2
c 0
b 0
f 0
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