| 1 |
<?php |
| 2 |
/** |
| 3 |
* Class Image_Functions_Check. |
| 4 |
* |
| 5 |
* @package plugin-check |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WordPress\Plugin_Check\Checker\Checks\Performance; |
| 9 |
|
| 10 |
use WordPress\Plugin_Check\Checker\Check_Categories; |
| 11 |
use WordPress\Plugin_Check\Checker\Check_Result; |
| 12 |
use WordPress\Plugin_Check\Checker\Checks\Abstract_PHP_CodeSniffer_Check; |
| 13 |
use WordPress\Plugin_Check\Traits\Stable_Check; |
| 14 |
|
| 15 |
/** |
| 16 |
* Check for running WordPress image functions sniffs. |
| 17 |
* |
| 18 |
* @since 1.3.0 |
| 19 |
*/ |
| 20 |
class Image_Functions_Check extends Abstract_PHP_CodeSniffer_Check { |
| 21 |
|
| 22 |
use Stable_Check; |
| 23 |
|
| 24 |
/** |
| 25 |
* Gets the categories for the check. |
| 26 |
* |
| 27 |
* Every check must have at least one category. |
| 28 |
* |
| 29 |
* @since 1.3.0 |
| 30 |
* |
| 31 |
* @return array The categories for the check. |
| 32 |
*/ |
| 33 |
public function get_categories() { |
| 34 |
return array( Check_Categories::CATEGORY_PERFORMANCE ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Returns an associative array of arguments to pass to PHPCS. |
| 39 |
* |
| 40 |
* @since 1.3.0 |
| 41 |
* |
| 42 |
* @param Check_Result $result The check result to amend, including the plugin context to check. |
| 43 |
* @return array An associative array of PHPCS CLI arguments. |
| 44 |
*/ |
| 45 |
protected function get_args( Check_Result $result ) { |
| 46 |
return array( |
| 47 |
'extensions' => 'php', |
| 48 |
'standard' => 'PluginCheck', |
| 49 |
'sniffs' => 'PluginCheck.CodeAnalysis.ImageFunctions', |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Gets the description for the check. |
| 55 |
* |
| 56 |
* Every check must have a short description explaining what the check does. |
| 57 |
* |
| 58 |
* @since 1.3.0 |
| 59 |
* |
| 60 |
* @return string Description. |
| 61 |
*/ |
| 62 |
public function get_description(): string { |
| 63 |
return __( 'Checks whether images are inserted using recommended functions.', 'plugin-check' ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Gets the documentation URL for the check. |
| 68 |
* |
| 69 |
* Every check must have a URL with further information about the check. |
| 70 |
* |
| 71 |
* @since 1.3.0 |
| 72 |
* |
| 73 |
* @return string The documentation URL. |
| 74 |
*/ |
| 75 |
public function get_documentation_url(): string { |
| 76 |
return __( 'https://developer.wordpress.org/plugins/', 'plugin-check' ); |
| 77 |
} |
| 78 |
} |
| 79 |
|