Test Failed
Pull Request — master (#56)
by
unknown
02:51
created

Factory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 3
dl 0
loc 18
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Resque\Job;
4
5
use \Resque\Exceptions\Exception as ResqueException;
6
7
class Factory implements FactoryInterface
8
{
9
	/**
10
	 * @param $className
11
	 * @param array $args
12
	 * @param $queue
13
	 * @return \Resque\Job\JobInterface
14
	 * @throws \Resque\Exceptions\Exception
15
	 */
16
	public function create($className, $args, $queue)
17
	{
18
		if (!class_exists($className)) {
19
			throw new ResqueException(
20
				'Could not find job class ' . $className . '.'
21
			);
22
		}
23
24
		if (!method_exists($className, 'perform')) {
25
			throw new ResqueException(
26
				'Job class ' . $className . ' does not contain a perform method.'
27
			);
28
		}
29
30
		$instance = new $className();
31
		$instance->args = $args;
32
		$instance->queue = $queue;
33
		return $instance;
34
	}
35
}
36