Skip to content

Commit e25d033

Browse files
authored
Merge pull request #85 from UseMuffin/dev
Dev
2 parents 675d087 + 9981890 commit e25d033

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2235
-358
lines changed

.semver

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

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: php
22

33
php:
4+
- 5.6
45
- 7.0
56
- 7.1
6-
- 5.6
7+
- 7.2
78

89
dist: trusty
910

@@ -24,7 +25,7 @@ matrix:
2425
- php: 7.0
2526
env: PHPCS=1 DEFAULT=0
2627

27-
- php: 7.0
28+
- php: 7.1
2829
env: PHPSTAN=1 DEFAULT=0
2930

3031
- php: 5.6
@@ -33,7 +34,7 @@ matrix:
3334
before_script:
3435
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
3536

36-
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.9; fi
37+
- if [[ $PHPSTAN = 1 ]]; then composer require --dev phpstan/phpstan:^0.11; fi
3738
- if [[ $PHPSTAN != 1 ]]; then composer install --no-interaction; fi
3839

3940
script:
@@ -42,7 +43,7 @@ script:
4243

4344
- if [[ $PHPCS = 1 ]]; then ./vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
4445

45-
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -l 2 src; fi
46+
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse src; fi
4647

4748
after_success:
4849
- if [[ $CODECOVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015 Use Muffin
1+
Copyright (c) 2015-Present Use Muffin
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ You then need to load the plugin. You can use the shell command:
2121
bin/cake plugin load Muffin/Webservice
2222
```
2323

24-
or by manually adding statement shown below to `boostrap.php`:
25-
26-
```php
27-
Plugin::load('Muffin/Webservice', ['bootstrap' => true]);
28-
```
29-
3024
## Usage
3125

3226
### As an ORM
@@ -35,21 +29,19 @@ Plugin::load('Muffin/Webservice', ['bootstrap' => true]);
3529

3630
```php
3731
<?php
38-
3932
namespace App\Webservice\Driver;
4033

4134
use Cake\Network\Http\Client;
4235
use Muffin\Webservice\AbstractDriver;
4336

4437
class Articles extends AbstractDriver
4538
{
46-
4739
/**
48-
* {@inheritDoc}
40+
* Initialize is used to easily extend the constructor.
4941
*/
5042
public function initialize()
5143
{
52-
$this->client(new Client([
44+
$this->setClient(new Client([
5345
'host' => 'example.com'
5446
]));
5547
}
@@ -60,23 +52,20 @@ class Articles extends AbstractDriver
6052

6153
```php
6254
<?php
63-
6455
namespace App\Webservice;
6556

66-
use Cake\Network\Http\Client;
6757
use Muffin\Webservice\Query;
6858
use Muffin\Webservice\ResultSet;
6959
use Muffin\Webservice\Webservice\Webservice;
7060

7161
class ArticlesWebservice extends Webservice
7262
{
73-
7463
/**
75-
* {@inheritDoc}
64+
* Executes a query with the read action using the Cake HTTP Client
7665
*/
7766
protected function _executeReadQuery(Query $query, array $options = [])
7867
{
79-
$response = $this->driver()->client()->get('/articles.json');
68+
$response = $this->getDriver()->getClient()->get('/articles.json');
8069

8170
if (!$response->isOk()) {
8271
return false;
@@ -93,59 +82,51 @@ class ArticlesWebservice extends Webservice
9382

9483
```php
9584
<?php
96-
9785
namespace App\Model\Endpoint;
9886

9987
use Muffin\Webservice\Model\Endpoint;
10088

10189
class ArticlesEndpoint extends Endpoint
10290
{
103-
10491
}
10592
```
10693

10794
#### Create a resource (optional)
10895

10996
```php
11097
<?php
111-
11298
namespace App\Model\Resource;
11399

114100
use Muffin\Webservice\Model\Resource;
115101

116102
class Article extends Resource
117103
{
118-
119104
}
120105
```
121106

122107
#### Use it
123108

124109
```php
125110
<?php
126-
127111
namespace App\Controller;
128112

129113
use Cake\Event\Event;
114+
use Muffin\Webservice\Model\EndpointLocator;
130115

131116
class ArticlesController extends AppController
132117
{
133-
public function initialize()
134-
{
135-
// You can also put this in AppController::initialize() itself
136-
$this->modelFactory('Endpoint', ['Muffin\Webservice\Model\EndpointRegistry', 'get']);
137-
}
118+
// Either set the default model type to "Endpoint" or explicitly specify
119+
// model type in loadModel() call as shown below.
120+
protected $_modelType = 'Endpoint';
138121

139-
public function beforeFilter(Event $event)
122+
public function index()
140123
{
124+
// This is required only if you haven't set `$_modelType` property to
125+
// "Endpoint" as shown above.
141126
$this->loadModel('Articles', 'Endpoint');
142-
}
143127

144-
public function index()
145-
{
146128
$articles = $this->Articles->find();
147129
}
148-
149130
}
150131
```
151132

@@ -195,7 +176,7 @@ http://github.com/usemuffin/webservice/issues
195176

196177
## License
197178

198-
Copyright (c) 2015, [Use Muffin] and licensed under [The MIT License][mit].
179+
Copyright (c) 2015-Present, [Use Muffin] and licensed under [The MIT License][mit].
199180

200181
[cakephp]:http://cakephp.org
201182
[composer]:http://getcomposer.org

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
"irc": "irc://irc.freenode.org/muffin"
4040
},
4141
"require": {
42+
"cakephp/cakephp": "^3.6"
4243
},
4344
"require-dev": {
44-
"cakephp/cakephp": "^3.6",
4545
"cakephp/cakephp-codesniffer": "^3.0",
46-
"phpunit/phpunit": "5.7.14|^6.0"
46+
"phpunit/phpunit": "^5.7.14|^6.0"
4747
},
4848
"autoload": {
4949
"psr-4": {
@@ -54,10 +54,5 @@
5454
"psr-4": {
5555
"Muffin\\Webservice\\Test\\": "tests"
5656
}
57-
},
58-
"extra": {
59-
"branch-alias": {
60-
"dev-master": "1.0.x-dev"
61-
}
6257
}
6358
}

config/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
2+
use Cake\Datasource\FactoryLocator;
3+
use Muffin\Webservice\Model\EndpointLocator;
24

3-
\Cake\Routing\DispatcherFactory::add('Muffin/Webservice.ControllerEndpoint');
5+
FactoryLocator::add('Endpoint', [new EndpointLocator(), 'get']);

phpstan.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
level: 4
3+
ignoreErrors:
4+
- '#Method Muffin\\Webservice\\Query::endpoint\(\) should return \$this\(Muffin\\Webservice\\Query\)|Muffin\\Webservice\\Model\\Endpoint but returns Cake\Datasource\RepositoryInterface#'
5+
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::callFinder\(\)#'
6+
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::dispatchEvent\(\)#'
7+
- '#Method Muffin\\Webservice\\Query::offset\(\) should return \$this\(Cake\\Datasource\\QueryInterface\) but returns \$this\(Muffin\\Webservice\\Query\)#'
8+
- '#Return type \(array\) of method Muffin\\Webservice\\Query::aliasField\(\) should be compatible with return type \(string\) of method Cake\\Datasource\\QueryInterface::aliasField\(\)#'
9+
- '#Call to an undefined method Cake\\Datasource\\RepositoryInterface::getName\(\)#'
10+
- '#Call to an undefined method Traversable::count\(\)#'
11+
- '#Strict comparison using === between string and null will always evaluate to false#'
12+
- '#Negated boolean expression is always false#'

0 commit comments

Comments
 (0)