Completed
Push — master ( 8cebaa...0cc554 )
by Josh
03:33
created

RepositoryCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2017 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\BBCodes\Configurator;
9
10
use s9e\TextFormatter\Configurator;
11
use s9e\TextFormatter\Configurator\Collections\NormalizedCollection;
12
13
class RepositoryCollection extends NormalizedCollection
14
{
15
	/**
16
	* @var BBCodeMonkey Instance of BBCodeMonkey passed to new Repository instances
17
	*/
18
	protected $bbcodeMonkey;
19
20
	/**
21
	* Constructor
22
	*
23
	* @param  BBCodeMonkey $bbcodeMonkey Instance of BBCodeMonkey used to parse definitions
24
	*/
25
	public function __construct(BBCodeMonkey $bbcodeMonkey)
26
	{
27
		$this->bbcodeMonkey = $bbcodeMonkey;
28
	}
29
30
	/**
31
	* Normalize a value for storage
32
	*
33
	* @param  mixed      $value Original value
34
	* @return Repository        Normalized value
35
	*/
36
	public function normalizeValue($value)
37
	{
38
		return ($value instanceof Repository)
39
		     ? $value
40
		     : new Repository($value, $this->bbcodeMonkey);
41
	}
42
}