Completed
Push — master ( a4d419...4706ec )
by Rémi
15:41
created

AbstractHook::getUrl()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
nc 1
1
<?php namespace G2R\Gitlab\Hook;
2
3
abstract class AbstractHook
4
{
5
    protected $data;
6
7
    protected $buildStatus;
8
9
    public function __construct($data)
10
    {
11
        if (gettype($data) == 'string') {
12
            $data = json_decode($data);
13
        }
14
15
        $this->data = $data;
16
    }
17
18
    public function getRef()
19
    {
20
        $ref = explode('/', $this->data->ref);
21
22
        return array_pop($ref);
23
    }
24
25
    public function getProjectName()
26
    {
27
        preg_match(
28
            '/.*\/(.+\/.+)/',
29
            $this->getUrl(),
30
            $matches
31
        );
32
33
        return preg_replace('/\.git$/', '', array_pop($matches));
34
    }
35
36
    abstract public function getUrl();
37
    abstract public function getBuildStatus();
38
}
39