Passed
Push — main ( 1db9f0...f366b1 )
by Michael
05:29
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 3
Bugs 1 Features 0
Metric Value
cc 2
eloc 4
c 3
b 1
f 0
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\Formatters\Traits;
6
7
use Illuminate\Support\Collection;
8
9
trait HelpsFormatData
10
{
11
    /**
12
     * @param Collection $collection
13
     *
14
     * @return string
15
     */
16 7
    private function extractStringFromCollection(Collection $collection): string
17
    {
18 7
        $extracted = $collection->first();
19
20 7
        return is_string($extracted)
21 6
            ? $extracted
22 7
            : (string) $extracted;
23
    }
24
}
25