| @@ -41,9 +41,11 @@ | ||
| 41 | 41 | return self::getInstance()->scriptFilter->output(); | 
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | - public static function do() | |
| 44 | +    public static function do { | |
| 45 | + () | |
| 45 | 46 |      { | 
| 46 | 47 |          $action = getenv('timer_action'); | 
| 48 | + } | |
| 47 | 49 | |
| 48 | 50 |          if ($timerId = getenv('timer_id')) { | 
| 49 | 51 | return Timer::$action($timerId); | 
| @@ -146,6 +146,9 @@ | ||
| 146 | 146 |          return __NAMESPACE__ . "\\Menus\\" . (self::getMenuClassName(getenv('action')) ?: 'Entrance'); | 
| 147 | 147 | } | 
| 148 | 148 | |
| 149 | + /** | |
| 150 | + * @param string $action | |
| 151 | + */ | |
| 149 | 152 | private static function getMenuClassName($action) | 
| 150 | 153 |      { | 
| 151 | 154 |          return str_replace('_', '', ucwords($action === false ? 'entrance' : $action, '_')); | 
| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Godbout\Alfred\Time; | 
| 4 | 4 | |
| 5 | -use Godbout\Alfred\Workflow\Config; | |
| 6 | -use Godbout\Alfred\Time\Services\Toggl; | |
| 7 | 5 | use Godbout\Alfred\Time\Services\Harvest; | 
| 6 | +use Godbout\Alfred\Time\Services\Toggl; | |
| 7 | +use Godbout\Alfred\Workflow\Config; | |
| 8 | 8 | use Godbout\Alfred\Workflow\ScriptFilter; | 
| 9 | 9 | |
| 10 | 10 | class Workflow | 
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 |      { | 
| 23 | 23 | $serviceEnabled = Workflow::serviceEnabled(); | 
| 24 | 24 | |
| 25 | -        if (! $serviceEnabled) { | |
| 25 | +        if (!$serviceEnabled) { | |
| 26 | 26 | return; | 
| 27 | 27 | } | 
| 28 | 28 | |
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | |
| 46 | 46 | private static function startTimer() | 
| 47 | 47 |      { | 
| 48 | -        if (! empty(Workflow::serviceEnabled())) { | |
| 48 | +        if (!empty(Workflow::serviceEnabled())) { | |
| 49 | 49 | return Item::create() | 
| 50 | 50 |                  ->uid('start_timer') | 
| 51 | 51 |                  ->title('Start "' . self::userInput() . '"') | 
| @@ -103,6 +103,9 @@ | ||
| 103 | 103 | return false; | 
| 104 | 104 | } | 
| 105 | 105 | |
| 106 | + /** | |
| 107 | + * @return integer | |
| 108 | + */ | |
| 106 | 109 | public function runningTimer() | 
| 107 | 110 |      { | 
| 108 | 111 |          try { | 
| @@ -5,8 +5,8 @@ | ||
| 5 | 5 | use Carbon\Carbon; | 
| 6 | 6 | use Carbon\CarbonInterval; | 
| 7 | 7 | use Required\Harvest\Client; | 
| 8 | -use Required\Harvest\Exception\NotFoundException; | |
| 9 | 8 | use Required\Harvest\Exception\AuthenticationException; | 
| 9 | +use Required\Harvest\Exception\NotFoundException; | |
| 10 | 10 | use Required\Harvest\Exception\ValidationFailedException; | 
| 11 | 11 | |
| 12 | 12 | class Harvest extends TimerService | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 |                  'spent_date' => date('Y-m-d') | 
| 77 | 77 | ]); | 
| 78 | 78 | |
| 79 | -            if (! isset($timer['id'])) { | |
| 79 | +            if (!isset($timer['id'])) { | |
| 80 | 80 | return false; | 
| 81 | 81 | } | 
| 82 | 82 |          } catch (ValidationFailedException $e) { | 
| @@ -91,7 +91,7 @@ discard block | ||
| 91 | 91 |          if ($timerId = $this->runningTimer()) { | 
| 92 | 92 | $timer = $this->client->timeEntries()->stop($timerId); | 
| 93 | 93 | |
| 94 | -            if (! isset($timer['id'])) { | |
| 94 | +            if (!isset($timer['id'])) { | |
| 95 | 95 |                  throw new \Exception("Can't stop current running timer.", 1); | 
| 96 | 96 | |
| 97 | 97 | return false; | 
| @@ -79,6 +79,9 @@ discard block | ||
| 79 | 79 | return false; | 
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | + /** | |
| 83 | + * @return integer | |
| 84 | + */ | |
| 82 | 85 | public function runningTimer() | 
| 83 | 86 |      { | 
| 84 | 87 | $timer = $this->client->getRunningTimeEntry(); | 
| @@ -106,6 +109,9 @@ discard block | ||
| 106 | 109 | return true; | 
| 107 | 110 | } | 
| 108 | 111 | |
| 112 | + /** | |
| 113 | + * @param string $needle | |
| 114 | + */ | |
| 109 | 115 | private function extractFromData($needle) | 
| 110 | 116 |      { | 
| 111 | 117 | $data = $this->getData(); | 
| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Godbout\Alfred\Time\Services; | 
| 4 | 4 | |
| 5 | -use Exception; | |
| 6 | 5 | use Carbon\Carbon; | 
| 7 | 6 | use Carbon\CarbonInterval; | 
| 7 | +use Exception; | |
| 8 | 8 | use MorningTrain\TogglApi\TogglApi; | 
| 9 | 9 | |
| 10 | 10 | class Toggl extends TimerService | 
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 | 'created_with' => 'Alfred Time' | 
| 53 | 53 | ]); | 
| 54 | 54 | |
| 55 | -            if (! isset($timer->id)) { | |
| 55 | +            if (!isset($timer->id)) { | |
| 56 | 56 | return false; | 
| 57 | 57 | } | 
| 58 | 58 |          } catch (Exception $e) { | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 |          if ($timerId = $this->runningTimer()) { | 
| 68 | 68 | $response = $this->client->stopTimeEntry($timerId); | 
| 69 | 69 | |
| 70 | -            if (! isset($response->id)) { | |
| 70 | +            if (!isset($response->id)) { | |
| 71 | 71 |                  throw new Exception("Can't stop current running timer.", 1); | 
| 72 | 72 | |
| 73 | 73 | return false; | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 |      { | 
| 111 | 111 | $data = $this->getData(); | 
| 112 | 112 | |
| 113 | -        if (! isset($data->$needle)) { | |
| 113 | +        if (!isset($data->$needle)) { | |
| 114 | 114 | return []; | 
| 115 | 115 | } | 
| 116 | 116 | |
| @@ -131,7 +131,7 @@ discard block | ||
| 131 | 131 | private function filterOutServerwiseDeletedItemsFromData($items = []) | 
| 132 | 132 |      { | 
| 133 | 133 |          return array_filter($items, function ($item) { | 
| 134 | - return ! isset($item->server_deleted_at); | |
| 134 | + return !isset($item->server_deleted_at); | |
| 135 | 135 | }); | 
| 136 | 136 | } | 
| 137 | 137 | |
| @@ -35,8 +35,8 @@ | ||
| 35 | 35 | private static function credentialsFound() | 
| 36 | 36 |      { | 
| 37 | 37 | return ( | 
| 38 | -            ! empty(Workflow::getConfig()->read('harvest.api_token')) | |
| 39 | -            || ! empty(Workflow::getConfig()->read('harvest.account_id')) | |
| 38 | +            !empty(Workflow::getConfig()->read('harvest.api_token')) | |
| 39 | +            || !empty(Workflow::getConfig()->read('harvest.account_id')) | |
| 40 | 40 | ); | 
| 41 | 41 | } | 
| 42 | 42 | |
| @@ -42,7 +42,7 @@ | ||
| 42 | 42 | |
| 43 | 43 | protected static function stateSubtitle() | 
| 44 | 44 |      { | 
| 45 | - return (self::toEnable() ? 'Other services disabled. ': '') . 'You may press enter to quit the workflow'; | |
| 45 | + return (self::toEnable() ? 'Other services disabled. ' : '') . 'You may press enter to quit the workflow'; | |
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | 48 | private static function back() | 
| @@ -5,7 +5,9 @@ | ||
| 5 | 5 | use Godbout\Alfred\Time\Workflow; | 
| 6 | 6 | |
| 7 | 7 |  if (getenv('action') === 'do') { | 
| 8 | - $result = Workflow::do(); | |
| 8 | +    $result = Workflow::do { | |
| 9 | + (); | |
| 10 | + } | |
| 9 | 11 | |
| 10 | 12 |      if (getenv('timer_action') !== 'exit') { | 
| 11 | 13 | print Workflow::notify($result); |