1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84:
<?php
namespace Apptus\ESales\Connector\Time;
class Month {
const JANUARY = 1;
const FEBRUARY = 2;
const MARCH = 3;
const APRIL = 4;
const MAY = 5;
const JUNE = 6;
const JULY = 7;
const AUGUST = 8;
const SEPTEMBER = 9;
const OCTOBER = 10;
const NOVEMBER = 11;
const DECEMBER = 12;
private static $names = array (
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December');
private function __construct() {
}
public static function name($number) {
return self::$names[self::validate($number)];
}
public static function forStartOfQuarter($quarter) {
switch ($quarter) {
case 1: return self::JANUARY;
case 2: return self::APRIL;
case 3: return self::JULY;
case 4: return self::OCTOBER;
}
throw new \InvalidArgumentException('Invalid quarter: ' . $quarter);
}
public static function validate($month) {
if (gettype($month) !== 'integer') {
throw new \InvalidArgumentException('Month must be an integer.');
} elseif ($month < 1 || $month > 12) {
throw new \InvalidArgumentException('Invalid month number. Valid numbers are 1-12.');
}
return $month;
}
}