MAPG-43 move existing interfaces into separate namespace

This commit is contained in:
Bence Pőcze 2020-05-28 00:27:35 +02:00
parent 17c0ec73df
commit 5738be5c98
6 changed files with 29 additions and 15 deletions

View File

@ -1,8 +0,0 @@
<?php namespace MapGuesser\Controller;
use MapGuesser\View\ViewBase;
interface ControllerInterface
{
public function run(): ViewBase;
}

View File

@ -1,12 +1,13 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use MapGuesser\Interfaces\Controller\IController;
use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Bounds;
use MapGuesser\View\HtmlView; use MapGuesser\View\HtmlView;
use MapGuesser\View\JsonView; use MapGuesser\View\JsonView;
use MapGuesser\View\ViewBase; use MapGuesser\Interfaces\View\IView;
use mysqli; use mysqli;
class GameController implements ControllerInterface class GameController implements IController
{ {
private mysqli $mysql; private mysqli $mysql;
@ -22,7 +23,7 @@ class GameController implements ControllerInterface
$this->jsonResponse = $jsonResponse; $this->jsonResponse = $jsonResponse;
} }
public function run(): ViewBase public function run(): IView
{ {
$bounds = $this->getMapBounds(); $bounds = $this->getMapBounds();

View File

@ -1,12 +1,13 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use MapGuesser\Interfaces\Controller\IController;
use MapGuesser\Util\Geo\Position; use MapGuesser\Util\Geo\Position;
use MapGuesser\View\JsonView; use MapGuesser\View\JsonView;
use MapGuesser\View\ViewBase; use MapGuesser\Interfaces\View\IView;
use mysqli; use mysqli;
use RestClient\Client; use RestClient\Client;
class PositionController implements ControllerInterface class PositionController implements IController
{ {
const NUMBER_OF_ROUNDS = 5; const NUMBER_OF_ROUNDS = 5;
const MAX_SCORE = 1000; const MAX_SCORE = 1000;
@ -21,7 +22,7 @@ class PositionController implements ControllerInterface
$this->mysql = new mysqli($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']); $this->mysql = new mysqli($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);
} }
public function run(): ViewBase public function run(): IView
{ {
if (!isset($_SESSION['state']) || $_SESSION['state']['mapId'] !== $this->mapId) { if (!isset($_SESSION['state']) || $_SESSION['state']['mapId'] !== $this->mapId) {
$data = ['error' => 'No valid session found!']; $data = ['error' => 'No valid session found!'];

View File

@ -0,0 +1,8 @@
<?php namespace MapGuesser\Interfaces\Controller;
use MapGuesser\Interfaces\View\IView;
interface IController
{
public function run(): IView;
}

View File

@ -0,0 +1,10 @@
<?php namespace MapGuesser\Interfaces\View;
interface IView
{
public function &getData(): array;
public function &render(): string;
public function getContentType(): string;
}

View File

@ -1,6 +1,8 @@
<?php namespace MapGuesser\View; <?php namespace MapGuesser\View;
abstract class ViewBase use MapGuesser\Interfaces\View\IView;
abstract class ViewBase implements IView
{ {
protected array $data; protected array $data;