1 | <?php |
||
20 | class FileCache implements CacheInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $cacheDirectory; |
||
26 | |||
27 | /** |
||
28 | * FileCache constructor. |
||
29 | * |
||
30 | * @param string $cacheDirectory |
||
31 | */ |
||
32 | public function __construct($cacheDirectory) |
||
33 | { |
||
34 | if (!is_dir($cacheDirectory)) { |
||
35 | mkdir($cacheDirectory, 0755, true); |
||
36 | } |
||
37 | |||
38 | if (!is_writable($cacheDirectory)) { |
||
39 | throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable.', $cacheDirectory)); |
||
40 | } |
||
41 | |||
42 | $this->cacheDirectory = rtrim($cacheDirectory, '\\/'); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function load($className) |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function save(ClassMetadata $metadata) |
||
71 | |||
72 | /** |
||
73 | * Renames a file with fallback for windows. |
||
74 | * |
||
75 | * @param string $source |
||
76 | * @param string $target |
||
77 | */ |
||
78 | private function renameFile($source, $target) |
||
84 | |||
85 | /** |
||
86 | * @param string $className |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | protected function fileName($className) |
||
94 | } |
||
95 |
If you suppress an error, we recommend checking for the error condition explicitly: