for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nip\Mvc\Modules;
/**
* Class ModulesManager
* @package Nip\Mvc\Modules
*/
class ModulesManager
{
* @var ModulesCollection
protected $modules = null;
* @param $name
public function addModule($name)
if (!$this->getModules()->offsetExists($name)) {
$this->getModules()->set($name, $name);
}
*
* @return string
public function getViewPath($name)
return $this->getModuleDirectory($name) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR;
public function getModuleDirectory($name)
return $this->getModulesBaseDirectory() . $name;
public function getModulesBaseDirectory()
return defined('MODULES_PATH') ?
MODULES_PATH
Nip\Mvc\Modules\MODULES_PATH
: app('path') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR;
app('path')
mixed|object
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
: /** @scrutinizer ignore-type */ app('path') . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR;
* @return ModulesCollection
public function getModules(): ModulesCollection
if ($this->modules === null) {
$this->modules = new ModulesCollection();
$this->loadFromConfig();
return $this->modules;
* @param ModulesCollection $sections
public function setModules(ModulesCollection $sections): void
$this->modules = $sections;
protected function loadFromConfig()
if (function_exists('config')) {
$data = config('mvc.modules', ['admin', 'frontend']);
foreach ($data as $key => $row) {
$this->modules->set($key, $row);