1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\DI
11: */
12:
13:
14:
15: /**
16: * Basic service builder.
17: *
18: * @author David Grudl
19: * @package Nette\DI
20: */
21: class NServiceBuilder extends NObject implements IServiceBuilder
22: {
23: /** @var string */
24: private $class;
25:
26:
27:
28: public function __construct($class)
29: {
30: $this->class = $class;
31: }
32:
33:
34:
35: public function getClass()
36: {
37: return $this->class;
38: }
39:
40:
41:
42: public function createService(IDIContainer $container)
43: {
44: if (!class_exists($this->class)) {
45: throw new InvalidStateException("Cannot instantiate service, class '$this->class' not found.");
46: }
47: return new $this->class;
48: }
49:
50: }
51: