-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework Stream readers and Sets to track stream properties
- Loading branch information
Showing
13 changed files
with
277 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
interface IStream { | ||
/** | ||
* @return IStreamProperties | ||
*/ | ||
function properties(): IStreamProperties; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
function stream(): string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
interface IStreamCollection { | ||
/** | ||
* Iterable collection read from the stream | ||
* | ||
* @return iterable | ||
*/ | ||
function collection(): iterable; | ||
|
||
/** | ||
* The original stream source for the collection | ||
* | ||
* @return IStream | ||
*/ | ||
function stream(): IStream; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
interface IStreamProperties { | ||
/** | ||
* Last modified timestamp of the stream | ||
* | ||
* @return int | ||
*/ | ||
function lastModifiedTimestamp(): int; | ||
|
||
/** | ||
* Count/length of the stream | ||
* | ||
* @return int | ||
*/ | ||
function length(): int; | ||
|
||
/** | ||
* Timestamp of the stream read event | ||
* | ||
* @return int | ||
*/ | ||
function readTimestamp(): int; | ||
|
||
/** | ||
* URI of the stream | ||
* | ||
* @return string | ||
*/ | ||
function uri(): string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
class Stream implements IStream { | ||
/** | ||
* @var IStreamProperties | ||
*/ | ||
protected IStreamProperties $_properties; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $_stream; | ||
|
||
public function __construct( | ||
string $_stream, | ||
IStreamProperties $_properties | ||
) { | ||
|
||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function properties(): IStreamProperties { | ||
return $this->_properties; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function stream(): string { | ||
return $this->_stream; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
class StreamCollection implements IStreamCollection { | ||
/** | ||
* @var IStream | ||
*/ | ||
protected IStream $_stream; | ||
|
||
/** | ||
* @var iterable | ||
*/ | ||
protected iterable $_collection; | ||
|
||
public function __construct( | ||
iterable $_collection, | ||
IStream $_stream | ||
) { | ||
$this->_collection = $_collection; | ||
$this->_stream = $_stream; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function collection(): iterable { | ||
return $this->_collection; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function stream(): IStream { | ||
return $this->_stream; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Kanopi\Components\Model\Data; | ||
|
||
class StreamProperties implements IStreamProperties { | ||
/** | ||
* @var int | ||
*/ | ||
protected int $_lastModifiedTimestamp; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected int $_length; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected int $_readTimestamp; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $_uri; | ||
|
||
/** | ||
* @param string $_uri | ||
* @param int $_lastModifiedTimestamp | ||
* @param int $_length | ||
* @param int $_readTimestamp | ||
*/ | ||
public function __construct( | ||
string $_uri, | ||
int $_lastModifiedTimestamp, | ||
int $_length, | ||
int $_readTimestamp | ||
) { | ||
$this->_length = $_length; | ||
$this->_lastModifiedTimestamp = $_lastModifiedTimestamp; | ||
$this->_readTimestamp = $_readTimestamp; | ||
$this->_uri = $_uri; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function lastModifiedTimestamp(): int { | ||
return $this->_lastModifiedTimestamp; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function length(): int { | ||
return $this->_length; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function readTimestamp(): int { | ||
return $this->_readTimestamp; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
function uri(): string { | ||
return $this->_uri; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
<?php | ||
/** | ||
* Reads an input stream into an iterable set | ||
* Reads an input stream into an iterable collection | ||
*/ | ||
|
||
namespace Kanopi\Components\Repositories; | ||
|
||
use Kanopi\Components\Model\Data\IStream; | ||
use Kanopi\Components\Model\Data\IStreamCollection; | ||
use Kanopi\Components\Model\Exception\SetStreamException; | ||
|
||
interface ISetStream { | ||
/** | ||
* Read an input stream value from a requested stream location | ||
* | ||
* @param string $_input_stream | ||
* @param IStream $_input_stream | ||
* | ||
* @throws SetStreamException | ||
* | ||
* @return iterable | ||
* @return IStreamCollection | ||
*/ | ||
function read( string $_input_stream ): iterable; | ||
function read( IStream $_input_stream ): IStreamCollection; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.