| 1 |
<?php |
| 2 |
/** |
| 3 |
* The pipeline dom modifier stage contract. |
| 4 |
* |
| 5 |
* Each modifier should implement this interface. |
| 6 |
* |
| 7 |
* @package SolidWP\Performance |
| 8 |
*/ |
| 9 |
|
| 10 |
declare( strict_types=1 ); |
| 11 |
|
| 12 |
namespace SolidWP\Performance\Dom\Contracts; |
| 13 |
|
| 14 |
use Closure; |
| 15 |
use SolidWP\Performance\Symfony\Component\DomCrawler\Crawler; |
| 16 |
|
| 17 |
/** |
| 18 |
* @internal |
| 19 |
*/ |
| 20 |
interface Modifier { |
| 21 |
|
| 22 |
/** |
| 23 |
* Whether this pipeline step is enabled. |
| 24 |
* |
| 25 |
* @return bool |
| 26 |
*/ |
| 27 |
public function is_enabled(): bool; |
| 28 |
|
| 29 |
/** |
| 30 |
* Allows us to first check all Modifiers via the Pipeline to see if any are enabled before proceeding |
| 31 |
* with DOM modification. |
| 32 |
* |
| 33 |
* Should immediately return true if this pipeline stage is enabled, otherwise |
| 34 |
* pass the current $enabled value to the next stage. |
| 35 |
* |
| 36 |
* @see self::is_enabled() |
| 37 |
* |
| 38 |
* @param bool $enabled Whether the previous stage is enabled. |
| 39 |
* @param Closure $next The closure passed to the next stage. |
| 40 |
* |
| 41 |
* @return bool |
| 42 |
*/ |
| 43 |
public function enabled( bool $enabled, Closure $next ): bool; |
| 44 |
|
| 45 |
/** |
| 46 |
* Handle modifying the HTML and passing it to the next stage of the pipeline, |
| 47 |
* assuming it's enabled. |
| 48 |
* |
| 49 |
* @param Crawler $crawler The symfony dom crawler instance. |
| 50 |
* @param Closure $next The closure passed to the next stage. |
| 51 |
* |
| 52 |
* @return Crawler |
| 53 |
*/ |
| 54 |
public function modify( Crawler $crawler, Closure $next ): Crawler; |
| 55 |
} |
| 56 |
|