RawTokensContext::addToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/**
4
 * @author Alexei Gorobet <[email protected]>
5
 */
6
7
namespace Behat\TokensExtension\Context;
8
9
use Behat\Gherkin\Node\StepNode;
10
use Behat\TokensExtension\Context\TokensContextInterface;
11
12
/**
13
 * Class RawTokensContext.
14
 *
15
 * @package Behat\TokensExtension\Context
16
 */
17
class RawTokensContext implements TokensContextInterface
18
{
19
    /**
20
     * Saved replacement tokens.
21
     *
22
     * @var array
23
     */
24
    private $tokens = [];
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function addToken($token, $value)
30
    {
31
        $this->tokens[$token] = $value;
32
    }
33
34
    /**
35
     * @TokensReplacement /\[\[(.+?)\]\]/
36
     */
37
    public function replaceStepTokens($value)
38
    {
39
        return isset($this->tokens[$value]) ? $this->tokens[$value] : false;
40
    }
41
}
42