<?php

namespace app\cores\database;

class FaultDm extends Dm
{
    public function commit()
    {
        if (getenv('POC_FAIL_AI_COMMIT') === '1'
            && (string)$this->getConfig('prefix') === 'yoshop_') {
            $redis = new \Redis();
            $redis->connect((string)getenv('POC_REDIS_HOST'), (int)getenv('POC_REDIS_PORT'), 1.0);
            $redis->setex('poc:ai_commit_fault', 300, '1');
            throw new \RuntimeException('POC_AI_COMMIT_FAIL');
        }
        parent::commit();
    }
}
