public function attributes(array $names = null)
    {
        if (!$this->node instanceof DOMElement) {
            return null;
        }

        if ($names === null) {
            $result = [];

            foreach ($this->node->attributes as $name => $attribute) {
                $result[$name] = $attribute->value;
            }

            return $result;
        }

        $result = [];

        foreach ($this->node->attributes as $name => $attribute) {
            if (in_array($name, $names, true)) {
                $result[$name] = $attribute->value;
            }
        }

        return $result;
    }
public function attributes(array $names = null)
    {
        if (!$this->node instanceof DOMElement) {
            return null;
        }

        if ($names === null) {
            $result = [];

            foreach ($this->node->attributes as $name => $attribute) {
                $result[$name] = $attribute->value;
            }

            return $result;
        }

        $result = [];

        foreach ($this->node->attributes as $name => $attribute) {
            if (in_array($name, $names, true)) {
                $result[$name] = $attribute->value;
            }
        }

        return $result;
    }
public function attributes ( array $ names = null ) { if ( ! $ this -> node instanceof DOMElement ) { return null ; } if ( $ names === null ) { $ result = [ ] ; foreach ( $ this -> node -> attributes as $ name => $ attribute ) { $ result [ $ name ] = $ attribute -> value ; } return $ result ; } $ result = [ ] ; foreach ( $ this -> node -> attributes as $ name => $ attribute ) { if ( in_array ( $ name , $ names , true ) ) { $ result [ $ name ] = $ attribute -> value ; } } return $ result ; }
Returns the node attributes or null, if it is not DOMElement.

@param string[] $names

@return array|null
Returns the node attributes or null if it is not DOMElement .