/** * the array that we use to matche the image name to the css cell * * @depends testInstantiateSprite */ public function testGetRelationshipArray() { // build the object $sprite = new Sprite('test'); $relationships = $sprite->getRelationshipArray(); // assert there are the expected number of relationships $this->assertArrayCount($relationships, 40); }
/** * takes the sprite folder and an image name, and returns the html used on the site to display a sprite * * @param string $sprite_name * @param string $image * @return string * @author Craig Ulliott */ function sprite($sprite_name, $image) { $sprite = new Sprite($sprite_name); $relationship_array = $sprite->getRelationshipArray(); //does this image exist in this sprite if (isset($relationship_array[$image])) { // get the cell id in the sprite for this image $class = $relationship_array[$image]; return '<span class="sprite_' . $sprite_name . ' ' . $class . '"></span>'; } throw new exception($image . ' not present in ' . $sprite . ' sprite'); }