Skip to content

Instantly share code, notes, and snippets.

@antonioribeiro
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonioribeiro/4276a55902b5be63026e to your computer and use it in GitHub Desktop.
Save antonioribeiro/4276a55902b5be63026e to your computer and use it in GitHub Desktop.

#####Let's say someone has this class

<?php 

// 

class Load {

    public static function load($file)
    {
        $lines = [];
    
        foreach (File::load($file) as $key => $value) 
        {
            $value = sanitize($value);
            
            $lines[$key] = transformToPHPDataType($value);
        }

        return $lines;
    }

    private static function sanitize($value)
    {
        /// do a lot of things to sanitize the value
        /// do a lot of things to sanitize the value
        /// do a lot of things to sanitize the value
        /// do a lot of things to sanitize the value
        
        return $value;
    }

    private static function sanitize($value)
    {
      /// do whatever is needed
      
      $return $value;
  } 
}

#####And I need to change a little bit the values after they have been sanitized but before they become PHP data types.

#####I can't see anything else, not even an adapter hooking into those values. Because there is no entry point, I would have to somehow work those values after they have been converted to PHP datatypes and, if not possible, yes, fork the package to suit my needs and keep merging the updates forever.

#####Yes, there is no room for an adapter in the class and that's the main problem of it, but I don't think I'll be able to fix all development problems in the world with tweets :)

#####Nor be able to PR better implementations for all of them, so extentable classes are the most simple and easily doable think I can ask people to do, but it may be just me.

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