Passed
Push — master ( 9ad74e...d4750c )
by Josh
02:29
created

MastodonHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addHost() 0 9 2
1
<?php declare(strict_types=1);
2
3
/**
4
* @package   s9e\TextFormatter
5
* @copyright Copyright (c) 2010-2023 The s9e authors
6
* @license   http://www.opensource.org/licenses/mit-license.php The MIT License
7
*/
8
namespace s9e\TextFormatter\Plugins\MediaEmbed\Configurator;
9
10
use function strtolower;
11
use s9e\TextFormatter\Configurator;
12
13
class MastodonHelper
14
{
15
	/**
16
	* @var Configurator
17
	*/
18
	protected Configurator $configurator;
19
20
	public function __construct(Configurator $configurator)
21
	{
22
		$this->configurator = $configurator;
23
	}
24
25
	public function addHost(string $host): void
26
	{
27
		if (!isset($this->configurator->registeredVars['MediaEmbed.sites']['mastodon']))
28
		{
29
			$this->configurator->MediaEmbed->add('mastodon');
30
		}
31
32
		$host = strtolower($host);
33
		$this->configurator->registeredVars['MediaEmbed.hosts'][$host] = 'mastodon';
34
	}
35
}