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

sam poplack
sam poplack
9,467 Points

how do i return the room string

I am trying to solve the objective and am stick could someone help me please?

index.php
<?php

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


    }
}

?>

1 Answer

Mathieu St-Vincent
Mathieu St-Vincent
9,244 Points

You must pass a static function as such : self::staticFunction

You needed to get the dimensions from the $room->getDimensions() method.

<?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());
    }
}

?>
sam poplack
sam poplack
9,467 Points

it worked but where does the getDimensions come from we didn't assign that function? im confused on that part

Mathieu St-Vincent
Mathieu St-Vincent
9,244 Points

The accepted parameter $room will be an object which has a method named getDimensions.

[...]

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