public function spec($spec, $value = null)
    {
        $key = "$spec";
        if (array_key_exists($key, $this->spec)) {
            return $this->spec[$key]; // return since spec is already cached
        }
        // cache a spec
        if (!is_null($value)) {
            return $this->spec[$key] = $value;
        }

        if (is_string($spec)) {
            $spec = new CK\MARCspec\MARCspec($spec);
        }

        $this->spec[$key] = $spec;
        $cmp = $this->spec[$key]->__toString();
        if ($cmp !== $key) {
            $this->spec[$cmp] = $this->spec[$key];
        }

        return $this->spec[$key];
    }
public function spec($spec, $value = null)
    {
        $key = "$spec";
        if (array_key_exists($key, $this->spec)) {
            return $this->spec[$key]; // return since spec is already cached
        }
        // cache a spec
        if (!is_null($value)) {
            return $this->spec[$key] = $value;
        }

        if (is_string($spec)) {
            $spec = new CK\MARCspec\MARCspec($spec);
        }

        $this->spec[$key] = $spec;
        $cmp = $this->spec[$key]->__toString();
        if ($cmp !== $key) {
            $this->spec[$cmp] = $this->spec[$key];
        }

        return $this->spec[$key];
    }
public function spec ( $ spec , $ value = null ) { $ key = "$spec" ; if ( array_key_exists ( $ key , $ this -> spec ) ) { return $ this -> spec [ $ key ] ; // return since spec is already cached } // cache a spec if ( ! is_null ( $ value ) ) { return $ this -> spec [ $ key ] = $ value ; } if ( is_string ( $ spec ) ) { $ spec = new CK \ MARCspec \ MARCspec ( $ spec ) ; } $ this -> spec [ $ key ] = $ spec ; $ cmp = $ this -> spec [ $ key ] -> __toString ( ) ; if ( $ cmp !== $ key ) { $ this -> spec [ $ cmp ] = $ this -> spec [ $ key ] ; } return $ this -> spec [ $ key ] ; }
Cache a spec.

This is a cache control method for specs

@param string|MARCspecInterface|SubSpecInterface $spec  The spec to cache
@param bool|null                                 $value Validation result for a subspec

@return mixed Returns either a spec or a validation result
Cache a spec .