for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/** @noinspection PhpDocMissingThrowsInspection */
namespace Nip\Dispatcher\Commands\Traits;
/**
* Trait HasActionTrait
* @package Nip\Dispatcher\Commands\Traits
*/
trait HasActionTrait
{
protected $action = null;
* @return mixed
public function getAction()
return $this->action;
}
* @param mixed $action
public function setAction($action)
$this->action = $action;
* @return bool
public function hasAction()
if ($this->action === null) {
return false;
if (is_array($this->action)) {
if (!isset($this->action['action'])) {
return true;
* @param $name
* @param $value
* @return void
public function setActionParam($name, $value)
/** @noinspection PhpUnhandledExceptionInspection */
$this->guardActionAsArray();
$this->action[$name] = $value;
* @throws \Exception
public function getActionParam($name)
return isset($this->action[$name]) ? $this->action[$name] : null;
protected function guardActionAsArray()
if (!is_array($this->action) && $this->action !== null) {
throw new \Exception(
"Command Action is not an array, [" . print_r($this->action, true) . "]"
print_r($this->action, true)
string|true
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
"Command Action is not an array, [" . /** @scrutinizer ignore-type */ print_r($this->action, true) . "]"
);
* @return boolean
public function hasActionParam($name)
return isset($this->action[$name]);