madlisp/src/Collection.php

34 lines
580 B
PHP
Raw Normal View History

2020-05-28 04:55:58 +00:00
<?php
namespace MadLisp;
abstract class Collection
{
public static function new(array $data = []): self
{
// late static binding
return new static($data);
}
2020-05-28 04:55:58 +00:00
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;
}
}