<commit_before><?php
/**
 * 
 * This file is part of Aura for PHP.
 * 
 * @package Aura.Web
 * 
 * @license http://opensource.org/licenses/bsd-license.php BSD
 * 
 */
namespace Aura\Web\Response;

use DateTime;
use DateTimeZone;
use Exception;

/**
 * 
 * Convenience methods related to HTTP caching.
 * 
 * @package Aura.Web
 * 
 * @todo Move (Age, Etag, Expires, Last-Modified) to Content object?
 * 
 */
class Cache
{
    /**
     * 
     * Cache-Control directives and values.
     * 
     * @var array
     * 
     */
    protected $control = array(
        'public' => false,
        'private' => false,
        'max-age' => null,
        's-maxage' => null,
        'no-cache' => false,
        'no-store' => false,
        'must-revalidate' => false,
        'proxy-revalidate' => false,
    );
    
    /**
     * 
     * The response headers.
     * 
     * @var Headers
     * 
     */
    protected $headers;
    
    /**
     * 
     * Constructor.
     * 
     * @param Headers $headers The response headers.
     * 
     */
    public function __construct(Headers $headers)
    {
        $this->headers = $headers;
    }
    
    /**
     * 
     * Disables HTTP caching.
     * 
     * @return null
     * 
     */
    public function disable()
    {
        $this->setAge(null);
        $this->setControl(array(
            'public' => false,
            'private' => false,
            'max-age' => 0,
            's-maxage' => null,
            'no-cache' => true,
            'no-store' => true,
            'must-revalidate' => true,
            'proxy-revalidate' => true,
        ));
        $this->setEtag(null);
        $this->setExpires(1);
        $this->setLastModified(null);
        $this->setVary(null);
    }
    
    /**
     * 
     * Resets caching headers to their original state (i.e., no caching
     * headers).
     * 
     * @return null<commit_msg>explicit date instead of just '1'<commit_after><?php
/**
 * 
 * This file is part of Aura for PHP.
 * 
 * @package Aura.Web
 * 
 * @license http://opensource.org/licenses/bsd-license.php BSD
 * 
 */
namespace Aura\Web\Response;

use DateTime;
use DateTimeZone;
use Exception;

/**
 * 
 * Convenience methods related to HTTP caching.
 * 
 * @package Aura.Web
 * 
 * @todo Move (Age, Etag, Expires, Last-Modified) to Content object?
 * 
 */
class Cache
{
    /**
     * 
     * Cache-Control directives and values.
     * 
     * @var array
     * 
     */
    protected $control = array(
        'public' => false,
        'private' => false,
        'max-age' => null,
        's-maxage' => null,
        'no-cache' => false,
        'no-store' => false,
        'must-revalidate' => false,
        'proxy-revalidate' => false,
    );
    
    /**
     * 
     * The response headers.
     * 
     * @var Headers
     * 
     */
    protected $headers;
    
    /**
     * 
     * Constructor.
     * 
     * @param Headers $headers The response headers.
     * 
     */
    public function __construct(Headers $headers)
    {
        $this->headers = $headers;
    }
    
    /**
     * 
     * Disables HTTP caching.
     * 
     * @return null
     * 
     */
    public function disable()
    {
        $this->setAge(null);
        $this->setControl(array(
            'public' => false,
            'private' => false,
            'max-age' => 0,
            's-maxage' => null,
            'no-cache' => true,
            'no-store' => true,
            'must-revalidate' => true,
            'proxy-revalidate' => true,
        ));
        $this->setEtag(null);
        $this->setExpires('Mon, 01 Jan 0001 00:00:00 GMT');
        $this->setLastModified(null);
        $this->setVary(null);
    }
    
    /**
     * 
     * Resets caching headers to their original state (i.e., no caching
     * headers).
     * 
     * @return null
{'fraction_non_alphanumeric': 0.1464751958224543, 'fraction_numerical': 0.004177545691906005, 'mean_word_length': 1.552298467688208, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '318396', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1203, 'n_words': 267}