1 | <?php |
||
16 | class FileRobotStore implements RobotStoreInterface |
||
17 | { |
||
18 | private const FILE_VERSION = '001'; |
||
19 | |||
20 | private static $store; |
||
21 | |||
22 | private $file; |
||
23 | |||
24 | private $logger; |
||
25 | |||
26 | /** |
||
27 | * __construct. |
||
28 | * |
||
29 | * @param \SplFileObject $file |
||
30 | * @param LoggerInterface|null $logger |
||
31 | */ |
||
32 | 1 | private function __construct(\SplFileObject $file, ?LoggerInterface $logger = null) |
|
37 | |||
38 | public function __destruct() |
||
42 | |||
43 | /** |
||
44 | * @param string $basePath |
||
45 | * @param LoggerInterface|null $logger |
||
46 | * |
||
47 | * @return RobotStoreInterface |
||
48 | */ |
||
49 | 1 | public static function getStore(string $basePath, ?LoggerInterface $logger = null): RobotStoreInterface |
|
58 | |||
59 | /** |
||
60 | * @param string $basePath |
||
61 | * @param LoggerInterface|null $logger |
||
62 | * |
||
63 | * @return RobotStoreInterface |
||
64 | */ |
||
65 | 1 | private static function createStore(string $basePath, ?LoggerInterface $logger): RobotStoreInterface |
|
82 | |||
83 | /** |
||
84 | * @return Robot|null |
||
85 | */ |
||
86 | public function getRobot(): ?Robot |
||
98 | |||
99 | /** |
||
100 | * @param Robot $robot |
||
101 | */ |
||
102 | public function saveRobot(Robot $robot): void |
||
115 | |||
116 | /** |
||
117 | * @param string $msg |
||
118 | */ |
||
119 | private function log(string $msg): void |
||
127 | } |
||
128 |