PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Commands / PolygonCommand.php

PolygonCommand.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php

50 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image\Commands;
4
5 use Closure;
6 use Intervention\Image\Exception\InvalidArgumentException;
7
8 class PolygonCommand extends AbstractCommand
9 {
10 /**
11 * Draw a polygon on given image
12 *
13 * @param \Intervention\Image\image $image
14 * @return boolean
15 */
16 public function execute($image)
17 {
18 $points = $this->argument(0)->type('array')->required()->value();
19 $callback = $this->argument(1)->type('closure')->value();
20
21 $vertices_count = count($points);
22
23 // check if number if coordinates is even
24 if ($vertices_count % 2 !== 0) {
25 throw new InvalidArgumentException(
26 "The number of given polygon vertices must be even."
27 );
28 }
29
30 if ($vertices_count < 6) {
31 throw new InvalidArgumentException(
32 "You must have at least 3 points in your array."
33 );
34 }
35
36 $polygon_classname = sprintf('\Intervention\Image\%s\Shapes\PolygonShape',
37 $image->getDriver()->getDriverName());
38
39 $polygon = new $polygon_classname($points);
40
41 if ($callback instanceof Closure) {
42 $callback($polygon);
43 }
44
45 $polygon->applyToImage($image);
46
47 return true;
48 }
49 }
50