EvangelistStatus   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 6
Bugs 6 Features 2
Metric Value
wmc 8
c 6
b 6
f 2
lcom 1
cbo 2
dl 0
loc 45
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
B getStatus() 0 12 6
1
<?php
2
/**
3
 *  @author chris.vundi
4
 *  This class returns a status based on the
5
 *  number of repos the usename you passed as an
6
 *  argument has on github.
7
 */
8
9
namespace Vundi\Checkpoint1;
10
11
use Vundi\Checkpoint1\GithubApi;
12
use Vundi\Checkpoint1\Exceptions\NoUsernamePassed;
13
14
class EvangelistStatus
15
{
16
    /**
17
     * Github username
18
     * @var string
19
     */
20
    protected $username;
21
22
    /**
23
     * Bring in the functionality of the
24
     * github api class
25
     * @var obj
26
     */
27
    protected $githubApi;
28
29
    public function __construct($username = null)
30
    {
31
        if (is_null($username)) {
32
            throw new NoUsernamePassed("You have to pass in a username, Username cannot be null", 1);
33
        }
34
35
        $this->username = $username;
36
        $this->githubApi = new GithubApi($this->username);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Vundi\Checkpoint1\GithubApi($this->username) of type object<Vundi\Checkpoint1\GithubApi> is incompatible with the declared type object<Vundi\Checkpoint1\obj> of property $githubApi.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
    }
38
39
    /**
40
     * Will return a status depending on the number of repos you have
41
     * on github
42
     * @return string
43
     */
44
    public function getStatus()
45
    {
46
        if ($this->githubApi->getRepos() >= 5 && $this->githubApi->getRepos() <= 10) {
47
            return "Yeah, I crown you Senior Evangelist. Thanks for making the world a better place";
48
        } elseif ($this->githubApi->getRepos() >=11 && $this->githubApi->getRepos() <= 20) {
49
            return "Keep Up The Good Work, I crown you Associate Evangelist";
50
        } elseif ($this->githubApi->getRepos() >= 21) {
51
            return "Damn It!!! Please make the world better, Oh Ye Prodigal Junior Evangelist";
52
        } else {
53
            return "You don't qualify to be called an evangelist....whatsoever";
54
        }
55
    }
56
57
58
}