Skip to content

Commit

Permalink
refactor: Simplify hasNeverHadStatus method by reusing hasEverHadStatus
Browse files Browse the repository at this point in the history
- Updated `hasNeverHadStatus($name): bool` method to return the negation of `hasEverHadStatus($name)`, simplifying the logic.

This change was made following a review suggestion from @freekmurze to avoid redundant logic.
  • Loading branch information
YazeedAlsaif committed May 24, 2024
1 parent 3fcf6b9 commit 083766b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/HasStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function hasEverHadStatus($name): bool
* Check if the model has never had a status with the given name.
*
* This method determines whether the current model instance has never had a status
* with the specified name.
* with the specified name by negating the result of hasEverHadStatus.
*
* @param string $name The name of the status to check for.
*
Expand All @@ -86,9 +86,7 @@ public function hasEverHadStatus($name): bool
*/
public function hasNeverHadStatus($name): bool
{
$statuses = $this->relationLoaded('statuses') ? $this->statuses : $this->statuses();

return $statuses->where('name', $name)->count() === 0;
return !$this->hasEverHadStatus($name);
}

public function deleteStatus(...$names)
Expand Down

0 comments on commit 083766b

Please sign in to comment.