Passed
Branch dev (1a31b5)
by Dispositif
03:03
created

TransformerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 9
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 7 2
1
<?php
2
/**
3
 * This file is part of dispositif/wikibot application
4
 * 2019 © Philippe M. <[email protected]>
5
 * For the full copyright and MIT license information, please view the LICENSE file.
6
 */
7
8
declare(strict_types=1);
9
10
11
namespace App\Domain;
12
13
14
use App\Application\RefWebTransformer;
15
use App\Application\TransformerInterface;
16
use App\Infrastructure\Logger;
17
18
class TransformerFactory
19
{
20
    public static function fromString(string $string): ?TransformerInterface
21
    {
22
        if (preg_match('#^https?://[^ ]+$#i', $string)) {
23
            return new RefWebTransformer(new Logger());
24
        }
25
26
        return null;
27
    }
28
29
}
30