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

FakerProvider::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
crap 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 Faker\Factory;
14
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
15
16
/**
17
 * Add support to use faker as generator of fake values
18
 *
19
 * @require fzaninotto/faker
20
 *
21
 * @example "{faker.sentence()}" => "Consequatur quisquam recusandae asperiores accusamus nihil repellat."
22
 * @example "{faker.randomNumber()}" => 7086
23
 */
24
class FakerProvider implements ExpressionPreprocessorInterface
25
{
26 1
    public function setUp(ExpressionLanguage $el, string &$expression, array &$values)
27
    {
28 1
        if (preg_match('/faker\./', $expression)) {
29 1
            $faker = Factory::create();
30 1
            $faker->seed(1);
31 1
            $values['faker'] = $faker;
32
        }
33 1
    }
34
}
35