Files
cachet/app/Repositories/Metric/AbstractMetricRepository.php
James Brooks 0c72e5eec8 Apply fixes from StyleCI (#2962)
[ci skip] [skip ci]
2018-03-26 19:18:30 +01:00

88 lines
1.7 KiB
PHP

<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Cachet\Repositories\Metric;
use CachetHQ\Cachet\Models\Metric;
use Illuminate\Contracts\Config\Repository;
/**
* This is the abstract metric repository class.
*
* @author Jams Brooks <james@alt-three.com>
*/
abstract class AbstractMetricRepository
{
/**
* The illuminate config repository.
*
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* The name of the metrics table.
*
* @var string
*/
protected $tableName;
/**
* Create a new abstract metric repository instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
*
* @return void
*/
public function __construct(Repository $config)
{
$this->config = $config;
}
/**
* Get the table names prefix.
*
* @return string
*/
protected function getPrefix()
{
$driver = $this->config->get('database.default');
$connection = $this->config->get('database.connections.'.$driver);
$prefix = $connection['prefix'];
return $prefix;
}
/**
* Get the metrics table name.
*
* @return string
*/
protected function getTableName()
{
$prefix = $this->getPrefix();
return $prefix.'metrics';
}
/**
* Get the metric points table name.
*
* @return string
*/
protected function getMetricPointsTableName()
{
$prefix = $this->getPrefix();
return $prefix.'metric_points';
}
}