Code Duplication    Length = 16-17 lines in 2 locations

src/Container.php 1 location

@@ 66-82 (lines=17) @@
63
     *
64
     * @return mixed created service
65
     */
66
    private function createService($name)
67
    {
68
        if (!isset($this->services[$name]) || empty($this->services[$name])) {
69
            throw new ContainerException(
70
                'Service should be an array with key value pair: ' . $name
71
            );
72
        }
73
74
        if (!class_exists($this->services[$name])) {
75
            throw new ContainerException(
76
                'Class does not exists: ' . $this->services[$name]
77
            );
78
        }
79
80
        $service = new \ReflectionClass($this->services[$name]);
81
        return $service->newInstance();
82
    }
83
}
84

src/Factory/JsonServiceFactory.php 1 location

@@ 63-78 (lines=16) @@
60
    /**
61
     * @inheritdoc
62
     */
63
    public function create($service)
64
    {
65
        if(!isset($this->serviceList[$service])) {
66
            throw new NotFoundException('Service not found: ' . $service);
67
        }
68
69
        if (!class_exists($this->serviceList[$service]->class)) {
70
            throw new ContainerException(
71
                'Class does not exists: ' . $this->serviceList[$service]->class
72
            );
73
        }
74
75
        $service = new \ReflectionClass($this->serviceList[$service]->class);
76
        return $service->newInstance();
77
78
    }
79
}
80