Completed
Pull Request — master (#1)
by Bogdan
03:18
created

Repository::createIssue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
use Github\Client;
4
5
class Repository
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    private $owner;
8
    private $name;
9
    private $public;
10
    private $branches;
11
12
    const PublicVisibility = 'public';
13
14
    /**
15
     * @param string $owner
16
     * @param string $name
17
     * @param string $visibility
18
     */
19
    public function Repository(string $owner, string $name, string $visibility)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
20
    {
21
        $this->owner = $owner;
22
        $this->name = $name;
23
        $this->public = $visibility === PublicVisibility;
24
        $this->client = new Client($_SERVER['API_TOKEN']);
0 ignored issues
show
Bug introduced by
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getFullName(): string
31
    {
32
        return $this->owner . $this->name;
33
    }
34
35
    /**
36
     * @return bool
37
     */
38
    public function getPublic(): bool
39
    {
40
        return $this->public;
41
    }
42
43
    /**
44
     * @param string $title
45
     * @param string $description
46
     */
47
    public function createIssue(string $title, string $description)
48
    {
49
        $this->client->createIssue($this->getFullName, $title, $description);
0 ignored issues
show
Bug introduced by
The property getFullName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
50
    }
51
}
52