Conditions | 8 |
Paths | 60 |
Total Lines | 112 |
Code Lines | 72 |
Lines | 14 |
Ratio | 12.5 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
24 | public function transcode_asset( |
||
25 | $tmpPathInput, |
||
26 | $pathToInputFile, |
||
27 | $pathToOutputFiles, |
||
28 | $metadata = null, |
||
29 | $outputWanted) |
||
30 | { |
||
31 | if ($metadata) { |
||
32 | // Extract an sanitize metadata |
||
33 | $metadata = $this->_extractFileInfo($metadata); |
||
|
|||
34 | } |
||
35 | |||
36 | $this->cpeLogger->log_out( |
||
37 | "INFO", |
||
38 | basename(__FILE__), |
||
39 | "Start Transcoding Asset '$pathToInputFile' ...", |
||
40 | $this->activityLogKey |
||
41 | ); |
||
42 | |||
43 | View Code Duplication | if ($metadata) |
|
44 | $this->cpeLogger->log_out( |
||
45 | "INFO", |
||
46 | basename(__FILE__), |
||
47 | "Input Video metadata: " . print_r($metadata, true), |
||
48 | $this->activityLogKey |
||
49 | ); |
||
50 | |||
51 | try { |
||
52 | $convertCmd = ""; |
||
53 | |||
54 | // Update output extension file if it ends with '.*' |
||
55 | // Output will take the same extension as input |
||
56 | $this->_updateOutputExtension( |
||
57 | $pathToInputFile, |
||
58 | $outputWanted); |
||
59 | |||
60 | // Custom command |
||
61 | if (isset($outputWanted->{'custom_cmd'}) && |
||
62 | $outputWanted->{'custom_cmd'}) { |
||
63 | $convertCmd = $this->craft_convert_custom_cmd( |
||
64 | $tmpPathInput, |
||
65 | $pathToInputFile, |
||
66 | $pathToOutputFiles, |
||
67 | $metadata, |
||
68 | $outputWanted |
||
69 | ); |
||
70 | } |
||
71 | else { |
||
72 | $convertCmd = $this->craft_convert_cmd( |
||
73 | $tmpPathInput, |
||
74 | $pathToInputFile, |
||
75 | $pathToOutputFiles, |
||
76 | $metadata, |
||
77 | $outputWanted |
||
78 | ); |
||
79 | } |
||
80 | |||
81 | $this->cpeLogger->log_out( |
||
82 | "INFO", |
||
83 | basename(__FILE__), |
||
84 | "CONVERT CMD:\n$convertCmd\n", |
||
85 | $this->activityLogKey |
||
86 | ); |
||
87 | |||
88 | // Use executer to start FFMpeg command |
||
89 | // Use 'capture_progression' function as callback |
||
90 | // Pass video 'duration' as parameter |
||
91 | // Sleep 1sec between turns and callback every 10 turns |
||
92 | // Output progression logs (true) |
||
93 | $this->executer->execute( |
||
94 | $convertCmd, |
||
95 | 1, |
||
96 | array(2 => array("pipe", "w")), |
||
97 | array($this, "capture_progression"), |
||
98 | $metadata['duration'], |
||
99 | true, |
||
100 | 10 |
||
101 | ); |
||
102 | |||
103 | // Test if we have an output file ! |
||
104 | View Code Duplication | if (!file_exists($pathToOutputFiles) || |
|
105 | $this->is_dir_empty($pathToOutputFiles)) { |
||
106 | throw new CpeSdk\CpeException( |
||
107 | "Output file '$pathToOutputFiles' hasn't been created successfully or is empty !", |
||
108 | self::TRANSCODE_FAIL |
||
109 | ); |
||
110 | } |
||
111 | |||
112 | // FFProbe the output file and return its information |
||
113 | $output_info = |
||
114 | $this->get_asset_info($pathToOutputFiles."/".$outputWanted->{'output_file_info'}['basename']); |
||
115 | } |
||
116 | catch (\Exception $e) { |
||
117 | $this->cpeLogger->log_out( |
||
118 | "ERROR", |
||
119 | basename(__FILE__), |
||
120 | "Execution of command '".$convertCmd."' failed: " . print_r($metadata, true). ". ".$e->getMessage(), |
||
121 | $this->activityLogKey |
||
122 | ); |
||
123 | return false; |
||
124 | } |
||
125 | |||
126 | // No error. Transcode successful |
||
127 | $this->cpeLogger->log_out( |
||
128 | "INFO", |
||
129 | basename(__FILE__), |
||
130 | "Transcoding successfull !", |
||
131 | $this->activityLogKey |
||
132 | ); |
||
133 | |||
134 | return $output_info; |
||
135 | } |
||
136 | |||
214 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.