respect-validation/src-dev/Markdown/File.php
Henrique Moody 098c973a2a
Add GitHub action to lint documentation files
When we make changes to the category of a validator, it's easy to forget
to update overall list of validators. This commit a GitHub actions that
will run a console command to check if the documentation it up-to-date.

The job will fail when we need to change the document, but the console
command will fix the issues, so there isn't a lot of friction there.
2026-01-13 23:37:05 -07:00

42 lines
877 B
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Dev\Markdown;
use Symfony\Component\Finder\SplFileInfo;
use function file_put_contents;
final readonly class File
{
public function __construct(
public string $filename,
public Content $content,
) {
}
public static function from(SplFileInfo $file): self
{
return new self($file->getRealPath(), Content::from($file->getRealPath()));
}
public function withContent(Content $content): self
{
if ($content->build() === $this->content->build()) {
return $this;
}
return clone($this, ['content' => $content]);
}
public function save(): void
{
file_put_contents($this->filename, $this->content->build());
}
}