Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Imagick
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
6 / 6
6
100.00% covered (success)
100.00%
1 / 1
 getAvailableAdapters
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isAvailable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 load
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 loadFromString
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 create
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createIndex
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
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 */
14namespace Pop\Image;
15
16/**
17 * Image Imagick 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 */
26class Imagick
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 Imagick adapter is available
41     *
42     * @return bool
43     */
44    public static function isAvailable(): bool
45    {
46        return Image::isAvailable('imagick');
47    }
48
49    /**
50     * Load the image resource from the existing image file into a Imagick object
51     *
52     * @param  string $image
53     * @return Adapter\Imagick
54     */
55    public static function load(string $image): Adapter\Imagick
56    {
57        return new Adapter\Imagick($image);
58    }
59
60    /**
61     * Load the image resource from data into a Imagick object
62     *
63     * @param  string  $data
64     * @param  ?string $name
65     * @return Adapter\Imagick
66     */
67    public static function loadFromString(string $data, ?string $name = null): Adapter\Imagick
68    {
69        $imagick = new Adapter\Imagick();
70        $imagick->loadFromString($data, $name);
71        return $imagick;
72    }
73
74    /**
75     * Create an Imagick adapter object from an existing image
76     *
77     * @param  int     $width
78     * @param  int     $height
79     * @param  ?string $image
80     * @return Adapter\Imagick
81     */
82    public static function create(int $width, int $height, ?string $image = null): Adapter\Imagick
83    {
84        return new Adapter\Imagick($width, $height, $image);
85    }
86
87    /**
88     * Create a new indexed image resource and load it into a Imagick object
89     *
90     * @param  int     $width
91     * @param  int     $height
92     * @param  ?string $image
93     * @return Adapter\Imagick
94     */
95    public static function createIndex(int $width, int $height, ?string $image = null): Adapter\Imagick
96    {
97        $imagick = new Adapter\Imagick();
98        $imagick->createIndex($width, $height, $image);
99        return $imagick;
100    }
101
102}