Passed
Push — master ( e83847...16b30f )
by Radu
01:36
created

App::haltHttp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace ParcelValue\ApiClient;
3
4
final class App extends \WebServCo\Framework\Application
5
{
6
    public function __construct($pathPublic, $pathProject = null)
7
    {
8
        /**
9
         * Project can be located in a completely different place
10
         * than the web directory.
11
         */
12
        $pathProject = $pathProject ?: realpath($pathPublic . '/..');
13
14
        parent::__construct($pathPublic, $pathProject, __NAMESPACE__);
15
16
        $this->config()->set('app/path/log', sprintf('%svar/log/', $this->projectPath));
17
    }
18
19
    /**
20
     * Handle HTTP errors.
21
     */
22
    protected function haltHttp($errorInfo = [])
23
    {
24
        $logger = new \WebServCo\Framework\FileLogger(
25
            'error',
26
            $this->config()->get('app/path/log'),
27
            $this->request()
28
        );
29
        $logger->error(
30
            sprintf('Error: %s in %s:%s', $errorInfo['message'], $errorInfo['file'], $errorInfo['line']),
31
            [] /* $errorInfo */
32
        );
33
        return parent::haltHttp($errorInfo);
34
    }
35
36
    /**
37
     * Handle CLI errors
38
     */
39
    protected function haltCli($errorInfo = [])
40
    {
41
        return parent::haltCli($errorInfo);
42
    }
43
}
44