Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
5 / 5
AjaxStack
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 register
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
<?php
declare(strict_types=1);
namespace Korobochkin\WPKit\AlmostControllers;
/**
 * Class AjaxStack
 *
 * Handle AJAX requests.
 */
class AjaxStack extends Stack
{
    /**
     * @inheritdoc
     */
    public function register()
    {
        if (empty($this->actions)) {
            throw new \LogicException('You need set actions before call register method.');
        }
        add_action('wp_ajax_'.$this->actionName, array($this, 'handleRequest'));
        add_action('wp_ajax_nopriv_'.$this->actionName, array($this, 'handleRequest'));
        return $this;
    }
}