Completed
Push — master ( 6d849d...f9dc97 )
by Michal
02:55 queued 57s
created

DevelopersTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A saveFromGithub() 0 12 3
1
<?php
2
3
/* vim: set expandtab sw=4 ts=4 sts=4: */
4
/**
5
 * A developer who has access to the system.
6
 *
7
 * phpMyAdmin Error reporting server
8
 * Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
9
 *
10
 * Licensed under The MIT License
11
 * For full copyright and license information, please see the LICENSE.txt
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright     Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
15
 * @license       https://opensource.org/licenses/mit-license.php MIT License
16
 *
17
 * @see          https://www.phpmyadmin.net/
18
 */
19
20
namespace App\Model\Table;
21
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 mixed  $developer
35
     *
36
     * @return bool true if the developer was correctly saved otherwise false
37
     */
38 2
    public function saveFromGithub($githubInfo, $accessToken, $developer)
39
    {
40 2
        $developer->full_name = $githubInfo['name'];
41 2
        $developer->gravatar_id = $githubInfo['gravatar_id'];
42 2
        $developer->email = $githubInfo['email'];
43 2
        $developer->github_id = $githubInfo['id'];
44 2
        $developer->access_token = $accessToken;
45 2
        $developer->has_commit_access = $githubInfo['has_commit_access'] ? 1 : 0;
46 2
        if ($this->save($developer)) {
47 2
            return $developer->id;
48
        }
49
    }
50
}
51