Completed
Branch 0.8-dev (0cddd9)
by Kacper
02:47
created

CommonFeatures::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Highlighter
4
 *
5
 * Copyright (C) 2016, Some right reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Highlighter\Language;
17
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
    public static function strings(array $strings, array $options = [])
30
    {
31
        return array_map(function($matcher) use ($options) {
32
            return new Rule(
33
                $matcher instanceof MatcherInterface ? $matcher : new SubStringMatcher($matcher),
34
                array_replace(['factory' => new TokenFactory(ContextualToken::class)], $options)
35
            );
36
        }, $strings);
37
    }
38
}
39