Completed
Push — master ( b21eaf...9104ac )
by Karthik
03:02
created

WorldDrop::validateFormat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace cyberinferno\Cabal\Helpers\FileSystem\Server;
4
5
use cyberinferno\Cabal\Helpers\Exceptions\FileBadFormatException;
6
use cyberinferno\Cabal\Helpers\FileSystem\File;
7
8
/**
9
 * Class WorldDrop
10
 *
11
 * Helper class to load contents from World_drop.scp file
12
 *
13
 * @package cyberinferno\Cabal\Helpers\FileSystem\Server
14
 */
15
class WorldDrop extends File
16
{
17
    /**
18
     * Returns array representation of the World_dop.scp file
19
     *
20
     * @return array
21
     */
22 3
    public function getArray()
23
    {
24 3
        $fileContents = $this->getFileContents();
25 3
        return explode("\n", $fileContents);
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31 9
    protected function validateFormat()
32
    {
33 9
        parent::validateFormat();
34 9
        $fileContents = $this->getFileContents();
35 9
        if (substr($fileContents, 0, strlen('[WorldDrop]')) !== '[WorldDrop]') {
36 3
            throw new FileBadFormatException();
37
        }
38
    }
39
}