PHP-də OOP-də dəyişəndən metod adını istifadə etmək

Xassə adlarının dəyişəndə saxlanmasına bənzə şəkildə metod adları da saxlanıla bilər. Gəlin bir nümunəyə baxaq. Bizə aşağıdakı User sinifi və onun xassə geterləri verilib:

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

Bu sinifdən bir obyekt yaradaq:

php<?php
  $user = new User('john', 'smit');
?>

Tutaq ki, dəyişəndə metodun adı saxlanılır:

php<?php
  $method = 'getName';
?>

Gəlin dəyişəndən gələn adla metodu çağıraq:

php<?php
  echo $user->$method(); // 'john' çap edəcək
?>
Задание 1

Aşağıdakı sinif verilib:

php<?php
  class Employee
  {
    private $name;
    private $salary;
    private $position;
    
    public function __construct($name, $salary, $position)
    {
      $this->name = $name;
      $this->salary = $salary;
      $this->position = $position;
    }
    
    public function getName()
    {
      return $this->name;
    }
    
    public function getSalary()
    {
      return $this->salary;
    }
    
    public function getPosition()
    {
      return $this->position;
    }
  }
?>

Aşağıdakı massiv verilib:

php<?php
  $methods = [
    'method1' => 'getName',
    'method2' => 'getSalary',
    'method3' => 'getPosition',
  ];
?>

Employee sinfindən bir obyekt yaradın və sonra onun xassələrinə massiv elementləri vasitəsilə müraciət edin.