Skip to content

Commit 93f47da

Browse files
committed
Keep camelCaseVariableNames
rename int to integer
1 parent 4078c40 commit 93f47da

File tree

17 files changed

+110
-79
lines changed

17 files changed

+110
-79
lines changed

src/Model/Property/Property.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ public function getExceptionClasses(): array
209209
*/
210210
protected function processAttributeName(string $name): string
211211
{
212+
$name = preg_replace_callback(
213+
'/([a-z])([A-Z])/',
214+
function ($matches) {
215+
return "{$matches[1]}-{$matches[2]}";
216+
},
217+
$name
218+
);
219+
212220
$elements = array_map(
213221
function ($element) {
214222
return ucfirst(strtolower($element));

src/PropertyProcessor/Property/IntProcessor.php renamed to src/PropertyProcessor/Property/IntegerProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @package PHPModelGenerator\PropertyProcessor\Property
1111
*/
12-
class IntProcessor extends AbstractNumericProcessor
12+
class IntegerProcessor extends AbstractNumericProcessor
1313
{
1414
protected const TYPE = 'int';
1515
}

tests/Objects/ArrayPropertyTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,13 @@ public function validTypedArrayDataProvider(): array
223223
'Empty array' => ['string', []],
224224
'String array' => ['string', ['a', 'b']],
225225
'String array with null' => ['string', ['a', 'b', null]],
226-
'Int array' => ['int', [1, 2, 3]],
227-
'Int array with null' => ['int', [1, 2, 3, null]],
226+
'Int array' => ['integer', [1, 2, 3]],
227+
'Int array with null' => ['integer', [1, 2, 3, null]],
228228
// Number array will cast int to float
229229
'Number array' => ['number', [1, 1.1, 4.5, 6], [1.0, 1.1, 4.5, 6.0]],
230230
'Boolean array' => ['boolean', [true, false, true]],
231231
'Null array' => ['null', [null, null]],
232-
'Nested array' => ['array","items":{"type":"int"},"injection":"yes we can', [[1, 2], [], [3], null]]
232+
'Nested array' => ['array","items":{"type":"integer"},"injection":"yes we can', [[1, 2], [], [3], null]]
233233
];
234234
}
235235

@@ -253,14 +253,17 @@ public function invalidTypedArrayDataProvider(): array
253253
{
254254
return [
255255
'String array containing int' => ['string', ['a', 'b', 1]],
256-
'Int array containing string' => ['int', [1, 2, 3, '4']],
257-
'Int array containing float' => ['int', [1, 2, 3, 2.5]],
256+
'Int array containing string' => ['integer', [1, 2, 3, '4']],
257+
'Int array containing float' => ['integer', [1, 2, 3, 2.5]],
258258
'Number array containing array' => ['number', [1, 1.1, 4.5, 6, []]],
259259
'Boolean array containing int' => ['boolean', [true, false, true, 3]],
260260
'Null array containing string' => ['null', [null, null, 'null']],
261-
'Nested array containing int' => ['array","items":{"type":"int"},"injection":"yes we can', [[1, 2], [], 3]],
261+
'Nested array containing int' => [
262+
'array","items":{"type":"integer"},"injection":"yes we can',
263+
[[1, 2], [], 3]
264+
],
262265
'Nested array inner array containing string' => [
263-
'array","items":{"type":"int"},"injection":"yes we can',
266+
'array","items":{"type":"integer"},"injection":"yes we can',
264267
[[1, '2'], [], [3]]
265268
]
266269
];

tests/Objects/IntPropertyTest.php renamed to tests/Objects/IntegerPropertyTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @package PHPModelGenerator\Tests\Objects
1515
*/
16-
class IntPropertyTest extends AbstractNumericPropertyTest
16+
class IntegerPropertyTest extends AbstractNumericPropertyTest
1717
{
1818
/**
1919
* @throws FileSystemException
@@ -22,7 +22,7 @@ class IntPropertyTest extends AbstractNumericPropertyTest
2222
*/
2323
public function testNotProvidedOptionalIntPropertyIsValid(): void
2424
{
25-
$className = $this->generateObjectFromFile('IntProperty.json');
25+
$className = $this->generateObjectFromFile('IntegerProperty.json');
2626

2727
$object = new $className([]);
2828
$this->assertNull($object->getProperty());
@@ -39,7 +39,7 @@ public function testNotProvidedOptionalIntPropertyIsValid(): void
3939
*/
4040
public function testProvidedIntPropertyIsValid(?int $input): void
4141
{
42-
$className = $this->generateObjectFromFile('IntProperty.json');
42+
$className = $this->generateObjectFromFile('IntegerProperty.json');
4343

4444
$object = new $className(['property' => $input]);
4545
$this->assertSame($input, $object->getProperty());
@@ -69,7 +69,7 @@ public function testInvalidPropertyTypeThrowsAnException($propertyValue): void
6969
$this->expectException(InvalidArgumentException::class);
7070
$this->expectExceptionMessage('invalid type for property');
7171

72-
$className = $this->generateObjectFromFile('IntProperty.json');
72+
$className = $this->generateObjectFromFile('IntegerProperty.json');
7373

7474
new $className(['property' => $propertyValue]);
7575
}
@@ -87,7 +87,7 @@ public function invalidPropertyTypeDataProvider(): array
8787

8888
protected function getMultipleOfFile(): string
8989
{
90-
return 'IntPropertyMultipleOf.json';
90+
return 'IntegerPropertyMultipleOf.json';
9191
}
9292

9393
public function validMultipleOfDataProvider(): iterable
@@ -116,7 +116,7 @@ public function invalidMultipleOfDataProvider(): iterable
116116

117117
protected function getRangeFile(): string
118118
{
119-
return 'IntPropertyRange.json';
119+
return 'IntegerPropertyRange.json';
120120
}
121121

122122
public function validRangeDataProvider(): iterable

tests/PropertyProcessor/PropertyProcessorFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use PHPModelGenerator\Model\Schema;
88
use PHPModelGenerator\PropertyProcessor\Property\ArrayProcessor;
99
use PHPModelGenerator\PropertyProcessor\Property\BooleanProcessor;
10-
use PHPModelGenerator\PropertyProcessor\Property\IntProcessor;
10+
use PHPModelGenerator\PropertyProcessor\Property\IntegerProcessor;
1111
use PHPModelGenerator\PropertyProcessor\Property\NullProcessor;
1212
use PHPModelGenerator\PropertyProcessor\Property\NumberProcessor;
1313
use PHPModelGenerator\PropertyProcessor\Property\ObjectProcessor;
@@ -56,7 +56,7 @@ public function validPropertyProvider(): array
5656
return [
5757
'array' => ['array', ArrayProcessor::class],
5858
'boolean' => ['boolean', BooleanProcessor::class],
59-
'int' => ['int', IntProcessor::class],
59+
'integer' => ['integer', IntegerProcessor::class],
6060
'null' => ['null', NullProcessor::class],
6161
'number' => ['number', NumberProcessor::class],
6262
'object' => ['object', ObjectProcessor::class],

tests/Schema/AdditionalPropertiesTest/AdditionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "string"
66
},
77
"age": {
8-
"type": "int"
8+
"type": "integer"
99
}
1010
},
1111
"additionalProperties": %s

tests/Schema/AdditionalPropertiesTest/AdditionalPropertiesNotDefined.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "string"
66
},
77
"age": {
8-
"type": "int"
8+
"type": "integer"
99
}
1010
}
1111
}

tests/Schema/BasicSchemaGenerationTest/RecursiveTest/SubFolder/SubSchema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"id": "SubClass",
44
"properties": {
55
"property": {
6-
"type": "int"
6+
"type": "integer"
77
}
88
}
99
}

tests/Schema/ComposedNotTest/ReferencedObjectSchema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"minLength": 2
99
},
1010
"age": {
11-
"type": "int"
11+
"type": "integer"
1212
}
1313
},
1414
"required": [

tests/Schema/IntPropertyTest/IntProperty.json renamed to tests/Schema/IntegerPropertyTest/IntegerProperty.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"type": "object",
33
"properties": {
44
"property": {
5-
"type": "int"
5+
"type": "integer"
66
}
77
}
88
}

0 commit comments

Comments
 (0)