<commit_before><?php
declare(strict_types=1);

namespace DiContainerBenchmarks\OutputGenerator;

use DiContainerBenchmarks\Benchmark\BenchmarkResult;
use DiContainerBenchmarks\Container\ContainerInterface;
use DiContainerBenchmarks\TestSuite\TestSuiteInterface;
use PackageVersions\Versions;

class HtmlOutputGenerator implements OutputGeneratorInterface
{
    /**
     * @var string
     */
    private $path;

    public function __construct(string $path)
    {
        $this->path = $path;
    }

    /**
     * @param TestSuiteInterface[] $testSuites
     * @param ContainerInterface[] $containers
     */
    public function generateOutput(array $testSuites, array $containers, BenchmarkResult $benchmarkResult): void
    {
        $now = date("Y-m-d H:i:s");

        $html = <<<HERE
<html lang="en">
<head>
    <title>DI Container Benchmark Results</title>
    <meta name="description" content="DI Container Benchmark Results for PHP">
    <meta name="keywords" content="PHP, Dependency Injection Container benchmark">
    <meta charset="utf-8">
    <style>
        table,p {
            width: 750px;
        }
    </style>
</head>
<body>
    <article>
        <h1>DI Container Benchmark</h1>
        <table>
            <tr>
                <td style="width: 85px;"><b>Author:</b></td><td><NAME> (<a target="_blank" href="https://twitter.com/kocsismate90">@kocsismate90</a>)</td>
            </tr>
            <tr>
                <td><b>Repository:</b></td><td><a target="_blank" href="https://github.com/kocsismate/php-di-container-benchmarks">https://github.com/kocsismate/php-di-container-benchmarks</a></td>
            </tr>
            <tr>
                <td><b>Generated:</b></td><td>$now</td>
            </tr>
        </table>

        <hr>
        <section>
            <h2>Table of Contents</h2>

            <nav>
                <ul>
                    <li><a href="#introduction">Introduction</a></li>
                    <li><a href="#method">Method</a></li>
                    <li><a href="#results">Results</a></li>
                    <li><a href="#conclusion">Conclusion</a></li>
                </ul>
            </nav>
        </section>

        <hr>
        <section>
            <h2 id="introduction">Introduction</h2>
            <p>
                In 2014, a really interesting benchmark about DI Containers for PHP was
                <a target="_blank" href="https://www.sitepoint.com/php-dependency-injection-container-performance-benchmarks/">published</a>
                on Sitepoint. Unfortunately, <a target="_blank" href="https://github.com/TomBZombie/php-dependency-injection-benchmarks">the implementation</a>
                of the tests turned out to be quite controversial, so the benchmark itself wasn't very insightful.
            </p>

            <p>
                
                I have been interested in the topic since then - and my curiosity was just growing after I had started
                to develop my own DI container, Zen - so I wanted to finally conduct a better benchmark than the last
                one was: I tried to fix its flaws while keeping its many good parts. So here is my take! If you have any
                suggestion in mind about the benchmark or you want to add your container to the list, please create an
                an <a target="_blank" href="https://github.com/kocsismate/php-di-container-benchmarks">issue or a Pull Request</a>.
            </p>

            <p>
                The examined containers are listed below along with some of their attributes:
            </p>

            <table border="1" style="width: 750px;">
                <thead>
                    <tr>
                        <th style="width: 300px;">Name</th>
                        <th style="width: 100px;">Version</th>
                        <th style="width: 175px;">Compiled/Dynamic</th>
                        <th style="width: 175px;">Autowiring</th>
                    </tr>
                </thead>
                <tbody>
HERE;
        foreach ($containers as $i => $container) {
            /** @var ContainerInterface $container */
            $name = $container->getPackage();
            $version = Versions::getVersion($container->getPackage());
            $displayedVersion = substr($version, 0, strpos($version, "@"));
            $url = $container->getUrl();
            $compiled = $container->isCompiled() ? "compiled" : "dynamic";
            $autowiring = $container->isAutowiringSupported() ? "supported" : "not supported";

            $html .= <<<HERE
                    <tr>
                        <td>
                            <a target="_blank" href="$url" style="display:block;width:240px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
                                <b>$name</b>
                            </a>
                        </td>
                        <td>$displayedVersion</td>
                        <td>$compiled</td>
                        <td>$autowiring</td>
                    </tr>
HERE;
        }

        $html .= <<<HERE
                </tbody>
            </table>

            <p>
                I'll try to give a vague definition below for some of the aforementioned notions:
            </p>

            <p>
                A DI Container is <i>compiled</i> if it can be generated into a new class for production usage
                from where container entries then can be fetched. It means that your dependency graph is resolved
                during build time. This technique usually results in a very fast DIC, because there is no need for any<commit_msg>Updated formatting of package name<commit_after><?php
declare(strict_types=1);

namespace DiContainerBenchmarks\OutputGenerator;

use DiContainerBenchmarks\Benchmark\BenchmarkResult;
use DiContainerBenchmarks\Container\ContainerInterface;
use DiContainerBenchmarks\TestSuite\TestSuiteInterface;
use PackageVersions\Versions;

class HtmlOutputGenerator implements OutputGeneratorInterface
{
    /**
     * @var string
     */
    private $path;

    public function __construct(string $path)
    {
        $this->path = $path;
    }

    /**
     * @param TestSuiteInterface[] $testSuites
     * @param ContainerInterface[] $containers
     */
    public function generateOutput(array $testSuites, array $containers, BenchmarkResult $benchmarkResult): void
    {
        $now = date("Y-m-d H:i:s");

        $html = <<<HERE
<html lang="en">
<head>
    <title>DI Container Benchmark Results</title>
    <meta name="description" content="DI Container Benchmark Results for PHP">
    <meta name="keywords" content="PHP, Dependency Injection Container benchmark">
    <meta charset="utf-8">
    <style>
        table,p {
            width: 750px;
        }
    </style>
</head>
<body>
    <article>
        <h1>DI Container Benchmark</h1>
        <table>
            <tr>
                <td style="width: 85px;"><b>Author:</b></td><td><NAME> (<a target="_blank" href="https://twitter.com/kocsismate90">@kocsismate90</a>)</td>
            </tr>
            <tr>
                <td><b>Repository:</b></td><td><a target="_blank" href="https://github.com/kocsismate/php-di-container-benchmarks">https://github.com/kocsismate/php-di-container-benchmarks</a></td>
            </tr>
            <tr>
                <td><b>Generated:</b></td><td>$now</td>
            </tr>
        </table>

        <hr>
        <section>
            <h2>Table of Contents</h2>

            <nav>
                <ul>
                    <li><a href="#introduction">Introduction</a></li>
                    <li><a href="#method">Method</a></li>
                    <li><a href="#results">Results</a></li>
                    <li><a href="#conclusion">Conclusion</a></li>
                </ul>
            </nav>
        </section>

        <hr>
        <section>
            <h2 id="introduction">Introduction</h2>
            <p>
                In 2014, a really interesting benchmark about DI Containers for PHP was
                <a target="_blank" href="https://www.sitepoint.com/php-dependency-injection-container-performance-benchmarks/">published</a>
                on Sitepoint. Unfortunately, <a target="_blank" href="https://github.com/TomBZombie/php-dependency-injection-benchmarks">the implementation</a>
                of the tests turned out to be quite controversial, so the benchmark itself wasn't very insightful.
            </p>

            <p>
                
                I have been interested in the topic since then - and my curiosity was just growing after I had started
                to develop my own DI container, Zen - so I wanted to finally conduct a better benchmark than the last
                one was: I tried to fix its flaws while keeping its many good parts. So here is my take! If you have any
                suggestion in mind about the benchmark or you want to add your container to the list, please create an
                an <a target="_blank" href="https://github.com/kocsismate/php-di-container-benchmarks">issue or a Pull Request</a>.
            </p>

            <p>
                The examined containers are listed below along with some of their attributes:
            </p>

            <table border="1" style="width: 750px;">
                <thead>
                    <tr>
                        <th style="width: 300px;">Name</th>
                        <th style="width: 100px;">Version</th>
                        <th style="width: 175px;">Compiled/Dynamic</th>
                        <th style="width: 175px;">Autowiring</th>
                    </tr>
                </thead>
                <tbody>
HERE;
        foreach ($containers as $i => $container) {
            /** @var ContainerInterface $container */
            $package = $container->getPackage();
            $version = Versions::getVersion($container->getPackage());
            $displayedVersion = substr($version, 0, strpos($version, "@"));
            $url = $container->getUrl();
            $compiled = $container->isCompiled() ? "compiled" : "dynamic";
            $autowiring = $container->isAutowiringSupported() ? "supported" : "not supported";

            $html .= <<<HERE
                    <tr>
                        <td><a target="_blank" href="$url"><b>$package</b></a></td>
                        <td>$displayedVersion</td>
                        <td>$compiled</td>
                        <td>$autowiring</td>
                    </tr>
HERE;
        }

        $html .= <<<HERE
                </tbody>
            </table>

            <p>
                I'll try to give a vague definition below for some of the aforementioned notions:
            </p>

            <p>
                A DI Container is <i>compiled</i> if it can be generated into a new class for production usage
                from where container entries then can be fetched. It means that your dependency graph is resolved
                during build time. This technique usually results in a very fast DIC, because there is no need for any
{'fraction_non_alphanumeric': 0.12391852919971161, 'fraction_numerical': 0.007119682768565248, 'mean_word_length': 1.835206949412366, 'pattern_counts': {'":': 0, '<': 265, '<?xml version=': 0, '>': 259, 'https://': 12, 'lorem ipsum': 0, 'www.': 2, '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': '4032011', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2871, 'n_words': 804}