Skip to content

Commit

Permalink
Module::has() using lowercase/uppercase name.
Browse files Browse the repository at this point in the history
- Added the `modules()` method to get the list of all modules in a simplified array format.
  • Loading branch information
solomon-ochepa committed Jul 21, 2024
1 parent ccbe1c2 commit 11845e0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/FileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,27 @@ public function getByStatus($status): array
*/
public function has($name): bool
{
return array_key_exists($name, $this->all());
return in_array(Str::studly($name), $this->modules());
}

/**
* Get list of modules.
*
* - $enabled = null: Get all modules,
* - $enabled = true: Get all enabled modules,
* - $enabled = false: Get all disabled modules,
*/
public function modules(?bool $enabled = null): array
{
if (is_bool($enabled)) {
if ($enabled) {
return array_keys($this->allEnabled());
}

return array_keys($this->allDisabled());
}

return array_keys($this->all());
}

/**
Expand Down

0 comments on commit 11845e0

Please sign in to comment.