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

HasFormatTrait::getFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 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
}