@param string $binary
@param string $version

@return \livetyping\hermitage\foundation\entities\Image
771810
public function modify(string $binary, string $version = null): Image
    {
        $clone = clone $this;
        $clone->binary = $binary;
        $clone->version = $version ?? $clone->version;

        return $clone;
    }
334251
public function createDatabasePlatformForVersion($version)
    {
        if (false === stripos($version, 'mariadb')) {
            if (preg_match('/^(\d+)/', $version, $match)) {
                if ((int) $match[1] >= 8) {
                    return new MySQL80Platform();
                }
            }
        }

        return parent::createDatabasePlatformForVersion($version);
    }
1205535
public function getVideoImage($version = 'default'){
        if (strpos($this->url, 'youtu') !== false) {
            switch($version){
                case 'max':
                    return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/maxresdefault.jpg';
                    break;

                case 'hq':
                    return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/hqdefault.jpg';
                    break;

                case 'mq':
                    return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/mqdefault.jpg';
                    break;

                case 'sd':
                    return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/sddefault.jpg';
                    break;

                default:
                    return 'https://img.youtube.com/vi/'.$this->getVideoCode().'/default.jpg';
            }
        }

        return '';
    }
519504
public function getFromRevision($version, $key)
    {
        return ($this->isPassedThrough($key))
            ? $this->passThrough($version, $key)
            : array_get($this->{$version}, $key);
    }
505120
public static function phpBinary()
    {
        if (Eye::laravelVersionIs('<', '5.5.26')) {
            return SymfonyProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
        }

        return LaravelProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
    }
360752
public function apply(BinaryInterface $binary, array $config): BinaryInterface
    {
        $config += [
            'quality' => 100,
            'animated' => false,
        ];

        return $this->applyPostProcessors($this->applyFilters($binary, $config), $config);
    }
644590
public function fallbackImage($options = [], $image = [], $version = null) {
		if (isset($options['fallback'])) {
			if ($options['fallback'] === true) {
				$imageFile = 'placeholder/' . $version . '.jpg';
			} else {
				$imageFile = $options['fallback'];
			}
			unset($options['fallback']);

			return $this->Html->image($imageFile, $options);
		}

		return '';
	}
963230
public function setProtocol($protocol, $version)
    {
        $this->protocol = $protocol;
        $this->protocolVersion = $version;

        return $this;
    }
1351194
public function appendVersion($uri, $version = null)
    {
        $version = $version ?: $this->getVersion();

        if (!$version) {
            return $uri;
        }

        $sep = strpos($uri, '?') !== false ? '&' : '?';

        return $uri . $sep . $version;
    }
358767
public function shouldProcess(Version $version)
    {
        $result = false;
        if (ExifMetadataReader::isSupported()) {
            if ($version->getTypeObject()->getName() == 'JPEG') {
                try {
                    $metadata = $version->hasImagineImage() ? $version->getImagineImage()->metadata() : null;
                    if ($metadata === null) {
                        $fr = $version->getFileResource();
                        $medatadaReader = new ExifMetadataReader();
                        $metadata = $medatadaReader->readData($fr->read());
                    }
                    switch ($metadata->get('ifd0.Orientation', null)) {
                        case 2: // top-right
                        case 3: // bottom-right
                        case 4: // bottom-left
                        case 5: // left-top
                        case 6: // right-top
                        case 7: // right-bottom
                        case 8: // left-bottom
                            $result = true;
                            break;
                    }
                } catch (Exception $x) {
                } catch (Throwable $x) {
                }
            }
        }

        return $result;
    }
354598
protected function _getHash($version, $image) {
		if (!empty($version)) {
			$hash = Configure::read('FileStorage.imageHashes.' . $image['model'] . '.' . $version);
			if (empty($hash)) {
				throw new InvalidArgumentException(sprintf('No valid version key (Identifier: `%s` Key: `%s`) passed!', @$image['model'], $version));
			}

			return $hash;
		}

		return null;
	}
734362
public static function majorVersion($version)
    {
        $components = explode('.', $version);
        foreach ($components as $key => $value) {
            if ($key > 0 && is_numeric($value)) {
                $components[$key] = '0';
            }
        }

        return implode('.', $components);
    }
1130783
public function setVersion($version)
    {
        if (!in_array($version, $this->supportedVersions)) {
            $this->throwError('The version ' . $version . ' is not supported by this library');
        }

        $this->version = $version;

        return $this;
    }
948707
public function addVersion( PhpVersion $version ) {
		$versionString = $version->getVersion();

		$this->phpVersions[$versionString] = $version;

		return $this;
	}
867331
public function withProtocolVersion($version)
    {
        if ($this->getProtocolVersion() === $version) {
            return $this;
        }

        $newInstance = clone $this;
        $newInstance->setProtocolVersion($version);
        return $newInstance;
    }
443446
public function setVersion ($version)
    {
        $version = strtolower(strval($version));
        if (! self::isValid($version)) {
            $version = self::DEFAULT_UNRESOLVED_VERSION;
        }
        
        $this->numbers = self::parse($version);
        $this->version = $version;
        return $this;
    }
1248851
public function loadBinaryFileByUri($binaryFileUri)
    {
        try {
            $image = $this->publishedIOService->loadBinaryFileByUri($binaryFileUri);

            if ($image instanceof MissingBinaryFile) {
                throw new InvalidArgumentException('binaryFileUri', sprintf("Can't find file with url %s", $binaryFileUri));
            }

            return $image;
        } catch (InvalidArgumentException $prefixException) {
            // InvalidArgumentException means that the prefix didn't match, NotFound can pass through
            try {
                return $this->draftIOService->loadBinaryFileByUri($binaryFileUri);
            } catch (InvalidArgumentException $e) {
                throw $prefixException;
            }
        }
    }