Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
Gd | |
100.00% |
10 / 10 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
getAvailableAdapters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isAvailable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
load | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
loadFromString | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
create | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
createIndex | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Image; |
15 | |
16 | /** |
17 | * Image Gd factory class |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Image |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 4.0.0 |
25 | */ |
26 | class Gd |
27 | { |
28 | |
29 | /** |
30 | * Get the available image adapters |
31 | * |
32 | * @return array |
33 | */ |
34 | public static function getAvailableAdapters(): array |
35 | { |
36 | return Image::getAvailableAdapters(); |
37 | } |
38 | |
39 | /** |
40 | * Determine if the GD adapter is available |
41 | * |
42 | * @return bool |
43 | */ |
44 | public static function isAvailable(): bool |
45 | { |
46 | return Image::isAvailable('gd'); |
47 | } |
48 | |
49 | /** |
50 | * Load the image resource from the existing image file into a Gd object |
51 | * |
52 | * @param string $image |
53 | * @return Adapter\Gd |
54 | */ |
55 | public static function load(string $image): Adapter\Gd |
56 | { |
57 | return new Adapter\Gd($image); |
58 | } |
59 | |
60 | /** |
61 | * Load the image resource from data into a Gd object |
62 | * |
63 | * @param string $data |
64 | * @param ?string $name |
65 | * @throws Adapter\Exception |
66 | * @return Adapter\Gd |
67 | */ |
68 | public static function loadFromString(string $data, ?string $name = null): Adapter\Gd |
69 | { |
70 | $gd = new Adapter\Gd(); |
71 | $gd->loadFromString($data, $name); |
72 | return $gd; |
73 | } |
74 | |
75 | /** |
76 | * Create a new image resource and load it into a Gd object |
77 | * |
78 | * @param int $width |
79 | * @param int $height |
80 | * @param ?string $image |
81 | * @return Adapter\Gd |
82 | */ |
83 | public static function create(int $width, int $height, ?string $image = null): Adapter\Gd |
84 | { |
85 | return new Adapter\Gd($width, $height, $image); |
86 | } |
87 | |
88 | /** |
89 | * Create a new indexed image resource and load it into a Gd object |
90 | * |
91 | * @param int $width |
92 | * @param int $height |
93 | * @param ?string $image |
94 | * @throws Adapter\Exception |
95 | * @return Adapter\Gd |
96 | */ |
97 | public static function createIndex(int $width, int $height, ?string $image = null): Adapter\Gd |
98 | { |
99 | $gd = new Adapter\Gd(); |
100 | $gd->createIndex($width, $height, $image); |
101 | return $gd; |
102 | } |
103 | |
104 | } |