1 | <?php |
||
13 | class File implements FileInterface |
||
14 | { |
||
15 | /** |
||
16 | * Version constants |
||
17 | */ |
||
18 | const CNAB240 = 240; |
||
19 | const CNAB400 = 400; |
||
20 | |||
21 | /** |
||
22 | * File lines collection. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $lines = []; |
||
27 | |||
28 | /** |
||
29 | * File schema file. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $schemaFile; |
||
34 | |||
35 | /** |
||
36 | * Return the file lines. |
||
37 | * |
||
38 | * @return array |
||
39 | */ |
||
40 | public function getLines() |
||
44 | |||
45 | /** |
||
46 | * Loads a file content. |
||
47 | * |
||
48 | * @param string $path |
||
49 | * @return \SmartCNAB\Support\File\File |
||
50 | * @throws \RuntimeException |
||
51 | */ |
||
52 | public function load($path) |
||
64 | |||
65 | /** |
||
66 | * Saves a file and return it. |
||
67 | * |
||
68 | * @param string $path |
||
69 | * @return \SplFileObject |
||
70 | * @throws \RuntimeException |
||
71 | */ |
||
72 | public function save($path) |
||
82 | |||
83 | /** |
||
84 | * Transform a class to a path. |
||
85 | * |
||
86 | * @param string $class |
||
87 | * @return string |
||
88 | */ |
||
89 | protected function classToPath($class) |
||
95 | |||
96 | /** |
||
97 | * Generate and return the file contents. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | protected function generate() |
||
102 | { |
||
103 | $lines = array_map(function ($line) { |
||
104 | return implode('', $line); |
||
105 | }, $this->getLines()); |
||
106 | |||
107 | $output = implode("\r\n", $lines); |
||
108 | // $output = iconv('UTF-8', 'ASCII//TRANSLIT', $output); |
||
|
|||
109 | $output = strtoupper($output); |
||
110 | |||
111 | return $output; |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Parse and return the schema structure. |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | protected function parseSchema() |
||
129 | |||
130 | /** |
||
131 | * Generate and return the schema file path. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | protected function schemaPath() |
||
139 | } |
||
140 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.