From 8350b6bd36d3a4bb3a99dfbf67e746f4f815927c Mon Sep 17 00:00:00 2001 From: Fbenas Date: Mon, 7 May 2018 15:02:39 +0100 Subject: Add some simple exception handling for bad inputs --- src/Script/Input.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Script/Input.php') diff --git a/src/Script/Input.php b/src/Script/Input.php index 4e437dd..772bb8c 100644 --- a/src/Script/Input.php +++ b/src/Script/Input.php @@ -63,6 +63,14 @@ class Input if ((array_key_exists('d', $this->options) <=> array_key_exists('t', $this->options)) !== 0) { throw new Exception('Both day and time options (`-d` and `-t`) are required for time based filtering'); } + + if (array_key_exists('c', $this->options) && !is_numeric($this->options['c'])) { + throw new Exception('Value for option `-c` must be an integer'); + } + + if (array_key_exists('l', $this->options) && is_numeric($this->options['l'])) { + throw new Exception('Value for option `-l` must be a string'); + } } /** -- cgit v1.2.3