1: <?php
2:
3: namespace Charcoal\Model;
4:
5: /**
6: * Defines a model collection.
7: */
8: interface CollectionInterface extends \ArrayAccess, \Countable, \IteratorAggregate
9: {
10: /**
11: * Merge the collection with the given objects.
12: *
13: * @param array|Traversable $objs Array of objects to append to this collection.
14: * @return CollectionInterface
15: */
16: public function merge($objs);
17:
18: /**
19: * Add an object to the collection.
20: *
21: * @param object $obj An acceptable object.
22: * @return CollectionInterface
23: */
24: public function add($obj);
25:
26: /**
27: * Retrieve the object by primary key.
28: *
29: * @param mixed $key The primary key.
30: * @return object|null The object or NULL if not in the collection.
31: */
32: public function get($key);
33:
34: /**
35: * Determine if an object exists in the collection by key.
36: *
37: * @param string $key The primary key to lookup.
38: * @return boolean
39: */
40: public function has($key);
41:
42: /**
43: * Remove object from collection by primary key.
44: *
45: * @param mixed $key The object primary key to remove.
46: * @return CollectionInterface
47: */
48: public function remove($key);
49:
50: /**
51: * Remove all objects from collection.
52: *
53: * @return CollectionInterface
54: */
55: public function clear();
56:
57: /**
58: * Retrieve all objects in collection indexed by primary keys.
59: *
60: * @return object[] An associative array of objects.
61: */
62: public function all();
63:
64: /**
65: * Retrieve all objects in the collection indexed numerically.
66: *
67: * @return object[] A sequential array of objects.
68: */
69: public function values();
70:
71: /**
72: * Retrieve the primary keys of the objects in the collection.
73: *
74: * @return array A sequential array of keys.
75: */
76: public function keys();
77: }
78: