@@ -2,14 +2,35 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | interface SubtitleContract { |
| 4 | 4 | |
| 5 | + /** |
|
| 6 | + * @return void |
|
| 7 | + */ |
|
| 5 | 8 | public static function convert($from_file_path, $to_file_path); |
| 6 | 9 | |
| 10 | + /** |
|
| 11 | + * @return Subtitles |
|
| 12 | + */ |
|
| 7 | 13 | public static function load($file_name, $extension = null); // load file |
| 14 | + |
|
| 15 | + /** |
|
| 16 | + * @return Subtitles |
|
| 17 | + */ |
|
| 8 | 18 | public function save($file_name); // save file |
| 9 | 19 | public function content($format); // output file content (instead of saving to file) |
| 10 | 20 | |
| 21 | + /** |
|
| 22 | + * @return Subtitles |
|
| 23 | + */ |
|
| 11 | 24 | public function add($start, $end, $text); // add one line // @TODO ability to add multilines |
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @return Subtitles |
|
| 28 | + */ |
|
| 12 | 29 | public function remove($from, $till); // delete test from subtitles |
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @return Subtitles |
|
| 33 | + */ |
|
| 13 | 34 | public function time($seconds); // shift time |
| 14 | 35 | |
| 15 | 36 | |
@@ -32,12 +53,24 @@ discard block |
||
| 32 | 53 | |
| 33 | 54 | |
| 34 | 55 | // input |
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @return Subtitles |
|
| 59 | + */ |
|
| 35 | 60 | public static function loadString($string, $extension); |
| 36 | 61 | |
| 37 | 62 | // chose format |
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @return Subtitles |
|
| 66 | + */ |
|
| 38 | 67 | public function convertTo($format); |
| 39 | 68 | |
| 40 | 69 | // only text from file (without timestamps) |
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @return string |
|
| 73 | + */ |
|
| 41 | 74 | public function getOnlyTextFromInput(); |
| 42 | 75 | |
| 43 | 76 | // output |
@@ -182,6 +215,9 @@ discard block |
||
| 182 | 215 | // )); |
| 183 | 216 | } |
| 184 | 217 | |
| 218 | + /** |
|
| 219 | + * @param string $format |
|
| 220 | + */ |
|
| 185 | 221 | public function content($format) |
| 186 | 222 | { |
| 187 | 223 | $format = strtolower(trim($format, '.')); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | 'end' => $end, |
| 92 | 92 | 'lines' => is_array($text) ? $text : [$text], |
| 93 | 93 | ]; |
| 94 | - usort($this->internal_format, function ($item1, $item2) { |
|
| 94 | + usort($this->internal_format, function($item1, $item2) { |
|
| 95 | 95 | // return $item2['start'] <=> $item1['start']; // from PHP 7 |
| 96 | 96 | if ($item2['start'] == $item1['start']) { |
| 97 | 97 | return 0; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | public static function removeUtf8Bom($text) |
| 225 | 225 | { |
| 226 | - $bom = pack('H*','EFBBBF'); |
|
| 226 | + $bom = pack('H*', 'EFBBBF'); |
|
| 227 | 227 | $text = preg_replace("/^$bom/", '', $text); |
| 228 | 228 | |
| 229 | 229 | return $text; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | |
| 72 | 72 | public static function fixLine() |
| 73 | 73 | { |
| 74 | - return function ($line) { |
|
| 74 | + return function($line) { |
|
| 75 | 75 | if (substr($line, 0, 3) == '<v ') { |
| 76 | 76 | $line = substr($line, 3); |
| 77 | 77 | $line = str_replace('>', ' ', $line); |