PHP Classes

File: ArrayOfGenericX.php

Recommend this page to a friend!
  Classes of Martin Alterisio   Generic Array   ArrayOfGenericX.php   Download  
File: ArrayOfGenericX.php
Role: Class source
Content type: text/plain
Description: Array generic template
Class: Generic Array
Create arrays that allow members of just one type
Author: By
Last change: Access without login.
Date: 16 years ago
Size: 665 bytes
 

Contents

Class file image Download
<?php
/**
 * @package genericarray
 */

/**
 * Array of GenericX.
 */
class ArrayOfGenericX extends ArrayObject {
   
/**
     * Sets an item in the array.
     * @param int|string $offset The offset of the item.
     * @param GenericX $value The value of the item.
     */
   
public function offsetSet($offset, $value) {
       
$this->checkType($value);
       
parent::offsetSet($offset, $value);
    }
   
   
/**
     * Uses type hints to check the type of the value being inserted into the array.
     * @param GenericX $value The value being inserted into the array.
     */
   
private function checkType(GenericX $value) { }
}
?>