Databag   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A saveValue() 0 3 1
A __construct() 0 2 1
1
<?php
2
3
/**
4
 * Databag.php
5
 *
6
 * Jaxon attribute.
7
 * Specifies a data bag stored in the browser and included in ajax requests to a method.
8
 *
9
 * @package jaxon-attributes
10
 * @author Thierry Feuzeu <[email protected]>
11
 * @copyright 2024 Thierry Feuzeu <[email protected]>
12
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
13
 * @link https://github.com/jaxon-php/jaxon-core
14
 */
15
16
namespace Jaxon\Attributes\Attribute;
17
18
use Jaxon\App\Metadata\Metadata;
19
use Attribute;
20
21
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
22
class Databag extends AbstractAttribute
23
{
24
    /**
25
     * @param string $name The data bag name
26
     */
27
    public function __construct(private string $name)
28
    {}
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
34
    {
35
        $xMetadata->databag($sMethod)->addValue($this->name);
36
    }
37
}
38