Skip to content

Commit 93c1cef

Browse files
committed
Merge pull request #16 from texdc/simplify_as_version
Simplify asVersion()
2 parents 9f27ea5 + 472549e commit 93c1cef

34 files changed

Lines changed: 1095 additions & 308 deletions

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ tmp/
1818

1919
# wild
2020
todo.md
21+
22+
# eclipse project files
23+
.buildpath
24+
.project
25+
.settings

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ php:
33
- 5.5
44
- 5.4
55
- hhvm
6-
before_script: cp tests/Config.php.travis-ci tests/Config.php
6+
before_script:
7+
- cp tests/Config.php.travis-ci tests/Config.php
8+
- composer install --dev

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Requires PHP 5.4 or later. (If you must run something older you should look at t
1717
TinCanPHP is available via [Composer](http://getcomposer.org).
1818

1919
```
20-
php composer.phar require rusticisoftware/tincan:~0.0
20+
php composer.phar require rusticisoftware/tincan:@stable
2121
```
2222

23-
With the package installed require the Composer autoloader:
23+
When not using Composer, require the autoloader:
2424

2525
```php
26-
require 'vendor/autoload.php';
26+
require 'path/to/TinCan/autoload.php';
2727
```
2828

2929
### Testing

autoload.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/*
3+
Copyright 2014 Rustici Software
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
if (file_exists('vendor/autoload.php')) {
19+
// prefer the composer autoloader
20+
return require_once('vendor/autoload.php');
21+
}
22+
23+
spl_autoload_register(function($className) {
24+
$namespace = 'TinCan\\';
25+
if (stripos($className, $namespace) === false) {
26+
return;
27+
}
28+
$sourceDir = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
29+
$fileName = str_replace([$namespace, '\\'], [$sourceDir, DIRECTORY_SEPARATOR], $className) . '.php';
30+
if (is_readable($fileName)) {
31+
include $fileName;
32+
}
33+
});

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
"issues": "https://github.com/RusticiSoftware/TinCanPHP/issues"
2525
},
2626
"require": {
27-
"php": ">=5.4.0"
27+
"php": "~5.4"
2828
},
2929
"require-dev": {
30-
"phpdocumentor/phpdocumentor": "2.*"
30+
"phpdocumentor/phpdocumentor": "2.*",
31+
"phpunit/phpunit": "@stable"
3132
},
3233
"autoload": {
3334
"psr-4": {

phpunit.php

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,10 @@
22

33
date_default_timezone_set('UTC');
44

5+
require_once('autoload.php');
56
require_once('tests/Config.php');
67
require_once('tests/Constants.php');
78

8-
require_once('src/LRSInterface.php');
9-
require_once('src/StatementTargetInterface.php');
10-
require_once('src/VersionableInterface.php');
11-
12-
require_once('src/ArraySetterTrait.php');
13-
require_once('src/FromJSONTrait.php');
14-
require_once('src/AsVersionTrait.php');
15-
16-
require_once('src/Map.php');
17-
require_once('src/LRSResponse.php');
18-
19-
require_once('src/Util.php');
20-
require_once('src/Version.php');
21-
require_once('src/LanguageMap.php');
22-
require_once('src/Extensions.php');
23-
require_once('src/ActivityDefinition.php');
24-
require_once('src/Activity.php');
25-
require_once('src/AgentAccount.php');
26-
require_once('src/Agent.php');
27-
require_once('src/Group.php');
28-
require_once('src/Verb.php');
29-
require_once('src/ContextActivities.php');
30-
require_once('src/Context.php');
31-
require_once('src/Score.php');
32-
require_once('src/Result.php');
33-
require_once('src/StatementRef.php');
34-
require_once('src/StatementBase.php');
35-
require_once('src/SubStatement.php');
36-
require_once('src/Statement.php');
37-
38-
require_once('src/StatementsResult.php');
39-
require_once('src/About.php');
40-
require_once('src/Document.php');
41-
require_once('src/ActivityProfile.php');
42-
require_once('src/AgentProfile.php');
43-
require_once('src/State.php');
44-
45-
require_once('src/RemoteLRS.php');
46-
479
register_shutdown_function(
4810
function () {
4911
if ($err = error_get_last()) {

src/About.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ class About implements VersionableInterface
2424
protected $version;
2525
protected $extensions;
2626

27-
private static $directProps = array(
28-
'version',
29-
);
30-
private static $versionedProps = array(
31-
'extensions',
32-
);
33-
3427
public function __construct() {
3528
if (func_num_args() == 1) {
3629
$arg = func_get_arg(0);

src/Activity.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ class Activity implements VersionableInterface, StatementTargetInterface
2525
protected $id;
2626
protected $definition;
2727

28-
private static $directProps = array(
29-
'objectType',
30-
'id',
31-
);
32-
33-
private static $versionedProps = array(
34-
'definition',
35-
);
36-
3728
public function __construct() {
3829
if (func_num_args() == 1) {
3930
$arg = func_get_arg(0);

src/ActivityDefinition.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,6 @@ class ActivityDefinition implements VersionableInterface
3434
protected $target;
3535
protected $steps;
3636

37-
private static $directProps = array(
38-
'type',
39-
'moreInfo',
40-
'interactionType',
41-
'correctResponsesPattern',
42-
'choices',
43-
'scale',
44-
'source',
45-
'target',
46-
'steps',
47-
);
48-
private static $versionedProps = array(
49-
'name',
50-
'description',
51-
'extensions',
52-
);
53-
5437
public function __construct() {
5538
if (func_num_args() == 1) {
5639
$arg = func_get_arg(0);

src/AgentAccount.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ class AgentAccount implements VersionableInterface
2424
protected $name;
2525
protected $homePage;
2626

27-
private static $directProps = array(
28-
'name',
29-
'homePage',
30-
);
31-
3227
public function __construct() {
3328
if (func_num_args() == 1) {
3429
$arg = func_get_arg(0);

0 commit comments

Comments
 (0)