Passed
Push — main ( 10ea54...ae133a )
by Michael
03:26
created

HelpsFormatData::extractStringFromCollection()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace MichaelRubel\Formatters\Traits;
4
5
use Illuminate\Support\Collection;
6
7
trait HelpsFormatData
8
{
9
    /**
10
     * @param Collection $collection
11
     *
12
     * @return string
13
     */
14 6
    private function extractStringFromCollection(Collection $collection): string
15
    {
16 6
        $extracted = $collection->first();
17
18 6
        return is_string($extracted)
19 6
            ? $extracted
20 6
            : '';
21
    }
22
}
23