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