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

mimmi20 / browser-detector / 12945342151

22 Jan 2025 07:24PM UTC coverage: 89.212% (-10.8%) from 100.0%
12945342151

push

github

web-flow
Merge pull request #872 from mimmi20/updates

rewrite Headers

2983 of 3466 new or added lines in 72 files covered. (86.06%)

9 existing lines in 2 files now uncovered.

4234 of 4746 relevant lines covered (89.21%)

11.89 hits per line

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

87.5
/src/Loader/EngineLoader.php
1
<?php
2

3
/**
4
 * This file is part of the browser-detector package.
5
 *
6
 * Copyright (c) 2012-2025, Thomas Mueller <mimmi20@live.de>
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 BrowserDetector\Loader;
15

16
use BrowserDetector\Version\VersionBuilderInterface;
17
use Override;
18
use Psr\Log\LoggerInterface;
19
use RuntimeException;
20
use UaLoader\EngineLoaderInterface;
21
use UaLoader\Exception\NotFoundException;
22
use UaResult\Company\Company;
23
use UaResult\Engine\Engine;
24
use UaResult\Engine\EngineInterface;
25

26
final class EngineLoader implements EngineLoaderInterface
27
{
28
    use VersionFactoryTrait;
29

30
    /** @throws void */
31
    public function __construct(
6✔
32
        private readonly LoggerInterface $logger,
33
        private readonly Data\Engine $initData,
34
        private readonly CompanyLoaderInterface $companyLoader,
35
        VersionBuilderInterface $versionBuilder,
36
    ) {
37
        $this->versionBuilder = $versionBuilder;
6✔
38
    }
39

40
    /** @throws NotFoundException */
41
    #[Override]
6✔
42
    public function load(string $key, string $useragent = ''): EngineInterface
43
    {
44
        try {
45
            $this->initData->init();
6✔
NEW
46
        } catch (RuntimeException $e) {
×
NEW
47
            throw new NotFoundException('the engine with key "' . $key . '" was not found', 0, $e);
×
48
        }
49

50
        $engineData = $this->initData->getItem($key);
6✔
51

52
        if ($engineData === null) {
6✔
53
            throw new NotFoundException('the engine with key "' . $key . '" was not found');
2✔
54
        }
55

56
        $version      = $this->getVersion($engineData->getVersion(), $useragent);
4✔
57
        $manufacturer = new Company(type: 'unknown', name: null, brandname: null);
4✔
58

59
        if ($engineData->getManufacturer() !== null) {
4✔
60
            try {
61
                $manufacturer = $this->companyLoader->load($engineData->getManufacturer());
4✔
62
            } catch (NotFoundException $e) {
1✔
63
                $this->logger->info($e);
1✔
64
            }
65
        }
66

67
        return new Engine(name: $engineData->getName(), manufacturer: $manufacturer, version: $version);
4✔
68
    }
69
}
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