Overview

Namespaces

  • SKJ
    • AppException
      • HTTP
      • Logic
      • Runtime

Classes

  • SKJ\Label

Interfaces

  • SKJ\AppExceptionInterface

Traits

  • SKJ\AppExceptionMethods

Exceptions

  • SKJ\AppException
  • SKJ\AppException\AbstractContainerException
  • SKJ\AppException\AbstractDateTimeException
  • SKJ\AppException\AbstractHttpException
  • SKJ\AppException\AbstractValidationException
  • SKJ\AppException\HTTP\BadGatewayException
  • SKJ\AppException\HTTP\BadRequestException
  • SKJ\AppException\HTTP\ConflictException
  • SKJ\AppException\HTTP\ExpectationFailedException
  • SKJ\AppException\HTTP\FailedDependencyException
  • SKJ\AppException\HTTP\ForbiddenException
  • SKJ\AppException\HTTP\GatewayTimeoutException
  • SKJ\AppException\HTTP\GoneException
  • SKJ\AppException\HTTP\HttpVersionNotSupportedException
  • SKJ\AppException\HTTP\InternalServerErrorException
  • SKJ\AppException\HTTP\LengthRequiredException
  • SKJ\AppException\HTTP\LockedException
  • SKJ\AppException\HTTP\MethodNotAllowedException
  • SKJ\AppException\HTTP\NotAcceptableException
  • SKJ\AppException\HTTP\NotFoundException
  • SKJ\AppException\HTTP\NotImplementedException
  • SKJ\AppException\HTTP\PaymentRequiredException
  • SKJ\AppException\HTTP\PreconditionFailedException
  • SKJ\AppException\HTTP\ProxyAuthenticationRequiredException
  • SKJ\AppException\HTTP\RequestedRangeNotSatisfiableException
  • SKJ\AppException\HTTP\RequestEntityTooLargeException
  • SKJ\AppException\HTTP\RequestTimeoutException
  • SKJ\AppException\HTTP\RequestUriTooLongException
  • SKJ\AppException\HTTP\ServiceUnavailableException
  • SKJ\AppException\HTTP\UnauthorizedException
  • SKJ\AppException\HTTP\UnprocessableEntityException
  • SKJ\AppException\HTTP\UnsupportedMediaTypeException
  • SKJ\AppException\HttpException
  • SKJ\AppException\Logic\BadFunctionCallException
  • SKJ\AppException\Logic\BadMethodCallException
  • SKJ\AppException\Logic\CircularReferenceException
  • SKJ\AppException\Logic\ContainerException
  • SKJ\AppException\Logic\DependencyInjectionException
  • SKJ\AppException\Logic\DomainException
  • SKJ\AppException\Logic\EnvironmentException
  • SKJ\AppException\Logic\InvalidArgumentException
  • SKJ\AppException\Logic\LengthException
  • SKJ\AppException\Logic\OutOfRangeException
  • SKJ\AppException\Logic\UnexpectedValueException
  • SKJ\AppException\LogicException
  • SKJ\AppException\Runtime\AuthenticationException
  • SKJ\AppException\Runtime\DeadLockException
  • SKJ\AppException\Runtime\DuplicationException
  • SKJ\AppException\Runtime\DurationException
  • SKJ\AppException\Runtime\EmptyResultException
  • SKJ\AppException\Runtime\ExpiryException
  • SKJ\AppException\Runtime\InvalidElementException
  • SKJ\AppException\Runtime\MissingElementException
  • SKJ\AppException\Runtime\NoConditionException
  • SKJ\AppException\Runtime\OutOfBoundsException
  • SKJ\AppException\Runtime\OverflowException
  • SKJ\AppException\Runtime\PermissionException
  • SKJ\AppException\Runtime\RangeException
  • SKJ\AppException\Runtime\TemporaryFailureException
  • SKJ\AppException\Runtime\TimeoutException
  • SKJ\AppException\Runtime\TransactionException
  • SKJ\AppException\Runtime\UnavailableServiceException
  • SKJ\AppException\Runtime\UnderflowException
  • SKJ\AppException\Runtime\UnexpectedValueException
  • SKJ\AppException\Runtime\UploadException
  • SKJ\AppException\Runtime\ValidationException
  • SKJ\AppException\Runtime\WrongArgumentException
  • SKJ\AppException\RuntimeException
  • Overview
  • Namespace
  • Class
 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: 
<?php
// このファイルの名前空間の定義
namespace SKJ\AppException;

/**
 * 日時エラー実行例外の抽象クラス
 *
 * 日時に関する事により処理が失敗した場合に使用する例外です
 *
 * ◆詳細◆
 * <ul>
 *     <li>このクラスは抽象クラスです</li>
 * </ul>
 *
 * @package SKJ\AppException
 * @version 0.8.0
 * @author y3high <y3public@49364.net>
 * @copyright 2019 Seikouhou.
 * @license https://opensource.org/licenses/MIT MIT
 * @since Class available since Release 0.8.0
 */
class AbstractDateTimeException extends RuntimeException
{
    /**
     * @internal
     * @var int|null タイムスタンプ(unixタイム)
     */
    protected $dateTime = null;

    /**
     * 日時を設定する
     *
     * 日時解釈できない文字列が渡された場合は設定されない
     *
     * @api
     * @param string $dateTime strtotime()関数が解釈できる日時形式で期限を指定
     * @return self 自分自身を返す
     */
    public function setDateTime($dateTime)
    {
        if (($unixTime = strtotime($dateTime)) !== false) {

            $this->dateTime = $unixTime;
        }

        return $this;
    }

    /**
     * 日時を取得する
     *
     * 日時が未設定の場合は2038-01-09 03:14:07のunixタイムを返す
     *
     * @api
     * @param string|null $format date()関数に準ずる日付フォーマット、未指定時はunixタイムで返す
     * @return int|string|false 引数の日付フォーマットに従った形式の期限、もしくはunixタイム、日付フォーマットが間違っている場合は偽を返す
     */
    public function getDateTime($format = null)
    {
        if (is_null($this->dateTime)) {

            return mktime(3, 14, 7, 1, 9, 2038); // time_t型の最大値
        }

        if (is_null($format)) {

            return $this->dateTime;

        } else {

            return @date($format, $this->dateTime);
        }
    }
}
API documentation generated by ApiGen