Completed
Push — master ( fae92f...abd407 )
by Josh
17:40
created

FirstAvailable::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2015 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Configurator\JavaScript\Minifiers;
9
10
use ArrayAccess;
11
use Exception;
12
use RuntimeException;
13
use s9e\TextFormatter\Configurator\Collections\MinifierList;
14
use s9e\TextFormatter\Configurator\JavaScript\Minifier;
15
use s9e\TextFormatter\Configurator\Traits\CollectionProxy;
16
17
class FirstAvailable extends Minifier implements ArrayAccess
18
{
19
	use CollectionProxy;
20
21
	/**
22
	* @var MinifierList
23
	*/
24
	protected $collection;
25
26
	/**
27
	* Constructor
28
	*
29
	* @return void
1 ignored issue
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
30
	*/
31 6
	public function __construct()
32
	{
33 6
		$this->collection = new MinifierList;
34 6
		foreach (func_get_args() as $minifier)
35
		{
36 1
			$this->collection->add($minifier);
37 6
		}
38 6
	}
39
40
	/**
41
	* {@inheritdoc}
42
	*/
43 1
	public function getCacheDifferentiator()
44
	{
45 1
		return '';
46
	}
47
48
	/**
49
	* {@inheritdoc}
50
	*/
51 4
	public function minify($src)
52
	{
53 4
		foreach ($this->collection as $minifier)
54
		{
55
			try
56
			{
57 3
				return $minifier->minify($src);
58
			}
59 2
			catch (Exception $e)
60
			{
61
				// Do nothing
62
			}
63 3
		}
64
65 2
		throw new RuntimeException('No minifier available');
66
	}
67
}