. */ declare(strict_types=1); namespace FireflyIII\Transformers; use FireflyIII\Models\RuleGroup; use Log; /** * Class RuleGroupTransformer */ class RuleGroupTransformer extends AbstractTransformer { /** * RuleGroupTransformer constructor. * * @codeCoverageIgnore */ public function __construct() { if ('testing' === config('app.env')) { Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); } } /** * Transform the rule group * * @param RuleGroup $ruleGroup * * @return array */ public function transform(RuleGroup $ruleGroup): array { $data = [ 'id' => (int)$ruleGroup->id, 'created_at' => $ruleGroup->created_at->toAtomString(), 'updated_at' => $ruleGroup->updated_at->toAtomString(), 'title' => $ruleGroup->title, 'description' => $ruleGroup->description, 'order' => $ruleGroup->order, 'active' => $ruleGroup->active, 'links' => [ [ 'rel' => 'self', 'uri' => '/rule_groups/' . $ruleGroup->id, ], ], ]; return $data; } }