Post   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormat() 0 3 1
A __construct() 0 19 4
A getValues() 0 3 1
1
<?php
2
/**
3
 * AssetPond plugin for Craft CMS 3.x
4
 *
5
 * Instant FilePond server that works with Craft Assets.
6
 *
7
 * @link      https://workingconcept.com
8
 * @copyright Copyright (c) 2019 Working Concept
9
 */
10
11
namespace workingconcept\assetpond\models;
12
13
use workingconcept\assetpond\helpers\PostHelper;
14
15
/**
16
 * @author    Working Concept
17
 * @package   AssetPond
18
 * @since     1.0.0
19
 */
20
class Post
21
{
22
    // Private Properties
23
    // =========================================================================
24
25
    private $_format;
26
    private $_values;
27
28
    // Public Methods
29
    // =========================================================================
30
31
    public function __construct($fieldName)
32
    {
33
        if (isset($_FILES[$fieldName]))
34
        {
35
            $this->_values = PostHelper::toArrayOfFiles($_FILES[$fieldName]);
36
            $this->_format = 'FILE_OBJECTS';
37
        }
38
39
        if (isset($_POST[$fieldName]))
40
        {
41
            $this->_values = PostHelper::toArray($_POST[$fieldName]);
42
43
            if (PostHelper::isEncodedFile($this->_values[0]))
44
            {
45
                $this->_format = 'BASE64_ENCODED_FILE_OBJECTS';
46
            }
47
            else
48
            {
49
                $this->_format = 'TRANSFER_IDS';
50
            }
51
        }
52
    }
53
54
    public function getFormat()
55
    {
56
        return $this->_format;
57
    }
58
59
    public function getValues()
60
    {
61
        return $this->_values;
62
    }
63
64
}
65