| Conditions | 4 |
| Paths | 4 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | private static function get_image_width( $post_id, $size ) { |
||
| 46 | $thumbnail_id = get_post_thumbnail_id( $post_id ); |
||
| 47 | if ( ! $thumbnail_id ) { |
||
| 48 | return false; |
||
| 49 | } |
||
| 50 | $data = wp_get_attachment_image_src( $thumbnail_id, $size ); |
||
| 51 | if ( ! $data ) { |
||
| 52 | return false; |
||
| 53 | } |
||
| 54 | |||
| 55 | return array_key_exists( 2, $data ) ? $data[2] : false; |
||
| 56 | } |
||
| 57 | |||
| 59 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.