Spatie\MediaLibrary\Exceptions\InvalidConversionParameter::invalidFit PHP Метод

invalidFit() публичный статический Метод

public static invalidFit ( string $givenFit, array $givenFits )
$givenFit string
$givenFits array
    public static function invalidFit(string $givenFit, array $givenFits)
    {
        $givenFits = implode(', ', $givenFits);
        return new static("Format `{$givenFit}` is not one of the allowed formats: {$givenFits}");
    }

Usage Example

Пример #1
0
 /**
  * Set the target fit.
  * Matches with Glide's 'fit'-parameter.
  *
  * @param string $fit
  *
  * @return $this
  *
  * @throws \Spatie\MediaLibrary\Exceptions\InvalidConversionParameter
  */
 public function setFit(string $fit)
 {
     $validFits = ['contain', 'max', 'fill', 'stretch', 'crop', 'crop-top-left', 'crop-top', 'crop-top-right', 'crop-left', 'crop-center', 'crop-right', 'crop-bottom-left', 'crop-bottom', 'crop-bottom-right'];
     if (!in_array($fit, $validFits)) {
         throw InvalidConversionParameter::invalidFit($fit, $validFits);
     }
     $this->setManipulationParameter('fit', $fit);
     return $this;
 }