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

move-elevator / composer-translation-validator / 16048787397

03 Jul 2025 11:07AM UTC coverage: 92.492% (-1.4%) from 93.894%
16048787397

Pull #16

github

jackd248
feat: enhance validation command options to allow skipping and specifying validators
Pull Request #16: feat: enhance validation command options to allow skipping and specifying validators

35 of 49 new or added lines in 2 files covered. (71.43%)

579 of 626 relevant lines covered (92.49%)

4.38 hits per line

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

52.63
/src/Utility/ClassUtility.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace MoveElevator\ComposerTranslationValidator\Utility;
6

7
use Psr\Log\LoggerInterface;
8

9
class ClassUtility
10
{
NEW
11
    public static function instantiate(string $interface, LoggerInterface $logger, string $type, ?string $className = null): ?object
×
12
    {
NEW
13
        if (null === $className) {
×
NEW
14
            return null;
×
15
        }
16

NEW
17
        if (!self::validateClass($interface, $logger, $className)) {
×
NEW
18
            $logger->error(
×
NEW
19
                sprintf('The %s class "%s" must implement %s.', $type, $className, $interface)
×
NEW
20
            );
×
21

NEW
22
            return null;
×
23
        }
24

NEW
25
        return new $className();
×
26
    }
27

28
    public static function validateClass(string $interface, LoggerInterface $logger, ?string $class): bool
4✔
29
    {
30
        if (is_null($class)) {
4✔
31
            return true;
1✔
32
        }
33

34
        if (!class_exists($class)) {
3✔
35
            $logger->error(sprintf('The class "%s" does not exist.', $class));
1✔
36

37
            return false;
1✔
38
        }
39

40
        if (!is_subclass_of($class, $interface)) {
2✔
41
            $logger->error(sprintf('The class "%s" must implement %s.', $class, $interface));
1✔
42

43
            return false;
1✔
44
        }
45

46
        return true;
1✔
47
    }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc