Skip to content

Instantly share code, notes, and snippets.

@manchuck
Created August 20, 2015 16:47
Show Gist options
  • Save manchuck/20894bd8273c289a0250 to your computer and use it in GitHub Desktop.
Save manchuck/20894bd8273c289a0250 to your computer and use it in GitHub Desktop.

Code Style Guide

  1. Follow PSR 0, 1, 2
  2. For gateways, use fetch, fetchBy, save, attach, detach and delete ex: fetchByEmail, saveChannel, deleteProduct, attachUser
    1. Fetch MUST include the noun on singular and All with fetching multiple ex: fetchProduct, fetchAllAccounts, fetchAllActiveUsers
    2. FetchBy MUST include the noun ex: fetchByEmail, fetchByName
    3. Save, delete, attach and detach MUST include the noun ex: attachUser, saveJob, detachAccount
    4. If you need to update part of an document, use the term update and the singular noun Good: updateUserPassword, updateProductPrice Bad: updateUsersPassword, saveNewProductPrice
  3. When Talking with 3rd party services, follow the rules for gateways however
    1. use import instead of fetch
    2. use send instead of save
    3. use remove instead of delete
  4. Abstract classes MUST HAVE the first word be "Abstract" ex: AbstractFooClass
  5. Interfaces MUST HAVE the last word be "Interface" ex: FooBarInterface
  6. Traits MUST HAVE the last word be "Trait" ex: FooBarTrait
  7. Events on object that will be series MUST be in the follow order: event.pre, event, event.post ex: saveUser.pre, saveUser, saveUser.post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment