Skip to content

Commit 0e98e72

Browse files
authored
Merge pull request #799 from eldario/fix-with-folders
Fix trouble with empty folders
2 parents 53af44f + 6fee304 commit 0e98e72

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/LfmItem.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public function isFile()
6565
*/
6666
public function isImage()
6767
{
68-
return starts_with($this->mimeType(), 'image');
68+
if (!$this->isDirectory()) {
69+
return starts_with($this->mimeType(), 'image');
70+
}
71+
72+
return false;
6973
}
7074

7175
/**
@@ -105,7 +109,11 @@ public function size()
105109

106110
public function time()
107111
{
108-
return $this->lfm->lastModified();
112+
if (!$this->isDirectory()) {
113+
return $this->lfm->lastModified();
114+
}
115+
116+
return false;
109117
}
110118

111119
public function thumbUrl()

tests/LfmItemTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public function testIsFile()
7575

7676
public function testIsImage()
7777
{
78-
$this->lfm_path->shouldReceive('mimeType')->andReturn('application/plain');
78+
$this->lfm_path->shouldReceive('mimeType')->andReturn('application/plain')->shouldReceive('isDirectory')
79+
->andReturn(false);
7980

8081
$item = new LfmItem($this->lfm_path, $this->lfm);
8182

@@ -150,7 +151,8 @@ public function testSize()
150151

151152
public function testTime()
152153
{
153-
$this->lfm_path->shouldReceive('lastModified')->andReturn(0);
154+
$this->lfm_path->shouldReceive('lastModified')->andReturn(0)->shouldReceive('isDirectory')
155+
->andReturn(false);
154156

155157
$item = new LfmItem($this->lfm_path, $this->lfm);
156158

@@ -185,7 +187,8 @@ public function testIcon()
185187

186188
public function testHasThumb()
187189
{
188-
$this->lfm_path->shouldReceive('mimeType')->andReturn('application/plain');
190+
$this->lfm_path->shouldReceive('mimeType')->andReturn('application/plain')->shouldReceive('isDirectory')
191+
->andReturn(false);
189192

190193
$item = new LfmItem($this->lfm_path, $this->lfm);
191194

0 commit comments

Comments
 (0)