Border   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 2

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 63
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A char() 0 6 1
A length() 0 6 1
A result() 0 8 3
1
<?php
2
3
namespace League\CLImate\TerminalObject\Basic;
4
5
class Border extends BasicTerminalObject
6
{
7
    /**
8
     * The character to repeat for the border
9
     *
10
     * @var string $char
11
     */
12
    protected $char = '-';
13
14
    /**
15
     * The length of the border
16
     *
17
     * @var integer $length
18
     */
19
    protected $length;
20
21 44
    public function __construct($char = null, $length = null)
22
    {
23 44
        $this->char($char)->length($length);
24 44
    }
25
26
    /**
27
     * Set the character to repeat for the border
28
     *
29
     * @param string $char
30
     *
31
     * @return Border
32
     */
33 44
    public function char($char)
34
    {
35 44
        $this->set('char', $char);
36
37 44
        return $this;
38
    }
39
40
    /**
41
     * Set the length of the border
42
     *
43
     * @param integer $length
44
     *
45
     * @return Border
46
     */
47 44
    public function length($length)
48
    {
49 44
        $this->set('length', $length);
50
51 44
        return $this;
52
    }
53
54
    /**
55
     * Return the border
56
     *
57
     * @return string
58
     */
59 44
    public function result()
60
    {
61 44
        $length = $this->length ?: $this->util->width() ?: 100;
62 44
        $str    = str_repeat($this->char, $length);
63 44
        $str    = substr($str, 0, $length);
64
65 44
        return $str;
66
    }
67
}
68