Completed
Push — 9.0-dev ( bc2bbc...09a935 )
by Radu
02:28
created

OutputTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A output() 0 3 1
A outputCli() 0 3 1
A outputHtml() 0 6 1
A outputJson() 0 6 1
1
<?php
2
namespace WebServCo\Framework\Traits;
3
4
trait OutputTrait
5
{
6
    protected $outputLoader;
7
    
8
    final protected function output()
9
    {
10
        return $this->outputLoader;
11
    }
12
    
13
    final protected function outputCli($string, $eol = true)
14
    {
15
        return $this->output()->cli($string, $eol);
16
    }
17
    
18
    protected function outputHtml($data, $pageTemplate, $mainTemplate = null)
19
    {
20
        return new \WebServCo\Framework\Libraries\HttpResponse(
21
            $this->output()->htmlPage($data, $pageTemplate, $mainTemplate),
22
            200,
23
            ['Content-Type' => 'text/html']
24
        );
25
    }
26
    
27
    protected function outputJson($data)
28
    {
29
        return new \WebServCo\Framework\Libraries\HttpResponse(
30
            $this->output()->json($data),
31
            200,
32
            ['Content-Type' => 'application/json']
33
        );
34
    }
35
}
36