Passed
Pull Request — master (#364)
by Arman
02:55
created

service()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.9
13
 */
14
15
use Quantum\Service\Exceptions\ServiceException;
16
use Quantum\Service\Factories\ServiceFactory;
17
use Quantum\App\Exceptions\BaseException;
18
use Quantum\Di\Exceptions\DiException;
19
use Quantum\Service\QtService;
20
21
/**
22
 * Gets or creates service instance
23
 * @param string $serviceClass
24
 * @param bool $singleton
25
 * @return QtService
26
 * @throws ReflectionException
27
 * @throws BaseException
28
 * @throws DiException
29
 * @throws ServiceException
30
 */
31
function service(string $serviceClass, bool $singleton = false): QtService
32
{
33
    return $singleton ? ServiceFactory::get($serviceClass) : ServiceFactory::create($serviceClass);
34
}
35