Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
24 / 24
CRAP
100.00% covered (success)
100.00%
44 / 44
MetaBox
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
24 / 24
24
100.00% covered (success)
100.00%
44 / 44
 register
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
10 / 10
 lateConstruct
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setId
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getTitle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setTitle
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getView
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setView
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getScreen
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setScreen
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getContext
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setContext
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getPriority
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setPriority
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getFormFactory
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setFormFactory
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getForm
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setForm
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getFormEntity
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setFormEntity
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 handleRequest
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getRequest
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 setRequest
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 render
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
declare(strict_types=1);
namespace Korobochkin\WPKit\MetaBoxes;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
/**
 * Class AbstractMetaBox
 */
class MetaBox implements MetaBoxInterface
{
    /**
     * @var string Meta Box ID.
     */
    protected $id;
    /**
     * @var string Title of Meta Box.
     */
    protected $title;
    /**
     * @var MetaBoxViewInterface View instance.
     */
    protected $view;
    /**
     * @var string|string[] The screens list on which to show the box (such as a post type, 'link', or 'comment').
     */
    protected $screen;
    /**
     * @var string The context within the screen where the boxes should display.
     */
    protected $context;
    /**
     * @var string The priority within the context where the boxes should show ('high', 'low').
     */
    protected $priority = 'default';
    /**
     * @var FormFactoryInterface Form factory.
     */
    protected $formFactory;
    /**
     * @var FormInterface HTML Form.
     */
    protected $form;
    /**
     * @var object Form data.
     */
    protected $formEntity;
    /**
     * @var Request HTTP request.
     */
    protected $request;
    /**
     * @inheritdoc
     */
    public function register()
    {
        add_meta_box(
            $this->getId(),
            $this->getTitle(),
            array($this, 'render'),
            $this->getScreen(),
            $this->getContext(),
            $this->getPriority()
        );
        add_action('load-post-new.php', array($this, 'lateConstruct'));
        add_action('load-post.php', array($this, 'lateConstruct'));
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function lateConstruct()
    {
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getId()
    {
        return $this->id;
    }
    /**
     * @inheritdoc
     */
    public function setId($id)
    {
        $this->id = $id;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getTitle()
    {
        return $this->title;
    }
    /**
     * @inheritdoc
     */
    public function setTitle($title)
    {
        $this->title = $title;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getView()
    {
        return $this->view;
    }
    /**
     * @inheritdoc
     */
    public function setView($view)
    {
        $this->view = $view;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getScreen()
    {
        return $this->screen;
    }
    /**
     * @inheritdoc
     */
    public function setScreen($screen)
    {
        $this->screen = $screen;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getContext()
    {
        return $this->context;
    }
    /**
     * @inheritdoc
     */
    public function setContext($context)
    {
        $this->context = $context;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getPriority()
    {
        return $this->priority;
    }
    /**
     * @inheritdoc
     */
    public function setPriority($priority)
    {
        $this->priority = $priority;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getFormFactory()
    {
        return $this->formFactory;
    }
    /**
     * @inheritdoc
     */
    public function setFormFactory(FormFactoryInterface $formFactory)
    {
        $this->formFactory = $formFactory;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getForm()
    {
        return $this->form;
    }
    /**
     * @inheritdoc
     */
    public function setForm(FormInterface $form)
    {
        $this->form = $form;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function getFormEntity()
    {
        return $this->formEntity;
    }
    /**
     * @inheritdoc
     */
    public function setFormEntity($formEntity)
    {
        $this->formEntity = $formEntity;
        return $this;
    }
    /**
     * @inheritdoc
     */
    public function handleRequest()
    {
    }
    /**
     * @inheritdoc
     */
    public function getRequest()
    {
        return $this->request;
    }
    /**
     * @inheritdoc
     */
    public function setRequest(Request $request)
    {
        $this->request = $request;
        return $this;
    }
    public function render()
    {
        $this->getView()->render($this);
    }
}