Passed
Push — master ( 20c7a2...113399 )
by Stephen
02:33 queued 01:07
created

NewlineCast   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A castAttribute() 0 3 2
A setAttribute() 0 3 1
1
<?php
2
3
4
namespace Sfneal\Casts;
5
6
use Vkovic\LaravelCustomCasts\CustomCastBase;
7
8
class NewlineCast extends CustomCastBase
9
{
10
    /**
11
     * Transcode newline characters as html <br> chars
12
     *
13
     * @param string $value
14
     * @return string
15
     */
16
    public function setAttribute($value)
17
    {
18
        return $value;
19
    }
20
21
    /**
22
     * Transcode newline characters as html <br> chars
23
     *
24
     * @param string $value
25
     * @return string
26
     */
27
    public function castAttribute($value)
28
    {
29
        return !empty($value) ? nl2br($value) : null;
30
    }
31
}
32