<commit_before><?php
/**
 * Created by PhpStorm.
 * User: Qoma
 * Date: 19/02/14
 * Time: 12:04
 */

namespace ZFS\DomainModel\Gateway;

use ZFS\DomainModel\Object\ObjectInterface;
use Zend\Db\TableGateway\TableGateway as BaseTableGateway;

/**
 * Class TableGateway
 * @package ZFS\DomainModel\Gateway
 */
class TableGateway extends BaseTableGateway
{
    /**
     * @param string|null $name
     *
     * @return int
     */
    public function getLastInsertValue($name = null)
    {
        return $this->adapter->getDriver()->getConnection()->getLastGeneratedValue($name);
    }

    /**
     * @param ObjectInterface $object
     *
     * @return int Affected rows amount
     */
    public function insertObject(ObjectInterface $object)
    {
        $insertResult = $this->insert($object->toArray());

        if ($insertResult) {
            $primary = $object->toArrayPrimary();

            foreach ($primary as $key => &$value) {
                $value = $this->getLastInsertValue($key);
            }

            $object->fromArray($primary);<commit_msg>initial<commit_after><?php
/**
 * Created by PhpStorm.
 * User: Qoma
 * Date: 19/02/14
 * Time: 12:04
 */

namespace ZFS\DomainModel\Gateway;

use ZFS\DomainModel\Object\ObjectInterface;
use Zend\Db\TableGateway\TableGateway as BaseTableGateway;

/**
 * Class TableGateway
 * @package ZFS\DomainModel\Gateway
 */
class TableGateway extends BaseTableGateway
{
    /**
     * @param string|null $name
     *
     * @return int
     */
    public function getLastInsertValue($name = null)
    {
        return $this->adapter->getDriver()->getConnection()->getLastGeneratedValue($name);
    }

    /**
     * @param ObjectInterface $object
     *
     * @return int Affected rows amount
     */
    public function insertObject(ObjectInterface $object)
    {
        $insertResult = $this->insert($object->toArray());

        if ($insertResult) {
            $primary = $object->toArrayPrimary();

            foreach ($primary as $key => &$value) {
                $value = $this->getLastInsertValue($key);
            }

            unset($value);

            $object->fromArray($primary);
{'fraction_non_alphanumeric': 0.13543599257884972, 'fraction_numerical': 0.00927643784786642, 'mean_word_length': 2.565289256198347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4926145', 'n_tokens_mistral': 640, 'n_tokens_neox': 627, 'n_words': 126}