private function add(
        Traversable $iterator = null,
        $message = null,
        $binary = false
    ) {
        static $count = 0;

        if ($iterator) {
            if ($message) {
                $this->putln('?', $message);
            }

            $box = $binary ? $this->box->getPhar() : $this->box;
            $baseRegex = $this->config->getBasePathRegex();
            $mapper = $this->config->getMapper();

            /** @var $file SplFileInfo */
            foreach ($iterator as $file) {
                if (0 === (++$count % 100)) {
                    gc_collect_cycles();
                }

                $relative = preg_replace($baseRegex, '', $file->getPathname());

                if (null !== ($mapped = $mapper($relative))) {
                    $relative = $mapped;
                }

                if ($this->isVerbose()) {
                    if (false === $file->isReadable()) {
                        throw new RuntimeException(
                            sprintf(
                                'The file "%s" is not readable.',
                                $file->getPathname()
                            )
                        );
                    }

                    $this->putln('+', $file);

                    if (null !== $mapped) {
                        $this->putln('>', $relative);
                    }
                }

                $box->addFile($file, $relative);
            }
        }
    }
private function add(
        Traversable $iterator = null,
        $message = null,
        $binary = false
    ) {
        static $count = 0;

        if ($iterator) {
            if ($message) {
                $this->putln('?', $message);
            }

            $box = $binary ? $this->box->getPhar() : $this->box;
            $baseRegex = $this->config->getBasePathRegex();
            $mapper = $this->config->getMapper();

            /** @var $file SplFileInfo */
            foreach ($iterator as $file) {
                if (0 === (++$count % 100)) {
                    gc_collect_cycles();
                }

                $relative = preg_replace($baseRegex, '', $file->getPathname());

                if (null !== ($mapped = $mapper($relative))) {
                    $relative = $mapped;
                }

                if ($this->isVerbose()) {
                    if (false === $file->isReadable()) {
                        throw new RuntimeException(
                            sprintf(
                                'The file "%s" is not readable.',
                                $file->getPathname()
                            )
                        );
                    }

                    $this->putln('+', $file);

                    if (null !== $mapped) {
                        $this->putln('>', $relative);
                    }
                }

                $box->addFile($file, $relative);
            }
        }
    }
private function add ( Traversable $ iterator = null , $ message = null , $ binary = false ) { static $ count = 0 ; if ( $ iterator ) { if ( $ message ) { $ this -> putln ( '?' , $ message ) ; } $ box = $ binary ? $ this -> box -> getPhar ( ) : $ this -> box ; $ baseRegex = $ this -> config -> getBasePathRegex ( ) ; $ mapper = $ this -> config -> getMapper ( ) ; /** @var $file SplFileInfo */ foreach ( $ iterator as $ file ) { if ( 0 === ( ++ $ count % 100 ) ) { gc_collect_cycles ( ) ; } $ relative = preg_replace ( $ baseRegex , '' , $ file -> getPathname ( ) ) ; if ( null !== ( $ mapped = $ mapper ( $ relative ) ) ) { $ relative = $ mapped ; } if ( $ this -> isVerbose ( ) ) { if ( false === $ file -> isReadable ( ) ) { throw new RuntimeException ( sprintf ( 'The file "%s" is not readable.' , $ file -> getPathname ( ) ) ) ; } $ this -> putln ( '+' , $ file ) ; if ( null !== $ mapped ) { $ this -> putln ( '>' , $ relative ) ; } } $ box -> addFile ( $ file , $ relative ) ; } } }
Adds files using an iterator.

@param Traversable $iterator The iterator.
@param string      $message  The message to announce.
@param boolean     $binary   Should the adding be binary-safe?

@throws RuntimeException If a file is not readable.
Adds files using an iterator .