-
Notifications
You must be signed in to change notification settings - Fork 20
/
PHPFileFactory.php
43 lines (34 loc) · 958 Bytes
/
PHPFileFactory.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
<?php
namespace Archetype\Factories;
use Archetype\Endpoints\PHP\Make;
use Archetype\PHPFile;
class PHPFileFactory
{
const FILE_TYPE = PHPFile::class;
public function __call($method, $args)
{
return static::__makeFileInstance()->$method(...$args);
}
public static function __callStatic($method, $args)
{
return static::__makeFileInstance()->$method(...$args);
}
protected static function __makeFileInstance()
{
$class = static::FILE_TYPE;
$instance = new $class(
static::__driver('input'),
static::__driver('output'),
new Make()
);
return $instance;
}
protected static function __driver($name)
{
$driver = [
"input" => config('archetype.input', \Archetype\Drivers\FileInput::class),
"output" => config('archetype.output', \Archetype\Drivers\FileOutput::class),
][$name];
return new $driver;
}
}