Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ChecksIfConfigIsUpToDate
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 findOptions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Hyde\Framework\Actions;
4
5use Hyde\Framework\Contracts\ActionContract;
6use Hyde\Framework\Hyde;
7
8/**
9 * Checks if the installed config is up-to-date with the Framework's config.
10 * Works by comparing the number of title blocks, which is a crude but fast way to check.
11 *
12 * @see \Tests\Feature\Actions\ChecksIfConfigIsUpToDateTest
13 */
14class ChecksIfConfigIsUpToDate implements ActionContract
15{
16    public string $hydeConfig;
17    public string $frameworkConfig;
18
19    public function __construct()
20    {
21        $this->hydeConfig = file_get_contents(Hyde::path('config/hyde.php'));
22        $this->frameworkConfig = file_get_contents(Hyde::vendorPath('config/hyde.php'));
23    }
24
25    public function execute(): bool
26    {
27        return $this->findOptions($this->hydeConfig) === $this->findOptions($this->frameworkConfig);
28    }
29
30    public function findOptions(string $config): int
31    {
32        return substr_count($config, '--------------------------------------------------------------------------');
33    }
34}