Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
9 / 9
ModuleHook
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
9 / 9
 install
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
7 / 7
 getModules
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
<?php
namespace Entity;
class ModuleHook extends ModelBase
{
    protected function install()
    {
        $dbPrefix = $this->getDbPrefix();
        $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}modulehook` (
            `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
            `module_id` INTEGER(11) UNSIGNED NOT NULL,
            `hookName` VARCHAR(32) NOT NULL,
            `hookPosition` INTEGER(11) NOT NULL,
            FOREIGN KEY (`module_id`) REFERENCES `{$dbPrefix}module`(id),
            UNIQUE(`module_id`, `hookName`)
        )");
        if ($result === false)
            throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
        return true;
    }
    public static function getModules($moduleIds)
    {
        $fetcher = new self();
        return $fetcher->selects(array("module_id" => $moduleIds), array("hookName", "hookPosition"));
    }
}