title: PHP OOP - issue with Static functions and variable or use Singleton?
body: <p>I'm creating Class for Tax purpose, which I need to use it on some pages in my app. I need a general suggestion is it a good way or to use Singleton, I don't want to use Singleton but a Static version of my class, here's the code:</p>
  
  <pre><code>class CalculationCommon extends ObjectModel
  {
  
  // Customer Address Array Object
  public static $userCountryCode;
  
  public static $cartProducts;
  
  public static $shopID;
  
  public static $theTaxRateIs;
  
  public static $context;
  
  public function __construct( $cartProductList  )
  {
  
      self::$shopID           = Context::getContext()-&gt;shop-&gt;id
      self::$userCountryCode  = cart::getCustomerAddressDetail($cartProductList[0]['id_address_delivery']);
      self::$cartProducts     = $cartProductList;
  }
  
  /* 
  * @param array Product obj (all products in current cart)
  * Calculate the Tax Rate Globally for the cart, instead of caluculating individually everywehre.
  * If Address is in Canada then check if the tax rate is Flat or Destination base
  * If Outside of Canada then check the export rate whether flat or Individual attribute base
  */
  
  public static function calculateGlobalTaxRate( )
  {
  
      //Check if any attribute is taxable then apply Tax in Cart
      if( self::taxableCart())
      {
          if(self::$userCountryCode[0]['iso_code'] =='CA') // Inside of Canada
          {
              echo "CANADA&lt;br&gt;";
          }
          else
          {
              // Reserved for Export Rate Outside of Canada
          }
      }
      else
          $globalTaxRateIs = 0; // if No attribute prone for tax then no Tax
  
      // self::$theTaxRateIs = $globalTaxRateIs;
  
      return $globalTaxRateIs;
  }
  
  
  /*
  * Check if any attribute is taxable before apply Tax in Cart
  */
  public static function taxableCart()
  {
  
      return true;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here's what I'm creating an instance of this class in an abc page.</p>
  
  <pre><code>$this-&gt;thisOrderProduct //having an array for current cart products.
  $calculationClass = new CalculationCommon( $this-&gt;thisOrderProduct );
  echo $calculationClass::calculateGlobalTaxRate( );
  </code></pre>
  
  <p>I'm getting error while accessing the function of this class in another class, Please suggest me what is the best practice or Rules of Thumbs?</p>
  
  <p>Thanks in Advance,
  Nadeem</p>