Skip to content

Commit 60fc4ad

Browse files
authored
Merge pull request #7 from jobcloud/fix/PRO-698/strtolower-with-null-php81-deprecation
fix(PRO-698): fix null on strtolower PHP 8.1 deprecation
2 parents c74b063 + 7addcc4 commit 60fc4ad

1 file changed

Lines changed: 56 additions & 41 deletions

File tree

lib/PHPPdf/Core/ColorPalette.php

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
1-
<?php
2-
3-
/*
4-
* Copyright 2011 Piotr Śliwa <peter.pl7@gmail.com>
5-
*
6-
* License information is in LICENSE file
7-
*/
8-
9-
10-
namespace PHPPdf\Core;
11-
12-
/**
13-
* Color palette
14-
*
15-
* @author Piotr Śliwa <peter.pl7@gmail.com>
16-
*/
17-
class ColorPalette
18-
{
19-
private $colors;
20-
21-
public function __construct(array $colors = array())
22-
{
23-
$this->colors = $colors;
24-
}
25-
26-
public function get($name)
27-
{
28-
$name = strtolower($name);
29-
return isset($this->colors[$name]) ? $this->colors[$name] : $name;
30-
}
31-
32-
public function merge(array $colors)
33-
{
34-
$this->colors = $colors + $this->colors;
35-
}
36-
37-
public function getAll()
38-
{
39-
return $this->colors;
40-
}
41-
}
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Piotr Śliwa <peter.pl7@gmail.com>
5+
*
6+
* License information is in LICENSE file
7+
*/
8+
9+
namespace PHPPdf\Core;
10+
11+
/**
12+
* Color palette
13+
*
14+
* @author Piotr Śliwa <peter.pl7@gmail.com>
15+
*/
16+
class ColorPalette
17+
{
18+
/** @var array<string, string> */
19+
private $colors;
20+
21+
/**
22+
* @param array<string, string> $colors
23+
*/
24+
public function __construct(array $colors = [])
25+
{
26+
$this->colors = $colors;
27+
}
28+
29+
/**
30+
* @param string|null $name
31+
* @return string
32+
*/
33+
public function get($name)
34+
{
35+
$name = strtolower((string) $name);
36+
37+
return isset($this->colors[$name]) ? $this->colors[$name] : $name;
38+
}
39+
40+
/**
41+
* @param array<string, string> $colors
42+
* @return void
43+
*/
44+
public function merge(array $colors)
45+
{
46+
$this->colors = $colors + $this->colors;
47+
}
48+
49+
/**
50+
* @return array<string, string>
51+
*/
52+
public function getAll()
53+
{
54+
return $this->colors;
55+
}
56+
}

0 commit comments

Comments
 (0)