Passed
Pull Request — master (#42)
by Korotkov
02:47
created

Files   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isFileType() 0 3 2
A getLoaded() 0 3 1
A isLoaded() 0 5 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Jagepard <[email protected]">
7
 * @copyright Copyright (c) 2019, Jagepard
8
 * @license   https://mit-license.org/ MIT
9
 */
10
11
namespace Rudra\Container\Request;
12
13
use Rudra\Container\AbstractContainer;
14
15
class Files extends AbstractContainer
16
{
17
    /**
18
     * @param  string  $key
19
     * @param  string  $fieldName
20
     * @param  string  $formName
21
     * @return string
22
     */
23
    public function getLoaded(string $key, string $fieldName, string $formName = 'upload'): string
24
    {
25
        return $this->data[$formName][$fieldName][$key];
26
    }
27
28
    /**
29
     * @param  string  $value
30
     * @param  string  $formName
31
     * @return bool
32
     */
33
    public function isLoaded(string $value, string $formName = 'upload'): bool
34
    {
35
        return isset($this->data[$formName]['name'][$value])
36
            ? ($this->data[$formName]['name'][$value] !== '')
37
            : false;
38
    }
39
40
    /**
41
     * @param  string  $key
42
     * @param  string  $value
43
     * @return bool
44
     */
45
    public function isFileType(string $key, string $value): bool
46
    {
47
        return ($this->data['type'][$key] == $value) ? true : false;
48
    }
49
}
50