Passed
Pull Request — master (#9)
by Rafael
03:29
created

StorageValuesProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setUp() 0 4 2
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Behat\Transformer\ExpressionLanguage;
12
13
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
14
use Ynlo\GraphQLBundle\Behat\Storage\Storage;
15
16
/**
17
 * Allow access to stored values in the temporal storage
18
 *
19
 * Given a previous step: `And grab "{response.user}" in "user"`
20
 *
21
 * @example "{user.username}" => "admin"
22
 * @example "{user.profile.name}" => "Administrator"
23
 */
24
class StorageValuesProvider implements ExpressionPreprocessorInterface
25
{
26
    /**
27
     * @var Storage
28
     */
29
    protected $storage;
30
31
    /**
32
     * StorageValuesProvider constructor.
33
     *
34
     * @param Storage $storage
35
     */
36 1
    public function __construct(Storage $storage)
37
    {
38 1
        $this->storage = $storage;
39 1
    }
40
41 1
    public function setUp(ExpressionLanguage $el, string &$expression, array &$values)
42
    {
43 1
        foreach ($this->storage as $name => $value) {
44 1
            $values[$name] = $value;
45
        }
46 1
    }
47
}
48