diff --git a/src/MemFactory.php b/src/MemFactory.php index 93bbfc9..fb28d9d 100644 --- a/src/MemFactory.php +++ b/src/MemFactory.php @@ -17,7 +17,7 @@ final class MemFactory /** * @param string $name * @param int $size - * @param array $columns + * @param array $columns ['field' => ['type', 'size']] * * @return MemTable */ diff --git a/src/MemTable.php b/src/MemTable.php index b1f1823..d9908f1 100644 --- a/src/MemTable.php +++ b/src/MemTable.php @@ -19,6 +19,7 @@ use function file_get_contents; use function file_put_contents; use function json_encode; +use function property_exists; /** * Class MemTable - an simple memory table base on swoole table @@ -76,14 +77,19 @@ class MemTable * @param string $name * @param int $size * @param array $columns ['field' => ['type', 'size']] - * - * @throws InvalidArgumentException + * @param array $options */ - public function __construct(string $name = '', int $size = 0, array $columns = []) + public function __construct(string $name = '', int $size = 0, array $columns = [], array $options = []) { $this->setName($name); $this->setSize($size); $this->setColumns($columns); + + foreach ($options as $key => $value) { + if (property_exists($this, $key)) { + $this->$key = $value; + } + } } /**