forked from kierwils/error
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
54 lines (43 loc) · 1.06 KB
/
example.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
ini_set('memory_limit', 1024 * 1024 * 10);
error_reporting(-1);
require __DIR__ . '/vendor/autoload.php';
$error = new \Error\ErrorHandler;
if ('cli' === php_sapi_name()) {
$error->attach(new \Error\Handler\ConsoleHandler);
} else {
$error->attach(new \Error\Handler\WebHandler($debug = true));
}
$error->register();
class Project
{
public static function has($filename): bool
{
return is_file('/this/should/fail/'.$filename);
}
public static function create($filename)
{
(new Symfony\Component\Filesystem\Filesystem)->touch('/this/should/fail/'.$filename);
}
}
function createProject(...$files)
{
foreach ($files as $filename) {
try {
createFile($filename);
} catch (Exception $e) {
throw new Exception('Failed', $e->getCode(), $e);
}
}
}
function createFile($filename)
{
Project::create($filename);
}
function setupProject()
{
return function ($extra) {
createProject('readme.md', 'composer.json', 'package.json');
};
}
setupProject()('test');