Example #1
0
 public function getAllEnums()
 {
     if (false === self::$installerRan) {
         Install::run();
         self::$installerRan = true;
     }
     $timeZoneEnumDir = '/../src/TimeZone';
     $enumFiles = Tree::from(__DIR__ . $timeZoneEnumDir)['TimeZone'];
     $enums = array_map(function ($item) {
         $name = str_replace('.php', '', $item);
         return ['WebIt4Me\\TimeZone\\' . $name, $name];
     }, $enumFiles);
     return $enums;
 }
Example #2
0
            return $value;
        }, $names);
        $last = end($propertyReads);
        $template = file_get_contents(self::makePathRelative(self::$tempClassPath));
        $content = str_replace('{property-reads}', implode('', $propertyReads) . ' *', $template);
        file_put_contents(self::makePathRelative(self::$timezoneClassPath), $content);
    }
    private static function loadData()
    {
        if (is_null(self::$dataSource)) {
            $currentStatus = ini_get('auto_detect_line_endings');
            ini_set('auto_detect_line_endings', true);
            if (($handle = fopen(self::makePathRelative(self::$dataSourcePath), "r")) !== false) {
                while (($row = fgetcsv($handle, 1000, ",")) !== false) {
                    self::$dataSource[] = $row;
                }
                fclose($handle);
            }
            ini_set('auto_detect_line_endings', $currentStatus);
        }
        return self::$dataSource;
    }
    private static function sanitize($value)
    {
        $what = ['\''];
        $toWhat = ['\\\''];
        return str_replace($what, $toWhat, $value);
    }
}
Install::run();