Passed
Push — master ( ea4658...dc61d8 )
by Josh
02:44
created

Slugger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 7
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getJS() 0 3 1
A setTagSlug() 0 8 2
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2020 The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\Litedown\Parser;
9
10
use s9e\TextFormatter\Parser\Tag;
11
12
class Slugger
13
{
14 4
	public static function getJS(): string
15
	{
16 4
		return file_get_contents(__DIR__ . '/Slugger.js');
17
	}
18
19 4
	public static function setTagSlug(Tag $tag, string $innerText): void
20
	{
21 4
		$slug = strtolower($innerText);
22 4
		$slug = preg_replace('/[^a-z0-9]+/', '-', $slug);
23 4
		$slug = trim($slug, '-');
24 4
		if ($slug !== '')
25
		{
26 4
			$tag->setAttribute('slug', $slug);
27
		}
28
	}
29
}