title: Is there reason to create class for single function?
body: <p>I've seen a lot of classes with a <strong>SINGLE</strong> function in it. Why do they put a SINGLE function into class?</p>
  
  <p>I use classes just to make things more clear, but about those who put a SINGLE function into class? Is there any reason for it?</p>
  
  <p>I see no difference between these:</p>
  
  <pre><code>&lt;?php
  class Image {
      private $resource;
      function resize($width, $height) {
          $resized = imagecreatetruecolor($width, $height);
          imagecopyresampled($resized, $this-&gt;resource, 0, 0, 0, 0, $width, $height, imagesx($this-&gt;resource), imagesy($this-&gt;resource));
          $this-&gt;resource = $resized;
      }
  }
  $image = new Image();
  $image-&gt;resource = "./someimage.jpg";
  $image-&gt;resize(320, 240);
  </code></pre>
  
  <p>and
      
  
  <pre><code>    function resize($width, $height) {
          $resource = "./someimage.jpg";    
          $resized = imagecreatetruecolor($width, $height);
          imagecopyresampled($resized, $resource, 0, 0, 0, 0, $width, $height, imagesx($resource), imagesy($resource));
          $resource = $resized;
          return $resource;
      }
  
  resize(320, 240);
  </code></pre>
  
  <p>My thought was that $resource is the main reason, because it's private:</p>
  
  <pre><code>class Image {
      private $resource;
      function resize($width, $height) {
          $resized = imagecreatetruecolor($width, $height);
          imagecopyresampled($resized, $this-&gt;resource, 0, 0, 0, 0, $width, $height, imagesx($this-&gt;resource), imagesy($this-&gt;resource));
          $this-&gt;resource = $resized;
      }
  }
  
  $image-&gt;resize(320, 240);
  </code></pre>
  
  <p>and therefore isn't accessible to the global scope. But why isn't a simple function used in this case?</p>