Skip to content

Commit

Permalink
Various Stream Fixes (#3)
Browse files Browse the repository at this point in the history
- Fix missing constructor assignments for the Stream
- Adjust the ExternalStreamSet to provide the entity count as the stream set length
  • Loading branch information
rleeson authored Jul 13, 2023
1 parent 5d73795 commit 6d87de1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/Model/Data/Stream/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ class Stream implements IStream {
*/
protected string $_stream;

/**
* Build a stream data entity
*
* @param string $_stream Stream content
* @param IStreamProperties $_properties Raw properties of the stream
*/
public function __construct(
string $_stream,
IStreamProperties $_properties
) {

$this->_properties = $_properties;
$this->_stream = $_stream;
}

/**
* @inheritDoc
*/
function properties(): IStreamProperties {
public function properties(): IStreamProperties {
return $this->_properties;
}

/**
* @inheritDoc
*/
function stream(): string {
public function stream(): string {
return $this->_stream;
}
}
9 changes: 7 additions & 2 deletions src/Services/External/ExternalStreamSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Kanopi\Components\Services\External;

use Kanopi\Components\Model\Data\Entities;
use Kanopi\Components\Model\Data\Stream\IStreamProperties;
use Kanopi\Components\Model\Data\Stream\{IStreamProperties,StreamProperties};
use Kanopi\Components\Model\Transform\IEntitySet;
use Kanopi\Components\Repositories\ISetStream;
use Kanopi\Components\Repositories\IStreamReader;
Expand Down Expand Up @@ -44,6 +44,11 @@ function readStream( string $_stream_path, IEntitySet $_transform ): IStreamProp
$streamCollection = $this->set_reader->read( $stream );
$this->entities = $_transform->transform( $streamCollection->collection() );

return $stream->properties();
return new StreamProperties(
$stream->properties()->uri(),
$stream->properties()->lastModifiedTimestamp(),
$this->entities->count(),
$stream->properties()->readTimestamp()
);
}
}

0 comments on commit 6d87de1

Please sign in to comment.