W3cubDocs

/Phalcon 2

Class Phalcon\Annotations\Collection

implements Iterator, Traversable, Countable

Represents a collection of annotations. This class allows to traverse a group of annotations easily

//Traverse annotations
 foreach ($classAnnotations as $annotation) {
     echo 'Name=', $annotation->getName(), PHP_EOL;
 }

 //Check if the annotations has a specific
 var_dump($classAnnotations->has('Cacheable'));

 //Get an specific annotation in the collection
 $annotation = $classAnnotations->get('Cacheable');

Methods

public __construct ([array $reflectionData])

Phalcon\Annotations\Collection constructor

public int count ()

Returns the number of annotations in the collection

public rewind ()

Rewinds the internal iterator

public Phalcon\Annotations\Annotation current ()

Returns the current annotation in the iterator

public int key ()

Returns the current position/key in the iterator

public next ()

Moves the internal iteration pointer to the next position

public boolean valid ()

Check if the current annotation in the iterator is valid

public Phalcon\Annotations\Annotation [] getAnnotations ()

Returns the internal annotations as an array

public Phalcon\Annotations\Annotation get (string $name)

Returns the first annotation that match a name

public Phalcon\Annotations\Annotation [] getAll (string $name)

Returns all the annotations that match a name

public boolean has (string $name)

Check if an annotation exists in a collection

© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Annotations_Collection.html