diff options
author | emkael <emkael@tlen.pl> | 2021-02-10 18:58:35 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2021-02-10 18:58:35 +0100 |
commit | 934a81305857d49d1a3168d297a0436524887048 (patch) | |
tree | 47e54b4f2c79f209597201667e48833779a62a9f /http | |
parent | d78f0e5763cc6d956ef19af9015b1d1be53c8f7a (diff) |
Refactoring BridgeNET methods before alteration
Diffstat (limited to 'http')
-rw-r--r-- | http/api-inc.php | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/http/api-inc.php b/http/api-inc.php index 3163618..b9b9cb6 100644 --- a/http/api-inc.php +++ b/http/api-inc.php @@ -245,9 +245,22 @@ class ApiPkl { return $result; } + protected function _bridgenet_parameters() { + } + function calculate_bridgenet_points() { throw new ParametersException('BridgeNET points not supported in this API version'); } + + protected function _set_board_count() { + if (isset($this->parameters['boards'])) { + $this->check_values($this->parameters, array( + 'boards' => function($r) { return is_integer_like($r); } + )); + $this->parameters['over39_boards'] = strval(intval($this->parameters['boards'] > 39)); + } + } + } class ApiPklV1 extends ApiPkl {} @@ -268,22 +281,21 @@ class ApiPklV2 extends ApiPklV1 { class ApiPklV3 extends ApiPklV2 { + protected function _bridgenet_parameters() { + $this->ensure_parameters(array('boards', 'type')); + if ($this->parameters['type'] == 4) { + throw new ParametersException('Parameter: type has incorrect value (' . $this->parameters['type'] . ') for BridgeNET tournament'); + } + } + function check_parameters() { if (isset($this->parameters['tournament_rank']) && $this->parameters['tournament_rank'] == ApiPkl::RANK_BNET) { - $this->ensure_parameters(array('boards', 'type')); - if ($this->parameters['type'] == 4) { - throw new ParametersException('Parameter: type has incorrect value (' . $this->parameters['type'] . ') for BridgeNET tournament'); - } + $this->_bridgenet_parameters(); if (isset($this->parameters['manual'])) { unset($this->parameters['manual']); } } - if (isset($this->parameters['boards'])) { - $this->check_values($this->parameters, array( - 'boards' => function($r) { return is_integer_like($r); } - )); - $this->parameters['over39_boards'] = strval(intval($this->parameters['boards'] > 39)); - } + $this->_set_board_count(); return parent::check_parameters(); } |