|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of file-fixture. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Noritaka Horio <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace holyshared\fixture\loader; |
|
13
|
|
|
|
|
14
|
|
|
use holyshared\fixture\Loader; |
|
15
|
|
|
use holyshared\fixture\FixtureLoader; |
|
16
|
|
|
use League\CLImate\CLImate; |
|
17
|
|
|
use League\CLImate\Util\Output; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
final class ArtLoader implements FixtureLoader |
|
21
|
|
|
{ |
|
22
|
|
|
const NAME = 'art'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \League\CLImate\CLImate |
|
26
|
|
|
*/ |
|
27
|
|
|
private $cli; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var \League\CLImate\Util\Output |
|
31
|
|
|
*/ |
|
32
|
|
|
private $output; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var \holyshared\fixture\Loader |
|
36
|
|
|
*/ |
|
37
|
|
|
private $loader; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getName() |
|
43
|
|
|
{ |
|
44
|
|
|
return static::NAME; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Create a new art loader |
|
49
|
|
|
* |
|
50
|
|
|
* @param \holyshared\fixture\Loader |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(Loader $loader) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->output = new Output(); |
|
55
|
|
|
$this->output->sameLine(); |
|
56
|
|
|
$this->output->defaultTo('buffer'); |
|
57
|
|
|
|
|
58
|
|
|
$this->cli = new CLImate(); |
|
59
|
|
|
$this->cli->setOutput($this->output); |
|
60
|
|
|
$this->loader = $loader; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
|
|
public function load($path, array $arguments = []) |
|
67
|
|
|
{ |
|
68
|
|
|
$content = $this->loader->load($path, $arguments); |
|
69
|
|
|
$this->cli->out($content); |
|
70
|
|
|
|
|
71
|
|
|
$bufferWriter = $this->output->get('buffer'); |
|
72
|
|
|
return $bufferWriter->get(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|