Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Object-Oriented PHP Basics Building the Recipe Static

The accepted parameter $room will be an object which has a method named getDimensions. Add a return value to the details

The accepted parameter $room will be an object which has a method named getDimensions. Add a return value to the detailsKitchen method that displays "Kitchen Dimensions: length x width", where length x width is returned from the displayDimensions method. You will need to call the static method displayDimensions from within the Render class and pass the dimensions from the $room object using the getDimensions method Final Output Example: Kitchen Dimensions: 12 x 14

guys can you help me to solve this I'm hands up no idea how to solve this here is the link

https://teamtreehouse.com/library/objectoriented-php-basics-2/building-the-recipe/static

index.php
<?php

class Render {
    public static function displayDimensions($size){
    return $size[0] . " x " . $size[1];
    }
  public static function detailsKitchen($room){
    return "Kitchen Dimensions" . self :: displayDimensions();
  }
}


?>

You've got it, you just forgot to address the part that says "pass the dimensions from the $room object using the getDimensions method". So ask yourself "How do I pass a method from another object into the displayDimensions() method?"

2 Answers

Simon Coates
Simon Coates
28,692 Points

it seems to accept:

<?php
class Render {
    public static function displayDimensions($size){
    return $size[0] . " x " . $size[1];
    }

    public static function detailsKitchen($room){
        return "Kitchen Dimensions: " .self::displayDimensions($room->getDimensions());
  }
}
?>

thanks i did the same code before but i don't know it give me an error when i pass $room object into displayDimensions() the error say that "the object from Render class cannot convert to string " this error occur, by the way thank for response

gurpreet singh
gurpreet singh
9,625 Points

check this code <?php class Render { public static function displayDimensions($size){ return "$size[0] x $size[1]"; }

public static function detailsKitchen($room){
    return "Kitchen Dimensions: " .self::displayDimensions($room->getDimensions());

} } ?>