Skip to content

Commit f84faad

Browse files
committed
redbox-scan-23 Improve on coverage
1 parent 142a7c0 commit f84faad

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

examples/assets/time.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1456050428
1+
1456051247

src/ScanService.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,25 @@ public function scan(Adapter\AdapterInterface $adapter = null)
116116

117117
$items = $report->getItems();
118118

119-
/**
120-
* Start building a basic report
121-
122-
$report = new Report\Report();
123-
$report->setName($report->getName());
124-
$report->setDate($report->getDate());
125-
$report->setPath($report->getPath());
126-
*/
127119
// set date
128120
$report->setDate(new \DateTime());
129121

130122

131-
132123
$new = array();
133124
$modified = array();
134125

135126
if (count($items) > 0) {
136127
foreach ($items as $path => $files) {
137128
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);
138129
foreach ($objects as $object) {
139-
if ($object->isFile() && isset($files[$object->getPathname()])) {
140-
if ($files[$object->getPathname()] != Filesystem\FileInfo::getFileHash($object->getRealPath())) {
130+
$pathname = $object->getPathname();
131+
$realpath = $object->getRealPath();
132+
133+
if ($object->isFile() && isset($files[$pathname])) {
134+
if ($files[$pathname] != Filesystem\FileInfo::getFileHash($realpath)) {
141135
$modified[] = $object;
142136
}
143-
} elseif ($object->isFile() && !isset($files[$object->getPathname()])) {
137+
} elseif ($object->isFile() && !isset($files[$pathname])) {
144138
$new[] = $object;
145139
}
146140
}

0 commit comments

Comments
 (0)