1 | <?php |
||
34 | class ReFormat implements FileModifierInterface, LoggerAwareInterface, BuilderAwareInterface |
||
35 | { |
||
36 | use OptionalLoggerTrait; |
||
37 | use GetOptionTrait; |
||
38 | use FileProcessTrait; |
||
39 | use FileHelper; |
||
40 | |||
41 | /** @var FormatterFactoryInterface */ |
||
42 | private $formatterFactory; |
||
43 | /** @var ParserFactoryInterface */ |
||
44 | private $parserFactory; |
||
45 | |||
46 | /** |
||
47 | * ReFormat constructor. |
||
48 | * |
||
49 | * @param FormatterFactoryInterface|null $formatterFactory |
||
50 | * @param ParserFactoryInterface|null $parserFactory |
||
51 | * @param BuilderInterface|null $builder |
||
52 | */ |
||
53 | 11 | public function __construct( |
|
54 | FormatterFactoryInterface $formatterFactory = null, |
||
55 | ParserFactoryInterface $parserFactory = null, |
||
56 | BuilderInterface $builder = null |
||
57 | ) { |
||
58 | 11 | $this->builder = $builder; |
|
59 | 11 | $this->formatterFactory = $formatterFactory ?: $this->getBuilder()->build(FormatterFactory::class); |
|
60 | 11 | $this->parserFactory = $parserFactory ?: $this->getBuilder()->build(ParserFactory::class); |
|
61 | 11 | } |
|
62 | |||
63 | /** |
||
64 | * Can this file be modified by this modifier |
||
65 | * |
||
66 | * @param FileNodeInterface $file |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | 2 | public function canModify(FileNodeInterface $file) |
|
77 | |||
78 | /** |
||
79 | * Modify the file |
||
80 | * |
||
81 | * @param FileNodeInterface $file |
||
82 | * @param array $options |
||
83 | * |
||
84 | * @return FileNodeInterface |
||
85 | */ |
||
86 | 3 | public function modify(FileNodeInterface $file, array $options = []) |
|
99 | |||
100 | /** |
||
101 | * @param FileNodeInterface $file |
||
102 | * @param FormatInterface|null $outputFormat |
||
103 | * @param FileNodeInterface|null $output |
||
104 | * @param FormatInterface|null $inputFormat |
||
105 | * |
||
106 | * @return FileNodeInterface |
||
107 | */ |
||
108 | 7 | public function reFormat( |
|
139 | } |
||
140 |