@@ -46,9 +46,9 @@ |
||
46 | 46 | DirectoriesInterface $dirs, |
47 | 47 | FilesInterface $files, |
48 | 48 | LoggerInterface $logger = null |
49 | - ) { |
|
49 | + ){ |
|
50 | 50 | return new FileSnapshotter( |
51 | - $dirs->get('runtime') . '/snapshots/', |
|
51 | + $dirs->get('runtime').'/snapshots/', |
|
52 | 52 | $env->get('SNAPSHOT_MAX_FILES', self::MAX_SNAPSHOTS), |
53 | 53 | $env->get('SNAPSHOT_VERBOSITY', HandlerInterface::VERBOSITY_VERBOSE), |
54 | 54 | new HtmlHandler(), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | HandlerInterface $handler, |
54 | 54 | FilesInterface $files, |
55 | 55 | LoggerInterface $logger = null |
56 | - ) { |
|
56 | + ){ |
|
57 | 57 | $this->directory = $directory; |
58 | 58 | $this->maxFiles = $maxFiles; |
59 | 59 | $this->verbosity = $verbosity; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $snapshot = new Snapshot($this->getID($e), $e); |
71 | 71 | |
72 | - if ($this->logger !== null) { |
|
72 | + if ($this->logger !== null){ |
|
73 | 73 | $this->logger->error($snapshot->getMessage()); |
74 | 74 | } |
75 | 75 | |
@@ -101,17 +101,17 @@ discard block |
||
101 | 101 | protected function rotateSnapshots(): void |
102 | 102 | { |
103 | 103 | $finder = new Finder(); |
104 | - $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) { |
|
104 | + $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b){ |
|
105 | 105 | return $b->getMTime() - $a->getMTime(); |
106 | 106 | }); |
107 | 107 | |
108 | 108 | $count = 0; |
109 | - foreach ($finder as $file) { |
|
109 | + foreach ($finder as $file){ |
|
110 | 110 | $count++; |
111 | - if ($count > $this->maxFiles) { |
|
112 | - try { |
|
111 | + if ($count > $this->maxFiles){ |
|
112 | + try{ |
|
113 | 113 | $this->files->delete($file->getRealPath()); |
114 | - } catch (FilesException $e) { |
|
114 | + }catch (FilesException $e){ |
|
115 | 115 | // ignore |
116 | 116 | } |
117 | 117 | } |
@@ -69,7 +69,8 @@ discard block |
||
69 | 69 | { |
70 | 70 | $snapshot = new Snapshot($this->getID($e), $e); |
71 | 71 | |
72 | - if ($this->logger !== null) { |
|
72 | + if ($this->logger !== null) |
|
73 | + { |
|
73 | 74 | $this->logger->error($snapshot->getMessage()); |
74 | 75 | } |
75 | 76 | |
@@ -101,17 +102,23 @@ discard block |
||
101 | 102 | protected function rotateSnapshots(): void |
102 | 103 | { |
103 | 104 | $finder = new Finder(); |
104 | - $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) { |
|
105 | + $finder->in($this->directory)->sort(function (SplFileInfo $a, SplFileInfo $b) |
|
106 | + { |
|
105 | 107 | return $b->getMTime() - $a->getMTime(); |
106 | 108 | }); |
107 | 109 | |
108 | 110 | $count = 0; |
109 | - foreach ($finder as $file) { |
|
111 | + foreach ($finder as $file) |
|
112 | + { |
|
110 | 113 | $count++; |
111 | - if ($count > $this->maxFiles) { |
|
112 | - try { |
|
114 | + if ($count > $this->maxFiles) |
|
115 | + { |
|
116 | + try |
|
117 | + { |
|
113 | 118 | $this->files->delete($file->getRealPath()); |
114 | - } catch (FilesException $e) { |
|
119 | + } |
|
120 | + catch (FilesException $e) |
|
121 | + { |
|
115 | 122 | // ignore |
116 | 123 | } |
117 | 124 | } |