@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 10:43 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 10:43 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator; |
12 | 12 |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - private $classes = []; |
|
18 | + private $classes = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var array |
22 | 22 | */ |
23 | - private $properties = []; |
|
23 | + private $properties = [ ]; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var bool |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | |
50 | 50 | $label = $this->renameIfPhpReservedWord(trim($label)); |
51 | 51 | |
52 | - $this->classes[$label] = (object) [ |
|
52 | + $this->classes[ $label ] = (object) [ |
|
53 | 53 | 'name' => $label, |
54 | 54 | 'doc' => $classComment, |
55 | 55 | 'url' => $classUrl, |
56 | - 'properties' => [], |
|
57 | - 'subClassOf' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($subClassOf)), |
|
56 | + 'properties' => [ ], |
|
57 | + 'subClassOf' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($subClassOf)), |
|
58 | 58 | ]; |
59 | 59 | } |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function addDataType($classUrl, $label, $classComment) |
66 | 66 | { |
67 | - $this->addClass($classUrl, $label, $classComment, [], []); |
|
67 | + $this->addClass($classUrl, $label, $classComment, [ ], [ ]); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | { |
79 | 79 | $label = $this->renameIfPhpReservedWord(trim($label)); |
80 | 80 | |
81 | - $this->properties[$label] = [ |
|
81 | + $this->properties[ $label ] = [ |
|
82 | 82 | 'name' => $label, |
83 | 83 | 'doc' => $propertyComment, |
84 | 84 | 'url' => $propertyUrl, |
85 | - 'usedOnClass' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($mainClass)), |
|
86 | - 'expectedType' => array_map([$this, 'renameIfPhpReservedWord'], array_filter($expectedType)), |
|
85 | + 'usedOnClass' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($mainClass)), |
|
86 | + 'expectedType' => array_map([ $this, 'renameIfPhpReservedWord' ], array_filter($expectedType)), |
|
87 | 87 | ]; |
88 | 88 | } |
89 | 89 | |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | foreach ($result as &$resultingClass) { |
138 | 138 | if (!empty($resultingClass->subClassOf)) { |
139 | 139 | foreach ($resultingClass->subClassOf as &$class) { |
140 | - $class = $result[$class]; |
|
140 | + $class = $result[ $class ]; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | 145 | //Add the properties |
146 | 146 | foreach ($this->properties as $propertyName => $propertyStructure) { |
147 | - foreach ($propertyStructure['usedOnClass'] as $class) { |
|
148 | - $result[$class]->properties[$propertyName] = ['name' => $propertyName, 'parent' => $class]; |
|
147 | + foreach ($propertyStructure[ 'usedOnClass' ] as $class) { |
|
148 | + $result[ $class ]->properties[ $propertyName ] = [ 'name' => $propertyName, 'parent' => $class ]; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | if (is_object($stdClassObject)) { |
157 | 157 | $next = $stdClassObject->subClassOf; |
158 | 158 | while (is_array($next) && !empty($next) && $object = array_pop($next)) { |
159 | - $resultingClass->properties = array_merge($resultingClass->properties, $object->properties); |
|
159 | + $resultingClass->properties = array_merge($resultingClass->properties, $object->properties); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | { |
23 | 23 | foreach ($schemaData->getClassesWithPropertyNames() as $class) { |
24 | 24 | $className = $class->name; |
25 | - $methods = []; |
|
26 | - $usableProperties = []; |
|
27 | - $useProperties = []; |
|
25 | + $methods = [ ]; |
|
26 | + $usableProperties = [ ]; |
|
27 | + $useProperties = [ ]; |
|
28 | 28 | |
29 | 29 | if (!empty($class->properties)) { |
30 | 30 | foreach ($class->properties as $propertyClassName => $property) { |
31 | - $propertyName = $property['name']; |
|
32 | - $parentClassName = $property['parent']; |
|
31 | + $propertyName = $property[ 'name' ]; |
|
32 | + $parentClassName = $property[ 'parent' ]; |
|
33 | 33 | $propertyNameMethodName = $propertyName; |
34 | - $propertyNameMethodName[0] = strtoupper($propertyNameMethodName[0]); |
|
34 | + $propertyNameMethodName[ 0 ] = strtoupper($propertyNameMethodName[ 0 ]); |
|
35 | 35 | |
36 | - $useProperties[] = 'use NilPortugues\\SchemaOrg\\Properties\\'.$propertyNameMethodName.'Property;'; |
|
36 | + $useProperties[ ] = 'use NilPortugues\\SchemaOrg\\Properties\\'.$propertyNameMethodName.'Property;'; |
|
37 | 37 | |
38 | - if (empty($usableProperties[$propertyNameMethodName])) { |
|
39 | - $usableProperties[$propertyNameMethodName] = $propertyClassName; |
|
38 | + if (empty($usableProperties[ $propertyNameMethodName ])) { |
|
39 | + $usableProperties[ $propertyNameMethodName ] = $propertyClassName; |
|
40 | 40 | |
41 | 41 | $schemaClass = 'self'; |
42 | 42 | if ($parentClassName !== $className) { |
43 | 43 | $schemaClass = $parentClassName; |
44 | 44 | } |
45 | 45 | |
46 | - $methods[$propertyName] = <<<PHP |
|
46 | + $methods[ $propertyName ] = <<<PHP |
|
47 | 47 | /** |
48 | 48 | * @return Mapping |
49 | 49 | */ |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - $useProperties[] = 'use NilPortugues\SchemaOrg\Mapping;'; |
|
60 | - $useProperties[] = 'use NilPortugues\SchemaOrg\SchemaClass;'; |
|
59 | + $useProperties[ ] = 'use NilPortugues\SchemaOrg\Mapping;'; |
|
60 | + $useProperties[ ] = 'use NilPortugues\SchemaOrg\SchemaClass;'; |
|
61 | 61 | |
62 | 62 | sort($useProperties, SORT_REGULAR); |
63 | 63 | $useProperties = implode("\n", array_unique($useProperties)); |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | {$useProperties} |
83 | 83 | |
84 | 84 | /** |
85 | - * Classes {$schemaData['name']} |
|
85 | + * Classes {$schemaData[ 'name' ]} |
|
86 | 86 | * @package NilPortugues\\SchemaOrg\\Classes |
87 | 87 | * |
88 | - * {$schemaData['doc']} |
|
88 | + * {$schemaData[ 'doc' ]} |
|
89 | 89 | */ |
90 | -class {$schemaData['name']} extends SchemaClass |
|
90 | +class {$schemaData[ 'name' ]} extends SchemaClass |
|
91 | 91 | { |
92 | 92 | /** |
93 | 93 | * @var string |
94 | 94 | */ |
95 | - protected static \$schemaUrl = "{$schemaData['url']}"; |
|
95 | + protected static \$schemaUrl = "{$schemaData[ 'url' ]}"; |
|
96 | 96 | |
97 | 97 | $methods |
98 | 98 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 10:46 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 10:46 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 11:00 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 11:00 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator\FileSystem; |
12 | 12 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class InMemoryFileSystem implements FileSystemInterface |
17 | 17 | { |
18 | - private $fileSystem = []; |
|
18 | + private $fileSystem = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param string $filePath |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function write($filePath, $contents) |
25 | 25 | { |
26 | - $this->fileSystem[$filePath] = $contents; |
|
26 | + $this->fileSystem[ $filePath ] = $contents; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -33,6 +33,6 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function get($filePath) |
35 | 35 | { |
36 | - return $this->fileSystem[$filePath]; |
|
36 | + return $this->fileSystem[ $filePath ]; |
|
37 | 37 | } |
38 | 38 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 11:01 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 11:01 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator\FileSystem; |
12 | 12 |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | public function write(SchemaRdfaData $schemaData) |
22 | 22 | { |
23 | 23 | foreach ($schemaData->getProperties() as $property) { |
24 | - $className = $property['name']; |
|
25 | - $className[0] = strtoupper($className[0]); |
|
24 | + $className = $property[ 'name' ]; |
|
25 | + $className[ 0 ] = strtoupper($className[ 0 ]); |
|
26 | 26 | |
27 | - $allowed = []; |
|
28 | - foreach ($property['usedOnClass'] as $belongs) { |
|
27 | + $allowed = [ ]; |
|
28 | + foreach ($property[ 'usedOnClass' ] as $belongs) { |
|
29 | 29 | if ('Type' === substr($belongs, -4)) { |
30 | 30 | $belongs = substr($belongs, 0, -4); |
31 | 31 | } |
32 | 32 | |
33 | - $allowed[] = "\t\t'".'http://schema.org/'.$belongs."'"; |
|
33 | + $allowed[ ] = "\t\t'".'http://schema.org/'.$belongs."'"; |
|
34 | 34 | } |
35 | 35 | $allowed = implode(",\n", $allowed); |
36 | 36 | |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | use NilPortugues\SchemaOrg\SchemaProperty; |
51 | 51 | |
52 | 52 | /** |
53 | - * {$property['doc']} |
|
53 | + * {$property[ 'doc' ]} |
|
54 | 54 | */ |
55 | 55 | class {$className}Property extends SchemaProperty |
56 | 56 | { |
57 | - const SCHEMA_URL = "{$property['url']}"; |
|
58 | - const PROPERTY_NAME = "{$property['name']}"; |
|
57 | + const SCHEMA_URL = "{$property[ 'url' ]}"; |
|
58 | + const PROPERTY_NAME = "{$property[ 'name' ]}"; |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * A list of schemas allowed to use this property. |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 10:46 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 10:46 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 10:46 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 10:46 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Generator; |
12 | 12 |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | { |
23 | 23 | foreach ($schemaData->getClassesWithPropertyNames() as $class) { |
24 | 24 | $className = $class->name; |
25 | - $methods = []; |
|
25 | + $methods = [ ]; |
|
26 | 26 | |
27 | 27 | if (!empty($class->properties)) { |
28 | 28 | foreach ($class->properties as $property) { |
29 | - $propertyName = $property['name']; |
|
29 | + $propertyName = $property[ 'name' ]; |
|
30 | 30 | $propertyNameMethodName = $propertyName; |
31 | - $propertyNameMethodName[0] = strtoupper($propertyNameMethodName[0]); |
|
31 | + $propertyNameMethodName[ 0 ] = strtoupper($propertyNameMethodName[ 0 ]); |
|
32 | 32 | |
33 | - if (empty($usableProperties[$propertyNameMethodName])) { |
|
34 | - $methods[$propertyName] = <<<PHP |
|
33 | + if (empty($usableProperties[ $propertyNameMethodName ])) { |
|
34 | + $methods[ $propertyName ] = <<<PHP |
|
35 | 35 | public function test{$propertyNameMethodName}WillReturnMappingObject() |
36 | 36 | { |
37 | 37 | \$this->assertInstanceOf(Mapping::class, {$className}::{$propertyName}()); |
@@ -59,18 +59,18 @@ discard block |
||
59 | 59 | |
60 | 60 | namespace NilPortugues\Tests\SchemaOrg\Classes; |
61 | 61 | |
62 | -use NilPortugues\\SchemaOrg\\Classes\\{$schemaData['name']}; |
|
62 | +use NilPortugues\\SchemaOrg\\Classes\\{$schemaData[ 'name' ]}; |
|
63 | 63 | use NilPortugues\\SchemaOrg\\Mapping; |
64 | 64 | |
65 | 65 | /** |
66 | - * Classes {$schemaData['name']}Test |
|
66 | + * Classes {$schemaData[ 'name' ]}Test |
|
67 | 67 | * @package NilPortugues\\Tests\\SchemaOrg\\Classes |
68 | 68 | */ |
69 | -class {$schemaData['name']}Test extends \PHPUnit_Framework_TestCase |
|
69 | +class {$schemaData[ 'name' ]}Test extends \PHPUnit_Framework_TestCase |
|
70 | 70 | { |
71 | 71 | public function testSchemaUrlReturnsExpectedUrl() |
72 | 72 | { |
73 | - \$this->assertEquals({$schemaData['name']}::schemaUrl(), "{$schemaData['url']}"); |
|
73 | + \$this->assertEquals({$schemaData[ 'name' ]}::schemaUrl(), "{$schemaData[ 'url' ]}"); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $methods |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | /** |
668 | 668 | * @var array |
669 | 669 | */ |
670 | - private static $instances = []; |
|
670 | + private static $instances = [ ]; |
|
671 | 671 | |
672 | 672 | /** |
673 | 673 | * @param $method |
@@ -680,15 +680,15 @@ discard block |
||
680 | 680 | public function __call($method, $args) |
681 | 681 | { |
682 | 682 | $name = $method; |
683 | - $name[0] = strtoupper($name[0]); |
|
683 | + $name[ 0 ] = strtoupper($name[ 0 ]); |
|
684 | 684 | |
685 | 685 | if (class_exists('NilPortugues\\SchemaOrg\\Classes\\'.$name, true)) { |
686 | - if (empty(self::$instances[$name])) { |
|
686 | + if (empty(self::$instances[ $name ])) { |
|
687 | 687 | $class = 'NilPortugues\\SchemaOrg\\Classes\\'.$name; |
688 | - self::$instances[$name] = new $class(); |
|
688 | + self::$instances[ $name ] = new $class(); |
|
689 | 689 | } |
690 | 690 | |
691 | - return self::$instances[$name]; |
|
691 | + return self::$instances[ $name ]; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | throw new RuntimeException(sprintf('Method %s does not exist.', $name)); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 11:36 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 11:36 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Classes; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/18/15 |
|
5 | - * Time: 11:36 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/18/15 |
|
5 | + * Time: 11:36 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg\Classes; |
12 | 12 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author: Nil Portugués Calderó <[email protected]> |
|
4 | - * Date: 12/17/15 |
|
5 | - * Time: 11:46 PM. |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Author: Nil Portugués Calderó <[email protected]> |
|
4 | + * Date: 12/17/15 |
|
5 | + * Time: 11:46 PM. |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace NilPortugues\SchemaOrg; |
12 | 12 |