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

NewlineCast::castAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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