ParcelSize::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Meanbee\MagentoRoyalmail\Model\Config\Source;
4
5
use \Magento\Framework\Option\ArrayInterface;
6
7
/**
8
 * Class ParcelSize Backend system config array field renderer
9
 */
10
class ParcelSize implements ArrayInterface
11
{
12
    const SMALL = 'SMALL';
13
    const MEDIUM = 'MEDIUM';
14
15
    /**
16
     * Sets the option array for the small and medium
17
     * parcel option in admin section of the extension
18
     *
19
     * @return array
20
     */
21 2
    public function toOptionArray()
22
    {
23
        $options = [
24
            [
25 2
                'value' => static::SMALL,
26 2
                'label' => __('Small Parcel (up to 2kg)')
27 2
            ],
28
            [
29 2
                'value' => static::MEDIUM,
30 2
                'label' => __('Medium Parcel')
31 2
            ]
32 2
        ];
33
34 2
        return $options;
35
    }
36
37
    /**
38
     * Get options in "key-value" format
39
     *
40
     * @return array
41
     */
42
    public function toArray()
43
    {
44 1
        return array_map(function ($array) {
45 1
            return [$array['value'] => $array['label']];
46 1
        }, $this->toOptionArray());
47
    }
48
}
49