These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Basis\Provider; |
||
4 | |||
5 | use Basis\Application; |
||
6 | use Basis\Cache; |
||
7 | use Basis\Config; |
||
8 | use Basis\Event; |
||
9 | use Basis\Filesystem; |
||
10 | use Basis\Service; |
||
11 | use League\Container\ServiceProvider\AbstractServiceProvider; |
||
12 | use Tarantool\Mapper\Pool; |
||
13 | |||
14 | class ServiceProvider extends AbstractServiceProvider |
||
15 | { |
||
16 | protected $provides = [ |
||
17 | Event::class, |
||
18 | Service::class, |
||
19 | ]; |
||
20 | |||
21 | public function register() |
||
22 | { |
||
23 | 7 | View Code Duplication | $this->getContainer()->share(Event::class, function () { |
0 ignored issues
–
show
|
|||
24 | 7 | $app = $this->getContainer()->get(Application::class); |
|
25 | 7 | $service = $this->getContainer()->get(Service::class); |
|
26 | 7 | $pool = $this->getContainer()->get(Pool::class); |
|
27 | 7 | $filesystem = $this->getContainer()->get(Filesystem::class); |
|
28 | 7 | return new Event($app, $service, $pool, $filesystem); |
|
29 | }); |
||
30 | |||
31 | $this->getContainer()->share(Service::class, function () { |
||
32 | $config = $this->getContainer()->get(Config::class); |
||
33 | $app = $this->getContainer()->get(Application::class); |
||
34 | $cache = $this->getContainer()->get(Cache::class); |
||
35 | return new Service($config['service'], $app, $cache); |
||
36 | }); |
||
37 | } |
||
38 | } |
||
39 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.