DevelopersTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 24
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A saveFromGithub() 0 13 3
1
<?php
2
3
/**
4
 * A developer who has access to the system.
5
 *
6
 * phpMyAdmin Error reporting server
7
 * Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
8
 *
9
 * Licensed under The MIT License
10
 * For full copyright and license information, please see the LICENSE.txt
11
 * Redistributions of files must retain the above copyright notice.
12
 *
13
 * @copyright     Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
14
 * @license       https://opensource.org/licenses/mit-license.php MIT License
15
 *
16
 * @see          https://www.phpmyadmin.net/
17
 */
18
19
namespace App\Model\Table;
20
21
use Cake\Datasource\EntityInterface;
22
use Cake\ORM\Table;
23
24
/**
25
 * A developer who has access to the system.
26
 */
27
class DevelopersTable extends Table
28
{
29
    /**
30
     * creates a developer record given his github info and his access token.
31
     *
32
     * @param array           $githubInfo  the data gitub has on this developer
33
     * @param string          $accessToken this developer's access token
34
     * @param EntityInterface $developer   the developper
35
     *
36
     * @return int|null The developer Id
37
     */
38 14
    public function saveFromGithub(array $githubInfo, string $accessToken, EntityInterface $developer): ?int
39
    {
40 14
        $developer->full_name = $githubInfo['name'];
41 14
        $developer->gravatar_id = $githubInfo['gravatar_id'];
42 14
        $developer->email = $githubInfo['email'];
43 14
        $developer->github_id = $githubInfo['id'];
44 14
        $developer->access_token = $accessToken;
45 14
        $developer->has_commit_access = $githubInfo['has_commit_access'] ? 1 : 0;
46 14
        if ($this->save($developer)) {
47 14
            return $developer->id;
48
        }
49
50
        return null;
51
    }
52
}
53