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

StorageValuesProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
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