Passed
Push — master ( 1d0ea2...0f9d68 )
by Kacper
05:34
created

CommonFeatures   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A strings() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Highlighter
7
 *
8
 * Copyright (C) 2016, Some right reserved.
9
 *
10
 * @author Kacper "Kadet" Donat <[email protected]>
11
 *
12
 * Contact with author:
13
 * Xmpp: [email protected]
14
 * E-mail: [email protected]
15
 *
16
 * From Kadet with love.
17
 */
18
19
namespace Kadet\Highlighter\Language;
20
21
use Kadet\Highlighter\Matcher\MatcherInterface;
22
use Kadet\Highlighter\Matcher\SubStringMatcher;
23
use Kadet\Highlighter\Parser\Rule;
24
use Kadet\Highlighter\Parser\Token\ContextualToken;
25
use Kadet\Highlighter\Parser\TokenFactory;
26
27
final class CommonFeatures
28
{
29
    private function __construct()
30
    {
31
    }
32
33 2
    public static function strings(array $strings, array $options = [])
34
    {
35 2
        return array_map(function ($matcher) use ($options) {
36 2
            return new Rule(
37 2
                $matcher instanceof MatcherInterface ? $matcher : new SubStringMatcher($matcher),
38 2
                array_replace(['factory' => new TokenFactory(ContextualToken::class)], $options)
39
            );
40 2
        }, $strings);
41
    }
42
}
43