Completed
Push — master ( e27ccc...d4c9ec )
by Josh
17:28
created

EmoticonCollection::getAlreadyExistsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2016 The s9e Authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\Emoticons\Configurator;
9
10
use RuntimeException;
11
use s9e\TextFormatter\Configurator\Collections\NormalizedCollection;
12
use s9e\TextFormatter\Configurator\Helpers\TemplateHelper;
13
14
class EmoticonCollection extends NormalizedCollection
15
{
16
	/**
17
	* Normalize an emoticon's template
18
	*
19
	* NOTE: this allows the HTML syntax to be used for individual emoticons
20
	*
21
	* @param  string $value Emoticon's original markup
22
	* @return string        Normalized template
23
	*/
24 3
	public function normalizeValue($value)
25
	{
26 3
		return TemplateHelper::saveTemplate(TemplateHelper::loadTemplate($value));
27
	}
28
29
	/**
30
	* {@inheritdoc}
31
	*/
32 1
	protected function getAlreadyExistsException($key)
33
	{
34 1
		return new RuntimeException("Emoticon '" . $key . "' already exists");
35
	}
36
37
	/**
38
	* {@inheritdoc}
39
	*/
40 1
	protected function getNotExistException($key)
41
	{
42 1
		return new RuntimeException("Emoticon '" . $key . "' does not exist");
43
	}
44
}