Files
cachet-docker/app/Presenters/MetricPresenter.php
Laravel Shift 2d2c1d4df3 Adopt PSR-2 coding style
The Laravel framework adopts the PSR-2 coding style in version 5.1.
Laravel apps *should* adopt this coding style as well. Read the
[PSR-2 coding style guide][1] for more details and check out [PHPCS][2]
to use as a code formatting tool.

[1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
[2]: https://github.com/squizlabs/PHP_CodeSniffer
2016-10-19 07:53:09 +00:00

84 lines
1.9 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\Presenters;
use CachetHQ\Cachet\Presenters\Traits\TimestampsTrait;
use Illuminate\Contracts\Support\Arrayable;
use McCool\LaravelAutoPresenter\BasePresenter;
class MetricPresenter extends BasePresenter implements Arrayable
{
use TimestampsTrait;
/**
* Determines the metric view filter name.
*
* @return string
*/
public function view_name()
{
switch ($this->wrappedObject->default_view) {
case 0:
return 'last_hour';
case 1:
return 'today';
case 2:
return 'week';
case 3:
return 'month';
}
}
/**
* Determines the metric view filter name, used in the API.
*
* @return string
*/
public function default_view_name()
{
return trans('cachet.metrics.filter.'.$this->trans_string_name());
}
/**
* Determines the metric translation view filter name.
*
* @return string
*/
public function trans_string_name()
{
switch ($this->wrappedObject->default_view) {
case 0:
return 'last_hour';
case 1:
return 'hourly';
case 2:
return 'weekly';
case 3:
return 'monthly';
}
}
/**
* Convert the presenter instance to an array.
*
* @return string[]
*/
public function toArray()
{
return array_merge($this->wrappedObject->toArray(), [
'created_at' => $this->created_at(),
'updated_at' => $this->updated_at(),
'default_view_name' => $this->default_view_name(),
]);
}
}