Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 10
IDLReflectedAttributeCORS
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 10
 get
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 6
 set
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 4
<?php
declare( strict_types = 1 );
namespace Wikimedia\Dodo;
/**
 * Parent constructor in ReflectedAttribute is fine, no need to override
 * ReflectedAttribute exposes two protected values, $element and $attributeName
 */
class IDLReflectedAttributeCORS extends ReflectedAttribute {
    /**
     * @return string|null
     */
    public function get() {
        $v = $this->element->getAttribute( $this->attributeName );
        if ( $v === null ) {
            return null;
        }
        if ( strtolower( $v ) === 'use-credentials' ) {
            return 'use-credentials';
        }
        return 'anonymous';
    }
    /**
     * @param mixed $value
     */
    public function set( $value = null ) {
        if ( $value === null ) {
            $this->element->removeAttribute( $this->attributeName );
        } else {
            $this->element->setAttribute( $this->attributeName, $value );
        }
    }
}