<commit_before><?php
namespace pyd\testkit\fixtures;

use pyd\testkit\Manager as Testkit;
use pyd\testkit\base\TestCase;
use yii\base\InvalidCallException;

/**
 * A manage for the @see \pyd\testkit\DbTable instances required by a test case.
 *
 * @author pyd <<EMAIL>>
 */
class Db extends base\Db
{
    /**
     * @var pyd\testkit\Manager
     */
    protected $testkit;
    /**
     * @var boolean
     * @see \pyd\testkit\base\TestCase::$shareDbFixture
     */
    protected $testCaseShareDbFixture;
    /**
     * @var boolean the currently processed test case requires some db tables to
     * be loaded.
     */
    protected $testCaseRequireDb;

    /**
     * Get data from a @see $dbTableInstances instance.
     *
     * <code>
     * $userData = $fixtureDb->user;
     * // is a shortcut for
     * $userData = $this->dbFixture->getTable('user')->getData();
     * <code>
     *
     * @param string $name the alias of a @see $dbTableInstances instance
     * @throw UnknownPropertyException @see \yii\base\Object
     */
    public function __get($name)
    {
        if (array_key_exists($this->dbTableInstances[$name])) {
            return $this->dbTableInstances[$name]->getData();
        } else {
            parent::__get($name);
        }
    }

    /**
     * Get a model populated with data from a @see $dbTableInstances instance.
     *
     * <code>
     * $adminModel = $this->fixtureDb->user('admin', '\app\models\user\Admin');
     * // is a shortcut for
     * $adminModel = $this->fixtureDb->getDbTableInstance('user')->getModel('admin', '\app\models\user\Admin');
     * <code>
     *
     * @param string $name the alias of a @see $dbTableInstances instance
     * @param array $params the first value must be the alias of a data row. A
     * second value (optional) can be the class name of the returned model.
     * @return yii\db\ActiveRecord
     * @throws \yii\base\InvalidParamException $params[0] is not an existing data alias
     * @throws \yii\base\UnknownMethodException @see \yii\base\Object
     */
    public function __call($name, $params)
    {
        if (array_key_exists($name, $this->dbTableInstances)) {

            if (empty($params)) {
                throw new InvalidCallException("Missing argument 1 for pyd\\testkit\\fixtures\\DbTable::getModel()"
                        . " called via " . __METHOD__ . ". You must provide the alias of a data row to populate the '$name' model.");<commit_msg>Bugfix: Db::__get does not return the expected DbTable instance by name.<commit_after><?php
namespace pyd\testkit\fixtures;

use pyd\testkit\Manager as Testkit;
use pyd\testkit\base\TestCase;
use yii\base\InvalidCallException;

/**
 * A manage for the @see \pyd\testkit\DbTable instances required by a test case.
 *
 * @author pyd <<EMAIL>>
 */
class Db extends base\Db
{
    /**
     * @var pyd\testkit\Manager
     */
    protected $testkit;
    /**
     * @var boolean
     * @see \pyd\testkit\base\TestCase::$shareDbFixture
     */
    protected $testCaseShareDbFixture;
    /**
     * @var boolean the currently processed test case requires some db tables to
     * be loaded.
     */
    protected $testCaseRequireDb;

    /**
     * Get data from a @see $dbTableInstances instance.
     *
     * <code>
     * $userData = $fixtureDb->user;
     * // is a shortcut for
     * $userData = $this->dbFixture->getTable('user')->getData();
     * <code>
     *
     * @param string $name the alias of a @see $dbTableInstances instance
     * @throw UnknownPropertyException @see \yii\base\Object
     */
    public function __get($name)
    {
        if (array_key_exists($name, $this->dbTableInstances)) {
            return $this->dbTableInstances[$name]->getData();
        } else {
            parent::__get($name);
        }
    }

    /**
     * Get a model populated with data from a @see $dbTableInstances instance.
     *
     * <code>
     * $adminModel = $this->fixtureDb->user('admin', '\app\models\user\Admin');
     * // is a shortcut for
     * $adminModel = $this->fixtureDb->getDbTableInstance('user')->getModel('admin', '\app\models\user\Admin');
     * <code>
     *
     * @param string $name the alias of a @see $dbTableInstances instance
     * @param array $params the first value must be the alias of a data row. A
     * second value (optional) can be the class name of the returned model.
     * @return yii\db\ActiveRecord
     * @throws \yii\base\InvalidParamException $params[0] is not an existing data alias
     * @throws \yii\base\UnknownMethodException @see \yii\base\Object
     */
    public function __call($name, $params)
    {
        if (array_key_exists($name, $this->dbTableInstances)) {

            if (empty($params)) {
                throw new InvalidCallException("Missing argument 1 for pyd\\testkit\\fixtures\\DbTable::getModel()"
                        . " called via " . __METHOD__ . ". You must provide the alias of a data row to populate the '$name' model.");
{'fraction_non_alphanumeric': 0.1285973032803381, 'fraction_numerical': 0.0008049909438518816, 'mean_word_length': 2.542409123307199, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, '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': '766822', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1493, 'n_words': 418}