Passed
Push — v3 ( 3d31db...9e8c74 )
by Andrew
29:00 queued 05:41
created

RetourType::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 4
1
<?php
2
/**
3
 * Retour plugin for Craft CMS 3.x
4
 *
5
 * Retour allows you to intelligently redirect legacy URLs, so that you don't
6
 * lose SEO value when rebuilding & restructuring a website
7
 *
8
 * @link      https://nystudio107.com/
9
 * @copyright Copyright (c) 2019 nystudio107
10
 */
11
12
namespace nystudio107\retour\gql\types;
13
14
use nystudio107\retour\gql\interfaces\RetourInterface;
15
16
use craft\gql\base\ObjectType;
17
18
use GraphQL\Type\Definition\ResolveInfo;
19
20
/**
21
 * Class RetourType
22
 *
23
 * @author    nystudio107
24
 * @package   Retour
25
 * @since     3.1.26
26
 */
27
class RetourType extends ObjectType
28
{
29
    /**
30
     * @inheritdoc
31
     */
32
    public function __construct(array $config)
33
    {
34
        $config['interfaces'] = [
35
            RetourInterface::getType(),
36
        ];
37
38
        parent::__construct($config);
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    protected function resolve($source, $arguments, $context, ResolveInfo $resolveInfo)
45
    {
46
        $fieldName = $resolveInfo->fieldName;
47
48
        return $source[$fieldName];
49
    }
50
}
51