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

Can someone help me with this code? I'm somewhat lost!

why is it telling me this? Make sure you add a return value to the detailsKitchen method.

I'm pretty sure that's what I did. Did I pass the parameters incorrectly?

index.php
<?php

class Render {

  public static function displayDimensions($size)
  {
    return $size[0] . " x " . $size[1];
  }

  public static function getDimensions($room)
  {
    return $size->room;
  }

    public static function detailsKitchen($room)
    {
return self::getDimensions($room);
    }
}

1 Answer

following code passes:

<?php
class Render {
    public static function  displayDimensions($size)
    {
      return "{$size[0]} x {$size[1]}"; //odd syntax, but just concatenation
    }
  public static function detailsKitchen($room){
    return "Kitchen Dimensions: ". self::displayDimensions($room->getDimensions());
  }
}
?>

The key feature is that you are meant to call getDimensions on the room variable, which is an object.

Simon, Thank you. But could you please elaborate why what I did was wrong? I would really appreciate it.

The problem was that you are meant to call getDimensions on $room. The room object is of a class that has a getDimensions method already defined. It returns an array, which is used as the argument for the static displayDimensions method. And you need to concatenate with "Kitchen Dimensions: " to produce the requested string.

I see it now! thank you!