Skip to content

Commit

Permalink
Renamed some interfaces and classes
Browse files Browse the repository at this point in the history
Removed not needed interface ObservesEvents
Added branch restriction to travis config
  • Loading branch information
hollodotme committed Sep 22, 2015
1 parent 0bbdd89 commit e05a5b5
Show file tree
Hide file tree
Showing 27 changed files with 162 additions and 194 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ php:
- 5.5
- 5.6

branches:
only:
- master
- development
- /^feature\/.+$/

before_script:
- git checkout $TRAVIS_BRANCH
- php build/tools/composer.phar install --prefer-dist -o --no-interaction
Expand Down
41 changes: 19 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,29 @@
* Restructured the project directories to fit best practice.

* Added PHP QA tools

* Added `getRawData()` method to `PostRequest`, serving the raw POST data (`php://input`).

* Removed the following methods from `DomainCommand` to avoid hard coded POST parameter names:
* `hasSuccessUrl()`
* `getSuccessUrl()`
* `hasFailUrl()`
* `getFailUrl()`

* Added the follwing protected methods to `DomainCommand` to give access to all POST request data:
* `getRequestData()` serves the whole POST request data array
* `getRequestRawData()` serves the raw post data (`php://input`)
* `getAllUploadedFiles()` serves all uploaded files as an assoc. array wrapped in `UploadedFileInfo` objects.
* `getUploadedFiles($key)` serves all uploaded files for a certain key as num. array wrapped in `UploadedFileInfo` objects.
* `getOneUploadedFile($key, $fileIndex = 0)` serves one uploaded file for a certain key and num. index wrapped in an `UploadedFileInfo` object. Or `NULL` if there is no file at `$key` and/or `$fileIndex`.

* `getAllUploadedFiles()` serves all uploaded files as an assoc. array wrapped in `UploadedFile` objects.
* `getUploadedFiles($key)` serves all uploaded files for a certain key as num. array wrapped in `UploadedFile` objects.
* `getOneUploadedFile($key, $fileIndex = 0)` serves one uploaded file for a certain key and num. index wrapped in an `UploadedFile` object. Or `NULL` if there is no file at `$key` and/or `$fileIndex`.
* Added the following protected methods to `DomainQuery` to give access to all GET request data:
* `getRequestData()` serves the whole GET request data array

* Removed `exit()` from `Unauthorized` response.

* Declared `SessionRegistry` as abstract.

* Added `InternalServerError` response class and HTTP code in `Http` class.
* Added the following methods to `RequestInfo` to access the basic auth data:
* `getAuthUser()`
* `getAuthPassword()`

* Removed hard coded default setup for error handling and session in `IceHawkDelegate`. Now these settings are based on the system's php defaults.

* Added more unit tests and clover code coverage.
* Declared `SessionRegistry` as abstract.

* Removed the following methods from `DomainCommand` to avoid hard coded POST parameter names:
* `hasSuccessUrl()`
* `getSuccessUrl()`
* `hasFailUrl()`
* `getFailUrl()`
* Removed `exit()` from `Unauthorized` response.
* Removed hard coded default setup for error handling and session in `IceHawkDelegate`. Now these settings are based on the system's php defaults.
* Removed internal class `RequestHandler` because it is obsolete.

* Method `IceHawk->init()` now checks the values served by the injected config object an can throw the following exceptions:
Expand All @@ -45,6 +37,11 @@
* `Fortuneglobe\IceHawk\Exceptions\InvalidDomainNamespace`
* `Fortuneglobe\IceHawk\Exceptions\InvalidEventListenerCollection`

* Renamed `ServesIceHawkConfig`'s `getProjectNamespace` to `getDomainNamespace`.
* Renamed method `getProjectNamespace` to `getDomainNamespace` in `ServesIceHawkConfig` and `IceHawkConfig`.
* Renamed interface `HandlesIceHawkTasks` to `ControlsHandlingBehaviour`
* Renamed interface `ListensToIceHawkEvents` to `ListensToEvents`
* Renamed interface `ServesIceHawkEventData` to `ServesEventData`
* Renamed interface `WrapsDataOfUploadedFile` to `ServesUploadedFileData`
* Renamed class `UploadedFileInfo` to `UploadedFile`

* Added `InternalServerError` response class and HTTP code in `Http` class.
* Completed unit tests.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contributions are **welcome** and will be fully **credited**.

We accept contributions via pull requests on [GitLab](http://gitlab.fortuneglobe.com/fortunesolutions/icehawk).
We accept contributions via pull requests on [GitHub](http://github.com/fortuneglobe/icehawk).


## Pull Requests
Expand Down
8 changes: 4 additions & 4 deletions src/DomainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Fortuneglobe\IceHawk;

use Fortuneglobe\IceHawk\Interfaces\ServesPostRequestData;
use Fortuneglobe\IceHawk\Interfaces\WrapsDataOfUploadedFile;
use Fortuneglobe\IceHawk\Interfaces\ServesUploadedFileData;

/**
* Class DomainCommand
Expand Down Expand Up @@ -55,7 +55,7 @@ protected function getRequestRawData()
}

/**
* @return array|WrapsDataOfUploadedFile[][]
* @return array|ServesUploadedFileData[][]
*/
protected function getAllUploadedFiles()
{
Expand All @@ -65,7 +65,7 @@ protected function getAllUploadedFiles()
/**
* @param string $key
*
* @return array|WrapsDataOfUploadedFile[]
* @return array|ServesUploadedFileData[]
*/
protected function getUploadedFiles( $key )
{
Expand All @@ -76,7 +76,7 @@ protected function getUploadedFiles( $key )
* @param string $key
* @param int $fileIndex
*
* @return WrapsDataOfUploadedFile|null
* @return ServesUploadedFileData|null
*/
protected function getOneUploadedFile( $key, $fileIndex = 0 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/Events/HandlingRequestEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Fortuneglobe\IceHawk\Events;

use Fortuneglobe\IceHawk\Interfaces\ServesEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesGetRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesPostRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestInfo;
Expand All @@ -17,7 +17,7 @@
*
* @package Fortuneglobe\IceHawk\Events
*/
final class HandlingRequestEvent implements ServesIceHawkEventData
final class HandlingRequestEvent implements ServesEventData
{

/** @var ServesRequestInfo */
Expand Down
4 changes: 2 additions & 2 deletions src/Events/IceHawkWasInitializedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

namespace Fortuneglobe\IceHawk\Events;

use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesEventData;

/**
* Class IceHawkWasInitializedEvent
*
* @package Fortuneglobe\IceHawk\Events
*/
final class IceHawkWasInitializedEvent implements ServesIceHawkEventData
final class IceHawkWasInitializedEvent implements ServesEventData
{

}
4 changes: 2 additions & 2 deletions src/Events/RequestWasHandledEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Fortuneglobe\IceHawk\Events;

use Fortuneglobe\IceHawk\Interfaces\ServesEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesGetRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesPostRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestInfo;
Expand All @@ -17,7 +17,7 @@
*
* @package Fortuneglobe\IceHawk\Events
*/
final class RequestWasHandledEvent implements ServesIceHawkEventData
final class RequestWasHandledEvent implements ServesEventData
{

/** @var ServesRequestInfo */
Expand Down
24 changes: 12 additions & 12 deletions src/IceHawk.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
use Fortuneglobe\IceHawk\Exceptions\InvalidUriResolverImplementation;
use Fortuneglobe\IceHawk\Exceptions\InvalidUriRewriterImplementation;
use Fortuneglobe\IceHawk\Exceptions\MalformedRequestUri;
use Fortuneglobe\IceHawk\Interfaces\ControlsHandlingBehaviour;
use Fortuneglobe\IceHawk\Interfaces\HandlesDomainRequests;
use Fortuneglobe\IceHawk\Interfaces\HandlesIceHawkTasks;
use Fortuneglobe\IceHawk\Interfaces\ListensToIceHawkEvents;
use Fortuneglobe\IceHawk\Interfaces\ListensToEvents;
use Fortuneglobe\IceHawk\Interfaces\ResolvesUri;
use Fortuneglobe\IceHawk\Interfaces\RewritesUri;
use Fortuneglobe\IceHawk\Interfaces\ServesEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkConfig;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkEventData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestData;
use Fortuneglobe\IceHawk\Interfaces\ServesRequestInfo;
use Fortuneglobe\IceHawk\Interfaces\ServesUriComponents;
Expand All @@ -44,20 +44,20 @@ final class IceHawk
/** @var string */
private $domainNamespace;

/** @var array|ListensToIceHawkEvents[] */
/** @var array|ListensToEvents[] */
private $eventListeners;

/** @var ServesRequestInfo */
private $requestInfo;

/** @var HandlesIceHawkTasks */
/** @var ControlsHandlingBehaviour */
private $delegate;

/**
* @param ServesIceHawkConfig $config
* @param HandlesIceHawkTasks $delegate
* @param ControlsHandlingBehaviour $delegate
*/
public function __construct( ServesIceHawkConfig $config, HandlesIceHawkTasks $delegate )
public function __construct( ServesIceHawkConfig $config, ControlsHandlingBehaviour $delegate )
{
$this->uriRewriter = $config->getUriRewriter();
$this->uriResolver = $config->getUriResolver();
Expand All @@ -76,8 +76,8 @@ public function __construct( ServesIceHawkConfig $config, HandlesIceHawkTasks $d
*/
public function init()
{
$this->delegate->configureErrorHandling();
$this->delegate->configureSession();
$this->delegate->setUpErrorHandling();
$this->delegate->setUpSessionHandling();

$this->guardConfigIsValid();

Expand Down Expand Up @@ -122,7 +122,7 @@ private function guardConfigIsValid()
{
foreach ( $this->eventListeners as $eventListener )
{
if ( !($eventListener instanceof ListensToIceHawkEvents) )
if ( !($eventListener instanceof ListensToEvents) )
{
throw new InvalidEventListenerCollection();
}
Expand All @@ -131,9 +131,9 @@ private function guardConfigIsValid()
}

/**
* @param ServesIceHawkEventData $event
* @param ServesEventData $event
*/
private function publishEvent( ServesIceHawkEventData $event )
private function publishEvent( ServesEventData $event )
{
foreach ( $this->eventListeners as $listener )
{
Expand Down
4 changes: 2 additions & 2 deletions src/IceHawkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Fortuneglobe\IceHawk;

use Fortuneglobe\IceHawk\Interfaces\ListensToIceHawkEvents;
use Fortuneglobe\IceHawk\Interfaces\ListensToEvents;
use Fortuneglobe\IceHawk\Interfaces\ResolvesUri;
use Fortuneglobe\IceHawk\Interfaces\RewritesUri;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkConfig;
Expand Down Expand Up @@ -43,7 +43,7 @@ public function getDomainNamespace()
}

/**
* @return array|ListensToIceHawkEvents[]
* @return array|ListensToEvents[]
*/
public function getEventListeners()
{
Expand Down
8 changes: 4 additions & 4 deletions src/IceHawkDelegate.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

namespace Fortuneglobe\IceHawk;

use Fortuneglobe\IceHawk\Interfaces\HandlesIceHawkTasks;
use Fortuneglobe\IceHawk\Interfaces\ControlsHandlingBehaviour;

/**
* Class IceHawkDelegate
*
* @package Fortuneglobe\IceHawk
*/
class IceHawkDelegate implements HandlesIceHawkTasks
class IceHawkDelegate implements ControlsHandlingBehaviour
{
public function configureSession()
public function setUpSessionHandling()
{
}

public function configureErrorHandling()
public function setUpErrorHandling()
{
}

Expand Down
16 changes: 8 additions & 8 deletions src/IceHawkEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@
namespace Fortuneglobe\IceHawk;

use Fortuneglobe\IceHawk\Exceptions\EventListenerMethodNotCallable;
use Fortuneglobe\IceHawk\Interfaces\ListensToIceHawkEvents;
use Fortuneglobe\IceHawk\Interfaces\ServesIceHawkEventData;
use Fortuneglobe\IceHawk\Interfaces\ListensToEvents;
use Fortuneglobe\IceHawk\Interfaces\ServesEventData;

/**
* Class IceHawkEventListener
* Class EventListener
*
* @package Fortuneglobe\IceHawk
*/
abstract class IceHawkEventListener implements ListensToIceHawkEvents
abstract class EventListener implements ListensToEvents
{
/**
* @param ServesIceHawkEventData $event
* @param ServesEventData $event
*
* @return bool
*/
public function acceptsEvent( ServesIceHawkEventData $event )
public function acceptsEvent( ServesEventData $event )
{
return in_array( get_class( $event ), $this->getAcceptedEvents() );
}

/**
* @param ServesIceHawkEventData $event
* @param ServesEventData $event
*
* @throws EventListenerMethodNotCallable
*/
public function notify( ServesIceHawkEventData $event )
public function notify( ServesEventData $event )
{
$namespaceComponents = explode( "\\", get_class( $event ) );
$methodName = sprintf( 'when%s', preg_replace( "#Event$#", '', end( $namespaceComponents ) ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
namespace Fortuneglobe\IceHawk\Interfaces;

/**
* Interface HandlesIceHawkTasks
* Interface ControlsHandlingBehaviour
*
* @package Fortuneglobe\IceHawk\Interfaces
*/
interface HandlesIceHawkTasks
interface ControlsHandlingBehaviour
{
public function configureSession();
public function setUpErrorHandling();

public function configureErrorHandling();
public function setUpSessionHandling();

/**
* @param \Exception $exception
Expand Down
32 changes: 32 additions & 0 deletions src/Interfaces/ListensToEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
*
* @author h.woltersdorf
*/

namespace Fortuneglobe\IceHawk\Interfaces;

/**
* Interface ListensToEvents
*
* @package Fortuneglobe\IceHawk\Interfaces
*/
interface ListensToEvents
{
/**
* @return array
*/
public function getAcceptedEvents();

/**
* @param ServesEventData $event
*
* @return bool
*/
public function acceptsEvent( ServesEventData $event );

/**
* @param ServesEventData $event
*/
public function notify( ServesEventData $event );
}

0 comments on commit e05a5b5

Please sign in to comment.