setasign\SetaPDF2\Core\Type

PdfArray Class representing an array

File: /SetaPDF v2/Core/Type/PdfArray.php
Old class name (alias): \SetaPDF_Core_Type_Array

Class hierarchy

Implements

Summary

Properties

$_count

protected int PdfArray::$_count = 0

The array count

$_observed

protected bool AbstractType::$_observed = false

Defines if this object is under observation

$_observers

protected array AbstractType::$_observers = array()

The Objects to notify on any change

This will be the PDF document or another value holding this one. Initially this will be an array.

$_values

protected array PdfArray::$_values = array()

The values

An array of AbstractType objects

$metadata

public array AbstractType::$metadata = array()

An array for individual metadata.


Static Methods

_ensureType()

protected static AbstractType::_ensureType (
string $type,
mixed $value,
string $errorMessage,
$ensure = true
): mixed

Ensure that a value is an instance of a specific PDF type.

Parameters
$type : string
 
$value : mixed
 
$errorMessage : string
 
$ensure
 
Exceptions

Throws Exception

ensureType()

public static PdfArray::ensureType (
mixed $array,
?int $size = null
): self

Ensures that the passed array is a PdfArray instance with a (optional) specific size.

Parameters
$array : mixed
 
$size : ?int
 
Exceptions

Throws Exception

ensureWithType()

public static AbstractType::ensureWithType (
string $type,
mixed $value
): \SetaPDF_Core_Type_AbstractType

Ensures that the passed value is an instance of the passed type.

Parameters
$type : string
 
$value : mixed
 
Exceptions

Throws Exception

is()

public static AbstractType::is (
string $type,
mixed $value,
bool $ensure = true
): bool

Checks if the type of a value is the expected one.

Indirect references will be evaluated if $ensure is set to true.

Parameters
$type : string
 
$value : mixed
 
$ensure : bool
 

writePdfString()

public static PdfArray::writePdfString (
\SetaPDF_Core_WriteInterface $writer,
array $values
): void

Parses a php array to a pdf array string and writes it into a writer.

Parameters
$writer : \SetaPDF_Core_WriteInterface
 
$values : array
 
Exceptions

Throws \InvalidArgumentException

See

Methods

__construct()

public PdfArray::__construct (
?array $values = null
)

The constructor.

Parameters
$values : ?array

An array filled with values of type AbstractType

Exceptions

Throws \InvalidArgumentException

__sleep()

public AbstractType::__sleep (
void
): array

Implementation of __sleep.

We remove the observers from all elements because they will get read if they are waked up in an observed object.

__wakeup()

public AbstractType::__wakeup (
void
): void

Implementation of __wakeup.

Unset the observed flag.

attach()

public PdfArray::attach (
\SplObserver $observer
): void

Add an observer to the object.

This method forwards the "attach()"-call to all values of this array.

Parameters
$observer : \SplObserver
 

cleanUp()

public PdfArray::cleanUp (
void
): void

Release objects/memory.

See

clear()

public PdfArray::clear (
void
): void

Clears the array.

count()

public PdfArray::count (
void
): int

Returns the number of elements in the array.

current()

Returns the current element.

deepClone()

Clone the object recursively in the context of a document.

Parameters
$document : \SetaPDF_Core_Document
 

detach()

public AbstractType::detach (
\SplObserver $observer
): void

Detach an observer from the object.

Implementation of the Observer Pattern.

Parameters
$observer : \SplObserver
 

detachAll()

public AbstractType::detachAll (
void
): void

Detach all observers from this object.

Be careful with this method!!!

ensure()

public AbstractType::ensure (
?bool $forceObservation = null,
array &$ensuredObjectsList = array ( )
): \SetaPDF_Core_Type_AbstractType

Returns the main value.

This method is used for automatically resolving of indirect references.

Parameters
$forceObservation : ?bool
 
$ensuredObjectsList : array

A list of all ensured indirect objects to prevent recursion

getChildren()

public PdfArray::getChildren (
void
): array

Returns an iterator for the current entry.

getValue()

public PdfArray::getValue (
void
): array

Get the value.

hasChildren()

public PdfArray::hasChildren (
void
): bool

Check whether the current entry is an PdfArray.

indexOf()

Returns the index of the element.

If the element isn't in this array -1 will be returned.

Parameters
$element : \SetaPDF_Core_Type_AbstractType|\SetaPDF_Core_Type_IndirectObjectInterface
 

insertBefore()

public PdfArray::insertBefore (
\SetaPDF_Core_Type_AbstractType $value,
?int $beforeIndex = 0
): void

Inserts an element before another one.

Index mustn't be higher than the count of elements in array.

Index 0 is allowed in an empty array.

Parameters
$value : \SetaPDF_Core_Type_AbstractType
 
$beforeIndex : ?int
 
Exceptions

Throws \InvalidArgumentException

isObserved()

public AbstractType::isObserved (
void
): bool

Checks if this object is observed.

key()

public PdfArray::key (
void
): int

Returns the key of the current element.

merge()

public PdfArray::merge (
void
): void

Merges this PDF array with other PDF arrays.

Exceptions

Throws \InvalidArgumentException

mergeUnique()

public PdfArray::mergeUnique (
void
): void

Merges this PDF array with other PDF arrays while only taking not existing values.

Exceptions

Throws \InvalidArgumentException

next()

Moves forward to next element.

notify()

public AbstractType::notify (
void
): void

Notifies all attached observers.

Implementation of the Observer Pattern.

Has to be called by any method that changes a value.

offsetExists()

public PdfArray::offsetExists (
int $offset
): bool

Checks whether a offset exists.

Parameters
$offset : int

An offset to check for.

offsetGet()

Offset to retrieve.

Parameters
$offset : int

The offset to retrieve.

offsetSet()

public PdfArray::offsetSet (
?int $offset,
\SetaPDF_Core_Type_AbstractType $value
): void

Offset to set.

Parameters
$offset : ?int

The offset to assign the value to.

$value : \SetaPDF_Core_Type_AbstractType

The value to set.

Exceptions

Throws \InvalidArgumentException

offsetUnset()

public PdfArray::offsetUnset (
string $offset
): void

Checks whether an offset exists.

Parameters
$offset : string
 

push()

Pushes a value onto the end of the array.

Parameters
$value : \SetaPDF_Core_Type_AbstractType
 

rewind()

public PdfArray::rewind (
void
): void

Rewinds the Iterator to the first element.

setValue()

public PdfArray::setValue (
array|\SetaPDF_Core_Type_Array $values
): void

Sets the values.

Parameters
$values : array|\SetaPDF_Core_Type_Array

An array of AbstractType objects

Exceptions

Throws \InvalidArgumentException

toPdfString()

public PdfArray::toPdfString (
?\SetaPDF_Core_Document $pdfDocument = null
): string

Returns the type as a formatted PDF string.

Parameters
$pdfDocument : ?\SetaPDF_Core_Document
 

toPhp()

public PdfArray::toPhp (
bool $ensure = false
): array

Converts the PDF data type to a PHP data type and returns it.

Parameters
$ensure : bool
 
See

unshift()

Prepends one element to the beginning of the array.

Parameters
$value : \SetaPDF_Core_Type_AbstractType
 

update()

public PdfArray::update (
\SplSubject $subject
): void

Triggered if a value of this object is changed.

Forward this to other observers.

Parameters
$subject : \SplSubject
 

valid()

public PdfArray::valid (
void
): bool

Checks if current position is valid.

See

writeTo()

public PdfArray::writeTo (
\SetaPDF_Core_Document $pdfDocument
): void

Writes the type as a formatted PDF string to the document.

Parameters
$pdfDocument : \SetaPDF_Core_Document