Skip to content

Commit e8d64ae

Browse files
swillaandreia
andauthored
Fix extra argument, clean up config (#58)
* remove unused config, remove outdated argument * add another workflow * phpstan * fix argument * fix neon errors * Apply fixes from StyleCI [ci skip] [skip ci] * Fix typo Co-authored-by: Steve Williamson <[email protected]> Co-authored-by: Andreia Bohner <[email protected]>
1 parent 41e6d6c commit e8d64ae

File tree

7 files changed

+57
-17
lines changed

7 files changed

+57
-17
lines changed

.github/workflows/phpstan.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'phpstan.neon.dist'
8+
pull_request:
9+
paths:
10+
- '**.php'
11+
- 'phpstan.neon.dist'
12+
13+
14+
jobs:
15+
phpstan:
16+
name: phpstan
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: '8.0'
25+
coverage: none
26+
27+
- name: Install composer dependencies
28+
uses: ramsey/composer-install@v1
29+
30+
- name: Run PHPStan
31+
run: ./vendor/bin/phpstan --error-format=github

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"require-dev": {
2525
"mockery/mockery": "^1.4",
2626
"orchestra/testbench": "^5.0 || ^6.0",
27+
"phpstan/extension-installer": "^1.1",
28+
"phpstan/phpstan-deprecation-rules": "^1.0",
29+
"phpstan/phpstan-phpunit": "^1.0",
2730
"phpunit/phpunit": "^8.4 || ^9.3.3"
2831
},
2932
"autoload": {
@@ -37,6 +40,7 @@
3740
}
3841
},
3942
"scripts": {
43+
"analyse": "vendor/bin/phpstan analyse",
4044
"test": "vendor/bin/phpunit",
4145
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
4246

config/config.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,12 @@
5454
|
5555
| This value can be found on the API docs page:
5656
| https://airtable.com/[BASE_ID]/api/docs#curl/table:tasks
57-
| The value will be hilighted at the beginning of each table section.
57+
| The value will be highlighted at the beginning of each table section.
5858
| Example:
5959
| Each record in the `Tasks` contains the following fields
6060
|
6161
*/
6262

63-
'log_http' => env('AIRTABLE_LOG_HTTP', false),
64-
'log_http_format' => env('AIRTABLE_LOG_HTTP_FORMAT', '{request} >>> {res_body}'),
65-
6663
'typecast' => env('AIRTABLE_TYPECAST', false),
6764

6865
// The API is limited to 5 requests per second per base.

phpstan-baseline.neon

Whitespace-only changes.

phpstan.neon.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 2
6+
paths:
7+
- src
8+
- config
9+
tmpDir: build/phpstan
10+
excludePaths:
11+
- ./vendor
12+
checkMissingIterableValueType: true

src/Airtable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function create($data)
2424
}
2525

2626
/**
27-
* @param dynamic $args (string) $id, $data | (array) $data
27+
* @param mixed $args (string) $id, $data | (array) $data
2828
* @return mixed
2929
*
3030
* @throws \InvalidArgumentException
@@ -45,7 +45,7 @@ public function update(...$args)
4545
}
4646

4747
/**
48-
* @param dynamic $args (string) $id, $data | (array) $data
48+
* @param mixed $args (string) $id, $data | (array) $data
4949
* @return mixed
5050
*
5151
* @throws \InvalidArgumentException

src/AirtableManager.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function __construct($app)
3737
* Get a airtable table instance.
3838
*
3939
* @param string $table
40-
* @return \Airtable\Table
4140
*/
4241
public function table(string $table)
4342
{
@@ -56,7 +55,7 @@ protected function configuration($name)
5655
{
5756
$name = $name ?: $this->getDefaultTable();
5857

59-
// To get the aritable table configuration, we will just pull each of the
58+
// To get the airtable table configuration, we will just pull each of the
6059
// connection configurations and get the configurations for the given name.
6160
// If the configuration doesn't exist, we'll throw an exception and bail.
6261
$tables = $this->app['config']['airtable.tables'];
@@ -112,18 +111,12 @@ protected function createAirtable($table, $table_base = false)
112111
$base = $table_base ?: $this->app['config']['airtable.base'];
113112
$access_token = $this->app['config']['airtable.key'];
114113

115-
if ($this->app['config']['airtable.log_http']) {
116-
$httpLogFormat = $this->app['config']['airtable.log_http_format'];
117-
} else {
118-
$httpLogFormat = null;
119-
}
120-
121114
$airtableTypeCast = $this->app['config']['airtable.typecast'];
122115
$delay = $this->app['config']['airtable.delay_between_requests'];
123116

124-
$client = new AirtableApiClient($base, $table, $access_token, $httpLogFormat, null, $airtableTypeCast, $delay);
117+
$client = new AirtableApiClient($base, $table, $access_token, null, $airtableTypeCast, $delay);
125118

126-
return new Airtable($client, $table);
119+
return new Airtable($client);
127120
}
128121

129122
/**
@@ -146,6 +139,9 @@ protected function getConfig($name)
146139
*/
147140
public function __call($method, $parameters)
148141
{
149-
return $this->table()->$method(...$parameters);
142+
$defaultConfig = $this->app['config']['airtable.default'];
143+
$defaultTable = $this->app['config']["airtable.tables.{$defaultConfig}"]['name'];
144+
145+
return $this->table($defaultTable)->$method(...$parameters);
150146
}
151147
}

0 commit comments

Comments
 (0)