Passed
Push — main ( 35cea8...263c2f )
by Andrey
21:51 queued 20:06
created

HttpBuilderPrepare::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Helldar\Support\Tools;
4
5
use Helldar\Support\Concerns\Makeable;
6
use Helldar\Support\Facades\Helpers\Str;
7
use Stringable;
8
9
class HttpBuilderPrepare implements Stringable
10
{
11
    use Makeable;
12
13
    protected $of;
14
15
    protected $prefix = '';
16
17
    protected $suffix = '';
18
19
    protected $default = '';
20
21 26
    public function __toString(): string
22
    {
23 26
        if (! empty($this->of)) {
24 23
            return $this->prefixed();
25
        }
26
27 21
        return $this->default;
28
    }
29
30 26
    public function of(?string $value): self
31
    {
32 26
        $this->of = $value;
33
34 26
        return $this;
35
    }
36
37 26
    public function prefix(string $value): self
38
    {
39 26
        $this->prefix = $value;
40
41 26
        return $this;
42
    }
43
44 26
    public function suffix(string $value): self
45
    {
46 26
        $this->suffix = $value;
47
48 26
        return $this;
49
    }
50
51 23
    protected function prefixed(): ?string
52
    {
53 23
        return (string) Str::of($this->of)
54 23
            ->start($this->prefix)
55 23
            ->finish($this->suffix)
56 23
            ->trim();
57
    }
58
}
59