-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRender.php
More file actions
35 lines (29 loc) · 1.03 KB
/
Render.php
File metadata and controls
35 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace NGFramer\NGFramerPHPExceptions;
use App\Config\ApplicationConfig;
use NGFramer\NGFramerPHPExceptions\Renderer\ApiExceptionRenderer;
use NGFramer\NGFramerPHPExceptions\Renderer\CliExceptionRenderer;
use NGFramer\NGFramerPHPExceptions\Renderer\HtmlExceptionRenderer;
use NGFramer\NGFramerPHPExceptions\Renderer\Supportive\BaseRenderer;
class Render
{
/**
* Creates and returns an appropriate Exception renderer based on the environment.
*
* @returns BaseRenderer
*/
public static function create()
{
// Check the environment and return the appropriate renderer.
// Check if the environment is cli.
if (php_sapi_name() === 'cli') {
return new CLIExceptionRenderer();
}
// Check if the environment is api.
if (ApplicationConfig::get('appType') === 'api') {
return new APIExceptionRenderer();
}
// If the environment is not cli or api, return the default renderer.
return new HtmlExceptionRenderer();
}
}