for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Psi\Component\Grid;
use Symfony\Component\Form\FormView;
/**
* TODO: Tests for this class.
*/
final class RowData
{
private $object;
private $form;
private function __construct()
}
public static function fromObject($object): RowData
if (!is_object($object)) {
throw new \InvalidArgumentException(sprintf(
'Object must be an object, got: "%s"',
gettype($object)
));
$instance = new self();
$instance->object = $object;
return $instance;
public static function fromForm(FormView $form): RowData
$instance->form = $form;
$instance->object = $instance->getFormObject();
public function getForm(): FormView
if (!$this->form) {
throw new \InvalidArgumentException(
'No form was set on row data.'
);
return $this->form;
public function getObject()
return $this->object;
private function getFormObject()
if (!isset($this->form->vars['data'])) {
throw new \RuntimeException(sprintf(
'Expected "data" to be set on the form view. Actual view variables: "%s"',
implode('", "', array_keys($this->form->vars))
return $this->form->vars['data'];