Passed
Push — master ( 4f415b...b6b0b7 )
by Gabriel
03:01
created

HasFormatTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
dl 0
loc 26
rs 10
c 1
b 0
f 0
ccs 5
cts 5
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormat() 0 3 1
A withDefaultFormat() 0 5 1
1
<?php
2
3
namespace Nip\Controllers\Response\ResponsePayload;
4
5
/**
6
 * Trait HasFormatTrait
7
 * @package Nip\Controllers\Response\ResponsePayload
8
 */
9
trait HasFormatTrait
10
{
11
12
    /**
13
     * @var string
14
     */
15
    protected $defaultFormat = null;
16
17
    /**
18
     * @var string
19
     */
20
    protected $format = null;
21
22 2
    public function withDefaultFormat(string $format): self
23
    {
24 2
        $this->defaultFormat = $format;
25
26 2
        return $this;
27
    }
28
29
    /**
30
     * @return string
31
     */
32 4
    public function getFormat()
33
    {
34 4
        return $this->format ?? $this->defaultFormat;
35
    }
36
}