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

Igor Skoldin
Igor Skoldin
6,779 Points

How do I get a private property dimensions?

I need to call the displayDimensions method like this: self::displayDimensions($dimensions); but have no idea how to get dimensions.

I cannot access it directly like $room->dimensions and there is no getter so that I could access them as $room->getDimensions();. And, actually, $room is not an instantiated class but an object, is this correct?

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

?>

1 Answer

Shane Oliver
Shane Oliver
19,977 Points
// you are not passing the width and length from the room object to the method
return 'Kitchen Dimensions: ' . self::displayDimensions($room->getDimensions());
Igor Skoldin
Igor Skoldin
6,779 Points

Weird, I definitely tried it and it didn't work for me. Actually, I should have taken a look at var_dump(get_class_methods($room));

Thanks for your reply, the issue is resolved.