1.2.225. Constant Class¶
A class or an interface only made up of constants. Constants usually have to be used in conjunction of some behavior (methods, class…) and never alone. As such, they should be PHP constants (build with define or const), or included in a class with other methods and properties.
<?php
class ConstantClass {
const KBIT = 1000;
const MBIT = self::KBIT * 1000;
const GBIT = self::MBIT * 1000;
const PBIT = self::GBIT * 1000;
}
?>
See also PHP Classes containing only constants.
1.2.225.1. Connex PHP features¶
1.2.225.1.1. Suggestions¶
Make the class an interface
Make the class an abstract class, to avoid its instantiation
1.2.225.1.2. Specs¶
Short name |
Classes/ConstantClass |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Slow (1 hour) |
Precision |
High |
Available in |