Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
HookContentRenderer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 render
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * Fast Forward Development Tools for PHP projects.
7 *
8 * This file is part of fast-forward/dev-tools project.
9 *
10 * @author   Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
11 * @license  https://opensource.org/licenses/MIT MIT License
12 *
13 * @see      https://github.com/php-fast-forward/
14 * @see      https://github.com/php-fast-forward/dev-tools
15 * @see      https://github.com/php-fast-forward/dev-tools/issues
16 * @see      https://php-fast-forward.github.io/dev-tools/
17 * @see      https://datatracker.ietf.org/doc/html/rfc2119
18 */
19
20namespace FastForward\DevTools\GitHooks;
21
22/**
23 * Renders packaged Git hooks with project-owned configuration paths.
24 */
25 class HookContentRenderer
26{
27    /**
28     * Placeholder replaced with the durable project-local GrumPHP config path.
29     */
30    public const string MANAGED_GRUMPHP_CONFIG_PLACEHOLDER = '__DEV_TOOLS_GRUMPHP_CONFIG__';
31
32    /**
33     * Renders the hook contents for the active DevTools runtime.
34     *
35     * @param string $contents the packaged hook contents
36     *
37     * @return string the rendered hook contents
38     */
39    public function render(string $contents): string
40    {
41        return str_replace(self::MANAGED_GRUMPHP_CONFIG_PLACEHOLDER, escapeshellarg('./grumphp.yml'), $contents);
42    }
43}