Completed
Pull Request — master (#44)
by Korotkov
01:42
created

Files::isLoaded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 5
rs 10
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;
12
13
class Files extends Container
14
{
15
    /**
16
     * @param  string  $key
17
     * @param  string  $fieldName
18
     * @param  string  $formName
19
     * @return string
20
     */
21
    public function getLoaded(string $key, string $fieldName, string $formName = 'upload'): string
22
    {
23
        return $this->data[$formName][$fieldName][$key];
24
    }
25
26
    /**
27
     * @param  string  $value
28
     * @param  string  $formName
29
     * @return bool
30
     */
31
    public function isLoaded(string $value, string $formName = 'upload'): bool
32
    {
33
        return isset($this->data[$formName]['name'][$value])
34
            ? ($this->data[$formName]['name'][$value] !== '')
35
            : false;
36
    }
37
38
    /**
39
     * @param  string  $key
40
     * @param  string  $value
41
     * @return bool
42
     */
43
    public function isFileType(string $key, string $value): bool
44
    {
45
        return ($this->data['type'][$key] == $value) ? true : false;
46
    }
47
}
48