Created
April 21, 2020 23:22
-
-
Save PJZ9n/5d262fd350598b8636e1a5ee4b12e744 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Copyright (c) 2020 NewCore. | |
* | |
* This file is part of NewCore. | |
* | |
* NewCore is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* NewCore is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with NewCore. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
declare(strict_types=1); | |
namespace NewCore\Utils\Chunk; | |
use InvalidArgumentException; | |
class ChunkInPos extends ChunkPos | |
{ | |
/** | |
* $numberが0-15であるか確かめる | |
* | |
* @param int $number | |
* | |
* @return bool | |
*/ | |
private static function isValidPos(int $number): bool | |
{ | |
if ($number < 0 || $number > 15) { | |
return false; | |
} | |
return true; | |
} | |
/** @var int */ | |
private $y; | |
/** | |
* ChunkInPos constructor. | |
* | |
* @param int $x | |
* @param int $y | |
* @param int $z | |
*/ | |
public function __construct(int $x, int $y, int $z) | |
{ | |
if (!self::isValidPos($x)) { | |
throw new InvalidArgumentException('$xは0-15である必要があります。'); | |
} | |
if (!self::isValidPos($z)) { | |
throw new InvalidArgumentException('$zは0-15である必要があります。'); | |
} | |
parent::__construct($x, $z); | |
$this->y = $y; | |
} | |
/** | |
* @inheritDoc | |
*/ | |
public function setX(int $x): void | |
{ | |
if (!self::isValidPos($x)) { | |
throw new InvalidArgumentException('$xは0-15である必要があります。'); | |
} | |
parent::setX($x); | |
} | |
/** | |
* @inheritDoc | |
*/ | |
public function setZ(int $z): void | |
{ | |
if (!self::isValidPos($z)) { | |
throw new InvalidArgumentException('$zは0-15である必要があります。'); | |
} | |
parent::setZ($z); | |
} | |
/** | |
* @param int $y | |
*/ | |
public function setY(int $y): void | |
{ | |
$this->y = $y; | |
} | |
/** | |
* @return int | |
*/ | |
public function getY(): int | |
{ | |
return $this->y; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment