blob: 61c78a817e3537ad43db168fb1984d5519c90cc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?php
namespace App\File\Handler;
use Exception;
/**
* File handler
*/
class Handler
{
protected $filename;
protected $file;
protected $array;
/**
* Check file can be read
* Read and parse file into array
*
* @author Phil Burton <phil@pgburton.com>
* @param string $filename [description]
*/
public function __construct(string $filename)
{
$this->filename = $filename;
if (!is_readable($filename)) {
throw new Exception('Cannot read from file: ' . $filename);
}
$this->load;
}
/**
* Load the file
*
* @author Phil Burton <phil@pgburton.com>
*/
public function load()
{
$this->file = file_get_contents($this->filename);
}
/**
* Parse file and return array
*
* @author Phil Burton <phil@pgburton.com>
* @return array
*/
public function getVendorArray(): array
{
if (!$this->array) {
$this->array = [];
}
return $this->array;
}
}
|