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

AssetFormHelper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A typeField() 0 10 2
A localeField() 0 4 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
}