Passed
Push — master ( 08368b...d03553 )
by Sebastian
02:27
created

VariableInfo_Renderer::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils;
6
7
abstract class VariableInfo_Renderer
8
{
9
   /**
10
    * @var mixed
11
    */
12
    protected $value;
13
    
14
   /**
15
    * @var VariableInfo
16
    */
17
    protected $info;
18
    
19
   /**
20
    * @var string
21
    */
22
    protected $type;
23
    
24
    public function __construct(VariableInfo $info)
25
    {
26
        $this->info = $info;
27
        $this->type = $info->getType();
28
        
29
        $this->init();
30
    }
31
    
32
    abstract protected function init();
33
34
   /**
35
    * Renders the value to the target format.
36
    * 
37
    * @return mixed
38
    */
39
    public function render()
40
    {
41
        return $this->_render();
42
    }
43
    
44
    abstract protected function _render();
45
46
    protected function cutString(string $string) : string
47
    {
48
        $cutAt = $this->info->getIntOption('cut-length', 1000);
49
        
50
        return ConvertHelper::text_cut($string, $cutAt, ' [...]');
51
    }
52
}
53