Вход Регистрация
Файл: vendor/intervention/image/src/Geometry/Factories/LineFactory.php
Строк: 156
<?php

declare(strict_types=1);

namespace 
InterventionImageGeometryFactories;

use 
Closure;
use 
InterventionImageGeometryPoint;
use 
InterventionImageGeometryLine;
use 
InterventionImageInterfacesDrawableFactoryInterface;
use 
InterventionImageInterfacesDrawableInterface;

class 
LineFactory implements DrawableFactoryInterface
{
    protected 
Line $line;

    
/**
     * Create the factory instance
     *
     * @param null|Closure|Line $init
     * @return void
     */
    
public function __construct(null|Closure|Line $init null)
    {
        
$this->line is_a($initLine::class) ? $init : new Line(new Point(), new Point());

        if (
is_callable($init)) {
            
$init($this);
        }
    }

    
/**
     * {@inheritdoc}
     *
     * @see DrawableFactoryInterface::init()
     */
    
public static function init(null|Closure|DrawableInterface $init null): self
    
{
        return new 
self($init);
    }

    
/**
     * {@inheritdoc}
     *
     * @see DrawableFactoryInterface::create()
     */
    
public function create(): DrawableInterface
    
{
        return 
$this->line;
    }

    
/**
     * Set the color of the line to be produced
     *
     * @param mixed $color
     * @return LineFactory
     */
    
public function color(mixed $color): self
    
{
        
$this->line->setBackgroundColor($color);
        
$this->line->setBorderColor($color);

        return 
$this;
    }

    
/**
     * Set the (background) color of the line to be produced
     *
     * @param mixed $color
     * @return LineFactory
     */
    
public function background(mixed $color): self
    
{
        
$this->line->setBackgroundColor($color);
        
$this->line->setBorderColor($color);

        return 
$this;
    }

    
/**
     * Set the border size & border color of the line to be produced
     *
     * @param mixed $color
     * @param int $size
     * @return LineFactory
     */
    
public function border(mixed $colorint $size 1): self
    
{
        
$this->line->setBackgroundColor($color);
        
$this->line->setBorderColor($color);
        
$this->line->setWidth($size);

        return 
$this;
    }

    
/**
     * Set the width of the line to be produced
     *
     * @param int $size
     * @return LineFactory
     */
    
public function width(int $size): self
    
{
        
$this->line->setWidth($size);

        return 
$this;
    }

    
/**
     * Set the coordinates of the starting point of the line to be produced
     *
     * @param int $x
     * @param int $y
     * @return LineFactory
     */
    
public function from(int $xint $y): self
    
{
        
$this->line->setStart(new Point($x$y));

        return 
$this;
    }

    
/**
     * Set the coordinates of the end point of the line to be produced
     *
     * @param int $x
     * @param int $y
     * @return LineFactory
     */
    
public function to(int $xint $y): self
    
{
        
$this->line->setEnd(new Point($x$y));

        return 
$this;
    }

    
/**
     * Produce the line
     *
     * @return Line
     */
    
public function __invoke(): Line
    
{
        return 
$this->line;
    }
}
Онлайн: 0
Реклама