Passed
Push — development ( befb7b...e34b45 )
by Alexander
03:13
created

RestApplication::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Application class intended for use with RestApiController
4
 *
5
 * @file      RestApplication.php
6
 *
7
 * PHP version 7.1+
8
 *
9
 * @author    Yancharuk Alexander <alex at itvault dot info>
10
 * @copyright © 2012-2021 Alexander Yancharuk <alex at itvault at info>
11
 * @date      2021-04-20 07:03
12
 * @license   The BSD 3-Clause License
13
 *            <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
14
 */
15
16
namespace Veles\Application;
17
18
use Application\Interfaces\ApplicationInterface;
19
use Application\Interfaces\RequestAwareInterface;
20
use Application\Interfaces\RouteAwareInterface;
21
use Exception;
22
use Veles\Application\Traits\RequestTrait;
23
use Veles\Application\Traits\RouteTrait;
24
use Veles\View\View;
25
26
class RestApplication implements
27
	ApplicationInterface,
28
	RequestAwareInterface,
29
	RouteAwareInterface
30
{
31
	use RequestTrait;
32
	use RouteTrait;
33
34
	/**
35
	 * Application start
36
	 *
37
	 * @throws Exception
38
	 */
39 2
	public function run(): void
40
	{
41 2
		$route      = $this->getRoute();
42 2
		$controller = $route->getController();
43
44 2
		if ($vars = $controller->setApplication($this)->index()) {
0 ignored issues
show
introduced by
The method index() does not exist on Veles\Controllers\BaseController. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
		if ($vars = $controller->setApplication($this)->/** @scrutinizer ignore-call */ index()) {
Loading history...
45 2
			View::set($vars);
46
		}
47
48 2
		View::show($route->getTemplate());
49 2
	}
50
}
51