summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2021-02-10 18:58:35 +0100
committeremkael <emkael@tlen.pl>2021-02-10 18:58:35 +0100
commit934a81305857d49d1a3168d297a0436524887048 (patch)
tree47e54b4f2c79f209597201667e48833779a62a9f
parentd78f0e5763cc6d956ef19af9015b1d1be53c8f7a (diff)
Refactoring BridgeNET methods before alteration
-rw-r--r--http/api-inc.php32
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();
}