Passed
Push — main ( f5b6ef...c06968 )
by Thierry
16:33 queued 05:42
created

Callback::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
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 Callback extends AbstractAttribute
23
{
24
    /**
25
     * @param string $name The javascript object 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->callback($sMethod)->addValue($this->name);
0 ignored issues
show
Bug introduced by
The method callback() does not exist on Jaxon\App\Metadata\Metadata. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $xMetadata->/** @scrutinizer ignore-call */ 
36
                    callback($sMethod)->addValue($this->name);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
    }
37
}
38