Passed
Push — master ( 0ad200...922ca9 )
by Josh
02:43
created

BlueskyHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 10
c 1
b 0
f 1
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSiteId() 0 3 1
A addHosts() 0 14 2
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\MediaEmbed\Configurator\SiteHelpers;
9
10
use s9e\RegexpBuilder\Builder;
11
12
class BlueskyHelper extends AbstractConfigurableHostHelper
13
{
14
	protected Builder $builder;
15
16
	public function addHosts(array $hosts): void
17
	{
18
		parent::addHosts($hosts);
19
20
		if (!isset($this->builder))
21
		{
22
			$this->builder = new Builder;
23
		}
24
25
		$siteId = $this->getSiteId();
26
		$hosts  = $this->getHosts();
27
28
		$this->configurator->tags[$siteId]->attributes['embedder']->filterChain[0]->setRegexp(
29
			'/^(?:[-\w]*\.)*' . $this->builder->build($hosts) . '$/'
30
		);
31
	}
32
33
	protected function getSiteId(): string
34
	{
35
		return 'bluesky';
36
	}
37
}