Initial Version
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
interface IRange {
|
||||
|
||||
/**
|
||||
* Gets the type of this range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function type(): RangeType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
use DateTimeInterface;
|
||||
|
||||
interface IRangeDate extends IRange {
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getStart(): DateTimeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStart(DateTimeInterface $value): void;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEnd(): DateTimeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setEnd(DateTimeInterface $value): void;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
interface IRangeTally extends IRange {
|
||||
|
||||
/**
|
||||
* Gets the anchor type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAnchor(): RangeAnchorType;
|
||||
|
||||
/**
|
||||
* Sets the anchor type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setAnchor(RangeAnchorType $value): void;
|
||||
|
||||
/**
|
||||
* Gets the start position of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getPosition(): string|int;
|
||||
|
||||
/**
|
||||
* Sets the start position of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setPosition(string|int $value): void;
|
||||
|
||||
/**
|
||||
* Gets the count of items in the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTally(): int;
|
||||
|
||||
/**
|
||||
* Sets the count of items in the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTally(int $value): void;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
class Range implements IRange {
|
||||
|
||||
/**
|
||||
* Returns the type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function type(): RangeType {
|
||||
return RangeType::NONE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
enum RangeAnchorType: string {
|
||||
case RELATIVE = 'relative'; // A relative anchor is used to indicate a starting position based on a record identifier
|
||||
case ABSOLUTE = 'absolute'; // A absolute anchor is used to indicate a starting position based on record count
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
|
||||
class RangeDate extends Range implements IRangeDate {
|
||||
|
||||
protected DateTimeInterface $start;
|
||||
protected DateTimeInterface $end;
|
||||
|
||||
/**
|
||||
* Returns the type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function type(): RangeType {
|
||||
return RangeType::DATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start date of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getStart(): DateTimeInterface {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the start date of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStart(DateTimeInterface $value): void {
|
||||
$this->start = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the end date of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEnd(): DateTimeInterface {
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the end date of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setEnd(DateTimeInterface $value): void {
|
||||
$this->end = $value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
class RangeTally extends Range implements IRangeTally {
|
||||
|
||||
protected RangeAnchorType $anchor = RangeAnchorType::ABSOLUTE;
|
||||
protected string|int $position = 0;
|
||||
protected int $tally = 32;
|
||||
|
||||
/**
|
||||
* Returns the type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function type(): RangeType {
|
||||
return RangeType::TALLY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the anchor type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAnchor(): RangeAnchorType {
|
||||
return $this->anchor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the anchor type of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setAnchor(RangeAnchorType $value): void {
|
||||
$this->anchor = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the start position of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getPosition(): string|int {
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the start position of the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setPosition(string|int $value): void {
|
||||
$this->position = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the count of items in the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getTally(): int {
|
||||
return $this->tally;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the count of items in the range
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTally(int $value): void {
|
||||
$this->tally = $value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Resource\Range;
|
||||
|
||||
enum RangeType: string {
|
||||
case NONE = 'none';
|
||||
case DATE = 'date';
|
||||
case TALLY = 'tally';
|
||||
}
|
||||
Reference in New Issue
Block a user