-
Notifications
You must be signed in to change notification settings - Fork 402
/
Copy pathMapperGen.php
executable file
·73 lines (66 loc) · 2.13 KB
/
MapperGen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml as YamlLib;
$classes = array();
$dir = __DIR__ . "/../api/yml/v1/";
$files = scandir($dir);
foreach ($files as $file) {
// echo "filename:" . $file . "\n";
// Elementing the ..
if($file != "." && $file != ".." ){
$value = YamlLib::parseFile($dir.$file);
//var_dump($value);
//array_push($classes, $value);
//var_dump($classes);
//echo $value['net\authorize\api\contract\v1\ANetApiRequestType']['properties']['merchantAuthentication']['type']."\n";
$key = key($value);
$classes[$key] = $value[$key];
//break;
}
}
file_put_contents(__DIR__ ."/classes.json",json_encode($classes));
# array.json => {"a":1,"b":2,"c":3,"d":4,"e":5}
$classes2 = json_decode(file_get_contents(__DIR__ ."/classes.json"), true);
//Validate the JSON
if($classes === $classes2) # => true
{
echo "JSON Created out of XML Successfully! - ".__DIR__ ."/classes.json\n";
}
// class MapperGen{
// private $classes = array();
// private $dir = __DIR__ . "/../../yml/v1/";
// private function __construct() {
// $files = scandir($this->dir);
// foreach ($files as $file) {
// // echo "filename:" . $file . "\n";
// // Elementing the ..
// if($file != "." && $file != ".." ){
// $value = Yaml::parseFile($this->dir.$file);
// //var_dump($value);
// //array_push($classes, $value);
// //var_dump($classes);
// //echo $value['net\authorize\api\contract\v1\ANetApiRequestType']['properties']['merchantAuthentication']['type']."\n";
// $key = key($value);
// $this->classes[$key] = $value[$key];
// //break;
// }
// }
// }
// public static function Instance()
// {
// static $inst = null;
// if ($inst === null) {
// $inst = new Mapper();
// }
// return $inst;
// }
// public function generateFile(){
// file_put_contents("array.json",json_encode($classes));
// # array.json => {"a":1,"b":2,"c":3,"d":4,"e":5}
// $classes2 = json_decode(file_get_contents('array.json'), true);
// if($classes === $classes2) # => true
// {
// echo "All Good!";
// }
// }
?>