File: D:/HostingSpaces/SBogers10/inzigd.komma.pro/app/Komma/Kms/Core/Sequence/Parts/AbstractPart.php
<?php
namespace App\Komma\Kms\Core\Sequence\Parts;
/**
* Class abstractPart
*
* All Parts must extend this class
*
* @package App\Komma\Kms\Core\Sequence\Parts
*/
abstract class AbstractPart
{
/** @var string The current value of the part */
protected $currentValue = null;
/** @var string The value to start "nexting" from */
protected $startingAtValue = null;
/** @var string The name of the part */
protected $name = '';
/** @var string Must answer the question: Why did it overflow? When it did overflow*/
protected $overflownBecause = '';
/** @var int The length of the part in characters */
protected $length;
/**
* AbstractPart constructor.
*
* @param int $length
*/
public function __construct(int $length)
{
if($length == 0) throw new \InvalidArgumentException('AbstractPart: The length parameter must be bigger than 0. But 0 was given');
$this->length = $length;
}
/**
* Calculate the next value
*/
abstract public function next(): AbstractPart;
/**
* Initialize the part with (a part of) the given value.
*
* @param string $value
* @param bool $mayOverflow This value determines if the given value must be limited to the length of the part
* @return AbstractPart
*/
abstract public function startingAt(string $value, $mayOverflow = false): AbstractPart;
/**
* Return the current value of the part
*
* @return string
*/
abstract public function getValue():string;
/**
* Describes in human language what the part consists of.
* End the description with a dot, not followed by a space.
*
* @return string
*/
abstract public function describe():string;
/**
* Return the name of the part
*/
abstract public function getName():string;
/**
* @return string An indication on why this value overflowed. If it is an empty string, it did not overflow.
*/
public function overflownBecause(): string
{
return $this->overflownBecause;
}
}