for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Stats\Providers;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Registry\Registry;
/**
* Configuration service provider
*
* @since 1.0
*/
class ConfigServiceProvider implements ServiceProviderInterface
{
* Configuration instance
* @var Registry
private $config;
* Constructor.
* @param string $file Path to the config file.
* @throws \RuntimeException
public function __construct($file)
// Verify the configuration exists and is readable.
if (!is_readable($file))
throw new \RuntimeException('Configuration file does not exist or is unreadable.');
}
$this->config = (new Registry)->loadFile($file);
* Registers the service provider with a DI container.
* @param Container $container The DI container.
* @return void
public function register(Container $container)
$container->share('config', [$this, 'getConfigService'], true);
* Get the `config` service
* @return Registry
public function getConfigService(Container $container)
$container
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return $this->config;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.