madlisp/src/Collection.php
2020-12-14 08:49:07 +07:00

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;
}
}