title: PHP OOP best practices of specifying property to be adjusted
body: <p>I'm trying to use a class that determine the salary and number of people with a salary, OOP is new to me and I have gone through plenty of tutorials and examples, but I am not sure if I am using best practices in the following:</p>
  
  <pre><code>class quickCalc
  {
      private $salary = 0;
      private $person = 0;
      private $person_salary = 0;
  
      private animal = 0;
      private animal_salary = 0;
  
      public function addCost($type, $salary)
      {
          $this-&gt;$type++;
  
          $type_two = $type.'_salary';
  
          $this-&gt;$type_two += $salary;
      }
  
      public function getCount($type)
      {
          return $this-&gt;$type;
      }
  
      public function getCost($type)
      {
          $type = $type.'_salary';
          return $this-&gt;$type;
      }
  
  }   
  
  $test = new quickCalc();
  $test-&gt;addCost('person', 15000);
  
  echo $test-&gt;getCount('person'); //1
  echo $test-&gt;getCost('person'); //10000
  echo $test-&gt;getCount('animal'); //0
  </code></pre>
  
  <p>So as can be seen, as I add a person, or animal, etc, the related property increases by 1, and the salary value is added to the existing value</p>
  
  <p>What I am not sure of, is if it is best practice to pass the property name through the object, as shown:</p>
  
  <pre><code>public function addCost($type, $salary)
  {
      $this-&gt;$type++;
  }
  </code></pre>
  
  <p>or should each property have its own function, such as this:</p>
  
  <pre><code>public function addPerson($salary)
  {
      $this-&gt;person++;
      $this-&gt;person_salary++;
  }
  </code></pre>