ArrayFileReader   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A readArrayFromFile() 0 7 1
A loadArray() 0 7 2
1
<?php
2
3
    namespace rAPId\Data;
4
5
    class ArrayFileReader
6
    {
7
        private $filename;
8
9
        public function __construct($filename) {
10
            $this->filename = $filename;
11
        }
12
13
        public function loadArray() {
14
            $data = [];
15
            if (file_exists($this->filename)) {
16
                $data = $this->readArrayFromFile($this->filename);
17
            }
18
19
            return $data;
20
        }
21
22
        /**
23
         * @param string $filename
24
         *
25
         * @return array
26
         */
27
        private function readArrayFromFile($filename) {
28
            // Use output buffer to avoid any unwanted side-effects
29
            ob_start();
30
            $array = include "$filename";
31
            ob_end_clean();
32
33
            return $array;
34
        }
35
36
    }