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

I have no idea what i should do here.

Hello, i guess that this is my worst lesson i ever had. I feel like i forgot what speaking and reading is. For an excuse, english isn't my native language so i might not understand it, for some reason... i doubt it tho.

So, $room object has a getDimensions method, ok. Add a return value to the detailsKitchen. return "Kitchen Dimensions: ".somethinghere; , ok. length x width is returned from displayDimensions.

return "Kitchen Dimensions: ".self::displayDimensions(); The displayDimensions has already an array with dimensions.

Call displayDimensions inside the Render class, ok.

Now even tho there is an array from the last step i need to get the dimensions from the $room object. So it would be $room->getDimensions right?

But what the heck is getDimensions returning? Json object, string, array with two integers? $room and getDimensions is just a black box that i don't see so i have no idea what they return. A snippet would be all i need.

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

  $this->display
}
?>

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Damian Toczek,

You are very close to the required answer!

A couple of things to point out first:

  1. $this->display isn't needed and is invalid code, it can be safely removed since the task doesn't require it
  2. The task asks us to use the getDimensions method on the $room object but you haven't done so in your attempt

To solve this, we simply need to pass the value of getDimensions to our static displayDimensions method as seen below.

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

?>

Happy coding!

A friend help me a bit... yes i know it's "SELF::" because it's static.

Chris Shaw
Chris Shaw
26,676 Points

Good to hear 🙂.

I'm not sure what you mean by your comment though as I didn't question you in that regard.