DigitalOceanPHP / Client

DigitalOcean API v2 client for PHP
MIT License
710 stars 205 forks source link

Property name convention seems to be wrong #289

Closed zspine closed 3 years ago

zspine commented 3 years ago

ConvertToCamelCase is used in the DigitalOceanV2Entity::build function, and entity property names are in snake case.

mrsimonbennett commented 3 years ago

Might be so, but this is going to be an annoying breaking change for anyone using this :/

zspine commented 3 years ago

@mrsimonbennett yes I agree :) , but all property names with snake_case returns null value.

owner_uuid
default_ingress
created_at
updated_at
active_deployment
in_progress_deployment
last_deployment_created_at
live_url
tier_slug
live_url_base
live_domain
zspine commented 3 years ago

Another workaround is to use property overloading in the AbstractEntity.

    public function __get($property)
    {
        $property = static::convertToCamelCase($property);
        if (\property_exists($this, $property)) {
            return $this->{$property};
        }        

        $trace = debug_backtrace();
        trigger_error(
            'Undefined property ' . $property .
            ' in ' . $trace[0]['file'] .
            ' on line ' . $trace[0]['line'],
            E_USER_NOTICE);
        return null;
    }