From 904ffaf78a263e1842564dc6d6d7712ae59b583f Mon Sep 17 00:00:00 2001 From: inhere Date: Thu, 16 Jan 2020 23:24:32 +0800 Subject: [PATCH] update some for mem table --- src/MemFactory.php | 2 +- src/MemTable.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) 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; + } + } } /**