1: <?php
2:
3: namespace Budabot\Core;
4:
5: use Exception;
6:
7: require_once 'SettingHandler.class.php';
8:
9: class NumberSettingHandler extends SettingHandler {
10:
11: public function __construct(DBRow $row) {
12: parent::__construct($row);
13: }
14:
15: 16: 17:
18: function getDescription() {
19: $msg = "For this setting you can set any positive integer.\n";
20: $msg .= "To change this setting: \n\n";
21: $msg .= "<highlight>/tell <myname> settings save {$this->row->name} <i>number</i><end>\n\n";
22: return $msg;
23: }
24:
25: 26: 27:
28: function save($newValue) {
29: if (preg_match("/^[0-9]+$/i", $newValue)) {
30: return $newValue;
31: } else {
32: throw new Exception("You must enter a positive integer for this setting.");
33: }
34: }
35: }
36: