Вход Регистрация
Файл: gapps/vendor/intervention/image/src/Intervention/Image/Commands/PolygonCommand.php
Строк: 74
<?php

namespace InterventionImageCommands;

use 
Closure;

class 
PolygonCommand extends InterventionImageCommandsAbstractCommand
{
    
/**
     * Draw a polygon on given image
     *
     * @param  InterventionImageimage $image
     * @return boolean
     */
    
public function execute($image)
    {
        
$points $this->argument(0)->type('array')->required()->value();
        
$callback $this->argument(1)->type('closure')->value();

        
$vertices_count count($points);

        
// check if number if coordinates is even
        
if ($vertices_count !== 0) {
            throw new 
InterventionImageExceptionInvalidArgumentException(
                
"The number of given polygon vertices must be even."
            
);
        }

        if (
$vertices_count 6) {
            throw new 
InterventionImageExceptionInvalidArgumentException(
                
"You must have at least 3 points in your array."
            
);
        }
        
        
$polygon_classname sprintf('InterventionImage%sShapesPolygonShape',
            
$image->getDriver()->getDriverName());

        
$polygon = new $polygon_classname($points);
        
        if (
$callback instanceof Closure) {
            
$callback($polygon);
        }

        
$polygon->applyToImage($image);

        return 
true;
    }
}
Онлайн: 0
Реклама