Test Failed
Push — master ( a92e12...446184 )
by Domenico
04:27
created

S3StorageClassNameValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 2
eloc 13
dl 0
loc 26
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 19 2
1
<?php
2
/**
3
 *  This file is part of the Simple S3 package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
namespace Matecat\SimpleS3\Components\Validators;
13
14
/**
15
 * This class check if a string is a valid S3 Storage Class name
16
 *
17
 * Complete reference:
18
 *
19
 * https://docs.aws.amazon.com/en_us/AmazonS3/latest/dev/storage-class-intro.html
20
 *
21
 * @package SimpleS3
22
 */
23
final class S3StorageClassNameValidator extends S3NameValidator
24
{
25
    /**
26
     * @param string $string
27
     *
28
     * @return array
29
     */
30 1
    public static function validate($string)
31
    {
32 1
        $errors = [];
33
34
        $allowedStorageClasses = [
35 1
            'STANDARD',
36
            'REDUCED_REDUNDANCY',
37
            'STANDARD_IA',
38
            'ONEZONE_IA',
39
            'INTELLIGENT_TIERING',
40
            'GLACIER',
41
            'DEEP_ARCHIVE',
42
        ];
43
44 1
        if (!in_array($string, $allowedStorageClasses)) {
45
            $errors[] = 'The string is not a valid StorageClass';
46
        }
47
48 1
        return $errors;
49
    }
50
}
51