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

Upload   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 15
rs 10
c 1
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
 * Upload.php
5
 *
6
 * Jaxon attribute.
7
 * Specifies an upload form field id.
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 Jaxon\Exception\SetupException;
20
use Attribute;
21
22
use function count;
23
24
#[Attribute(Attribute::TARGET_METHOD)]
25
class Upload extends AbstractAttribute
26
{
27
    /**
28
     * @param string $field The name of the upload field
29
     */
30
    public function __construct(private string $field)
31
    {}
32
33
    /**
34
     * @inheritDoc
35
     */
36
    public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void
37
    {
38
        $xMetadata->upload($sMethod)->setValue($this->field);
0 ignored issues
show
Bug introduced by
The method upload() 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

38
        $xMetadata->/** @scrutinizer ignore-call */ 
39
                    upload($sMethod)->setValue($this->field);

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...
39
    }
40
}
41