41 lines
872 B
PHP
41 lines
872 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\BusProNet\Model;
|
|
|
|
/**
|
|
* Represents base data with item collection and retrieval functionality.
|
|
*
|
|
* This class provides a container for generic data items with methods
|
|
* to access the entire collection or individual items by key.
|
|
*/
|
|
class BaseData
|
|
{
|
|
public function __construct(private readonly array $items)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Retrieves all items in the base data collection.
|
|
*
|
|
* @return array The complete items array
|
|
*/
|
|
public function getItems(): array
|
|
{
|
|
return $this->items;
|
|
}
|
|
|
|
/**
|
|
* Retrieves a specific item by its key.
|
|
*
|
|
* @param string $key The key to search for
|
|
*
|
|
* @return mixed The item value or null if not found
|
|
*/
|
|
public function getItemByKey(string $key): mixed
|
|
{
|
|
return $this->items[$key] ?? null;
|
|
}
|
|
}
|