Inheritance of Public Methods in OOP in PHP

A child class inherits all public methods from its parents. Let's look at an example. Suppose we have a class with the following methods:

php<?php
  class User {
    private $name;
    
    public function setName($name) {
      $this->name = $name;
    }
    public function getName() {
      return $this->name;
    }
  }
?>

Suppose the following class inherits from this class:

php<?php
  class Student extends User {
    
  }
?>

Let's check that the methods were inherited. Let's create a new student object:

php<?php
  $student = new Student;
?>

Set his name using the inherited method:

php<?php
  $student->setName('john');
?>

Read his name using the inherited method:

php<?php
  $name = $student->getName();
  echo $name;
?>
Задание 1

Check that your class Employee inherits methods from the User class.