| Conditions | 5 |
| Paths | 8 |
| Total Lines | 52 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 23 | public function getHelperProperties(MediaInterface $media, $format, $options = array()) |
||
| 24 | { |
||
| 25 | // documentation : http://vimeo.com/api/docs/moogaloop |
||
| 26 | $defaults = array( |
||
| 27 | // (optional) Flash Player version of app. Defaults to 9 .NEW! |
||
| 28 | // 10 - New Moogaloop. 9 - Old Moogaloop without newest features. |
||
| 29 | 'fp_version' => 10, |
||
| 30 | |||
| 31 | // (optional) Enable fullscreen capability. Defaults to true. |
||
| 32 | 'fullscreen' => true, |
||
| 33 | |||
| 34 | // (optional) Show the byline on the video. Defaults to true. |
||
| 35 | 'title' => true, |
||
| 36 | |||
| 37 | // (optional) Show the title on the video. Defaults to true. |
||
| 38 | 'byline' => 0, |
||
| 39 | |||
| 40 | // (optional) Show the user's portrait on the video. Defaults to true. |
||
| 41 | 'portrait' => true, |
||
| 42 | |||
| 43 | // (optional) Specify the color of the video controls. |
||
| 44 | 'color' => null, |
||
| 45 | |||
| 46 | // (optional) Set to 1 to disable HD. |
||
| 47 | 'hd_off' => 0, |
||
| 48 | |||
| 49 | // Set to 1 to enable the Javascript API. |
||
| 50 | 'js_api' => null, |
||
| 51 | |||
| 52 | // (optional) JS function called when the player loads. Defaults to vimeo_player_loaded. |
||
| 53 | 'js_onLoad' => 0, |
||
| 54 | |||
| 55 | // Unique id that is passed into all player events as the ending parameter. |
||
| 56 | 'js_swf_id' => uniqid('vimeo_player_'), |
||
| 57 | ); |
||
| 58 | |||
| 59 | $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : array()); |
||
| 60 | |||
| 61 | $box = $this->getBoxHelperProperties($media, $format, $options); |
||
| 62 | |||
| 63 | $params = array( |
||
| 64 | 'src' => http_build_query($player_parameters), |
||
| 65 | 'id' => $player_parameters['js_swf_id'], |
||
| 66 | 'frameborder' => isset($options['frameborder']) ? $options['frameborder'] : 0, |
||
| 67 | 'width' => $box->getWidth(), |
||
| 68 | 'height' => $box->getHeight(), |
||
| 69 | 'class' => isset($options['class']) ? $options['class'] : '', |
||
| 70 | 'allow_fullscreen' => isset($options['allowfullscreen']) ? true : false, |
||
| 71 | ); |
||
| 72 | |||
| 73 | return $params; |
||
| 74 | } |
||
| 75 | |||
| 157 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: