/** * @param mixed $key * @param mixed $value * @return void */ public function put($key, $value) { /** @var \ArrayObject $xs */ if (!$this->dict->contains($key)) { $this->dict->put($key, new \ArrayObject()); } $xs = $this->dict->get($key); $xs->append($value); }
public function testObjectKeys() { $josephine = new Rabbit("Josephine"); $flopsy = new Rabbit("Flopsy"); $mopsy = new Rabbit("Mopsy"); $cottontail = new Rabbit("Cotton-tail"); $josephine->addChild($flopsy); $josephine->addChild($mopsy); $josephine->addChild($cottontail); $dict = new Dictionary(); $dict->put($josephine, "josephine"); $dict->put($flopsy, "flopsy"); $dict->put($mopsy, "mopsy"); $dict->put($cottontail, "cottontail"); $this->assertEquals("josephine", $dict->get($josephine)); $this->assertEquals("flopsy", $dict->get($flopsy)); $this->assertEquals("mopsy", $dict->get($mopsy)); $this->assertEquals("cottontail", $dict->get($cottontail)); }