Completed
Push — master ( 3c5e5f...6e3c38 )
by Korotkov
02:32
created

ContainerFilesTrait::setFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Date: 06.04.17
7
 * Time: 15:00
8
 *
9
 * @author    : Korotkov Danila <[email protected]>
10
 * @copyright Copyright (c) 2016, Korotkov Danila
11
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
12
 */
13
14
namespace Rudra;
15
16
/**
17
 * Class ContainerFilesTrait
18
 *
19
 * @package Rudra
20
 */
21
trait ContainerFilesTrait
22
{
23
24
    /**
25
     * @var array
26
     */
27
    protected $files;
28
29
    /**
30
     * @param array $files
31
     */
32
    public function setFiles(array $files)
33
    {
34
        $this->files = $files;
35
    }
36
37
    /**
38
     * @param string $key
39
     * @param string $fieldName
40
     * @param string $formName
41
     *
42
     * @return string
43
     */
44
    public function getUpload(string $key, string $fieldName, string $formName = 'upload') : string
45
    {
46
        return $this->files[$formName][$fieldName][$key];
47
    }
48
49
    /**
50
     * @param string $value
51
     * @param string $formName
52
     *
53
     * @return bool
54
     */
55
    public function isUploaded(string $value, string $formName = 'upload') : bool
56
    {
57
        return ($this->files[$formName]['name'][$value] !== '');
58
    }
59
60
    /**
61
     * @param string $key
62
     * @param string $value
63
     *
64
     * @return bool
65
     */
66
    public function isFileType(string $key, string $value) : bool
67
    {
68
        return ($this->files['type'][$key] == $value) ? true : false;
69
    }
70
}