Passed
Push — 2.0 ( 3cd779...fe8057 )
by Kirill
03:09
created

AttributeExists::whenExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of laravel.su package.
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace App\GraphQL\Kernel;
10
11
/**
12
 * Class AttributeExists
13
 * @package App\GraphQL\Kernel
14
 */
15
trait AttributeExists
16
{
17
    /**
18
     * @param array $args
19
     * @param string $name
20
     * @param \Closure $then
21
     * @return mixed
22
     */
23
    protected function whenExists(array $args, string $name, \Closure $then)
24
    {
25
        if (isset($args[$name])) {
26
            return $then($args[$name]);
27
        }
28
29
        return null;
30
    }
31
}