Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static properties in Merchant_Billing_Gateway class #10

Closed
akDeveloper opened this issue Jun 1, 2011 · 1 comment
Closed

Static properties in Merchant_Billing_Gateway class #10

akDeveloper opened this issue Jun 1, 2011 · 1 comment
Labels

Comments

@akDeveloper
Copy link
Owner

In Merchant_Billing_Gateway class there are some properties that must be available without making an instance of class.
These properties are:
$default_currency;
$supported_countries;
$homepage_url;
$display_name;
$supported_cardtypes;
$money_format;

This is useful when we want to display information for each gateway, without make an instance. Also an instance requires some options in constructor that may not be available to someone who wants just to see what each gateway supports.

First thought is to make these properties static and access their values via Reflection class.

But ... $money_format and $supported_cardtypes are used in amount() and supported_cardtypes(), methods. So if we make them static and use self::$money_format or self::$supported_countries this will end up with the default value of Merchant_Billing_Gateway and not the value we have in each Gateway.

Is there any way to resolve this?

@akDeveloper
Copy link
Owner Author

The solution was possible with Reflection class as well.
In money format() method:

  public function money_format() {
    $class = get_class($this);
    $ref = new ReflectionClass($class);
    return $ref->getStaticPropertyValue('money_format');
  }

So in amount() method the line where $this->money_format is, will change to $this->money_format()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant