From dd5e6d2c32de64be57da3302cad76723868300b7 Mon Sep 17 00:00:00 2001 From: Mark Hester Date: Thu, 5 Jul 2018 19:03:02 +0100 Subject: [PATCH] Allow chaining of set and save method. Allows code to be set and saved, simplified to one line. ``` $repository->set('key', 'value')->save(); ``` --- src/Repository.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Repository.php b/src/Repository.php index 3cd1d28..f363f52 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -17,7 +17,22 @@ public function __construct($name) parent::__construct(Config::get($name, [])); } + + /** + * Return self to allow chain of set and save. + * + * @param array|string $key + * @param null $value + * + * @return $this + */ + public function set($key, $value = null) + { + parent::set($key, $value); + return $this; + } + public function save($from = null, $to = null, $validate = true) { if ($from === null) {