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

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,650 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,650 Points

Good to hear 🙂.

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