__construct() public method

Instantiate the file object, either from a file on disk or as a new file.
public __construct ( string $file, array $types = null ) : File
$file string
$types array
return File
Exemplo n.º 1
0
 /**
  * Constructor
  *
  * Instantiate the file writer object.
  *
  * @param  string $file
  * @param  array  $types
  * @return \Pop\Log\Writer\File
  */
 public function __construct($file, $types = null)
 {
     parent::__construct($file, $types);
 }
Exemplo n.º 2
0
 /**
  * Constructor
  *
  * Instantiate a PDF file object based on either a pre-existing PDF file on disk,
  * or a new PDF file. Arguments may be passed to add a page upon instantiation.
  * The PDF file exists, it and all of its assets will be imported.
  *
  * @param  string $pdf
  * @param  string $sz
  * @param  int    $w
  * @param  int    $h
  * @return \Pop\Pdf\Pdf
  */
 public function __construct($pdf, $sz = null, $w = null, $h = null)
 {
     $this->fillColor = new \Pop\Color\Space\Rgb(0, 0, 0);
     $this->backgroundColor = new \Pop\Color\Space\Rgb(255, 255, 255);
     parent::__construct($pdf);
     $this->objects[1] = new Object\Root();
     $this->objects[2] = new Object\ParentObject();
     $this->objects[3] = new Object\Info();
     // If the PDF file already exists, import it.
     if ($this->size != 0) {
         $this->import($this->fullpath);
     }
     // If page parameters were passed, add a new page.
     if (null !== $sz || null !== $w && null !== $h) {
         $this->addPage($sz, $w, $h);
     }
 }
Exemplo n.º 3
0
 /**
  * Constructor
  *
  * Instantiate the archive object
  *
  * @param  string $archive
  * @param  string $password
  * @param  string $prefix
  * @return \Pop\Archive\Archive
  */
 public function __construct($archive, $password = null, $prefix = 'Pop\\Archive\\Adapter\\')
 {
     $this->allowed = self::formats();
     parent::__construct($archive);
     $this->setAdapter($password, $prefix);
 }
Exemplo n.º 4
0
 /**
  * Constructor
  *
  * Instantiate the code generator object
  *
  * @param  string $file
  * @param  int    $type
  * @return \Pop\Code\Generator
  */
 public function __construct($file, $type = Generator::CREATE_NONE)
 {
     parent::__construct($file);
     if ($type == self::CREATE_CLASS) {
         $this->createClass();
     } else {
         if ($type == self::CREATE_INTERFACE) {
             $this->createInterface();
         } else {
             if ($type == self::CREATE_NONE && file_exists($file)) {
                 $this->body = str_replace('<?php', '', $this->read());
                 $this->body = trim(str_replace('?>', '', $this->body)) . PHP_EOL . PHP_EOL;
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Constructor
  *
  * Instantiate an SVG image object based on either a pre-existing SVG image
  * file on disk, or a new SVG image file.
  *
  * @param  string                          $svg
  * @param  int|string                      $w
  * @param  int|string                      $h
  * @param  \Pop\Color\Space\ColorInterface $color
  * @throws Exception
  * @return \Pop\Image\Svg
  */
 public function __construct($svg, $w = null, $h = null, ColorInterface $color = null)
 {
     parent::__construct($svg);
     // If SVG image exists, get image info and store in an array.
     if (file_exists($this->fullpath) && $this->size > 0) {
         $this->resource = new \SimpleXMLElement($svg, null, true);
         $w = $this->resource->attributes()->width;
         $h = $this->resource->attributes()->height;
         // If SVG image does not exists, check to make sure the width and height
         // properties of the new SVG image have been passed.
     } else {
         if (null === $w || null === $h) {
             throw new Exception('Error: You must define a width and height for a new image object.');
         }
         $this->backgroundColor = null !== $color ? $color : new Rgb(255, 255, 255);
         $newSvg = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg width=\"{$w}\" height=\"{$h}\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n    <desc>\n        SVG Image generated by Pop PHP Library\n    </desc>\n</svg>\n";
         $this->resource = new \SimpleXMLElement($newSvg);
         if (null !== $color) {
             $rect = $this->resource->addChild('rect');
             $rect->addAttribute('x', '0' . $this->units);
             $rect->addAttribute('y', '0' . $this->units);
             $rect->addAttribute('width', $w);
             $rect->addAttribute('height', $h);
             $rect->addAttribute('fill', $color->get(3, true));
         }
     }
     if (!is_numeric(substr($w, -1)) && !is_numeric(substr($w, -2, 1))) {
         $unit = substr($w, -2);
         if (in_array($unit, $this->allowedUnits)) {
             $this->units = $unit;
         }
         $this->width = (double) substr($w, 0, -2);
         $this->height = (double) substr($h, 0, -2);
     } else {
         if (!is_numeric(substr($w, 0, -1)) && substr($w, 0, -1) == '%') {
             $this->units = '%';
             $this->width = (double) substr($w, 0, -1);
             $this->height = (double) substr($h, 0, -1);
         } else {
             $this->width = (double) $w;
             $this->height = (double) $h;
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Constructor
  *
  * Instantiate a font file object based on a pre-existing font file on disk.
  *
  * @param  string $font
  * @throws Exception
  * @return \Pop\Font\AbstractFont
  */
 public function __construct($font)
 {
     if (!file_exists($font)) {
         throw new Exception('The font file does not exist.');
     }
     $this->flags = new \ArrayObject(array('isFixedPitch' => false, 'isSerif' => false, 'isSymbolic' => false, 'isScript' => false, 'isNonSymbolic' => false, 'isItalic' => false, 'isAllCap' => false, 'isSmallCap' => false, 'isForceBold' => false), \ArrayObject::ARRAY_AS_PROPS);
     parent::__construct($font);
 }
Exemplo n.º 7
0
 /**
  * Constructor
  *
  * Instantiate an image file object based on either a pre-existing
  * image file on disk, or a new image file.
  *
  * @param  string                          $img
  * @param  int|string                      $w
  * @param  int|string                      $h
  * @param  \Pop\Color\Space\ColorInterface $color
  * @param  array                           $types
  * @return \Pop\Image\AbstractImage
  */
 public function __construct($img, $w = null, $h = null, ColorInterface $color = null, $types = null)
 {
     parent::__construct($img, $types);
 }