1 | <?php namespace Simondubois\UnsplashDownloader; |
||
12 | class History |
||
13 | { |
||
14 | |||
15 | // |
||
16 | // Attributes |
||
17 | // |
||
18 | |||
19 | /** |
||
20 | * Has a file content been loaded |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $loaded = false; |
||
24 | |||
25 | /** |
||
26 | * Path of the file to use for history |
||
27 | * @var string |
||
28 | */ |
||
29 | private $path; |
||
30 | |||
31 | /** |
||
32 | * History content |
||
33 | * @var array |
||
34 | */ |
||
35 | private $content = []; |
||
36 | |||
37 | |||
38 | |||
39 | // |
||
40 | // Getters |
||
41 | // |
||
42 | |||
43 | /** |
||
44 | * Get path attribute |
||
45 | * @return string Path to file |
||
46 | */ |
||
47 | 2 | public function getPath() |
|
51 | |||
52 | |||
53 | /** |
||
54 | * Get content attribute |
||
55 | * @return array Content data |
||
56 | */ |
||
57 | 4 | public function getContent() |
|
61 | |||
62 | |||
63 | |||
64 | // |
||
65 | // File handling |
||
66 | // |
||
67 | |||
68 | /** |
||
69 | * Read and parse file content |
||
70 | * @param string|null $path Path to file |
||
71 | * @return bool True if the file has been successfully loaded |
||
72 | */ |
||
73 | 6 | public function load($path) { |
|
86 | |||
87 | /** |
||
88 | * Save content to file |
||
89 | * @return bool True if the file has been successfully saved |
||
90 | */ |
||
91 | 3 | public function save() { |
|
98 | |||
99 | |||
100 | |||
101 | // |
||
102 | // Content handling |
||
103 | // |
||
104 | |||
105 | /** |
||
106 | * Check if a string is in history |
||
107 | * @param string $str String to look for |
||
108 | * @return bool True if the string has been found in history |
||
109 | */ |
||
110 | 2 | public function has($str) |
|
114 | |||
115 | /** |
||
116 | * Append a string to the history |
||
117 | * @param string $str String to add to history |
||
118 | */ |
||
119 | 1 | public function put($str) |
|
123 | |||
124 | /** |
||
125 | * Load file content into content attribute |
||
126 | * @return bool True if the file has been successfully loaded |
||
127 | */ |
||
128 | 6 | private function loadContent() { |
|
139 | |||
140 | /** |
||
141 | * Save content attribute into file |
||
142 | * @return bool True if the file has been successfully saved |
||
143 | */ |
||
144 | 1 | private function saveContent() { |
|
150 | |||
151 | } |
||
152 |