PHP code example of szepeviktor / consistent-versions
1. Go to this page and download the library: Download szepeviktor/consistent-versions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
szepeviktor / consistent-versions example snippets
declare(strict_types=1);
namespace Project;
use SzepeViktor\ConsistentVersions\Document;
use SzepeViktor\ConsistentVersions\Reader\Reader;
final class ManifestReader implements Reader
{
public function read(string $path): Document
{
$contents = file_get_contents($path);
if ($contents === false) {
throw new \RuntimeException(sprintf('Could not read %s', $path));
}
return new Document(
['release' => trim($contents)],
$path
);
}
}
use Project\ManifestReader;
use SzepeViktor\ConsistentVersions\Engine;
use SzepeViktor\ConsistentVersions\Normalizer\NormalizerRegistry;
use SzepeViktor\ConsistentVersions\Reader\ReaderRegistry;
$readers = ReaderRegistry::withDefaults();
$readers->register('manifest', new ManifestReader());
$engine = new Engine(
$readers,
NormalizerRegistry::withDefaults()
);
declare(strict_types=1);
namespace Project;
use SzepeViktor\ConsistentVersions\Normalizer\Normalizer;
final class LowercaseNormalizer implements Normalizer
{
public function normalize(
string|int|float|bool|null $value
): string|int|float|bool|null {
return is_string($value) ? strtolower($value) : $value;
}
}
use Project\LowercaseNormalizer;
use SzepeViktor\ConsistentVersions\Engine;
use SzepeViktor\ConsistentVersions\Normalizer\NormalizerRegistry;
use SzepeViktor\ConsistentVersions\Reader\ReaderRegistry;
$normalizers = NormalizerRegistry::withDefaults();
$normalizers->register('lowercase', new LowercaseNormalizer());
$engine = new Engine(
ReaderRegistry::withDefaults(),
$normalizers
);
text
VERSION
plugin.php
readme.txt
composer.json
src/Plugin.php
text
composer.json
plugin.php
readme.txt
.github/workflows/tests.yml
phpcs.xml