for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/**
* This file is part of the Ray.Di package.
*
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Ray\Di;
final class Instance implements DependencyInterface
{
* @var mixed
public $value;
public function __construct($value)
$this->value = $value;
}
public function __toString()
if (is_scalar($this->value)) {
return sprintf(
'(%s) %s',
gettype($this->value),
(string) $this->value
);
if (is_object($this->value)) {
return '(object) ' . get_class($this->value);
return '(' . gettype($this->value) . ')';
* {@inheritdoc}
public function register(array &$container, Bind $bind)
$index = (string) $bind;
$container[$index] = $bind->getBound();
public function inject(Container $container)
unset($container);
return $this->value;
* @codeCoverageIgnore
public function setScope($scope)