• 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

0.0
/src/Loader/InitData/Company.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\InitData;
15

16
use stdClass;
17

18
use function array_change_key_case;
19
use function array_key_exists;
20
use function is_string;
21

22
use const CASE_LOWER;
23

24
/** @phpcs:disable SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion.RequiredConstructorPropertyPromotion */
25
final class Company
26
{
27
    private string | null $name      = null;
28
    private string | null $brandname = null;
29

30
    /** @throws void */
NEW
31
    public function __construct(string | null $name, string | null $brandname)
×
32
    {
NEW
33
        $this->name      = $name;
×
NEW
34
        $this->brandname = $brandname;
×
35
    }
36

37
    /**
38
     * @param stdClass $data
39
     * @phpstan-param array{name: string|null, brandname: string|null} $data
40
     *
41
     * @throws void
42
     */
NEW
43
    public function __unserialize(array $data): void
×
44
    {
NEW
45
        $this->exchangeArray($data);
×
46
    }
47

48
    /**
49
     * @return array{name: string|null, brandname: string|null}
50
     *
51
     * @throws void
52
     */
NEW
53
    public function __serialize(): array
×
54
    {
NEW
55
        return $this->getArrayCopy();
×
56
    }
57

58
    /** @throws void */
NEW
59
    public function getName(): string | null
×
60
    {
NEW
61
        return $this->name;
×
62
    }
63

64
    /** @throws void */
NEW
65
    public function getBrandname(): string | null
×
66
    {
NEW
67
        return $this->brandname;
×
68
    }
69

70
    /**
71
     * @return array{name: string|null, brandname: string|null}
72
     *
73
     * @throws void
74
     *
75
     * @api
76
     */
NEW
77
    public function getArrayCopy(): array
×
78
    {
NEW
79
        return [
×
NEW
80
            'name' => $this->name,
×
NEW
81
            'brandname' => $this->brandname,
×
NEW
82
        ];
×
83
    }
84

85
    /**
86
     * @param array{name: string|null, brandname: string|null} $data
87
     *
88
     * @throws void
89
     *
90
     * @api
91
     */
NEW
92
    public function exchangeArray(array $data): void
×
93
    {
NEW
94
        $data = array_change_key_case($data, CASE_LOWER);
×
95

NEW
96
        $name = null;
×
97

NEW
98
        if (array_key_exists('name', $data) && is_string($data['name'])) {
×
NEW
99
            $name = $data['name'];
×
100
        }
101

NEW
102
        $brandname = null;
×
103

NEW
104
        if (array_key_exists('brandname', $data) && is_string($data['brandname'])) {
×
NEW
105
            $brandname = $data['brandname'];
×
106
        }
107

NEW
108
        $this->name      = $name;
×
NEW
109
        $this->brandname = $brandname;
×
110
    }
111
}
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