Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Object-Oriented PHP Basics Building the Recipe Static

Where do i get the getDimensions method?

not sure where i am supposed to call the getDimensions method from, keep calling it in different ways and it still doesn't work. I assumed it was just public method in order to access the private variable dimensions from $room.

index.php
<?php

class Render {
    public static function displayDimensions($size){

      return $size[0]." x ".$size[1];    
    }

    public static function detailsKitchen($room){

      return "Kitchen Dimensions".Render::displayDimensions($room);

    }
}
  Render::displayDimensions($room->getDimensions());
?>

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The getDimensions method is defined somewhere outside of this code. We are just supposed to use it. The first part of your return statement (the string literal) is incorrect. It should be "Kitchen Dimensions: ". You've omitted a colon and a space.

However, as far as the placement of the call to getDimensions you were definitely on the right track! What you need here is a combination of the return line you have and the line you have at the bottom. Take a look at how close you actually are:

return "Kitchen Dimensions: " . self::displayDimensions($room->getDimensions());

This will return "Kitchen Dimensions: " and concatenate the dimensions of the object (remember we sent in the dimensions earlier) and then the result of running the getDimensions method on the $room that was passed in. We get the dimensions and pass them in to displayDimensions and concatenate them onto the end of the string literal.

Hope this helps! :sparkles: