| 1 | <?php |
||
| 7 | class Mileage extends Quantity { |
||
| 8 | |||
| 9 | // The base unit for the `$units` conversion table |
||
| 10 | const BASE_UNIT = 'kmpl'; // kilometer / liter |
||
| 11 | |||
| 12 | // New objects will convert to this unit |
||
| 13 | static public $default_unit = self::BASE_UNIT; |
||
| 14 | |||
| 15 | // Conversion table for this Quantity |
||
| 16 | // XpY => (X in km) / (Y in l) |
||
| 17 | // USMpG => (1.6 / 3.8) |
||
| 18 | static public $units = array( |
||
| 19 | 'kmpl' => 1, // base |
||
| 20 | 'lp100km' => -100, // 100 / l |
||
| 21 | 'mpusg' => 0.425144, // 1.6 / 3.8 |
||
| 22 | 'mpbg' => 0.354005, // 1.6 / 4.5 |
||
| 23 | ); |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The convertor heart, that every sub class needs |
||
| 27 | */ |
||
| 28 | protected function convertor( $toUnit ) { |
||
| 31 | |||
| 32 | } |
||
| 33 |