<commit_before><?php
/**
 * Default implementation for generic repository to do universal operations with data (CRUD).
 *
 * User: <NAME> <<EMAIL>>
 */

namespace Flancer32\Lib\Repo\Repo\Def;

use Flancer32\Lib\Data;

class  Generic
    extends \Flancer32\Lib\Repo\Repo\Def\Db
    implements \Flancer32\Lib\Repo\Repo\IGeneric
{

    public function addEntity($entity, $bind)
    {
        $result = null;
        $tbl = $this->_resource->getTableName($entity);
        if ($bind instanceof Data) {
            $data = (array)$bind->get();
        } else {
            $data = $bind;
        }
        $rowsAdded = $this->_conn->insert($tbl, $data);
        if ($rowsAdded) {
            $result = $this->_conn->lastInsertId($tbl);
        }
        return $result;
    }

    public function deleteEntity($entity, $where)
    {
        $tbl = $this->_resource->getTableName($entity);
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }

    /**
     * @inheritdoc
     *
     * @SuppressWarnings(PHPMD.ShortVariable)
     */
    public function deleteEntityById($entity, $id)
    {
        $tbl = $this->_resource->getTableName($entity);
        $where = [];
        foreach ($id as $field => $value) {
            $where["$field=?"] = $value;
        }
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }

    public function getEntities($entity, $cols = null, $where = null, $order = null, $limit = null, $offset = null)
    {
        $tbl = $this->_resource->getTableName($entity);
        $query = $this->_conn->select();
        if (is_null($cols)) {
            $cols = '*';
        }
        $query->from($tbl, $cols);
        if ($where) {
            $query->where($where);
        }
        if ($order) {
            $query->order($order);
        }
        if ($limit) {
            $query->limit($limit, $offset);
        }
        $result = $this->_conn->fetchAll($query);
        return $result;
    }
<commit_msg>Authenticate customer in session<commit_after><?php
/**
 * Default implementation for generic repository to do universal operations with data (CRUD).
 *
 * User: <NAME> <<EMAIL>>
 */

namespace Flancer32\Lib\Repo\Repo\Def;

use Flancer32\Lib\Data;

class  Generic
    extends \Flancer32\Lib\Repo\Repo\Def\Db
    implements \Flancer32\Lib\Repo\Repo\IGeneric
{

    public function addEntity($entity, $bind)
    {
        $result = null;
        $tbl = $this->_resource->getTableName($entity);
        if ($bind instanceof Data) {
            $data = (array)$bind->get();
        } else {
            $data = $bind;
        }
        $rowsAdded = $this->_conn->insert($tbl, $data);
        if ($rowsAdded) {
            $result = $this->_conn->lastInsertId($tbl);
        }
        return $result;
    }

    public function deleteEntity($entity, $where)
    {
        $tbl = $this->_resource->getTableName($entity);
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }

    /**
     * @inheritdoc
     *
     * @SuppressWarnings(PHPMD.ShortVariable)
     */
    public function deleteEntityById($entity, $id)
    {
        $tbl = $this->_resource->getTableName($entity);
        $where = [];
        foreach ($id as $field => $value) {
            $where["`$field`=?"] = $value;
        }
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }

    public function getEntities($entity, $cols = null, $where = null, $order = null, $limit = null, $offset = null)
    {
        $tbl = $this->_resource->getTableName($entity);
        $query = $this->_conn->select();
        if (is_null($cols)) {
            $cols = '*';
        }
        $query->from($tbl, $cols);
        if ($where) {
            $query->where($where);
        }
        if ($order) {
            $query->order($order);
        }
        if ($limit) {
            $query->limit($limit, $offset);
        }
        $result = $this->_conn->fetchAll($query);
        return $result;
    }

{'fraction_non_alphanumeric': 0.16729088639200998, 'fraction_numerical': 0.003995006242197253, 'mean_word_length': 2.01203007518797, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 61, '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': '3916368', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1233, 'n_words': 243}