Passed
Push — master ( 1564fa...d2ad69 )
by Kacper
03:00 queued 15s
created

WholeMatcher::match()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Highlighter
4
 *1
5
 * Copyright (C) 2015, 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\Matcher;
17
18
19
use Kadet\Highlighter\Parser\Token;
20
use Kadet\Highlighter\Parser\TokenFactoryInterface;
21
22
class WholeMatcher implements MatcherInterface
23
{
24
25
    /**
26
     * Matches all occurrences and returns token list
27
     *
28
     * @param string                $source Source to match tokens
29
     *
30
     * @param TokenFactoryInterface $factory
31
     *
32
     * @return array
33
     */
34 1
    public function match($source, TokenFactoryInterface $factory)
35
    {
36 1
        $token = $factory->create(['pos' => 0, 'length' => strlen($source)]);
37 1
        $end = $token->getEnd();
38
39 1
        return [spl_object_hash($token) => $token, spl_object_hash($end) => $end];
40
    }
41
}