Build a binary.

@param string $binary

@return \Rocketeer\Binaries\AbstractBinary|\Rocketeer\Binaries\PackageManagers\AbstractPackageManager
431266
public function buildBinary($binary)
    {
        $class = $this->modulable->findQualifiedName($binary, 'binaries');

        // If there is a class by that name
        if ($class) {
            return new $class($this->container);
        }

        // Else wrap the command in an AnonymousBinary
        $anonymous = new AnonymousBinary($this->container);
        $anonymous->setBinary($this->bash->which($binary));

        return $anonymous;
    }
597331
public function build(string $className): interfaces\commands\Command
    {
        $params = is_subclass_of($className, interfaces\commands\ExecutableCommand::class) ? [$this->bus] : [];

        /** @var interfaces\commands\Command $command */
        $command = \Yii::createObject($className, $params);

        $this->prepareCommand($command);

        return $command;
    }
530928
public static function binaryBatch(Api\MtBatchBinarySmsCreate $batch)
    {
        $fields = Serialize::_createBatchHelper($batch);

        $fields['type'] = 'mt_binary';
        $fields['body'] = base64_encode($batch->getBody());
        $fields['udh'] = bin2hex($batch->getUdh());

        return Serialize::_toJson($fields);
    }
716743
public function parse($file)
    {
        $this->file = $file;
        $this->validateSelf();
        $this->process->run("{$this->binary} {$this->file} -");

        return $this;
    }
162758
public function binary($operator = null, AbstractBuilder $leftExpression = null, AbstractBuilder $rightExpression = null)
    {
        return new BinaryOperator($operator, $leftExpression, $rightExpression);
    }
329087
public static function binary($name, $value)
    {
        return new self($name, $value, '', true, false, false, true);
    }
360752
public function apply(BinaryInterface $binary, array $config): BinaryInterface
    {
        $config += [
            'quality' => 100,
            'animated' => false,
        ];

        return $this->applyPostProcessors($this->applyFilters($binary, $config), $config);
    }
57602
public function process(BinaryInterface $binary, array $options = []): BinaryInterface
    {
        $type = mb_strtolower($binary->getMimeType());
        if (!\in_array($type, ['image/jpeg', 'image/jpg'], true)) {
            return $binary;
        }

        $processArguments = [$this->mozjpegBin];

        // Places emphasis on DC
        $processArguments[] = '-quant-table';
        $processArguments[] = 2;

        $transformQuality = \array_key_exists('quality', $options) ? $options['quality'] : $this->quality;
        if (null !== $transformQuality) {
            $processArguments[] = '-quality';
            $processArguments[] = $transformQuality;
        }

        $processArguments[] = '-optimise';

        // Favor stdin/stdout so we don't waste time creating a new file.
        $proc = new Process($processArguments);
        $proc->setInput($binary->getContent());
        $proc->run();

        if (false !== mb_strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {
            throw new ProcessFailedException($proc);
        }

        $result = new Binary($proc->getOutput(), $binary->getMimeType(), $binary->getFormat());

        return $result;
    }
767259
public function loadBinaryFile($binaryFileId)
    {
        $this->checkBinaryFileId($binaryFileId);

        if ($this->isAbsolutePath($binaryFileId)) {
            throw new InvalidBinaryAbsolutePathException($binaryFileId);
        }

        try {
            $spiBinaryFile = $this->metadataHandler->load($this->getPrefixedUri($binaryFileId));
        } catch (BinaryFileNotFoundException $e) {
            $this->logMissingFile($binaryFileId);

            return new MissingBinaryFile([
                'id' => $binaryFileId,
                'uri' => $this->binarydataHandler->getUri($this->getPrefixedUri($binaryFileId)),
            ]);
        }

        if (!isset($spiBinaryFile->uri)) {
            $spiBinaryFile->uri = $this->binarydataHandler->getUri($spiBinaryFile->id);
        }

        return $this->buildDomainBinaryFileObject($spiBinaryFile);
    }
1080961
public function bundle()
    {
        $bundle = new Bundle();
        $this->bundleBins($bundle);

        $autoload = $this->package->getAutoload();
        $this->bundlePsr0($bundle, $autoload);
        $this->bundleClassmap($bundle, $autoload);
        $this->bundleFiles($bundle, $autoload);

        return $bundle;
    }
667687
public function find($path)
    {
        $data = $this->pathResolver->resolvePath($path);
        $mime = $this->pathResolver->resolveMime($path);

        $binary = new Binary($data, $mime, str_replace('image/', '', $mime));

        return $binary;
    }
1082359
public function initFromBinary($binary)
    {
        $resource = @imagecreatefromstring($binary);

        if ($resource === false) {
             throw new \Intervention\Image\Exception\NotReadableException(
                "Unable to init from given binary data."
            );
        }

        $image = $this->initFromGdResource($resource);
        $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);

        return $image;
    }
826127
public function build($args)
    {
        $data = [];

        $args = Cuztom::merge($args, [
            'parent'   => $this,
            'metaType' => $this->metaType,
            'object'   => $this->object,
        ]);

        // Build with value
        if (Cuztom::isArray($this->value)) {
            $i = 0;

            foreach ($this->value as $value) {
                $args = Cuztom::merge($args, "index=>$i");

                $data[] = new BundleItem($args, $value);

                $i++;
            }
        }

        // Without value
        else {
            $args = Cuztom::merge($args, 'index=>0');

            $data[] = new BundleItem($args);
        }

        return $data;
    }
668338
public static function getBinary(): string
    {
        // Custom PHP path
        if (self::$binary === null) {
            if ((self::$binary = getenv('PHP_BINARY_CUSTOM')) === false) {
                self::$binary = PHP_BINARY;
            }
        }

        // HHVM
        if (self::$binary === null && self::isHHVM()) {
            if ((self::$binary = getenv('PHP_BINARY')) === false) {
                self::$binary = PHP_BINARY;
            }
            self::$binary = escapeshellarg(self::$binary) . ' --php';
        }

        // PHP >= 5.4.0
        if (self::$binary === null && defined('PHP_BINARY')) {
            self::$binary = escapeshellarg(PHP_BINARY);
        }

        // PHP < 5.4.0
        if (self::$binary === null) {
            if (PHP_SAPI === 'cli' && isset($_SERVER['_'])) {
                if (strpos($_SERVER['_'], 'phpunit') !== false) {
                    $file = file($_SERVER['_']);

                    if (strpos($file[0], ' ') !== false) {
                        $tmp = explode(' ', $file[0]);
                        self::$binary = escapeshellarg(trim($tmp[1]));
                    } else {
                        self::$binary = escapeshellarg(ltrim(trim($file[0]), '#!'));
                    }
                } elseif (strpos(basename($_SERVER['_']), 'php') !== false) {
                    self::$binary = escapeshellarg($_SERVER['_']);
                }
            }
        }

        if (self::$binary === null) {
            $binaryLocations = [
                PHP_BINDIR . '/php',
                PHP_BINDIR . '/php-cli.exe',
                PHP_BINDIR . '/php.exe',
            ];

            foreach ($binaryLocations as $binary) {
                if (is_readable($binary)) {
                    self::$binary = escapeshellarg($binary);
                    break;
                }
            }
        }

        if (self::$binary === null) {
            self::$binary = 'php';
        }

        return self::$binary;
    }
1220154
public function build()
    {
        $callback = $this->callback;

        $callback($this);

        if (is_null($this->primary)) {
            $this->primary = self::$defaultPrimary;
        }

        return $this;
    }
691937
public static function twoSha256($data, $binary = false)
    {
        return self::sha256(self::sha256($data, $binary), $binary);
    }
577034
public function andBinaryBody($body)
    {
        $this->response->setBody(BinaryInfo::BINARY_BODY_PREFIX . base64_encode($body));

        return $this;
    }