-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiOSTools.php
More file actions
93 lines (80 loc) · 2.41 KB
/
iOSTools.php
File metadata and controls
93 lines (80 loc) · 2.41 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Created by PhpStorm.
* User: QDFish
* Date: 2018/4/27
* Time: 下午4:11
*/
require_once __DIR__ . "/iOSModelVar.php";
//大写代替下滑线
function ucReplaceUnderLine($str) {
$strs = explode('_', $str);
$isFirstStr = true;
$result = '';
foreach ($strs as $value) {
if ($isFirstStr) {
$value = lcfirst($value);
$isFirstStr = false;
} else {
$value = ucfirst($value);
}
$result = $result . $value;
}
return $result;
}
//URL头文件参数描述
function apiInterface($parameters) {
$parameterDesc = '';
foreach ($parameters as $parameterInfo) {
$name = ucReplaceUnderLine($parameterInfo['name']);
$type = $parameterInfo['type'];
$parameterDesc = $parameterDesc . $name . ":" . $type . $name . ' ';
}
$parameterDesc = ucfirst($parameterDesc);
return substr($parameterDesc, 0, strlen($parameterDesc) - 1);
}
//URL实现文件参数描述
function apiImplementation($parameters) {
$parameterDesc = '';
foreach ($parameters as $parameterInfo) {
$str = '=%@';
$name = $parameterInfo['name'];
$type = $parameterInfo['type'];
if ($type == '(int)') {
$str = '=%d';
}
$parameterDesc = $parameterDesc . $name . $str . '&';
}
$parameterDesc = substr($parameterDesc, 0, strlen($parameterDesc) - 1);
return $parameterDesc;
}
function parameterStr($parameters) {
$parameterDesc = '';
foreach ($parameters as $parameterInfo) {
$name = ucReplaceUnderLine($parameterInfo['name']);
$parameterDesc = $parameterDesc . $name. ', ';
}
return substr($parameterDesc, 0, strlen($parameterDesc) - 2);
}
function parameterSetter($parameters) {
$parameterDesc = '';
foreach ($parameters as $parameterInfo) {
$name = ucReplaceUnderLine($parameterInfo['name']);
$type = $parameterInfo['type'];
$parameterDesc .= $name . ":" . $name . ' ';
}
$parameterDesc = ucfirst($parameterDesc);
return substr($parameterDesc, 0, strlen($parameterDesc) - 1);
}
function classMapContainType($type) {
global $classMap;
global $modelType;
$containType = false;
foreach ($classMap as $key => $value) {
if (strpos($type, $value) !== false) {
$containType = ucfirst($value) . $modelType[0];
break;
}
}
return $containType;
}