Issues (33)

src/Traits/Attributes.php (2 issues)

1
<?php
2
3
namespace Bmatovu\Ussd\Traits;
4
5
use Bmatovu\Ussd\Support\Util;
6
7
trait Attributes
8
{
9 27
    public function readAttr(string $name, $default = '', ?\DOMNode $node = null)
10
    {
11 27
        if (! $node) {
12 27
            return $this->node->attributes->getNamedItem($name)->nodeValue ?? $default;
13
        }
14
15 2
        return $node->attributes->getNamedItem($name)->nodeValue ?? $default;
0 ignored issues
show
The method getNamedItem() does not exist on null. ( Ignorable by Annotation )

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

15
        return $node->attributes->/** @scrutinizer ignore-call */ getNamedItem($name)->nodeValue ?? $default;

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...
16
    }
17
18 15
    public function readAttrText(string $name = 'text', $default = '', ?\DOMNode $node = null)
19
    {
20 15
        $value = $this->readAttr($name, $default, $node);
21
22 15
        if (! $value) {
23 2
            return $value;
24
        }
25
26 14
        return Util::hydrate($this->store, trans($value));
0 ignored issues
show
trans($value) of type Illuminate\Translation\Translator is incompatible with the type string expected by parameter $text of Bmatovu\Ussd\Support\Util::hydrate(). ( Ignorable by Annotation )

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

26
        return Util::hydrate($this->store, /** @scrutinizer ignore-type */ trans($value));
Loading history...
27
    }
28
}
29