1 <?php
2
3 namespace Alo\FileSystem;
4
5 if (!defined('GEN_START')) {
6 http_response_code(404);
7 } else {
8
9 /**
10 * The abstract file system class
11 *
12 * @author Art <a.molcanovas@gmail.com>
13 */
14 abstract class AbstractFileSystem {
15
16 /**
17 * Static reference to the last instance of the class
18 *
19 * @var AbstractFileSystem
20 */
21 static $this;
22 /**
23 * Replacements for placeholders
24 *
25 * @var array
26 */
27 protected $replace;
28
29 /**
30 * Instantiates the class
31 *
32 * @author Art <a.molcanovas@gmail.com>
33 */
34 function __construct() {
35 $time = time();
36 $this->replace = ['search' => ['{timestamp}',
37 '{datetime}',
38 '{date}',
39 '{time}',
40 '{year}',
41 '{month}',
42 '{day}',
43 '{weekday}'],
44 'replace' => [$time,
45 date('Y-m-d H.i.s', $time),
46 date('Y-m-d', $time),
47 date('H.i.s', $time),
48 date('Y', $time),
49 date('m', $time),
50 date('d', $time),
51 date('l', $time)]];
52
53 self::$this = &$this;
54 }
55
56 /**
57 * Perform placeholder replacement operations
58 *
59 * @author Art <a.molcanovas@gmail.com>
60 *
61 * @param string $subject The string to perform operations in
62 */
63 protected function replace(&$subject) {
64 $subject = str_ireplace($this->replace['search'], $this->replace['replace'], $subject);
65 }
66 }
67 }
68