mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
40 lines
683 B
PHP
40 lines
683 B
PHP
<?php
|
|
/**
|
|
* MadLisp language
|
|
* @link http://madlisp.com/
|
|
* @copyright Copyright (c) 2020 Pekka Laiho
|
|
*/
|
|
|
|
namespace MadLisp;
|
|
|
|
abstract class Collection
|
|
{
|
|
public static function new(array $data = []): self
|
|
{
|
|
// late static binding
|
|
return new static($data);
|
|
}
|
|
|
|
protected array $data = [];
|
|
|
|
public function __construct(array $data = [])
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return count($this->data);
|
|
}
|
|
|
|
public function has(string $key): bool
|
|
{
|
|
return array_key_exists($key, $this->data);
|
|
}
|
|
|
|
public function getData(): array
|
|
{
|
|
return $this->data;
|
|
}
|
|
}
|