<commit_before><?php
/*
 * Lstr/Silex source code
 *
 * Copyright <NAME> <<EMAIL>>
 *
 * For copyright and licensing information, please view the LICENSE
 * that is distributed with this source code.
 */

namespace Lstr\Silex\Database;

use Lstr\YoPdo\Factory as YoPdoFactory;
use Silex\Application;

class DatabaseService
{
    private $app;
    private $config;

    private $yo_pdo;

    public function __construct(Application $app, array $config)
    {
        $this->app    = $app;
        $this->config = $config;
    }

    public function getPdo()
    {
        return $this->getYoPdo()->getPdo();
    }

    public function query($sql, array $params = array())
    {
        return $this->getYoPdo()->query($sql, $params);
    }

    public function queryMultiple($sql, array $params = array())
    {
        return $this->getYoPdo()->queryMultiple($sql, $params);
    }

    public function getLastInsertId($sequence_table = null)
    {
        return $this->getYoPdo()->getLastInsertId($sequence_table);
    }

    public function insert($tablename, array $values)
    {
        return $this->getYoPdo()->insert($tablename, $values);
    }

    public function update($tablename, array $set_cols, $where_sql, array $values)
    {
        return $this->getYoPdo()->update($tablename, $set_cols, $where_sql, $values);
    }

    private function getYoPdo()
    {
        if ($this->yo_pdo) {
            return $this->yo_pdo;
        }

        $factory = new YoPdoFactory();
        $this->yo_pdo = $factory->createFromConfig($this->config);

        return $this->yo_pdo;
    }
}<commit_msg>Add PHPdoc comments to DatabaseService<commit_after><?php
/*
 * Lstr/Silex source code
 *
 * Copyright <NAME> <<EMAIL>>
 *
 * For copyright and licensing information, please view the LICENSE
 * that is distributed with this source code.
 */

namespace Lstr\Silex\Database;

use Lstr\YoPdo\Factory as YoPdoFactory;
use Silex\Application;

class DatabaseService
{
    /**
     * @var Application
     */
    private $app;

    /**
     * @var array
     */
    private $config;

    /**
     * @var YoPdo
     */
    private $yo_pdo;

    /**
     * @param Application $app
     * @param array $config
     */
    public function __construct(Application $app, array $config)
    {
        $this->app    = $app;
        $this->config = $config;
    }

    /**
     * @return \PDO
     */
    public function getPdo()
    {
        return $this->getYoPdo()->getPdo();
    }

    /**
     * @param string $sql
     * @param array $params
     * @return \PDOStatement
     */
    public function query($sql, array $params = array())
    {
        return $this->getYoPdo()->query($sql, $params);
    }

    /**
     * @param string $sql
     * @param array $params
     * @return \PDOStatement
     */
    public function queryMultiple($sql, array $params = array())
    {
        return $this->getYoPdo()->queryMultiple($sql, $params);
    }

    /**
     * @param string $sequence_table
     * @return string
     */
    public function getLastInsertId($sequence_table = null)
    {
        return $this->getYoPdo()->getLastInsertId($sequence_table);
    }

    /**
     * @param string $tablename
     * @param array $values
     */
    public function insert($tablename, array $values)
    {
        return $this->getYoPdo()->insert($tablename, $values);
    }

    /**
     * @param string $tablename
     * @param array $set_cols
     * @param string $where_sql
     * @param array $values
     */
    public function update($tablename, array $set_cols, $where_sql, array $values)
    {
        return $this->getYoPdo()->update($tablename, $set_cols, $where_sql, $values);
    }

    /**
     * @return YoPdo
     */
    private function getYoPdo()
    {
        if ($this->yo_pdo) {
            return $this->yo_pdo;
        }

        $factory = new YoPdoFactory();
        $this->yo_pdo = $factory->createFromConfig($this->config);

        return $this->yo_pdo;
    }
}
{'fraction_non_alphanumeric': 0.13962264150943396, 'fraction_numerical': 0.0, 'mean_word_length': 2.3666384419983064, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 49, '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': '2640029', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1249, 'n_words': 285}