Skip to content

Commit

Permalink
Convert Plugin\Runner from abstract class to interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed May 2, 2021
1 parent d79477e commit f377662
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 32 deletions.
57 changes: 27 additions & 30 deletions src/Plugin/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,50 @@
* @link https://github.com/captainhookphp/captainhook
* @since Class available since Release 5.9.0.
*/
abstract class Runner implements CaptainHook
interface Runner extends CaptainHook
{
/**
* @var Config
* Configure the runner plugin.
*
* @param Config $config
* @param IO $io
* @param Repository $repository
* @param Config\Plugin $plugin
* @return void
*/
protected $config;

/**
* @var IO
*/
protected $io;

/**
* @var Repository
*/
protected $repository;

/**
* @var Config\Plugin
*/
protected $plugin;

public function configure(Config $config, IO $io, Repository $repository, Config\Plugin $plugin): void
{
$this->config = $config;
$this->io = $io;
$this->repository = $repository;
$this->plugin = $plugin;
}
public function configure(Config $config, IO $io, Repository $repository, Config\Plugin $plugin): void;

/**
* Execute before all actions
*
* @param RunnerHook $hook
* @return void
*/
abstract public function beforeHook(RunnerHook $hook): void;
public function beforeHook(RunnerHook $hook): void;

/**
* Execute before each action
*
* @param RunnerHook $hook
* @param Config\Action $action
* @return void
*/
abstract public function beforeAction(RunnerHook $hook, Config\Action $action): void;
public function beforeAction(RunnerHook $hook, Config\Action $action): void;

/**
* Execute after each action
*
* @param RunnerHook $hook
* @param Config\Action $action
* @return void
*/
abstract public function afterAction(RunnerHook $hook, Config\Action $action): void;
public function afterAction(RunnerHook $hook, Config\Action $action): void;

/**
* Execute after all actions
*
* @param RunnerHook $hook
* @return void
*/
abstract public function afterHook(RunnerHook $hook): void;
public function afterHook(RunnerHook $hook): void;
}
56 changes: 56 additions & 0 deletions src/Plugin/Runner/Base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* This file is part of CaptainHook
*
* (c) Sebastian Feldmann <sf@sebastian-feldmann.info>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace CaptainHook\App\Plugin\Runner;

use CaptainHook\App\Config;
use CaptainHook\App\Console\IO;
use CaptainHook\App\Plugin;
use SebastianFeldmann\Git\Repository;

/**
* Base runner plugin abstract class
*
* @package CaptainHook
* @author Sebastian Feldmann <sf@sebastian-feldmann.info>
* @link https://github.com/captainhookphp/captainhook
* @since Class available since Release 5.9.0.
*/
abstract class Base implements Plugin\Runner
{
/**
* @var Config
*/
protected $config;

/**
* @var IO
*/
protected $io;

/**
* @var Repository
*/
protected $repository;

/**
* @var Config\Plugin
*/
protected $plugin;

public function configure(Config $config, IO $io, Repository $repository, Config\Plugin $plugin): void
{
$this->config = $config;
$this->io = $io;
$this->repository = $repository;
$this->plugin = $plugin;
}
}
2 changes: 1 addition & 1 deletion src/Plugin/Runner/PreserveWorkingTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @link https://github.com/captainhookphp/captainhook
* @since Class available since Release 5.9.0.
*/
class PreserveWorkingTree extends Plugin\Runner implements Plugin\CaptainHook
class PreserveWorkingTree extends Base implements Plugin\Runner
{
/**
* The name of the environment variable used to indicate the post-checkout
Expand Down
2 changes: 1 addition & 1 deletion tests/CaptainHook/Plugin/DummyRunnerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use CaptainHook\App\Config;
use CaptainHook\App\Runner\Hook as RunnerHook;

class DummyRunnerPlugin extends Runner
class DummyRunnerPlugin extends Runner\Base
{
public $beforeHookCalled = 0;
public $beforeActionCalled = 0;
Expand Down

0 comments on commit f377662

Please sign in to comment.