Completed
Push — master ( bc825a...1aba9a )
by William
06:03
created

DevelopersTable::saveFromGithub()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 4
nop 3
dl 0
loc 10
ccs 9
cts 9
cp 1
crap 3
rs 10
c 0
b 0
f 0
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 \Cake\Datasource\EntityInterface $developer   the developper
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'];
0 ignored issues
show
Bug introduced by
Accessing full_name on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
41 2
        $developer->gravatar_id = $githubInfo['gravatar_id'];
0 ignored issues
show
Bug introduced by
Accessing gravatar_id on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
42 2
        $developer->email = $githubInfo['email'];
0 ignored issues
show
Bug introduced by
Accessing email on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
43 2
        $developer->github_id = $githubInfo['id'];
0 ignored issues
show
Bug introduced by
Accessing github_id on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
44 2
        $developer->access_token = $accessToken;
0 ignored issues
show
Bug introduced by
Accessing access_token on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
45 2
        $developer->has_commit_access = $githubInfo['has_commit_access'] ? 1 : 0;
0 ignored issues
show
Bug introduced by
Accessing has_commit_access on the interface Cake\Datasource\EntityInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
46 2
        if ($this->save($developer)) {
47 2
            return $developer->id;
48
        }
49
    }
50
}
51