@param string $file
@param string $message
@param array  $options

@throws \LogicException

@return Image
543683
public function encode($file, $message, array $options = [])
    {
        $image   = new Image($file);
        $message = $this->encodeMessage($message, $options);
        $pixels  = ceil(strlen($message) / self::BITS_PER_PIXEL + (self::LENGTH_BITS / self::BITS_PER_PIXEL));

        if ($pixels > $image->getPixels()) {
            throw new \LogicException('Number of pixels is fewer than ' . $pixels);
        }

        $image->setBinaryString(new BinaryIterator($message));

        return $image;
    }
896583
public static function log($message, $options = array())
    {
        if (array_key_exists('inputs', $options)) {
            $inputs = $options['inputs'];
        } else {
            $inputs = array(
                self::getTimestamp(),
                'LOG',
                self::getFilename(),
                self::getLineNumber()
            );
        }

        if (!array_key_exists('output', $options)) {
            $options['output'] = 'STDOUT';
        }

        if (array_key_exists('format', $options)) {
            array_unshift($inputs, $options['format']);
        } else {
            array_unshift($inputs, self::$format);
        }

        $inputs[] = $message;

        $logMessage = self::getLogMessage($inputs);
        if (array_key_exists('colour', $options) && !empty($options['colour'])) {
            self::out($logMessage, $options['colour'], $options['output']);
        } else {
            self::out($logMessage, false, $options['output']);
        }
    }
243191
public function writeLn($message = '', $options = 0)
    {
        $this->write($message, $options);
        $this->write(PHP_EOL);

        return $this;
    }
948679
public static function image($src, $options = [])
    {
        Html::addCssClass($options, 'ui ' . ArrayHelper::remove($options, 'class') . ' image');
        return Html::img($src, $options);
    }
352883
public function manipulateImage($file, array $options, $imageType)
    {
        // Detect file type
        if ($file instanceof Temp) {
            $sanitizedFilename = $this->sanitizeFilename($file->filename);
        } elseif ($file instanceof UploadedFile) {
            $sanitizedFilename = $this->sanitizeFilename($file->getClientOriginalName());
        } elseif ($file instanceof File) {
            $actualFilename = str_replace('_source.', '.', $file->getFilename());
            $sanitizedFilename = $this->sanitizeFilename($actualFilename);
            $sourceFile = clone $file;
        } else {
            throw new \Exception('Unexpected file of class '.get_class($file));
        }

        $images = [];
        $pathParts = pathinfo($sanitizedFilename);
        // Move uploaded file and rename it as source file if this is needed.
        // We need to generate unique name if the name is already in use.
        if (! isset($sourceFile)) {
            $filename = $pathParts['filename']."_source{$imageType}.".$pathParts['extension'];
            $sourceFile = $file->move($this->getThumbnailPath(), $filename);
        }

        $images['original']['source'] = $sourceFile;
        $sanitizedFilename = $pathParts['filename'].$imageType.'.'.$pathParts['extension'];

        // If we have retina factor
        if ($this->getRetinaFactor()) {
            // Generate retina image by just copying the source.
            $retinaFilename = $this->generateRetinaName($sanitizedFilename);
            FileFacade::copy($sourceFile->getRealPath(), $this->getThumbnailPath().$retinaFilename);
            $images['original']['retina'] = Image::make($this->getThumbnailPath().$retinaFilename);

            // The original image is scaled down version of the source.
            $originalImage = Image::make($sourceFile->getRealPath());
            $width = round($originalImage->getWidth() / $this->getRetinaFactor());
            $height = round($originalImage->getHeight() / $this->getRetinaFactor());
            //$originalImage->resize($width, $height);
            $images['original']['original_file'] = $originalImage->save($this->getThumbnailPath().$sanitizedFilename);

            // Generate thumbs
            foreach ($options['thumbnails'] as $thumbnailName => $thumbnailOptions) {
                // Create retina thumb
                $images['thumbnails'][$thumbnailName]['retina'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $this->generateRetinaName($sanitizedFilename),
                    $thumbnailOptions['width'] * $this->getRetinaFactor(),
                    $thumbnailOptions['height'] * $this->getRetinaFactor(),
                    $thumbnailOptions['type'],
                    array_get($thumbnailOptions, 'color'));
                // Create original thumb
                $images['thumbnails'][$thumbnailName]['original'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $sanitizedFilename, $thumbnailOptions['width'],
                    $thumbnailOptions['height'], $thumbnailOptions['type'],
                    array_get($thumbnailOptions, 'color'));
            }
        } else {
            // Copy source file.
            $filename = $this->sanitizeFilename($file->getFilename());
            FileFacade::copy($sourceFile->getRealPath(), $this->getThumbnailPath().$filename);
            $images['original']['original_file'] = Image::make($this->getThumbnailPath().$filename);

            // Generate thumbs
            foreach ($options['thumbnails'] as $thumbnailName => $thumbnailOptions) {
                // Create original thumb
                $images['thumbnails'][$thumbnailName]['original'] = $this->createThumbnail($sourceFile->getRealPath(),
                    $thumbnailName, $sanitizedFilename, $thumbnailOptions['width'],
                    $thumbnailOptions['height'], $thumbnailOptions['type']);
            }
        }

        return $images;
    }
1086434
private function processImage($field, $options)
    {
        $originalPath = $this->getFilePath(null, $this->fileName);
        $resultPath = $this->getFilePath($field, $this->fileName);
        $this->createFilePath($resultPath);
        switch ($options['method']) {
            case 'thumbnail' :
                \yii\imagine\Image::thumbnail(
                    $originalPath, $options['width'], $options['height']
                )->save($resultPath, [
                    'format' => pathinfo($this->fileName, \PATHINFO_EXTENSION)
                ]);
                break;
        }
    }
874428
public function debug($message = '', $options = 0)
    {
        $this->logger->debug($message);

        $this->write($message, $options);
        $this->write(PHP_EOL);

        return $this;
    }
87982
public function save($image, $options)
    {
        $image = $this->saveToString($image, $options);
        return $this->saveFromString($image, $options);
    }
485598
public function encode(Message $message, int $options = 0): string
    {
        $ctx = new Context($options);
        $qdCount = $anCount = $nsCount = $arCount = 0;

        foreach ($message->getQuestionRecords() as $record) {
            if (!$this->encodeQuestionRecord($ctx, $record)) {
                goto done;
            }

            $qdCount++;
        }

        foreach ($message->getAnswerRecords() as $record) {
            if (!$this->encodeResourceRecord($ctx, $record)) {
                goto done;
            }

            $anCount++;
        }

        foreach ($message->getAuthorityRecords() as $record) {
            if (!$this->encodeResourceRecord($ctx, $record)) {
                goto done;
            }

            $nsCount++;
        }

        foreach ($message->getAdditionalRecords() as $record) {
            if (!$this->encodeResourceRecord($ctx, $record)) {
                goto done;
            }

            $arCount++;
        }

        done:
        $packet = $this->encodeHeader($ctx, $message, $qdCount, $anCount, $nsCount, $arCount) . $ctx->data;

        if (!($options & EncodingOptions::FORMAT_TCP)) {
            \assert(
                \strlen($packet) <= 512,
                new \Error('UDP packet exceeds 512 byte limit: got ' . \strlen($packet) . ' bytes')
            );

            return $packet;
        }

        \assert(
            \strlen($packet) <= 65535,
            new \Error('TCP packet exceeds 65535 byte limit: got ' . \strlen($packet) . ' bytes')
        );

        return \pack('n', \strlen($packet)) . $packet;
    }
930258
public static function DecryptMessage ($message, $key, $options = []) {
		$options = static::_AdjustOptions($options);
		return openssl_decrypt($message, $options['method'], $key, $options['openssl_options'], $options['iv']);
	}
306035
protected function loadFile(string $file, array $options)
    {
        $yaml = file_get_contents($file);

        // Workaround for the bad practise of PHP extensions to trigger a warning and return false.
        error_clear_last();

        $unused = null;

        $data = @yaml_parse(
            $yaml,
            $options['pos'] ?? 0,
            $unused,
            $options['callbacks'] ?? []
        );

        return $data;
    }
423823
public function deserialize($data, Message $message, array $options)
    {
        if (!in_array(Options::REFRESH_UUID, $options)) {
            $message->setUuid($data['id']);
        }

        $this->sipe('title', 'setTitle', $data, $message);
        $this->sipe('content', 'setContent', $data, $message);

        if (isset($data['workspace']['uuid'])) {
            $workspace = $this->workspaceRepo->findOneBy(['uuid' => $data['workspace']['uuid']]);

            if (!empty($workspace)) {
                $message->setWorkspace($workspace);
            }
        }

        return $message;
    }
58626
public function send($message, array $options = [])
    {
        $config = Ioc::getConfig();

        if (empty($options['force']) && !$config->get('mail.enabled', true)) {
            return true;
        }

        if (\is_callable($message)) {
            $msgObject = $this->createMessage();

            $message = $message($msgObject, $this);

            if (!$message instanceof MailMessage) {
                $message = $msgObject;
            }
        }

        if (!$message instanceof MailMessage) {
            throw new \InvalidArgumentException(sprintf('Mail Message should instance of %s', MailMessage::class));
        }

        $this->triggerEvent('onMailerBeforeSend', [
            'message' => $message,
            'manager' => $this,
        ]);

        // Set default sender
        if (!$message->getFrom()) {
            if ($config->exists('mail.from.email')) {
                $message->from($config->get('mail.from.email'), $config->get('mail.from.name'));
            }
        }

        // CC/BCC
        if ($cc = $config->get('mail.cc')) {
            if (is_string($cc)) {
                $cc = array_filter(array_map('trim', explode(',', $cc)), 'strlen');
            }

            $message->cc($cc);
        }

        if ($bcc = $config->get('mail.bcc')) {
            if (is_string($bcc)) {
                $bcc = array_filter(array_map('trim', explode(',', $bcc)), 'strlen');
            }

            $message->bcc($bcc);
        }

        $result = $this->getAdapter()->send($message);

        $this->triggerEvent('onMailerAfterSend', [
            'message' => $message,
            'manager' => $this,
            'result' => &$result,
        ]);

        return $result;
    }
631045
public function startInsert($message, array $options = null) {
		return $this->startEvent($message, ProfileInterface::TYPE_INSERT, $options);
	}
227668
public static function image($image, $options = [])
	{
		$static = new static;

		$static->image = $image;
		$static->options = $options;
		$static->intervention = new ImageManager(['driver' => 'gd']);

		$static->normalizeNames();

		return $static;
	}
1198873
public function image($text, array $options = []) {
		return $this->Html->image($this->uri($text), $options);
	}
1260564
public function xSendFile($file, $options = array())
    {
        Yii::app()->request->xSendFile($file->resolvePath(), $options);
    }