Completed
Branch tooling/eslint-plugin-react (cf30c8)
by
unknown
110:10 queued 101:37
created

TicketDatetimesConnection::resolveConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 5
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\services\graphql\connections;
4
5
use EE_Base_Class;
6
use EEM_Datetime;
7
use EventEspresso\core\domain\services\graphql\connection_resolvers\DatetimeConnectionResolver;
8
use EventEspresso\core\services\graphql\connections\ConnectionInterface;
9
use Exception;
10
11
/**
12
 * Class TicketDatetimesConnection
13
 * Description
14
 *
15
 * @package EventEspresso\core\domain\services\graphql\connections
16
 * @author  Brent Christensen
17
 * @since   $VID:$
18
 */
19 View Code Duplication
class TicketDatetimesConnection implements ConnectionInterface
20
{
21
22
    /**
23
     * @var EEM_Datetime $model
24
     */
25
    protected $model;
26
27
28
    /**
29
     * DatetimeConnection constructor.
30
     *
31
     * @param EEM_Datetime $model
32
     */
33
    public function __construct(EEM_Datetime $model)
34
    {
35
        $this->model = $model;
36
    }
37
38
39
    /**
40
     * @return array
41
     * @since $VID:$
42
     */
43
    public function config()
44
    {
45
        return [
46
            'fromType'           => 'Ticket',
47
            'toType'             => 'Datetime',
48
            'fromFieldName'      => 'datetimes',
49
            'connectionTypeName' => 'TicketDatetimesConnection',
50
            'resolve'            => [$this, 'resolveConnection'],
51
            'resolveNode'        => [$this, 'resolveNode']
52
        ];
53
    }
54
55
56
    /**
57
     * @param $entity
58
     * @param $args
59
     * @param $context
60
     * @param $info
61
     * @return array
62
     * @throws Exception
63
     * @since $VID:$
64
     */
65
    public function resolveConnection($entity, $args, $context, $info)
66
    {
67
        $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info);
68
        return $resolver->get_connection();
69
    }
70
71
72
    /**
73
     * @param $id
74
     * @param $args
75
     * @param $context
76
     * @param $info
77
     * @return EE_Base_Class
78
     * @since $VID:$
79
     */
80
    public function resolveNode($id, $args, $context, $info)
81
    {
82
        return $this->model->get_one_by_ID($id);
83
    }
84
}