Skip to content

Commit 49da461

Browse files
authored
Merge pull request #4 from there4/update-readme
Convert to PSR4, add initial sanity test, add travis configuration
2 parents 1a0b5db + 3ab9e94 commit 49da461

8 files changed

Lines changed: 198 additions & 9 deletions

File tree

.gitignore

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,86 @@
1+
2+
# Created by https://www.gitignore.io/api/osx,composer,phpstorm
3+
4+
### Composer ###
5+
composer.phar
6+
composer.lock
17
/vendor/
8+
9+
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
10+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
11+
# composer.lock
12+
13+
### OSX ###
14+
*.DS_Store
15+
.AppleDouble
16+
.LSOverride
17+
18+
# Icon must end with two \r
19+
Icon
20+
21+
# Thumbnails
22+
._*
23+
24+
# Files that might appear in the root of a volume
25+
.DocumentRevisions-V100
26+
.fseventsd
27+
.Spotlight-V100
28+
.TemporaryItems
29+
.Trashes
30+
.VolumeIcon.icns
31+
.com.apple.timemachine.donotpresent
32+
33+
# Directories potentially created on remote AFP share
34+
.AppleDB
35+
.AppleDesktop
36+
Network Trash Folder
37+
Temporary Items
38+
.apdisk
39+
40+
### PhpStorm ###
41+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
42+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
43+
44+
.idea
45+
46+
# CMake
47+
cmake-build-debug/
48+
49+
# Mongo Explorer plugin:
50+
.idea/**/mongoSettings.xml
51+
52+
## File-based project format:
53+
*.iws
54+
55+
## Plugin-specific files:
56+
57+
# IntelliJ
58+
/out/
59+
60+
# mpeltonen/sbt-idea plugin
61+
.idea_modules/
62+
63+
# JIRA plugin
64+
atlassian-ide-plugin.xml
65+
66+
# Ruby plugin and RubyMine
67+
/.rakeTasks
68+
69+
# Crashlytics plugin (for Android Studio and IntelliJ)
70+
com_crashlytics_export_strings.xml
71+
crashlytics.properties
72+
crashlytics-build.properties
73+
fabric.properties
74+
75+
### PhpStorm Patch ###
76+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
77+
78+
# *.iml
79+
# modules.xml
80+
# .idea/misc.xml
81+
# *.ipr
82+
83+
# Sonarlint plugin
84+
.idea/sonarlint
85+
86+
# End of https://www.gitignore.io/api/osx,composer,phpstorm

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
language: php
2+
3+
matrix:
4+
fast_finish: true
5+
include:
6+
- php: 7.0
7+
- php: 7.1
8+
- php: 7.2
9+
10+
allow_failures:
11+
- php: 7.2
12+
13+
cache:
14+
directories:
15+
- vendor
16+
- $HOME/.composer/cache
17+
18+
install:
19+
# show versions and env information
20+
- php --version
21+
- composer --version
22+
23+
# disable xdebug for performance reasons
24+
- phpenv config-rm xdebug.ini || echo "xdebug is not installed"
25+
26+
# Install out dependencies
27+
- travis_retry composer self-update
28+
- travis_retry composer install --prefer-source --no-interaction --dev
29+
30+
before_script:
31+
# Enable code coverage
32+
- |
33+
if [ $TASK_TESTS_COVERAGE == 1 ]; then
34+
PHPUNIT_FLAGS="--coverage-clover=$TRAVIS_BUILD_DIR/build/logs/clover.xml"
35+
fi
36+
37+
script:
38+
- vendor/bin/phpunit --verbose $PHPUNIT_FLAGS

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
PHP Analytics Events
1+
PHP Analytics Events [![Build Status](https://travis-ci.org/there4/php-analytics-event.svg?branch=master)](https://travis-ci.org/there4/php-analytics-event)
22
================================================================================
33
> Create a Google Analytics Event from PHP
44
55
This is a small class to post Analytics events from PHP. This is useful for
66
logging and event tracking.
77

8+
## Installation
9+
10+
```bash
11+
composer require there4/php-analytics-event
12+
```
13+
14+
## Example
815
```php
916
<?php
1017

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
],
1111
"keywords": ["analytics", "Google Analytics", "events"],
1212
"minimum-stability": "dev",
13-
"require": {},
13+
"require": {
14+
},
1415
"autoload": {
15-
"psr-0": {
16-
"There4": "src/"
16+
"psr-4": {
17+
"There4\\Analytics\\": "src/",
18+
"Tests\\": "tests/"
1719
}
20+
},
21+
"require-dev": {
22+
"phpunit/phpunit": "^6.5@dev"
23+
},
24+
"scripts": {
25+
"test": "vendor/bin/phpunit"
1826
}
1927
}

phpunit.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
syntaxCheck="false">
11+
<testsuites>
12+
<testsuite name="Application Test Suite">
13+
<directory suffix="Test.php">./tests</directory>
14+
</testsuite>
15+
</testsuites>
16+
<filter>
17+
<whitelist processUncoveredFilesFromWhitelist="true">
18+
<directory suffix=".php">./src</directory>
19+
</whitelist>
20+
</filter>
21+
<php>
22+
<env name="APP_ENV" value="testing"/>
23+
</php>
24+
</phpunit>
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class AnalyticsEvent
5252
*
5353
* @param string $code Google Analytics key (default: const GOOG_UA)
5454
* @param string $domain HTTP_HOST (default: $_SERVER['HTTP_HOST'])
55-
*
56-
* @return void
5755
*/
5856
public function __construct($code = '', $domain = '')
5957
{
@@ -80,7 +78,7 @@ public function __construct($code = '', $domain = '')
8078
* interaction for the web object.
8179
* @param string $label An optional string to provide additional dimensions
8280
* to the event data.
83-
* @param string $value An integer that you can use to provide numerical
81+
* @param integer $value An integer that you can use to provide numerical
8482
* data about the user event.
8583
*
8684
* @return bool success
@@ -143,10 +141,10 @@ public function trackEvent($object, $action, $label = '', $value = 1)
143141

144142
return $is_gif;
145143
}
146-
144+
147145
/**
148146
* Get the current Url
149-
*
147+
*
150148
* @return string current url
151149
*/
152150
public function getCurrentUrl() {

tests/TestCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
namespace Tests;
3+
4+
abstract class TestCase extends \PHPUnit\Framework\TestCase
5+
{
6+
}
7+
8+
/* End of file TestCase.php */

tests/Unit/SanityTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
namespace Tests\Unit;
3+
4+
use Tests\TestCase;
5+
use There4\Analytics\AnalyticsEvent;
6+
7+
class SanityTest extends TestCase
8+
{
9+
/**
10+
* @test
11+
*/
12+
public function canInstantiate()
13+
{
14+
$this->assertInstanceOf(
15+
AnalyticsEvent::class,
16+
new AnalyticsEvent('UAxxxxxxx', 'example.com')
17+
);
18+
}
19+
}
20+
21+
/* End of file SanityTest.php */

0 commit comments

Comments
 (0)