• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ducks-project / encoding-repair / 21228444070

21 Jan 2026 10:45PM UTC coverage: 75.976% (+4.7%) from 71.26%
21228444070

push

github

donaldinou
feat : add object oriented transcoders

97 of 127 new or added lines in 6 files covered. (76.38%)

253 of 333 relevant lines covered (75.98%)

7.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/Transcoder/UConverterTranscoder.php
1
<?php
2

3
/**
4
 * Part of EncodingRepair package.
5
 *
6
 * (c) Adrien Loyant <donald_duck@team-df.org>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Ducks\Component\EncodingRepair\Transcoder;
15

16
use UConverter;
17

18
/**
19
 * UConverter-based transcoder (requires ext-intl).
20
 *
21
 * @final
22
 */
23
final class UConverterTranscoder implements TranscoderInterface
24
{
25
    /**
26
     * @inheritDoc
27
     */
28
    public function transcode(string $data, string $to, string $from, ?array $options = null): ?string
18✔
29
    {
30
        if (!$this->isAvailable()) {
18✔
NEW
31
            return null;
×
32
        }
33

34
        /** @var false|string $result */
35
        // @phpstan-ignore argument.type
36
        $result = UConverter::transcode($data, $to, $from, $this->resolveOptions($options ?? []));
18✔
37

38
        return false !== $result ? $result : null;
18✔
39
    }
40

41
    /**
42
     * @inheritDoc
43
     */
44
    public function getPriority(): int
19✔
45
    {
46
        return 100;
19✔
47
    }
48

49
    /**
50
     * @inheritDoc
51
     */
52
    public function isAvailable(): bool
18✔
53
    {
54
        return \class_exists(UConverter::class);
18✔
55
    }
56

57
    /**
58
     * Resolve options for UConverter.
59
     *
60
     * @param array<string,mixed> $options
61
     *
62
     * @return array<string,mixed>|null
63
     */
64
    private function resolveOptions(array $options): ?array
18✔
65
    {
66
        return \array_intersect_key(
18✔
67
            $options,
18✔
68
            ['to_subst' => true]
18✔
69
        ) ?: null;
18✔
70
    }
71
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc