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

MastodonHelper::addHost()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 9
rs 10
cc 2
nc 2
nop 1
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
}