Completed
Branch dev (1399ad)
by
unknown
60:04 queued 50:49
created

EventManagerData   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getData() 0 14 2
1
<?php
2
3
namespace EventEspresso\core\domain\services\admin\events\editor;
4
5
use EventEspresso\core\domain\entities\users\EventManagers;
6
use EventEspresso\core\domain\services\graphql\Utilities;
7
8
/**
9
 * Class EventManagerData
10
 *
11
 * formats a list of event manager users for use with GraphQL
12
 *
13
 * @author  Brent Christensen
14
 * @package EventEspresso\core\domain\services\admin\events\editor
15
 * @since   $VID:$
16
 */
17
class EventManagerData implements EventEditorDataInterface
18
{
19
20
    /**
21
     * @var EventManagers
22
     */
23
    private $event_managers;
24
25
    /**
26
     * @var Utilities
27
     */
28
    private $utilities;
29
30
31
    /**
32
     * EventManagerRoles constructor.
33
     *
34
     * @param EventManagers $event_managers
35
     * @param Utilities $utilities
36
     */
37
    public function __construct(EventManagers $event_managers, Utilities $utilities)
38
    {
39
        $this->event_managers = $event_managers;
40
        $this->utilities = $utilities;
41
    }
42
43
44
    /**
45
     * @param int $eventId
46
     * @return array
47
     */
48
    public function getData(int $eventId): array
49
    {
50
        $event_managers = [];
51
        $event_manager_users = $this->event_managers->userList();
52
        // now convert to a format that's usable by GQL
53
        foreach ($event_manager_users as $user) {
54
            $GUID = $this->utilities->convertToGlobalId('user', $user->ID);
55
            $event_managers[] = [
56
                'id'   => $GUID,
57
                'name' => $user->display_name,
58
            ];
59
        }
60
        return $event_managers;
61
    }
62
}
63