Ldap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 67
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A updateMappingUser() 0 5 1
A syncMappingUser() 0 5 1
A updateMappingTeam() 0 5 1
A syncMappingTeam() 0 5 1
1
<?php
2
namespace FlexyProject\GitHub\Receiver\Enterprise;
3
4
use Exception;
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * The LDAP API is used to update account relationships between a GitHub Enterprise user and its linked LDAP entry or
9
 * queue a new synchronization.
10
 *
11
 * @link    https://developer.github.com/v3/enterprise/ldap/
12
 * @since   2.2
13
 * @package FlexyProject\GitHub\Receiver\Enterprise
14
 */
15
class Ldap extends AbstractEnterprise
16
{
17
18
    /**
19
     * Update LDAP mapping for a user
20
     *
21
     * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-user
22
     *
23
     * @param string $username
24
     *
25
     * @return array
26
     * @throws Exception
27
     */
28
    public function updateMappingUser(string $username): array
29
    {
30
        return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:username/mapping', $username),
31
            Request::METHOD_PATCH);
32
    }
33
34
    /**
35
     * Sync LDAP mapping for a user
36
     *
37
     * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-user
38
     *
39
     * @param int $userId
40
     *
41
     * @return array
42
     * @throws Exception
43
     */
44
    public function syncMappingUser(int $userId): array
45
    {
46
        return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/user/:user_id/sync', (string)$userId),
47
            Request::METHOD_POST);
48
    }
49
50
    /**
51
     * Update LDAP mapping for a team
52
     *
53
     * @link https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team
54
     *
55
     * @param int $teamId
56
     *
57
     * @return array
58
     * @throws Exception
59
     */
60
    public function updateMappingTeam(int $teamId): array
61
    {
62
        return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/mapping', (string)$teamId),
63
            Request::METHOD_PATCH);
64
    }
65
66
    /**
67
     * Sync LDAP mapping for a team
68
     *
69
     * @link https://developer.github.com/v3/enterprise/ldap/#sync-ldap-mapping-for-a-team
70
     *
71
     * @param int $teamId
72
     *
73
     * @return array
74
     * @throws Exception
75
     */
76
    public function syncMappingTeam(int $teamId): array
77
    {
78
        return $this->getApi()->request($this->getApi()->sprintf('/admin/ldap/teams/:team_id/sync', (string)$teamId),
79
            Request::METHOD_POST);
80
    }
81
}