Skip to content

Commit 275f836

Browse files
committed
Initial commit
0 parents  commit 275f836

25 files changed

+1910
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/composer.lock
2+
/.idea
3+
/vendor

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: php
2+
3+
php:
4+
- 7.3
5+
- 7.4
6+
- 8.0
7+
- 8.1
8+
9+
install: composer update
10+
11+
script: ./vendor/bin/phpunit .

LICENSE.md

Lines changed: 636 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# yocLib - Open Location Code (PHP)
2+
3+
This yocLibrary enables your project to read and write MPEGURL files in PHP.
4+
5+
## Status
6+
7+
[![Build Status](https://travis-ci.com/yocto/yoclib-mpegurl-php.svg?branch=master)](https://travis-ci.com/yocto/yoclib-mpegurl-php)
8+
9+
## Installation
10+
11+
`composer require yocto/yoclib-mpegurl`
12+
13+
## Use
14+
15+
Read:
16+
```php
17+
use YOCLIB\MPEGURL\MPEGURL;
18+
19+
$fileContent = '';
20+
$fileContent .= '#EXTM3U'."\r\n";
21+
$fileContent .= '#EXTINF:123,The example file'."\r\n";
22+
$fileContent .= '/home/user/test.mp3'."\r\n";
23+
24+
$mpegurl = MPEGURL::read($fileContent);
25+
```
26+
27+
Write:
28+
```php
29+
use YOCLIB\MPEGURL\MPEGURL;
30+
use YOCLIB\MPEGURL\Lines\Location;
31+
use YOCLIB\MPEGURL\Lines\Tags\EXTINF;
32+
use YOCLIB\MPEGURL\Lines\Tags\EXTMxU;
33+
34+
$mpegurl = new MPEGURL();
35+
$mpegurl->addLine(new EXTMxU());
36+
$mpegurl->addLine(new EXTINF('123,The example file'));
37+
$mpegurl->addLine(new Location('/home/user/test.mp3'));
38+
39+
$fileContent = MPEGURL::write($mpegurl);
40+
```

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "yocto/yoclib-openlocationcode",
3+
"type": "library",
4+
"description": "This yocLibrary enables your project to read and write MPEGURL files in PHP.",
5+
"keywords":[
6+
"composer",
7+
"openlocationcode",
8+
"php",
9+
"pluscode",
10+
"yocto",
11+
"yoclib"
12+
],
13+
"license": "GPL-3.0-or-later",
14+
"require": {
15+
"php": "^7||^8"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "^7||^8||^9"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"YOCLIB\\OpenLocationCode\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"YOCLIB\\OpenLocationCode\\Tests\\": "tests/"
28+
}
29+
}
30+
}

src/CodeArea.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
namespace YOCLIB\OpenLocationCode;
3+
4+
class CodeArea{
5+
6+
/**@var double $southLatitude*/
7+
private $southLatitude;
8+
/**@var double $westLongitude*/
9+
private $westLongitude;
10+
/**@var double $northLatitude*/
11+
private $northLatitude;
12+
/**@var double $eastLongitude*/
13+
private $eastLongitude;
14+
/**@var int $length*/
15+
private $length;
16+
17+
/**
18+
* @param double $southLatitude
19+
* @param double $westLongitude
20+
* @param double $northLatitude
21+
* @param double $eastLongitude
22+
* @param int $length
23+
*/
24+
public function __construct($southLatitude,$westLongitude,$northLatitude,$eastLongitude,$length){
25+
$this->southLatitude = $southLatitude;
26+
$this->westLongitude = $westLongitude;
27+
$this->northLatitude = $northLatitude;
28+
$this->eastLongitude = $eastLongitude;
29+
$this->length = $length;
30+
}
31+
32+
/**
33+
* @return double
34+
*/
35+
public function getSouthLatitude(){
36+
return $this->southLatitude;
37+
}
38+
39+
/**
40+
* @return double
41+
*/
42+
public function getWestLongitude(){
43+
return $this->westLongitude;
44+
}
45+
46+
/**
47+
* @return double
48+
*/
49+
public function getLatitudeHeight(){
50+
return $this->northLatitude - $this->southLatitude;
51+
}
52+
53+
/**
54+
* @return double
55+
*/
56+
public function getLongitudeWidth(){
57+
return $this->eastLongitude - $this->westLongitude;
58+
}
59+
60+
/**
61+
* @return double
62+
*/
63+
public function getCenterLatitude(){
64+
return ($this->southLatitude + $this->northLatitude)/2;
65+
}
66+
67+
/**
68+
* @return double
69+
*/
70+
public function getCenterLongitude(){
71+
return ($this->westLongitude + $this->eastLongitude)/2;
72+
}
73+
74+
/**
75+
* @return double
76+
*/
77+
public function getNorthLatitude(){
78+
return $this->northLatitude;
79+
}
80+
81+
/**
82+
* @return double
83+
*/
84+
public function getEastLongitude(){
85+
return $this->eastLongitude;
86+
}
87+
88+
/**
89+
* @return int
90+
*/
91+
public function getLength(){
92+
return $this->length;
93+
}
94+
95+
}

0 commit comments

Comments
 (0)