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

Configurator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 45
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 17 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\Autoemail;
9
10
use s9e\TextFormatter\Plugins\ConfiguratorBase;
11
12
class Configurator extends ConfiguratorBase
13
{
14
	/**
15
	* @var string Name of attribute that stores the link's URL
16
	*/
17
	protected $attrName = 'email';
18
19
	/**
20
	* {@inheritdoc}
21
	*/
22
	protected $quickMatch = '@';
23
24
	/**
25
	* {@inheritdoc}
26
	*/
27
	protected $regexp = '/\\b[-a-z0-9_+.]+@[-a-z0-9.]*[a-z0-9]/Si';
28
29
	/**
30
	* @var string Name of the tag used to represent links
31
	*/
32
	protected $tagName = 'EMAIL';
33
34
	/**
35
	* Creates the tag used by this plugin
36
	*
37
	* @return void
38
	*/
39
	protected function setUp()
40
	{
41
		if (isset($this->configurator->tags[$this->tagName]))
42
		{
43
			return;
44
		}
45
46
		// Create a tag
47
		$tag = $this->configurator->tags->add($this->tagName);
48
49
		// Add an attribute using the default email filter
50
		$filter = $this->configurator->attributeFilters->get('#email');
51
		$tag->attributes->add($this->attrName)->filterChain->append($filter);
52
53
		// Set the default template
54
		$tag->template = '<a href="mailto:{@' . $this->attrName . '}"><xsl:apply-templates/></a>';
55
	}
56
}