ProjectPresenter::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 8
loc 8
rs 9.4286
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Presenters;
13
14
use Gitamin\Presenters\Traits\TimestampsTrait;
15
16
class ProjectPresenter extends AbstractPresenter
17
{
18
    use TimestampsTrait;
19
20
    /**
21
     * Returns the override class name for theming.
22
     *
23
     * @return string
24
     */
25
    public function status_color()
26
    {
27
        switch ($this->wrappedObject->visibility_level) {
28
            case 1: return 'greens';
29
            case 2: return 'blues';
30
            case 3: return 'yellows';
31
            case 4: return 'reds';
32
        }
33
    }
34
35
    /**
36
     * Convert the presenter instance to an array.
37
     *
38
     * @return string[]
39
     */
40 View Code Duplication
    public function toArray()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        return array_merge($this->wrappedObject->toArray(), [
43
            'created_at' => $this->created_at(),
44
            'updated_at' => $this->updated_at(),
45
            'status_name' => $this->wrappedObject->humanStatus,
46
        ]);
47
    }
48
}
49