Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
 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: 
<?php
namespace Apptus\ESales\Connector\Time;

class Weekday {
    const MONDAY = 'MONDAY';
    const TUESDAY = 'TUESDAY';
    const WEDNESDAY = 'WEDNESDAY';
    const THURSDAY = 'THURSDAY';
    const FRIDAY = 'FRIDAY';
    const SATURDAY = 'SATURDAY';
    const SUNDAY = 'SUNDAY';

    private static $names = array (
            0 => 'SUNDAY',
            1 => 'MONDAY',
            2 => 'TUESDAY',
            3 => 'WEDNESDAY',
            4 => 'THURSDAY',
            5 => 'FRIDAY',
            6 => 'SATURDAY',
            7 => 'SUNDAY',
        );

    public static function fromDateTime(\DateTime $dt) {
        return self::$names[(int) $dt->format('w')];
    }

    public static function fromNumber($day) {
        return self::$names[self::validate($day)];
    }

    /**
     * @internal
     * @param int
     * @throws \InvalidArgumentException
     * @return int
     */
    public static function validate($day) {
        if (gettype($day) !== 'integer') {
            throw new \InvalidArgumentException('Day must be an integer.');
        } elseif ($day < 0 || $day > 7) {
            throw new \InvalidArgumentException('Invalid day number. Valid numbers are 0-7.');
        }
        return $day;
    }
}
Apptus ESales Connector PHP API documentation generated by ApiGen