From b94721b5b05ce532544b1e8df4d7d6b84c0d46f2 Mon Sep 17 00:00:00 2001 From: Andrew DalPino Date: Fri, 15 Nov 2019 21:43:24 -0600 Subject: [PATCH] Fixed bug in boot command bus --- src/RESTServer.php | 35 +++++++++++++++++------------------ src/RPCServer.php | 35 +++++++++++++++++------------------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/RESTServer.php b/src/RESTServer.php index 360e8b5..7bd1131 100644 --- a/src/RESTServer.php +++ b/src/RESTServer.php @@ -243,24 +243,23 @@ protected function bootCommandBus(Estimator $estimator) : CommandBus { $commands = []; - switch (true) { - case $estimator instanceof Estimator: - $commands[QueryModel::class] = new QueryModelHandler($estimator); - $commands[Predict::class] = new PredictHandler($estimator); - - // no break - case $estimator instanceof Learner: - $commands[PredictSample::class] = new PredictSampleHandler($estimator); - - // no break - case $estimator instanceof Probabilistic: - $commands[Proba::class] = new ProbaHandler($estimator); - $commands[ProbaSample::class] = new ProbaSampleHandler($estimator); - - // no break - case $estimator instanceof Ranking: - $commands[Rank::class] = new RankHandler($estimator); - $commands[RankSample::class] = new RankSampleHandler($estimator); + if ($estimator instanceof Estimator) { + $commands[QueryModel::class] = new QueryModelHandler($estimator); + $commands[Predict::class] = new PredictHandler($estimator); + } + + if ($estimator instanceof Learner) { + $commands[PredictSample::class] = new PredictSampleHandler($estimator); + } + + if ($estimator instanceof Probabilistic) { + $commands[Proba::class] = new ProbaHandler($estimator); + $commands[ProbaSample::class] = new ProbaSampleHandler($estimator); + } + + if ($estimator instanceof Ranking) { + $commands[Rank::class] = new RankHandler($estimator); + $commands[RankSample::class] = new RankSampleHandler($estimator); } if ($this instanceof Verbose) { diff --git a/src/RPCServer.php b/src/RPCServer.php index 016e0ed..6b6f1ef 100644 --- a/src/RPCServer.php +++ b/src/RPCServer.php @@ -228,24 +228,23 @@ protected function bootCommandBus(Estimator $estimator) : CommandBus { $commands = []; - switch (true) { - case $estimator instanceof Estimator: - $commands[QueryModel::class] = new QueryModelHandler($estimator); - $commands[Predict::class] = new PredictHandler($estimator); - - // no break - case $estimator instanceof Learner: - $commands[PredictSample::class] = new PredictSampleHandler($estimator); - - // no break - case $estimator instanceof Probabilistic: - $commands[Proba::class] = new ProbaHandler($estimator); - $commands[ProbaSample::class] = new ProbaSampleHandler($estimator); - - // no break - case $estimator instanceof Ranking: - $commands[Rank::class] = new RankHandler($estimator); - $commands[RankSample::class] = new RankSampleHandler($estimator); + if ($estimator instanceof Estimator) { + $commands[QueryModel::class] = new QueryModelHandler($estimator); + $commands[Predict::class] = new PredictHandler($estimator); + } + + if ($estimator instanceof Learner) { + $commands[PredictSample::class] = new PredictSampleHandler($estimator); + } + + if ($estimator instanceof Probabilistic) { + $commands[Proba::class] = new ProbaHandler($estimator); + $commands[ProbaSample::class] = new ProbaSampleHandler($estimator); + } + + if ($estimator instanceof Ranking) { + $commands[Rank::class] = new RankHandler($estimator); + $commands[RankSample::class] = new RankSampleHandler($estimator); } if ($this instanceof Verbose) {