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

Map simpleType restriction to constants #20

Open
flerro opened this issue Jan 31, 2011 · 2 comments
Open

Map simpleType restriction to constants #20

flerro opened this issue Jan 31, 2011 · 2 comments

Comments

@flerro
Copy link

flerro commented Jan 31, 2011

IMHO, mapping a simpleType restriction to a group of static members would help producing less error-prone code.

e.g. mapping

<xs:simpleType name="ActivityStatus">
    <xs:restriction base="xs:string">
        <xs:enumeration value="pending"/>
        <xs:enumeration value="in_progress"/>
                    ...
    </xs:restriction>
</xs:simpleType>

to

class ActivityStatus {
     public static $PENDING = "pending";
     public static $IN_PROGRESS = "in_progress";
     ....
}

would allow a safer usage of ActivityStatus values

    $myStatus = ActivityStatus::$PENDING;
@mikebevz
Copy link
Member

mikebevz commented Feb 1, 2011

Hey,

Thanks for feedback.

Regarding your idea. It's also possible to use class constant (fx, const constant = 'constant value';) instead of static properties. Have you got any pro/contra for both options?

@flerro
Copy link
Author

flerro commented Feb 1, 2011

Sorry I'm not a PHP expert... const is way better as I see here:

http://stackoverflow.com/questions/1685922/php5-const-vs-static

Thanks

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

No branches or pull requests

2 participants