Skip to content

Commit

Permalink
d
Browse files Browse the repository at this point in the history
  • Loading branch information
mondrake committed Jan 24, 2024
1 parent fcb9721 commit 46a54b8
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/ItemDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,57 @@ class ItemDefinition
*/
public function __construct(
public readonly CollectionInterface $collection,
protected int $format = DataFormat::BYTE,
protected int $valuesCount = 1,
protected int $dataOffset = 0,
protected int $itemDefinitionOffset = 0,
protected int $sequence = 0,
public readonly int $format = DataFormat::BYTE,
public readonly int $valuesCount = 1,
public readonly int $dataOffset = 0,
public readonly int $itemDefinitionOffset = 0,
public readonly int $sequence = 0,
) {
}

/**
* @deprecated
*/
public function getCollection(): CollectionInterface
{
return $this->collection;
}

/**
* @deprecated
*/
public function getFormat(): int
{
return $this->format;
}

/**
* @deprecated
*/
public function getValuesCount(): int
{
return $this->valuesCount;
}

/**
* @deprecated
*/
public function getDataOffset(): int
{
return $this->dataOffset;
}

/**
* @deprecated
*/
public function getItemDefinitionOffset(): int
{
return $this->itemDefinitionOffset;
}

/**
* @deprecated
*/
public function getSequence(): int
{
return $this->sequence;
Expand All @@ -69,7 +87,7 @@ public function getSequence(): int
*/
public function getSize(): int
{
return DataFormat::getSize($this->getFormat()) * $this->getValuesCount();
return DataFormat::getSize($this->format) * $this->valuesCount;
}

/**
Expand All @@ -81,18 +99,18 @@ public function getEntryClass(): string
// Return the specific entry class if defined, or fall back to
// default class for the format.
if (!$entry_class = $this->collection->getPropertyValue('entryClass')) {
if (empty($this->getFormat())) {
if (empty($this->format)) {
throw new MediaProbeException(
'No format can be derived for item: %s (%s)',
$this->collection->getPropertyValue('item') ?? 'n/a',
$this->collection->getPropertyValue('name') ?? 'n/a'
);
}

if (!$entry_class = DataFormat::getClass($this->getFormat())) {
if (!$entry_class = DataFormat::getClass($this->format)) {
throw new MediaProbeException(
'Unsupported format %d for item: %s (%s)',
$this->getFormat(),
$this->format,
$this->collection->getPropertyValue('item') ?? 'n/a',
$this->collection->getPropertyValue('name') ?? 'n/a'
);
Expand Down

0 comments on commit 46a54b8

Please sign in to comment.