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

CommonFeatures   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 14
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A strings() 0 9 2
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