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 Extending Object-Oriented PHP Extending the Family Grandchild Relationships

Bummer! Use the keyword "this" to access internal properties.

I don't know why my getter is not passing.

The Questions is:

Step 1: In the Manager.php file, create a new class named "Manager" that takes it's initial abilities and attributes from both the User class, and the Developer class. Step 2: Add a new Manager array property named "reports" along with its GETTERS and SETTERS.

Step 1 ask me to create a child from Developer (which is a child from User). Step two is pretty straightforward, but I just forgot something I can't see.

Thanks

User.php
<?php
//do not modify this file
class User {
    protected $name;
    protected $title;

    public function __construct($name = null, $title = null) {
        $this->name = $name;
        $this->title = $title;
    }

    public function __toString() {
        return $this->getSalutation();
    }

    public function getSalutation() {
        return $this->title . " " . $this->name;
    }

    public function getName() {
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function getTitle() {
        return $this->title;
    }

    public function setTitle($title) {
        $this->title = $title;
    }
}
Developer.php
<?php
//do not modify this file
class Developer extends User 
{
  protected $skills;

  public function getSkills() {
      return $this->skills;
  }

  public function setSkills($array) {
      $this->skills = $array;
  }

  public function displayUserSkills() {
      return $this->getName() . ' has the following skills: ' . implode(", ", $this->skills);
  }
}
Manager.php
<?php
//add code for Manager class here

class Manager extends Developer
{
  protected $reports = array();

   public function setReports($value)
  {
    $this->reports[] = $value;
  }

   public function getReports()
  {
    return $this->reports;
  }

}

1 Answer

devope devope
devope devope
11,490 Points
<?php
//add code for Manager class here

class Manager extends Developer {

  protected $reports = array();

  public function getReports(){
    return $this->reports;
  }

  public function setReports($reports){
    $this->reports = $reports;
  }

}

YEsss... Thanks dude. I should have tried that. I thought it was the getter but it was the setter. I was pushing a $value in the array but it seems the parameter at the setter isn't a value like in an "add" function, but an array itself. Gonna rewatch a few vids.

Thanks for the reply.