Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 1986043

Browse files
committed
simplified namespace
1 parent c5bd038 commit 1986043

11 files changed

+28
-26
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ A couple of choices here:
3030
```
3131
Run ```composer update``` from the command line.
3232

33+
The composer.json file should autoload the ```phpFITFileAnalysis``` class, so as long as you ```<?php require __DIR__ . '/vendor/autoload.php'; ?>``` in your PHP file (assuming it is in your project's root folder), you should be able to instantiate the class with ```<?php $pFFA = new adriangibbons\phpFITFileAnalysis('fit_files/my_fit_file.fit'); ?>```
34+
3335
**The more manual way:** Download the ZIP from GitHub and put PHP class file from the /src directory somewhere appropriate (e.g. classes/). A conscious effort has been made to keep everything in a single file.
3436

3537
Then include the file on the PHP page where you want to use it and instantiate an object of the class:
3638
```php
3739
<?php
3840
include('classes/phpFITFileAnalysis.php');
39-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis('fit_files/my_fit_file.fit');
41+
$pFFA = new adriangibbons\phpFITFileAnalysis('fit_files/my_fit_file.fit');
4042
?>
4143
```
4244
Note that the only mandatory parameter required when creating an instance is the path to the FIT file that you want to load.
@@ -117,7 +119,7 @@ $options = [
117119
'units' => 'statute',
118120
'pace' => true
119121
];
120-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis('my_fit_file.fit', $options);
122+
$pFFA = new adriangibbons\phpFITFileAnalysis('my_fit_file.fit', $options);
121123
````
122124
The optional parameters are described in more detail below.
123125
####"Fix" the Data

demo/mountain-biking.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// 'units' => 'metric',
2121
// 'pace' => false
2222
];
23-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis(__DIR__ . $file, $options);
23+
$pFFA = new adriangibbons\phpFITFileAnalysis(__DIR__ . $file, $options);
2424
} catch (Exception $e) {
2525
echo 'caught exception: '.$e->getMessage();
2626
die();

demo/power-analysis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// 'fixData' => ['all'],
1515
'units' => ['metric']
1616
];
17-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis(__DIR__ . $file, $options);
17+
$pFFA = new adriangibbons\phpFITFileAnalysis(__DIR__ . $file, $options);
1818

1919
// Google Time Zone API
2020
$date = new DateTime("1989-12-31", new DateTimeZone("UTC")); // timestamp[s]: seconds since UTC 00:00:00 Dec 31 1989

demo/swim.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'units' => 'raw',
1515
// 'pace' => false
1616
];
17-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis(__DIR__ . $file, $options);
17+
$pFFA = new adriangibbons\phpFITFileAnalysis(__DIR__ . $file, $options);
1818
} catch (Exception $e) {
1919
echo 'caught exception: '.$e->getMessage();
2020
die();

src/phpFITFileAnalysis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace adriangibbons\phpFITFileAnalysis;
2+
namespace adriangibbons;
33

44
/**
55
* phpFITFileAnalysis

tests/pFFA-Basic-Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
error_reporting(E_ALL);
3-
if(!class_exists('adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis')) {
3+
if(!class_exists('adriangibbons\phpFITFileAnalysis')) {
44
require __DIR__ . '/../src/phpFITFileAnalysis.php';
55
}
66

@@ -28,7 +28,7 @@ public function testDemoFileBasics()
2828
{
2929
foreach($this->demo_files as $filename) {
3030

31-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $filename);
31+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $filename);
3232

3333
$this->assertGreaterThan(0, $pFFA->data_mesgs['activity']['timestamp'], 'No Activity timestamp!');
3434

tests/pFFA-EnumData-Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
error_reporting(E_ALL);
3-
if(!class_exists('adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis')) {
3+
if(!class_exists('adriangibbons\phpFITFileAnalysis')) {
44
require __DIR__ . '/../src/phpFITFileAnalysis.php';
55
}
66

@@ -13,7 +13,7 @@ class EnumDataTest extends PHPUnit_Framework_TestCase
1313
public function setUp()
1414
{
1515
$this->base_dir = __DIR__ . '/../demo/fit_files/';
16-
$this->pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
16+
$this->pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
1717
}
1818

1919
public function testEnumData_manufacturer()

tests/pFFA-FixData-Test.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
error_reporting(E_ALL);
3-
if(!class_exists('adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis')) {
3+
if(!class_exists('adriangibbons\phpFITFileAnalysis')) {
44
require __DIR__ . '/../src/phpFITFileAnalysis.php';
55
}
66

@@ -30,7 +30,7 @@ public function setUp()
3030
*/
3131
public function testFixData_before()
3232
{
33-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename);
33+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename);
3434

3535
$this->assertEquals(4309, count($pFFA->data_mesgs['record']['position_lat']));
3636
$this->assertEquals(4309, count($pFFA->data_mesgs['record']['position_long']));
@@ -47,15 +47,15 @@ public function testFixData_before()
4747
*/
4848
public function testFixData_hr_missing_key()
4949
{
50-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename);
50+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename);
5151

5252
$hr_missing_key = array_diff($pFFA->data_mesgs['record']['timestamp'], array_keys($pFFA->data_mesgs['record']['heart_rate']));
5353
$this->assertEquals([3036 => 805987192], $hr_missing_key);
5454
}
5555

5656
public function testFixData_after()
5757
{
58-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['all']]);
58+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['all']]);
5959

6060
$this->assertEquals(4317, count($pFFA->data_mesgs['record']['position_lat']));
6161
$this->assertEquals(4317, count($pFFA->data_mesgs['record']['position_long']));
@@ -72,7 +72,7 @@ public function testFixData_after()
7272
*/
7373
public function testFixData_hr_missing_key_fixed()
7474
{
75-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['heart_rate']]);
75+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['heart_rate']]);
7676

7777
$this->assertEquals(117.5, $pFFA->data_mesgs['record']['heart_rate'][805987192]);
7878
}
@@ -82,7 +82,7 @@ public function testFixData_validate_options_pass()
8282
// Positive testing
8383
$valid_options = ['all', 'cadence', 'distance', 'heart_rate', 'lat_lon', 'speed', 'power'];
8484
foreach($valid_options as $valid_option) {
85-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => [$valid_option]]);
85+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => [$valid_option]]);
8686
}
8787
}
8888

@@ -91,6 +91,6 @@ public function testFixData_validate_options_pass()
9191
*/
9292
public function testFixData_validate_options_fail()
9393
{
94-
$pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['INVALID']]);
94+
$pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['fixData' => ['INVALID']]);
9595
}
9696
}

tests/pFFA-HR-Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
error_reporting(E_ALL);
3-
if(!class_exists('adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis')) {
3+
if(!class_exists('adriangibbons\phpFITFileAnalysis')) {
44
require __DIR__ . '/../src/phpFITFileAnalysis.php';
55
}
66

@@ -13,7 +13,7 @@ class HRTest extends PHPUnit_Framework_TestCase
1313
public function setUp()
1414
{
1515
$this->base_dir = __DIR__ . '/../demo/fit_files/';
16-
$this->pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
16+
$this->pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
1717
}
1818

1919
public function testHR_hrMetrics()

tests/pFFA-Power-Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
error_reporting(E_ALL);
3-
if(!class_exists('adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis')) {
3+
if(!class_exists('adriangibbons\phpFITFileAnalysis')) {
44
require __DIR__ . '/../src/phpFITFileAnalysis.php';
55
}
66

@@ -13,7 +13,7 @@ class PowerTest extends PHPUnit_Framework_TestCase
1313
public function setUp()
1414
{
1515
$this->base_dir = __DIR__ . '/../demo/fit_files/';
16-
$this->pFFA = new adriangibbons\phpFITFileAnalysis\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
16+
$this->pFFA = new adriangibbons\phpFITFileAnalysis($this->base_dir . $this->filename, ['units' => 'raw']);
1717
}
1818

1919
public function testPower_criticalPower_values()

0 commit comments

Comments
 (0)