Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/CoverageProbe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php declare(strict_types=1);
/*
* (c) shopware AG <info@shopware.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Swag\MigrationMagento;

use Shopware\Core\Framework\Log\Package;

/**
* @internal Probe for the Codecov setup — DO NOT MERGE.
*/
#[Package('fundamentals@after-sales')]
class CoverageProbe
{
public function classify(int $value): string
{
if ($value < 0) {
return 'negative';
}

if ($value === 0) {
return 'zero';
}

if ($value < 10) {
return 'small';
}

if ($value < 100) {
return 'medium';
}

return 'large';
}

/**
* @param list<int> $values
*
* @return list<string>
*/
public function classifyAll(array $values): array
{
$result = [];
foreach ($values as $value) {
$result[] = $this->classify($value);
}

return $result;
}

public function describe(int $value): string
{
$label = $this->classify($value);

if ($label === 'zero') {
return 'the value is zero';
}

return \sprintf('the value is %s (%d)', $label, $value);
}
}