title: Object of class Dollar could not be converted to int
body: <p>I was going through the book named "Test-Driven Development By Example" By the author Kent Beck. </p>
  
  <p>I am trying to write a similar function in php but not understanding the steps.</p>
  
  <p>Original function:</p>
  
  <p>Test function:</p>
  
  <pre><code>public void testEquality() {
      assertTrue(new Dollar(5).equals(new Dollar(5)));
      assertFalse(new Dollar(5).equals(new Dollar(6)));
  }
  </code></pre>
  
  <p>Class function: </p>
  
  <pre><code>public boolean equals(Object object) {
     Dollar dollar = (Dollar) object;
     return amount == dollar.amount;
  }
  </code></pre>
  
  <p>My code:</p>
  
  <p>Test function:</p>
  
  <pre><code>public function setup() {
     $this-&gt;dollarFive = new Dollar(5);
  }
  
  public function testEquality() {
      $this-&gt;assertTrue($this-&gt;dollarFive-&gt;equals(new Dollar(5)));
  }
  </code></pre>
  
  <p>Class Function:</p>
  
  <pre><code>class Dollar
  {   
    public function __construct($amount) {
      $this-&gt;amount = (int) $amount;
    }
  
     public function equals(Dollar $object) {
       $this-&gt;Object = $object;
       return $this-&gt;amount == $this-&gt;Object;
     }    
  }
  </code></pre>
  
  <p>While executing the test case i am getting the following error.</p>
  
  <blockquote>
    <p>Object of class Dollar could not be converted to int</p>
  </blockquote>
  
  <p>Need some help on this. How can i fix this?</p>