1<?php
2
3
4namespace ComboStrap;
5
6/**
7 * Interface CompiledDocument
8 * @package ComboStrap
9 * A document that is generated and where
10 * the output may be stored in the cache
11 */
12interface CachedDocument
13{
14
15
16    /**
17     * Execute the transformation process
18     *   * from one format to another
19     *   * optimization
20     * And stores the output in the {@link PageCompilerDocument::getCachePath() cache file}
21     * if the cache is enabled
22     * @return mixed - the object
23     */
24    public function process();
25
26    /**
27     * @return LocalPath - the path where the generated content is stored
28     */
29    public function getCachePath(): LocalPath;
30
31    /**
32     * @return bool true if the {@link CachedDocument::process() compilation} should occurs
33     *
34     * For instance:
35     *   * if the output cache file is stale: The most obvious reason would be that the source file has changed but change in configuration may also stale output file
36     *   * True if the cache page does not exist
37     *   * True if the cache is not allowed
38     *
39     */
40    public function shouldProcess(): bool;
41
42    /**
43     * @return mixed - a simple method to get the cache content
44     * or process it and get it in once
45     */
46    public function getOrProcessContent();
47
48    /**
49     * @return mixed - a simple method to get the content
50     */
51    public function getContent();
52
53    /**
54     * @return mixed - store the processed content on disk
55     */
56    public function storeContent($content);
57
58    /**
59     * @return string - the file extension / format
60     * For instance:
61     *   * "xhtml" for an html document
62     *   * "svg" for an svg document
63     */
64    function getExtension(): string;
65
66}
67