Skip to content

Commit

Permalink
Get rid of methods using DispatchTask (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 authored and mrook committed Nov 12, 2018
1 parent 1816687 commit 1306320
Showing 1 changed file with 7 additions and 45 deletions.
52 changes: 7 additions & 45 deletions classes/phing/tasks/ext/StopwatchTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* <http://phing.info>.
*/

use Symfony\Component\Stopwatch\Stopwatch;

/**
* Stopwatch.
*
* @author Siad Ardroumli <siad.ardroumli@gmail.com>
* @package phing.tasks.ext.stopwatch
*/
class StopwatchTask extends Task
class StopwatchTask extends DispatchTask
{
/**
* Name of the timer.
Expand All @@ -40,13 +41,6 @@ class StopwatchTask extends Task
*/
private $category = '';

/**
* Timer action.
*
* @var string $action
*/
private $action = 'start';

/**
* Holds an instance of Stopwatch.
*
Expand All @@ -61,36 +55,22 @@ class StopwatchTask extends Task
*/
public function init()
{
}

/**
* Load stopwatch.
*
* @return void
*
* @throws BuildException
*/
private function loadStopwatch()
{
@include_once 'Symfony/Component/Stopwatch/autoload.php';
@include_once 'Symfony/Component/Stopwatch/autoloader.php';
@include_once 'vendor/autoload.php';

if (!class_exists('\\Symfony\\Component\\Stopwatch\\Stopwatch')) {
throw new BuildException("StopwatchTask requires symfony/stopwatch to be installed.");
}

$this->setAction('start');
}

/**
* Get the stopwatch instance.
*
* @return \Symfony\Component\Stopwatch\Stopwatch
* @return Stopwatch
*/
private function getStopwatchInstance()
{
if (self::$timer === null) {
$stopwatch = '\\Symfony\\Component\\Stopwatch\\Stopwatch';
self::$timer = new $stopwatch;
self::$timer = new Stopwatch();
}

return self::$timer;
Expand Down Expand Up @@ -165,22 +145,6 @@ public function setCategory($category)
$this->category = $category;
}

/**
* Set the action.
* Action could be one of
* - start
* - lap
* - stop
*
* @param string $action
*
* @return void
*/
public function setAction($action)
{
$this->action = $action;
}

/**
* The main entry point
*
Expand All @@ -190,9 +154,7 @@ public function setAction($action)
*/
public function main()
{
$this->loadStopwatch();

switch ($this->action) {
switch ($this->getAction()) {
case "start":
$this->start();
break;
Expand Down

0 comments on commit 1306320

Please sign in to comment.