Completed
Push — master ( 9b98d4...f3f280 )
by Maciej
06:39
created

CommonFeatures::strings()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 1
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * Highlighter
5
 *
6
 * Copyright (C) 2016, Some right reserved.
7
 *
8
 * @author Kacper "Kadet" Donat <[email protected]>
9
 *
10
 * Contact with author:
11
 * Xmpp: [email protected]
12
 * E-mail: [email protected]
13
 *
14
 * From Kadet with love.
15
 */
16
17
namespace Kadet\Highlighter\Language;
18
19
use Kadet\Highlighter\Matcher\MatcherInterface;
20
use Kadet\Highlighter\Matcher\SubStringMatcher;
21
use Kadet\Highlighter\Parser\Rule;
22
use Kadet\Highlighter\Parser\Token\ContextualToken;
23
use Kadet\Highlighter\Parser\TokenFactory;
24
25
final class CommonFeatures
26
{
27
    private function __construct()
28
    {
29
    }
30
31 2
    public static function strings(array $strings, array $options = [])
32
    {
33
        return array_map(function ($matcher) use ($options) {
34 2
            return new Rule(
35 2
                $matcher instanceof MatcherInterface ? $matcher : new SubStringMatcher($matcher),
36 2
                array_replace(['factory' => new TokenFactory(ContextualToken::class)], $options)
37
            );
38 2
        }, $strings);
39
    }
40
}
41