![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Stdlib/DateTime/Timezone/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Stdlib\DateTime\Timezone; use Magento\Framework\Exception\ValidatorException; use Magento\Framework\Phrase; /** * @api * @since 100.0.2 */ class Validator { /** * Maximum allowed year value * * @var int */ protected $_yearMaxValue; /** * Minimum allowed year value * * @var int */ protected $_yearMinValue; /** * @param int $yearMinValue * @param int $yearMaxValue */ public function __construct( $yearMinValue = \Magento\Framework\Stdlib\DateTime::YEAR_MIN_VALUE, $yearMaxValue = \Magento\Framework\Stdlib\DateTime::YEAR_MAX_VALUE ) { $this->_yearMaxValue = $yearMaxValue; $this->_yearMinValue = $yearMinValue; } /** * Validate timestamp * * @param int|string $timestamp * @param int|string $toDate * @return void * @throws \Magento\Framework\Exception\ValidatorException */ public function validate($timestamp, $toDate) { $transitionYear = date('Y', $timestamp); if ($transitionYear > $this->_yearMaxValue || $transitionYear < $this->_yearMinValue) { throw new ValidatorException( new Phrase( "The transition year isn't included in the system date range. " . "Verify the year date range and try again." ) ); } if ((int) $timestamp > (int) $toDate) { throw new ValidatorException( new Phrase('Transition year is out of specified date range.') ); } } }