src/Producer.php
public function &produce($type, array $attributes = null, $save = true)
    {
        /** @var object|EntityInterface $object */
        $object = new $type($this->connection, $this->pool, $this->log);

        if ($object instanceof ContainerAccessInterface && $this->hasContainer()) {
            $object->setContainer($this->getContainer());
        }

        if ($attributes) {
            foreach ($attributes as $k => $v) {
                if ($object->fieldExists($k)) {
                    $object->setFieldValue($k, $v);
                } else {
                    $object->setAttribute($k, $v);
                }
            }
        }

        if ($save) {
            $object->save();
        }

        return $object;
    }
public function &produce($type, array $attributes = null, $save = true)
    {
        /** @var object|EntityInterface $object */
        $object = new $type($this->connection, $this->pool, $this->log);

        if ($object instanceof ContainerAccessInterface && $this->hasContainer()) {
            $object->setContainer($this->getContainer());
        }

        if ($attributes) {
            foreach ($attributes as $k => $v) {
                if ($object->fieldExists($k)) {
                    $object->setFieldValue($k, $v);
                } else {
                    $object->setAttribute($k, $v);
                }
            }
        }

        if ($save) {
            $object->save();
        }

        return $object;
    }
{@inheritdoc}