Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ResourceCustomActionResourceHeader
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 getFallbackText
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2namespace Apie\Core\Translator\ValueObjects;
3
4use Apie\Core\Attributes\Description;
5use Apie\Core\Attributes\ExampleValue;
6
7#[Description('Header shown on form for a domain specific action')]
8#[ExampleValue('apie.bounded.test.example.user.action.custom.1234.deactivate.header.authenticated')]
9class ResourceCustomActionResourceHeader extends AbstractTranslation
10{
11    protected const MIDDLE_REGEX = 'action\.custom\.:id\.:action\.header';
12
13    public function getFallbackText(): string
14    {
15        $resourceId = $this->getPlaceholders()['id'] ?? null;
16        $action = $this->getPlaceholders()['action'] ?? 'action';
17        
18        $suffix = $resourceId ? (' on ' . $resourceId) : '';
19        $id = $this->prefix->getResourceIdentifier();
20        if ($id) {
21            return $id . ' ' . $action . $suffix;
22        }
23        return ucfirst($action) . $suffix;
24    }
25}