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

SaveableTrait::validateSaveable()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4.5923

Importance

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