Skip to content

Commit 7a205ee

Browse files
committed
Optimize package
1 parent 8cd6a12 commit 7a205ee

File tree

15 files changed

+1127
-1083
lines changed

15 files changed

+1127
-1083
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
16+
name: PHP ${{ matrix.php }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Install Composer
20+
run: composer install
21+
- name: Run Tests
22+
run: composer test

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
[![Build Status](https://travis-ci.org/parsilver/thailand-provinces-php.svg?branch=master)](https://github.com/parsilver/thailand-provinces-php)
66

7+
8+
## ความต้องการของระบบ
9+
```
10+
{
11+
"php" : "^7.3||^8.0",
12+
}
13+
```
14+
15+
716
## การติดตั้ง
817

918
```sh

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
{
22
"name": "parsilver/thailand-provinces-php",
3-
"description": "Provinces database in thailand.",
4-
"keywords": ["province", "thailand", "amphure"],
3+
"description": "Thailand address database",
4+
"keywords": ["province", "thailand", "amphure", "address"],
55
"type": "library",
66
"license": "MIT",
77
"authors": [
88
{
9-
"name": "Parkorn Soonthornchai",
10-
"email": "magician_canobi@hotmail.com"
9+
"name": "PA",
10+
"role": "DevOps"
1111
}
1212
],
1313
"minimum-stability": "stable",
1414
"prefer-stable": true,
1515
"require": {
16-
"php": "^7.2"
16+
"php": "^7.2||^8.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "8.*"
19+
"phpunit/phpunit": "^9.4"
2020
},
2121
"autoload": {
2222
"psr-4": {
2323
"PA\\ProvinceTh\\": "src/"
2424
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Farzai\\ThailandAddress\\Tests\\": "tests"
29+
}
30+
},
31+
"scripts": {
32+
"test" : "vendor/bin/phpunit"
2533
}
2634
}

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<testsuites>
1414
<testsuite name="Application Test Suite">
15-
<directory suffix=".php">./tests/</directory>
15+
<directory suffix="Test.php">./tests/</directory>
1616
</testsuite>
1717
</testsuites>
1818

src/Factory.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<?php namespace PA\ProvinceTh;
1+
<?php
2+
3+
namespace PA\ProvinceTh;
24

35
use PA\ProvinceTh\Provider\Amphure;
46
use PA\ProvinceTh\Provider\District;
57
use PA\ProvinceTh\Provider\Geography;
68
use PA\ProvinceTh\Provider\Province;
79

8-
class Factory {
9-
10+
class Factory
11+
{
1012

1113
/**
1214
* @return Geography
@@ -33,14 +35,11 @@ public static function amphure()
3335
return new Amphure();
3436
}
3537

36-
3738
/**
3839
* @return District
3940
*/
4041
public static function district()
4142
{
4243
return new District();
4344
}
44-
4545
}
46-

src/Provider/Amphure.php

Lines changed: 1013 additions & 1011 deletions
Large diffs are not rendered by default.

src/Provider/District.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<?php namespace PA\ProvinceTh\Provider;
1+
<?php
22

3-
4-
class District extends ProviderCollection {
3+
namespace PA\ProvinceTh\Provider;
54

65

6+
class District extends ProviderCollection
7+
{
78
/**
89
* @return array
910
*/
@@ -8933,6 +8934,4 @@ public function data()
89338934
['id' => '380803', 'zip_code' => '38000', 'name_th' => 'หนองเดิน', 'name_en' => 'Nong Doen', 'amphure_id' => '1006'],
89348935
];
89358936
}
8936-
8937-
8938-
}
8937+
}

src/Provider/Geography.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
<?php namespace PA\ProvinceTh\Provider;
1+
<?php
22

3+
namespace PA\ProvinceTh\Provider;
34

4-
class Geography extends ProviderCollection {
5+
6+
class Geography extends ProviderCollection
7+
{
58

69

710
/**
@@ -26,6 +29,4 @@ public function data()
2629
['id' => '6', 'name' => 'ภาคใต้'],
2730
];
2831
}
29-
30-
31-
}
32+
}

src/Provider/ProviderCollection.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<?php namespace PA\ProvinceTh\Provider;
1+
<?php
2+
3+
namespace PA\ProvinceTh\Provider;
24

35
use PA\ProvinceTh\Support\Collection;
46

5-
abstract class ProviderCollection extends Collection {
7+
abstract class ProviderCollection extends Collection
8+
{
69

710
/**
811
* @return array
@@ -37,10 +40,10 @@ public function find($id)
3740
*/
3841
public function each(callable $callback)
3942
{
40-
foreach($this->getItems() as $key => $value) {
43+
foreach ($this->getItems() as $key => $value) {
4144
$callbackResult = $callback(new static($value), $key);
4245

43-
if($callbackResult === false) {
46+
if ($callbackResult === false) {
4447
break;
4548
}
4649
}
@@ -63,13 +66,13 @@ public function getPrimaryKey()
6366
*/
6467
protected function hasMany($provider, $foreignKey = null)
6568
{
66-
if($this->itemIsObject()) {
69+
if ($this->itemIsObject()) {
6770
$this->setItems([$this->getItems()]);
6871
}
6972

7073
$provider = new $provider();
7174

72-
if(is_null($foreignKey)) {
75+
if (is_null($foreignKey)) {
7376
$foreignKey = strtolower($this->getClassName($this)) . '_id';
7477
}
7578

@@ -84,13 +87,13 @@ protected function hasMany($provider, $foreignKey = null)
8487
*/
8588
protected function belongsTo($provider, $localForeignKey = null)
8689
{
87-
if($this->itemIsObject()) {
90+
if ($this->itemIsObject()) {
8891
$this->setItems([$this->getItems()]);
8992
}
9093

9194
$provider = new $provider();
9295

93-
if(is_null($localForeignKey)) {
96+
if (is_null($localForeignKey)) {
9497
$localForeignKey = strtolower($this->getClassName($provider)) . '_id';
9598
}
9699

@@ -113,4 +116,4 @@ private function itemIsObject()
113116
{
114117
return isset($this->getItems()[$this->getPrimaryKey()]);
115118
}
116-
}
119+
}

0 commit comments

Comments
 (0)