Skip to content

Commit 3d5ff7a

Browse files
committed
refactor: replace empty()
1 parent 2f0669d commit 3d5ff7a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/Entities/GitHub/URITrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __get(string $key)
2222
$result = parent::__get($key);
2323

2424
if (is_string($result) && is_int(strpos($key, 'url'))) {
25-
return empty($result) ? null : new URI($result);
25+
return ($result === '') ? null : new URI($result);
2626
}
2727

2828
return $result;

app/Libraries/Blog.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getRecentPosts(int $limit = 5, int $offset = 0, ?string $categor
7373
$temp = $this->readPost($this->config->contentPath, $file);
7474

7575
// Only collect from the correct category.
76-
if (! empty($category) && ! in_array($category, $temp->tags, true)) {
76+
if ($category !== null && ! in_array($category, $temp->tags, true)) {
7777
continue;
7878
}
7979

@@ -146,7 +146,7 @@ public function getPost(string $slug)
146146
if (! $post = cache($cacheKey)) {
147147
$files = glob("{$this->config->contentPath}*.{$slug}.md");
148148

149-
if (empty($files)) {
149+
if ($files === [] || $files === false) {
150150
throw PageNotFoundException::forPageNotFound();
151151
}
152152

@@ -227,7 +227,7 @@ protected function readPost(string $folder, string $filename)
227227
{
228228
$contents = file($folder . $filename);
229229

230-
if (empty($contents)) {
230+
if ($contents === [] || $contents === false) {
231231
return null;
232232
}
233233

0 commit comments

Comments
 (0)