Skip to content

Request Prefixing constants #4

@markwalet

Description

@markwalet

It seems like a good idea to define the constants in a namespace. This is generally seen as a good practice.

Something like the following would be nice:

class Token {

    const METHOD_UNIQUE = 'Unique';
    const METHOD_UNIQUE_STRING = 'UniqueString';
    const METHOD_UNIQUE_NUMBER = 'UniqueNumber';

    // ...
}

You can call this like the following:

switch ($this->DT_settings['type']) {
    case Token::METHOD_UNIQUE:
        $generated_token = $token->unique($table, $this->DT_Column, $this->DT_settings['size'], $this->DT_settings['special_chr']);

        break;
    case Token::METHOD_UNIQUE_NUMBER:
        $generated_token = $token->uniqueNumber($table, $this->DT_Column, $this->DT_settings['size'], $this->DT_settings['special_chr']);

        break;
}

This makes more sense than defining global constants and prefixing them with a abbreviation of the package name.

For backward compatibility you could leave the constants in (but deprecated) for this version. On the next main version you can delete those constants permanently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions