Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit bd4ca1b

Browse files
committed
:octocat:
0 parents  commit bd4ca1b

35 files changed

+4126
-0
lines changed

.codeclimate.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
engines:
2+
fixme:
3+
enabled: true
4+
phpmd:
5+
enabled: true
6+
config:
7+
file_extensions: "php"
8+
rulesets: "phpmd.xml"
9+
markdownlint:
10+
enabled: true
11+
ratings:
12+
paths:
13+
- "**.php"
14+
exclude_paths:
15+
- config/**/*
16+
- examples/**/*
17+
- tests/**/*
18+
- "**/vendor/**/*"

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
vendor
3+
config/.env
4+
composer.lock
5+
6+
*.pdf
7+
_stuff

.scrutinizer.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
filter:
2+
excluded_paths:
3+
- config/*
4+
- examples/*
5+
- tests/*

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: php
2+
3+
php:
4+
- 7.0
5+
- 7.1
6+
7+
before_install: pip install --user codecov
8+
install: travis_retry composer install --no-interaction --prefer-source
9+
script: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
10+
after_success: codecov

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Smiley <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# php-webfleet
2+
3+
A wrapper for the [TomTom Business Webfleet.connect API](https://business.tomtom.com/partners/integration/resources/).
4+
5+
## Requirements
6+
- a TomTom Business account
7+
- PHP 7+

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "codemasher/php-webfleet",
3+
"description": "A wrapper for the TomTom Business Webfleet.connect API. PHP 7+",
4+
"homepage": "https://github.com/codemasher/php-webfleet",
5+
"license": "MIT",
6+
"type": "library",
7+
"keywords": [
8+
"webfleet", "tomtom", "telematics" ,"api", "wrapper"
9+
],
10+
"authors": [
11+
{
12+
"name": "Smiley",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"require": {
17+
"php": ">=7.0.3",
18+
"chillerlan/php-curl": "dev-master",
19+
"vlucas/phpdotenv": "2.*"
20+
},
21+
"require-dev": {
22+
"phpunit/phpunit": "6.0.*"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"TomTom\\Telematics\\": "src",
27+
"TomTom\\TelematicsTest\\": "tests"
28+
}
29+
}
30+
}

config/.env_example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
WEBFLEET_ACCOUNT=
2+
WEBFLEET_USERNAME=
3+
WEBFLEET_PASSWORD=
4+
WEBFLEET_APIKEY=

phpmd.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="codemasher/php-webfleet PMD ruleset"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
<description>codemasher/php-webfleet PMD ruleset</description>
8+
<exclude-pattern>*/config/*</exclude-pattern>
9+
<exclude-pattern>*/examples/*</exclude-pattern>
10+
<exclude-pattern>*/tests/*</exclude-pattern>
11+
<rule ref="rulesets/cleancode.xml"/>
12+
<rule ref="rulesets/codesize.xml"/>
13+
<rule ref="rulesets/design.xml"/>
14+
<rule ref="rulesets/controversial.xml">
15+
<exclude name="CamelCaseMethodName"/>
16+
<exclude name="CamelCasePropertyName"/>
17+
<exclude name="CamelCaseParameterName"/>
18+
<exclude name="CamelCaseVariableName"/>
19+
</rule>
20+
<rule ref="rulesets/naming.xml">
21+
<exclude name="LongVariable"/>
22+
<exclude name="ShortVariable"/>
23+
</rule>
24+
<rule ref="rulesets/unusedcode.xml">
25+
<exclude name="UnusedFormalParameter"/>
26+
</rule>
27+
</ruleset>

phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
>
13+
<filter>
14+
<whitelist processUncoveredFilesFromWhitelist="true">
15+
<directory suffix=".php">./src</directory>
16+
</whitelist>
17+
</filter>
18+
<testsuites>
19+
<testsuite name="php-webfleet test suite">
20+
<directory suffix=".php">./tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
</phpunit>

src/Container.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
/**
3+
* Class Container
4+
*
5+
* @filesource Container.php
6+
* @created 14.03.2017
7+
* @package TomTom\Telematics
8+
* @author Smiley <[email protected]>
9+
* @copyright 2017 Smiley
10+
* @license MIT
11+
*/
12+
13+
namespace TomTom\Telematics;
14+
15+
/**
16+
* a generic container with getter and setter
17+
*/
18+
abstract class Container{
19+
20+
/**
21+
* Boa constructor.
22+
*
23+
* @param array $properties
24+
*/
25+
public function __construct(array $properties = []){
26+
27+
foreach($properties as $key => $value){
28+
$this->__set($key, $value);
29+
}
30+
31+
}
32+
33+
/**
34+
* David Getter
35+
*
36+
* @param string $property
37+
*
38+
* @return mixed|bool
39+
*/
40+
public function __get(string $property){
41+
42+
if(property_exists($this, $property)){
43+
return $this->{$property};
44+
}
45+
46+
return false;
47+
}
48+
49+
/**
50+
* Jet-setter
51+
*
52+
* @param string $property
53+
* @param mixed $value
54+
*
55+
* @return void
56+
*/
57+
public function __set(string $property, $value){
58+
59+
if(property_exists($this, $property)){
60+
$this->{$property} = $value;
61+
}
62+
63+
}
64+
65+
/**
66+
* @return array
67+
*/
68+
public function __toArray():array{
69+
70+
$arr = [];
71+
72+
foreach($this as $key => $val){
73+
$arr[$key] = $val;
74+
}
75+
76+
return $arr;
77+
}
78+
79+
}

0 commit comments

Comments
 (0)