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

WorldDrop::getArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
}