src/Checks/CacheHeadersCheck.php
private function checkCacheControl(ResponseInterface $response)
    {
        $cacheControl = $response->getHeaderLine('Cache-Control');
        $vals = array_map('trim', explode(',', $cacheControl));
        $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);

        // All entries from must contain should be present
        if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
            $matched = implode(",", $this->mustInclude);
            $this->result->addMessage(
                "$fullURL includes all settings: {$matched}",
                ValidationResult::TYPE_GOOD
            );
        } else {
            $missing = implode(",", array_diff($this->mustInclude, $vals));
            $this->result->addError(
                "$fullURL is excluding some settings: {$missing}"
            );
        }

        // All entries from must exclude should not be present
        if (empty(array_intersect($this->mustExclude, $vals))) {
            $missing = implode(",", $this->mustExclude);
            $this->result->addMessage(
                "$fullURL excludes all settings: {$missing}",
                ValidationResult::TYPE_GOOD
            );
        } else {
            $matched = implode(",", array_intersect($this->mustExclude, $vals));
            $this->result->addError(
                "$fullURL is including some settings: {$matched}"
            );
        }
    }
private function checkCacheControl(ResponseInterface $response)
    {
        $cacheControl = $response->getHeaderLine('Cache-Control');
        $vals = array_map('trim', explode(',', $cacheControl));
        $fullURL = Controller::join_links(Director::absoluteBaseURL(), $this->url);

        // All entries from must contain should be present
        if ($this->mustInclude == array_intersect($this->mustInclude, $vals)) {
            $matched = implode(",", $this->mustInclude);
            $this->result->addMessage(
                "$fullURL includes all settings: {$matched}",
                ValidationResult::TYPE_GOOD
            );
        } else {
            $missing = implode(",", array_diff($this->mustInclude, $vals));
            $this->result->addError(
                "$fullURL is excluding some settings: {$missing}"
            );
        }

        // All entries from must exclude should not be present
        if (empty(array_intersect($this->mustExclude, $vals))) {
            $missing = implode(",", $this->mustExclude);
            $this->result->addMessage(
                "$fullURL excludes all settings: {$missing}",
                ValidationResult::TYPE_GOOD
            );
        } else {
            $matched = implode(",", array_intersect($this->mustExclude, $vals));
            $this->result->addError(
                "$fullURL is including some settings: {$matched}"
            );
        }
    }
private function checkCacheControl ( ResponseInterface $ response ) { $ cacheControl = $ response -> getHeaderLine ( 'Cache-Control' ) ; $ vals = array_map ( 'trim' , explode ( ',' , $ cacheControl ) ) ; $ fullURL = Controller :: join_links ( Director :: absoluteBaseURL ( ) , $ this -> url ) ; // All entries from must contain should be present if ( $ this -> mustInclude == array_intersect ( $ this -> mustInclude , $ vals ) ) { $ matched = implode ( "," , $ this -> mustInclude ) ; $ this -> result -> addMessage ( "$fullURL includes all settings: {$matched}" , ValidationResult :: TYPE_GOOD ) ; } else { $ missing = implode ( "," , array_diff ( $ this -> mustInclude , $ vals ) ) ; $ this -> result -> addError ( "$fullURL is excluding some settings: {$missing}" ) ; } // All entries from must exclude should not be present if ( empty ( array_intersect ( $ this -> mustExclude , $ vals ) ) ) { $ missing = implode ( "," , $ this -> mustExclude ) ; $ this -> result -> addMessage ( "$fullURL excludes all settings: {$missing}" , ValidationResult :: TYPE_GOOD ) ; } else { $ matched = implode ( "," , array_intersect ( $ this -> mustExclude , $ vals ) ) ; $ this -> result -> addError ( "$fullURL is including some settings: {$matched}" ) ; } }
Check that the correct header settings are either included or excluded.

@param ResponseInterface $response
@return void
Check that the correct header settings are either included or excluded .