Passed
Push — main ( 1db9f0...f366b1 )
by Michael
05:29
created

HelpsFormatData   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 5
c 3
b 1
f 0
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractStringFromCollection() 0 7 2
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