Completed
Push — master ( f49e02...f705ca )
by Johnny
02:06
created

src/Resolver.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redbox\DNS;
3
4
class Resolver extends Reflectable
5
{
6
    /**
7
     * Resolver constructor.
8
     */
9 16
    public function __construct()
10
    {
11 16
        $this->DNS       = [];
0 ignored issues
show
The property DNS does not exist on object<Redbox\DNS\Resolver>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
12 16
    }
13
14
    /**
15
     * @param string $domain
16
     * @param int $type
17
     * @return bool
18
     */
19 16
    public function resolve($domain = '', $type = DNS_ANY)
20
    {
21 16
        if (empty($domain))
22 16
            return false;
23
24 12
        $this->clear();
25
26 12
        $result = dns_get_record($domain, $type);
27
28 12
        if (empty($result) || $result === false) {
29 4
            return false;
30
        }
31
32 8
        $this->DNS = $result;
0 ignored issues
show
The property DNS does not exist on object<Redbox\DNS\Resolver>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
33 8
        return true;
34
    }
35
36
}