Pop\Pdf\Object\Root::__construct PHP Метод

__construct() публичный Метод

Instantiate a PDF root object.
public __construct ( string $str = null ) : Root
$str string
Результат Root
    public function __construct($str = null)
    {
        // Use default settings for a new PDF and its root object.
        if (null === $str) {
            $this->data = "1 0 obj\n<</Pages 2 0 R/Type/Catalog>>\nendobj\n";
        } else {
            // Else, parse out any metadata and determine the root and parent object indices.
            $this->index = substr($str, 0, strpos($str, ' '));
            // Strip away any metadata reference, recording the metadata object index.
            if (strpos($str, '/Metadata') !== false) {
                $m = substr($str, strpos($str, 'Metadata'));
                $m = substr($m, 0, strpos($m, '/'));
                $m = str_replace('Metadata', '', $m);
                $m = str_replace('0 R', '', $m);
                $m = str_replace(' ', '', $m);
                $this->metadata = $m;
                $m = substr($str, strpos($str, 'Metadata'));
                $m = '/' . substr($m, 0, strpos($m, '/'));
                $str = str_replace($m, '', $str);
            }
            // Determine the parent index.
            $p = substr($str, strpos($str, 'Pages'));
            $p = substr($p, 5, strpos($p, '0 R') - 5);
            $p = str_replace(' ', '', $p);
            // Set the root object parent index and the data.
            $this->parent = $p;
            $this->data = $str . "\n";
        }
    }