@@ -109,6 +109,6 @@ |
||
109 | 109 | */ |
110 | 110 | protected static function internalTimeToFormat($internal_time) |
111 | 111 | { |
112 | - return round($internal_time * 1000); |
|
112 | + return round($internal_time * 1000); |
|
113 | 113 | } |
114 | 114 | } |
@@ -108,7 +108,7 @@ |
||
108 | 108 | $file_content .= '<SYNC Start=' . self::internalTimeToFormat($last_time) . '><P Class=ENUSCC> ' . "</P></SYNC>\r\n"; |
109 | 109 | } |
110 | 110 | |
111 | - $file_content .= '<SYNC Start=' . self::internalTimeToFormat($block['start']) . '><P Class=ENUSCC>' . implode('<br>', $block['lines']) . "</P></SYNC>\r\n"; |
|
111 | + $file_content .= '<SYNC Start=' . self::internalTimeToFormat($block['start']) . '><P Class=ENUSCC>' . implode('<br>', $block['lines']) . "</P></SYNC>\r\n"; |
|
112 | 112 | $last_time = $block['end']; |
113 | 113 | } |
114 | 114 | $file_content .= '<SYNC Start=' . self::internalTimeToFormat($last_time) . '><P Class=ENUSCC> ' . "</P></SYNC>\r\n"; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $parts = explode('.', $vtt_time); |
54 | 54 | |
55 | 55 | // parts[0] could be mm:ss or hh:mm:ss format -> always use hh:mm:ss |
56 | - $parts[0] = substr_count($parts[0], ':') == 2 ? $parts[0] : '00:'.$parts[0]; |
|
56 | + $parts[0] = substr_count($parts[0], ':') == 2 ? $parts[0] : '00:' . $parts[0]; |
|
57 | 57 | |
58 | 58 | $only_seconds = strtotime("1970-01-01 {$parts[0]} UTC"); |
59 | 59 | $milliseconds = (float)('0.' . $parts[1]); |
@@ -913,7 +913,7 @@ |
||
913 | 913 | '91bf' => 'û', |
914 | 914 | ]; |
915 | 915 | |
916 | - private static $extended_chars = [ |
|
916 | + private static $extended_chars = [ |
|
917 | 917 | '9220' => 'Á', |
918 | 918 | '92a1' => 'É', |
919 | 919 | '92a2' => 'Ó', |
@@ -97,7 +97,7 @@ |
||
97 | 97 | protected static function internalTimeToScc($internal_time) |
98 | 98 | { |
99 | 99 | $parts = explode('.', $internal_time); |
100 | - $whole = (int) $parts[0]; |
|
100 | + $whole = (int)$parts[0]; |
|
101 | 101 | $decimal = isset($parts[1]) ? (float)('0.' . $parts[1]) : 0.0; |
102 | 102 | $frame = round($decimal * self::$fps); |
103 | 103 | $frame = min($frame, floor(self::$fps)); // max 29 |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $time_parts = explode('.', $ttml_time); |
132 | 132 | $milliseconds = 0; |
133 | 133 | if (isset($time_parts[1])) { |
134 | - $milliseconds = (float) ('0.' . $time_parts[1]); |
|
134 | + $milliseconds = (float)('0.' . $time_parts[1]); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | list($hours, $minutes, $seconds) = array_map('intval', explode(':', $time_parts[0])); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | |
144 | 144 | protected static function internalTimeToTtml($internal_time) |
145 | 145 | { |
146 | - $formatted_output = round($internal_time, 3); |
|
146 | + $formatted_output = round($internal_time, 3); |
|
147 | 147 | |
148 | 148 | if (strpos($formatted_output, '.') === false) { |
149 | - $formatted_output .= ".0"; // Add at least one digit after decimal if there are no digits |
|
149 | + $formatted_output .= ".0"; // Add at least one digit after decimal if there are no digits |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $formatted_output; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | list($numerator, $denominator) = array_map('intval', explode(' ', $frameRateMultiplier)); |
163 | 163 | return $frameRate / $denominator * $numerator; |
164 | 164 | } else if ($frameRate) { |
165 | - return (int) $frameRate; |
|
165 | + return (int)$frameRate; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | //This is a standard frame rate used in many video formats and broadcast television. |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | foreach ($expected as $k => $block) { |
14 | 14 | $this->assertTrue(abs(round($expected[$k]['start'], 2) - round($actual[$k]['start'], 2)) < $allowable_error, round($expected[$k]['start'], 3) . ' vs ' . round($actual[$k]['start'], 3)); |
15 | - $this->assertTrue(abs(round($expected[$k]['end'], 2) - round($actual[$k]['end'], 2)) < $allowable_error, round($expected[$k]['end'], 3) . ' vs ' . round($actual[$k]['end'], 3)); |
|
15 | + $this->assertTrue(abs(round($expected[$k]['end'], 2) - round($actual[$k]['end'], 2)) < $allowable_error, round($expected[$k]['end'], 3) . ' vs ' . round($actual[$k]['end'], 3)); |
|
16 | 16 | |
17 | 17 | foreach ($expected[$k]['lines'] as $line_k => $line) { |
18 | 18 | $this->assertEquals($line, $actual[$k]['lines'][$line_k]); |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | protected $output; |
29 | 29 | |
30 | 30 | public static $formats = [ |
31 | - ['extension' => 'ass', 'format' => 'ass', 'name' => 'Advanced Sub Station Alpha', 'class' => AssConverter::class], |
|
32 | - ['extension' => 'ssa', 'format' => 'ass', 'name' => 'Advanced Sub Station Alpha', 'class' => AssConverter::class], |
|
33 | - ['extension' => 'dfxp', 'format' => 'dfxp', 'name' => 'Netflix Timed Text', 'class' => DfxpConverter::class], |
|
34 | - ['extension' => 'sbv', 'format' => 'sbv', 'name' => 'YouTube', 'class' => SbvConverter::class], |
|
35 | - ['extension' => 'srt', 'format' => 'srt', 'name' => 'SubRip', 'class' => SrtConverter::class], |
|
36 | - ['extension' => 'stl', 'format' => 'stl', 'name' => 'Spruce Subtitle File', 'class' => StlConverter::class], |
|
37 | - ['extension' => 'sub', 'format' => 'sub_microdvd', 'name' => 'MicroDVD', 'class' => SubMicroDvdConverter::class], |
|
38 | - ['extension' => 'sub', 'format' => 'sub_subviewer', 'name' => 'SubViewer2.0', 'class' => SubViewerConverter::class], |
|
39 | - ['extension' => 'ttml', 'format' => 'ttml', 'name' => 'TimedText 1.0', 'class' => TtmlConverter::class], |
|
40 | - ['extension' => 'xml', 'format' => 'ttml', 'name' => 'TimedText 1.0', 'class' => TtmlConverter::class], |
|
41 | - ['extension' => 'smi', 'format' => 'smi', 'name' => 'SAMI', 'class' => SmiConverter::class], |
|
42 | - ['extension' => 'txt', 'format' => 'txt_quicktime', 'name' => 'Quick Time Text', 'class' => TxtQuickTimeConverter::class], |
|
43 | - ['extension' => 'vtt', 'format' => 'vtt', 'name' => 'WebVTT', 'class' => VttConverter::class], |
|
44 | - ['extension' => 'scc', 'format' => 'scc', 'name' => 'Scenarist', 'class' => SccConverter::class], |
|
45 | - ['extension' => 'csv', 'format' => 'csv', 'name' => 'Coma Separated Values', 'class' => CsvConverter::class], // must be last from bottom |
|
46 | - ['extension' => 'txt', 'format' => 'txt', 'name' => 'Plaintext', 'class' => TxtConverter::class], // must be the last one |
|
31 | + ['extension' => 'ass', 'format' => 'ass', 'name' => 'Advanced Sub Station Alpha', 'class' => AssConverter::class], |
|
32 | + ['extension' => 'ssa', 'format' => 'ass', 'name' => 'Advanced Sub Station Alpha', 'class' => AssConverter::class], |
|
33 | + ['extension' => 'dfxp', 'format' => 'dfxp', 'name' => 'Netflix Timed Text', 'class' => DfxpConverter::class], |
|
34 | + ['extension' => 'sbv', 'format' => 'sbv', 'name' => 'YouTube', 'class' => SbvConverter::class], |
|
35 | + ['extension' => 'srt', 'format' => 'srt', 'name' => 'SubRip', 'class' => SrtConverter::class], |
|
36 | + ['extension' => 'stl', 'format' => 'stl', 'name' => 'Spruce Subtitle File', 'class' => StlConverter::class], |
|
37 | + ['extension' => 'sub', 'format' => 'sub_microdvd', 'name' => 'MicroDVD', 'class' => SubMicroDvdConverter::class], |
|
38 | + ['extension' => 'sub', 'format' => 'sub_subviewer', 'name' => 'SubViewer2.0', 'class' => SubViewerConverter::class], |
|
39 | + ['extension' => 'ttml', 'format' => 'ttml', 'name' => 'TimedText 1.0', 'class' => TtmlConverter::class], |
|
40 | + ['extension' => 'xml', 'format' => 'ttml', 'name' => 'TimedText 1.0', 'class' => TtmlConverter::class], |
|
41 | + ['extension' => 'smi', 'format' => 'smi', 'name' => 'SAMI', 'class' => SmiConverter::class], |
|
42 | + ['extension' => 'txt', 'format' => 'txt_quicktime', 'name' => 'Quick Time Text', 'class' => TxtQuickTimeConverter::class], |
|
43 | + ['extension' => 'vtt', 'format' => 'vtt', 'name' => 'WebVTT', 'class' => VttConverter::class], |
|
44 | + ['extension' => 'scc', 'format' => 'scc', 'name' => 'Scenarist', 'class' => SccConverter::class], |
|
45 | + ['extension' => 'csv', 'format' => 'csv', 'name' => 'Coma Separated Values', 'class' => CsvConverter::class], // must be last from bottom |
|
46 | + ['extension' => 'txt', 'format' => 'txt', 'name' => 'Plaintext', 'class' => TxtConverter::class], // must be the last one |
|
47 | 47 | ]; |
48 | 48 | |
49 | 49 | public static function convert($from_file_path, $to_file_path, $to_format = null) |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | protected function sortInternalFormat() |
161 | 161 | { |
162 | - usort($this->internal_format, function ($item1, $item2) { |
|
162 | + usort($this->internal_format, function($item1, $item2) { |
|
163 | 163 | if ($item2['start'] == $item1['start']) { |
164 | 164 | return 0; |
165 | 165 | } elseif ($item2['start'] < $item1['start']) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $internal_format = []; |
33 | 33 | foreach ($data as $k => $row) { |
34 | 34 | $timestamp = preg_replace(TxtConverter::$time_regexp, '', $row[0]); |
35 | - if ($k === 0 && trim($timestamp) !== '') { // heading |
|
35 | + if ($k === 0 && trim($timestamp) !== '') { // heading |
|
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $separator = self::detectSeparator($content); |
84 | 84 | $csv = []; |
85 | - while ( ($data = fgetcsv($fp, 0, $separator) ) !== false ) { |
|
85 | + while (($data = fgetcsv($fp, 0, $separator)) !== false) { |
|
86 | 86 | $csv[] = $data; |
87 | 87 | } |
88 | 88 | fclose($fp); |
@@ -97,7 +97,10 @@ |
||
97 | 97 | foreach ($lines as $line) { |
98 | 98 | foreach (self::$allowedSeparators as $delimiter) { |
99 | 99 | $count = count(explode($delimiter, $line)); |
100 | - if ($count === 1) continue; // delimiter not found in line |
|
100 | + if ($count === 1) { |
|
101 | + continue; |
|
102 | + } |
|
103 | + // delimiter not found in line |
|
101 | 104 | |
102 | 105 | if (empty($results[$delimiter])) { |
103 | 106 | $results[$delimiter] = []; |
@@ -129,16 +129,16 @@ |
||
129 | 129 | $total_parts = count($time_parts); |
130 | 130 | |
131 | 131 | if ($total_parts === 1) { |
132 | - $tmp = (float) str_replace(',', '.', $time_parts[0]); |
|
132 | + $tmp = (float)str_replace(',', '.', $time_parts[0]); |
|
133 | 133 | return $tmp; |
134 | 134 | } elseif ($total_parts === 2) { // minutes:seconds format |
135 | 135 | list($minutes, $seconds) = array_map('intval', $time_parts); |
136 | - $tmp = (float) str_replace(',', '.', $time_parts[1]); |
|
136 | + $tmp = (float)str_replace(',', '.', $time_parts[1]); |
|
137 | 137 | $milliseconds = $tmp - floor($tmp); |
138 | 138 | return ($minutes * 60) + $seconds + $milliseconds; |
139 | 139 | } elseif ($total_parts === 3) { // hours:minutes:seconds,milliseconds format |
140 | 140 | list($hours, $minutes, $seconds) = array_map('intval', $time_parts); |
141 | - $tmp = (float) str_replace(',', '.', $time_parts[2]); |
|
141 | + $tmp = (float)str_replace(',', '.', $time_parts[2]); |
|
142 | 142 | $milliseconds = $tmp - floor($tmp); |
143 | 143 | return ($hours * 3600) + ($minutes * 60) + $seconds + $milliseconds; |
144 | 144 | } elseif ($total_parts === 4) { // hours:minutes:seconds:frames format |