Passed
Push — master ( 765c1f...eb8479 )
by Philippe
02:18
created

AssetFormHelper::localeField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Thinktomorrow\AssetLibrary\Utilities;
4
5
6
class AssetFormHelper
7
{
8
9
    /**
10
     * Generates the hidden field that links the file to a specific type.
11
     *
12
     * @param string $type
13
     * @param null $locale
14
     *
15
     * @param string $name
16
     * @return string
17
     */
18 3
    public static function typeField($type = '', $locale = null, $name = 'type'): string
19
    {
20 3
        $result = '<input type="hidden" value="'.$type.'" name="';
21
22 3
        if (! $locale) {
23 3
            return $result.$name.'">';
24
        }
25
26 1
        return $result.'trans['.$locale.'][files][]">';
27
    }
28
29
    /**
30
     * Generates the hidden field that links the file to translations.
31
     *
32
     * @param string $locale
33
     *
34
     * @return string
35
     */
36 1
    public static function localeField($locale = ''): string
37
    {
38 1
        return self::typeField($locale, null, 'locale');
39
    }
40
}