Skip to content

Commit 4dd3e46

Browse files
Merged Pull Request '#20 main->main : PSR-4 autoloading'
PSR-4 autoloading
2 parents cd38195 + 3a023d2 commit 4dd3e46

36 files changed

+724
-765
lines changed

composer.json

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,23 @@
2323
"license": "EUPL-1.2",
2424
"type": "library",
2525
"require": {
26+
"ext-ctype": "*",
27+
"ext-json": "*",
2628
"mustache/mustache": "^2.13",
2729
"tedivm/jshrink": "~1.0"
2830
},
31+
"require-dev": {
32+
"kint-php/kint": "^3.3",
33+
"phpunit/phpunit": "*"
34+
},
2935
"autoload": {
30-
"classmap": [
31-
"ElementData.php",
32-
"AspectPropertyValue.php",
33-
"ElementDataDictionary.php",
34-
"Evidence.php",
35-
"EvidenceKeyFilter.php",
36-
"BasicListEvidenceKeyFilter.php",
37-
"FlowData.php",
38-
"FlowElement.php",
39-
"Logger.php",
40-
"Messages.php",
41-
"Pipeline.php",
42-
"PipelineBuilder.php",
43-
"JavascriptBuilder.php",
44-
"JsonBundler.php",
45-
"SequenceElement.php",
46-
"SetHeaderElement.php",
47-
"Constants.php",
48-
"Utils.php"
49-
]
36+
"psr-4": {
37+
"fiftyone\\pipeline\\core\\": "src/"
38+
}
5039
},
51-
"require-dev": {
52-
"kint-php/kint": "^3.3"
40+
"autoload-dev": {
41+
"psr-4": {
42+
"fiftyone\\pipeline\\core\\tests\\": "tests/"
43+
}
5344
}
5445
}

examples/CustomFlowElement.php

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
1-
<?php
2-
/* *********************************************************************
3-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4-
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5-
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6-
*
7-
* This Original Work is licensed under the European Union Public Licence
8-
* (EUPL) v.1.2 and is subject to its terms as set out below.
9-
*
10-
* If a copy of the EUPL was not distributed with this file, You can obtain
11-
* one at https://opensource.org/licenses/EUPL-1.2.
12-
*
13-
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14-
* amended by the European Commission) shall be deemed incompatible for
15-
* the purposes of the Work and the provisions of the compatibility
16-
* clause in Article 5 of the EUPL shall not apply.
17-
*
18-
* If using the Work as, or as part of, a network application, by
19-
* including the attribution notice(s) required under Article 5 of the EUPL
20-
* in the end user terms of the application under an appropriate heading,
21-
* such notice(s) shall fulfill the requirements of that article.
1+
<?php
2+
/* *********************************************************************
3+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4+
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5+
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6+
*
7+
* This Original Work is licensed under the European Union Public Licence
8+
* (EUPL) v.1.2 and is subject to its terms as set out below.
9+
*
10+
* If a copy of the EUPL was not distributed with this file, You can obtain
11+
* one at https://opensource.org/licenses/EUPL-1.2.
12+
*
13+
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14+
* amended by the European Commission) shall be deemed incompatible for
15+
* the purposes of the Work and the provisions of the compatibility
16+
* clause in Article 5 of the EUPL shall not apply.
17+
*
18+
* If using the Work as, or as part of, a network application, by
19+
* including the attribution notice(s) required under Article 5 of the EUPL
20+
* in the end user terms of the application under an appropriate heading,
21+
* such notice(s) shall fulfill the requirements of that article.
2222
* ********************************************************************* */
2323

2424
/**
25-
* @example CustomFlowElement.php
26-
*
27-
* This example demonstrates the creation of a custom flow element. In this case
28-
* the FlowElement takes the results of a client side form collecting
29-
* date of birth, setting this as evidence on a FlowData object to calculate
30-
* a person's starsign. The FlowElement also serves additional JavaScript
31-
* which gets a user's geolocation and saves the latitude as a cookie.
32-
* This latitude is also then passed in to the FlowData to calculate if
33-
* a person is in the northern or southern hemispheres.
25+
* @example CustomFlowElement.php
26+
*
27+
* This example demonstrates the creation of a custom flow element. In this case
28+
* the FlowElement takes the results of a client side form collecting
29+
* date of birth, setting this as evidence on a FlowData object to calculate
30+
* a person's starsign. The FlowElement also serves additional JavaScript
31+
* which gets a user's geolocation and saves the latitude as a cookie.
32+
* This latitude is also then passed in to the FlowData to calculate if
33+
* a person is in the northern or southern hemispheres.
3434
35-
*/
35+
*/
3636

37-
include(__DIR__ . "/../vendor/autoload.php");
3837

3938
use fiftyone\pipeline\core\PipelineBuilder;
4039
use fiftyone\pipeline\core\BasicListEvidenceKeyFilter;
@@ -87,11 +86,11 @@ public function processInternal($FlowData)
8786
{
8887
$result = [];
8988

90-
89+
9190
// Get the date of birth from the query string (submitted through
9291
// a form on the client side)
9392
$dateOfBirth = $FlowData->evidence->get("query.dateOfBirth");
94-
93+
9594
if ($dateOfBirth) {
9695
$dateOfBirth = explode("-", $dateOfBirth);
9796

examples/FlowElementsForExamples.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
<?php
2-
/* *********************************************************************
3-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4-
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5-
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6-
*
7-
* This Original Work is licensed under the European Union Public Licence
8-
* (EUPL) v.1.2 and is subject to its terms as set out below.
9-
*
10-
* If a copy of the EUPL was not distributed with this file, You can obtain
11-
* one at https://opensource.org/licenses/EUPL-1.2.
12-
*
13-
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14-
* amended by the European Commission) shall be deemed incompatible for
15-
* the purposes of the Work and the provisions of the compatibility
16-
* clause in Article 5 of the EUPL shall not apply.
17-
*
18-
* If using the Work as, or as part of, a network application, by
19-
* including the attribution notice(s) required under Article 5 of the EUPL
20-
* in the end user terms of the application under an appropriate heading,
21-
* such notice(s) shall fulfill the requirements of that article.
1+
<?php
2+
/* *********************************************************************
3+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4+
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5+
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6+
*
7+
* This Original Work is licensed under the European Union Public Licence
8+
* (EUPL) v.1.2 and is subject to its terms as set out below.
9+
*
10+
* If a copy of the EUPL was not distributed with this file, You can obtain
11+
* one at https://opensource.org/licenses/EUPL-1.2.
12+
*
13+
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14+
* amended by the European Commission) shall be deemed incompatible for
15+
* the purposes of the Work and the provisions of the compatibility
16+
* clause in Article 5 of the EUPL shall not apply.
17+
*
18+
* If using the Work as, or as part of, a network application, by
19+
* including the attribution notice(s) required under Article 5 of the EUPL
20+
* in the end user terms of the application under an appropriate heading,
21+
* such notice(s) shall fulfill the requirements of that article.
2222
* ********************************************************************* */
2323

2424
use fiftyone\pipeline\core\FlowElement;
@@ -73,7 +73,7 @@ public function getEvidenceKeyFilter()
7373
}
7474

7575

76-
if (!class_exists("errorFlowElement")) {
76+
if (!class_exists("ErrorFlowElement")) {
7777
// A FlowElement that triggers an error
7878

7979
class ErrorFlowElement extends FlowElement
@@ -93,7 +93,7 @@ public function getEvidenceKeyFilter()
9393
}
9494

9595

96-
if (!class_exists("stopFlowElement")) {
96+
if (!class_exists("StopFlowElement")) {
9797
// A FlowElement that stops processing
9898

9999
class StopFlowElement extends FlowElement

examples/Pipeline.php

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
<?php
2-
/* *********************************************************************
3-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4-
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5-
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6-
*
7-
* This Original Work is licensed under the European Union Public Licence
8-
* (EUPL) v.1.2 and is subject to its terms as set out below.
9-
*
10-
* If a copy of the EUPL was not distributed with this file, You can obtain
11-
* one at https://opensource.org/licenses/EUPL-1.2.
12-
*
13-
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14-
* amended by the European Commission) shall be deemed incompatible for
15-
* the purposes of the Work and the provisions of the compatibility
16-
* clause in Article 5 of the EUPL shall not apply.
17-
*
18-
* If using the Work as, or as part of, a network application, by
19-
* including the attribution notice(s) required under Article 5 of the EUPL
20-
* in the end user terms of the application under an appropriate heading,
21-
* such notice(s) shall fulfill the requirements of that article.
1+
<?php
2+
/* *********************************************************************
3+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4+
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5+
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6+
*
7+
* This Original Work is licensed under the European Union Public Licence
8+
* (EUPL) v.1.2 and is subject to its terms as set out below.
9+
*
10+
* If a copy of the EUPL was not distributed with this file, You can obtain
11+
* one at https://opensource.org/licenses/EUPL-1.2.
12+
*
13+
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14+
* amended by the European Commission) shall be deemed incompatible for
15+
* the purposes of the Work and the provisions of the compatibility
16+
* clause in Article 5 of the EUPL shall not apply.
17+
*
18+
* If using the Work as, or as part of, a network application, by
19+
* including the attribution notice(s) required under Article 5 of the EUPL
20+
* in the end user terms of the application under an appropriate heading,
21+
* such notice(s) shall fulfill the requirements of that article.
2222
* ********************************************************************* */
2323

2424
/**
25-
* @example Pipeline.php
26-
*
27-
* This example demonstrates how various FlowElements can be combined in a Pipeline and processed
28-
*
29-
*/
30-
31-
require(__DIR__ . "/../vendor/autoload.php");
25+
* @example Pipeline.php
26+
*
27+
* This example demonstrates how various FlowElements can be combined in a Pipeline and processed
28+
*
29+
*/
3230

3331
use fiftyone\pipeline\core\PipelineBuilder;
3432
use fiftyone\pipeline\core\Logger;
@@ -38,12 +36,12 @@
3836

3937
// Two simple example FlowElements
4038

41-
$fe1 = new exampleFlowElementA();
42-
$fe2 = new exampleFlowElementB();
39+
$fe1 = new ExampleFlowElementA();
40+
$fe2 = new ExampleFlowElementB();
4341

4442
// A FlowElement that stops processing (and prevents and subsequent elements in the Pipeline from processing)
4543

46-
$feStop = new stopFlowElement();
44+
$feStop = new StopFlowElement();
4745

4846
// Pipelines can log info, errors and other messages if you supply a logger to them, here is a basic logger example that stores the logs in an array
4947

@@ -62,11 +60,11 @@ public function logInternal($log)
6260
// We make a Pipeline with our elements
6361

6462
$Pipeline = (new PipelineBuilder())
65-
->add($fe1)
66-
->add($feStop)
67-
->add($fe2)
68-
->addLogger(new ArrayLogger("info"))
69-
->build();
63+
->add($fe1)
64+
->add($feStop)
65+
->add($fe2)
66+
->addLogger(new ArrayLogger("info"))
67+
->build();
7068

7169
// We create FlowData which we will add evidence to
7270

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<phpunit>
1+
<phpunit bootstrap="vendor/autoload.php">
22
<testsuites>
33
<testsuite name="Unit">
44
<file>tests/CoreTests.php</file>

AspectPropertyValue.php renamed to src/AspectPropertyValue.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
<?php
2-
/* *********************************************************************
3-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4-
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5-
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6-
*
7-
* This Original Work is licensed under the European Union Public Licence
8-
* (EUPL) v.1.2 and is subject to its terms as set out below.
9-
*
10-
* If a copy of the EUPL was not distributed with this file, You can obtain
11-
* one at https://opensource.org/licenses/EUPL-1.2.
12-
*
13-
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14-
* amended by the European Commission) shall be deemed incompatible for
15-
* the purposes of the Work and the provisions of the compatibility
16-
* clause in Article 5 of the EUPL shall not apply.
17-
*
18-
* If using the Work as, or as part of, a network application, by
19-
* including the attribution notice(s) required under Article 5 of the EUPL
20-
* in the end user terms of the application under an appropriate heading,
21-
* such notice(s) shall fulfill the requirements of that article.
1+
<?php
2+
/* *********************************************************************
3+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4+
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5+
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6+
*
7+
* This Original Work is licensed under the European Union Public Licence
8+
* (EUPL) v.1.2 and is subject to its terms as set out below.
9+
*
10+
* If a copy of the EUPL was not distributed with this file, You can obtain
11+
* one at https://opensource.org/licenses/EUPL-1.2.
12+
*
13+
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14+
* amended by the European Commission) shall be deemed incompatible for
15+
* the purposes of the Work and the provisions of the compatibility
16+
* clause in Article 5 of the EUPL shall not apply.
17+
*
18+
* If using the Work as, or as part of, a network application, by
19+
* including the attribution notice(s) required under Article 5 of the EUPL
20+
* in the end user terms of the application under an appropriate heading,
21+
* such notice(s) shall fulfill the requirements of that article.
2222
* ********************************************************************* */
2323

2424

BasicListEvidenceKeyFilter.php renamed to src/BasicListEvidenceKeyFilter.php

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
<?php
2-
/* *********************************************************************
3-
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4-
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5-
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6-
*
7-
* This Original Work is licensed under the European Union Public Licence
8-
* (EUPL) v.1.2 and is subject to its terms as set out below.
9-
*
10-
* If a copy of the EUPL was not distributed with this file, You can obtain
11-
* one at https://opensource.org/licenses/EUPL-1.2.
12-
*
13-
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14-
* amended by the European Commission) shall be deemed incompatible for
15-
* the purposes of the Work and the provisions of the compatibility
16-
* clause in Article 5 of the EUPL shall not apply.
17-
*
18-
* If using the Work as, or as part of, a network application, by
19-
* including the attribution notice(s) required under Article 5 of the EUPL
20-
* in the end user terms of the application under an appropriate heading,
21-
* such notice(s) shall fulfill the requirements of that article.
1+
<?php
2+
/* *********************************************************************
3+
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
4+
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
5+
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
6+
*
7+
* This Original Work is licensed under the European Union Public Licence
8+
* (EUPL) v.1.2 and is subject to its terms as set out below.
9+
*
10+
* If a copy of the EUPL was not distributed with this file, You can obtain
11+
* one at https://opensource.org/licenses/EUPL-1.2.
12+
*
13+
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
14+
* amended by the European Commission) shall be deemed incompatible for
15+
* the purposes of the Work and the provisions of the compatibility
16+
* clause in Article 5 of the EUPL shall not apply.
17+
*
18+
* If using the Work as, or as part of, a network application, by
19+
* including the attribution notice(s) required under Article 5 of the EUPL
20+
* in the end user terms of the application under an appropriate heading,
21+
* such notice(s) shall fulfill the requirements of that article.
2222
* ********************************************************************* */
2323

2424

2525

2626
namespace fiftyone\pipeline\core;
2727

28-
use fiftyone\pipeline\core\EvidenceKeyFilter;
29-
3028
/**
3129
* An instance of EvidenceKeyFilter that uses a simple array of keys
3230
* Evidence not using these keys is filtered out

0 commit comments

Comments
 (0)