Skip to content

Commit f2f89f8

Browse files
committed
refact(API-1925): Run rector
1 parent 140fb81 commit f2f89f8

File tree

63 files changed

+110
-957
lines changed

Some content is hidden

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

63 files changed

+110
-957
lines changed

spec/Routing/UriGeneratorSpec.php

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

77
class UriGeneratorSpec extends ObjectBehavior
88
{
9-
const BASE_URI = 'http://akeneo-pim.local/';
9+
public const BASE_URI = 'http://akeneo-pim.local/';
1010

1111
function let()
1212
{

spec/Security/AuthenticationSpec.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace spec\Akeneo\Pim\ApiClient\Security;
44

5+
use Akeneo\Pim\ApiClient\Security\Authentication;
56
use PhpSpec\ObjectBehavior;
67

78
class AuthenticationSpec extends ObjectBehavior
89
{
910
function it_is_initializable_from_a_password()
1011
{
1112
$this->beConstructedThrough('fromPassword', ['client_id', 'secret', 'Julia', 'Julia_pwd']);
12-
$this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication');
13+
$this->shouldHaveType(Authentication::class);
1314

1415
$this->getClientId()->shouldReturn('client_id');
1516
$this->getSecret()->shouldReturn('secret');
@@ -22,7 +23,7 @@ function it_is_initializable_from_a_password()
2223
function it_is_initializable_from_a_token()
2324
{
2425
$this->beConstructedThrough('fromToken', ['client_id', 'secret', 'token', 'refresh_token']);
25-
$this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication');
26+
$this->shouldHaveType(Authentication::class);
2627

2728
$this->getClientId()->shouldReturn('client_id');
2829
$this->getSecret()->shouldReturn('secret');
@@ -35,7 +36,7 @@ function it_is_initializable_from_a_token()
3536
function it_is_initializable_from_an_app_token()
3637
{
3738
$this->beConstructedThrough('fromAppToken', ['a_token']);
38-
$this->shouldHaveType('Akeneo\Pim\ApiClient\Security\Authentication');
39+
$this->shouldHaveType(Authentication::class);
3940

4041
$this->getClientId()->shouldReturn(null);
4142
$this->getSecret()->shouldReturn(null);

src/AkeneoPimClient.php

Lines changed: 2 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -50,124 +50,8 @@
5050
*/
5151
class AkeneoPimClient implements AkeneoPimClientInterface
5252
{
53-
protected Authentication $authentication;
54-
protected ProductApiInterface $productApi;
55-
protected CategoryApiInterface $categoryApi;
56-
protected AttributeApiInterface $attributeApi;
57-
protected AttributeOptionApiInterface $attributeOptionApi;
58-
protected AttributeGroupApiInterface $attributeGroupApi;
59-
protected FamilyApiInterface $familyApi;
60-
protected MediaFileApiInterface $productMediaFileApi;
61-
protected LocaleApiInterface $localeApi;
62-
protected ChannelApiInterface $channelApi;
63-
protected CurrencyApiInterface $currencyApi;
64-
protected MeasureFamilyApiInterface $measureFamilyApi;
65-
protected AssociationTypeApiInterface $associationTypeApi;
66-
protected FamilyVariantApiInterface $familyVariantApi;
67-
protected ProductModelApiInterface $productModelApi;
68-
private MeasurementFamilyApiInterface $measurementFamilyApi;
69-
private PublishedProductApiInterface $publishedProductApi;
70-
private ProductModelDraftApiInterface $productModelDraftApi;
71-
private ProductDraftApiInterface $productDraftApi;
72-
private AssetApiInterface $assetApi;
73-
private AssetCategoryApiInterface $assetCategoryApi;
74-
private AssetTagApiInterface $assetTagApi;
75-
private AssetReferenceFileApiInterface $assetReferenceFileApi;
76-
private AssetVariationFileApiInterface $assetVariationFileApi;
77-
private ReferenceEntityRecordApiInterface $referenceEntityRecordApi;
78-
private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi;
79-
private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi;
80-
private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi;
81-
private ReferenceEntityApiInterface $referenceEntityApi;
82-
private AssetManagerApiInterface $assetManagerApi;
83-
private AssetFamilyApiInterface $assetFamilyApi;
84-
private AssetAttributeApiInterface $assetAttributeApi;
85-
private AssetAttributeOptionApiInterface $assetAttributeOptionApi;
86-
private AssetMediaFileApiInterface $assetMediaFileApi;
87-
private AppCatalogApiInterface $appCatalogApi;
88-
private AppCatalogProductApiInterface $appCatalogProductApi;
89-
90-
private ProductUuidApiInterface $productUuidApi;
91-
private ProductDraftUuidApiInterface $productDraftUuidApi;
92-
93-
public function __construct(
94-
Authentication $authentication,
95-
ProductApiInterface $productApi,
96-
CategoryApiInterface $categoryApi,
97-
AttributeApiInterface $attributeApi,
98-
AttributeOptionApiInterface $attributeOptionApi,
99-
AttributeGroupApiInterface $attributeGroupApi,
100-
FamilyApiInterface $familyApi,
101-
MediaFileApiInterface $productMediaFileApi,
102-
LocaleApiInterface $localeApi,
103-
ChannelApiInterface $channelApi,
104-
CurrencyApiInterface $currencyApi,
105-
MeasureFamilyApiInterface $measureFamilyApi,
106-
MeasurementFamilyApiInterface $measurementFamilyApi,
107-
AssociationTypeApiInterface $associationTypeApi,
108-
FamilyVariantApiInterface $familyVariantApi,
109-
ProductModelApiInterface $productModelApi,
110-
ProductModelDraftApiInterface $productModelDraftApi,
111-
PublishedProductApiInterface $publishedProductApi,
112-
ProductDraftApiInterface $productDraftApi,
113-
AssetApiInterface $assetApi,
114-
AssetCategoryApiInterface $assetCategoryApi,
115-
AssetTagApiInterface $assetTagApi,
116-
AssetReferenceFileApiInterface $assetReferenceFileApi,
117-
AssetVariationFileApiInterface $assetVariationFileApi,
118-
ReferenceEntityRecordApiInterface $referenceEntityRecordApi,
119-
ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi,
120-
ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi,
121-
ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi,
122-
ReferenceEntityApiInterface $referenceEntityApi,
123-
AssetManagerApiInterface $assetManagerApi,
124-
AssetFamilyApiInterface $assetFamilyApi,
125-
AssetAttributeApiInterface $assetAttributeApi,
126-
AssetAttributeOptionApiInterface $assetAttributeOptionApi,
127-
AssetMediaFileApiInterface $assetMediaFileApi,
128-
ProductUuidApiInterface $productUuidApi,
129-
ProductDraftUuidApiInterface $productDraftUuidApi,
130-
AppCatalogApiInterface $appCatalogApi,
131-
AppCatalogProductApiInterface $appCatalogProductApi
132-
) {
133-
$this->authentication = $authentication;
134-
$this->productApi = $productApi;
135-
$this->categoryApi = $categoryApi;
136-
$this->attributeApi = $attributeApi;
137-
$this->attributeOptionApi = $attributeOptionApi;
138-
$this->attributeGroupApi = $attributeGroupApi;
139-
$this->familyApi = $familyApi;
140-
$this->productMediaFileApi = $productMediaFileApi;
141-
$this->localeApi = $localeApi;
142-
$this->channelApi = $channelApi;
143-
$this->currencyApi = $currencyApi;
144-
$this->measureFamilyApi = $measureFamilyApi;
145-
$this->measurementFamilyApi = $measurementFamilyApi;
146-
$this->associationTypeApi = $associationTypeApi;
147-
$this->familyVariantApi = $familyVariantApi;
148-
$this->productModelApi = $productModelApi;
149-
$this->publishedProductApi = $publishedProductApi;
150-
$this->productDraftApi = $productDraftApi;
151-
$this->productModelDraftApi = $productModelDraftApi;
152-
$this->assetApi = $assetApi;
153-
$this->assetCategoryApi = $assetCategoryApi;
154-
$this->assetTagApi = $assetTagApi;
155-
$this->assetReferenceFileApi = $assetReferenceFileApi;
156-
$this->assetVariationFileApi = $assetVariationFileApi;
157-
$this->referenceEntityRecordApi = $referenceEntityRecordApi;
158-
$this->referenceEntityMediaFileApi = $referenceEntityMediaFileApi;
159-
$this->referenceEntityAttributeApi = $referenceEntityAttributeApi;
160-
$this->referenceEntityAttributeOptionApi = $referenceEntityAttributeOptionApi;
161-
$this->referenceEntityApi = $referenceEntityApi;
162-
$this->assetManagerApi = $assetManagerApi;
163-
$this->assetFamilyApi = $assetFamilyApi;
164-
$this->assetAttributeApi = $assetAttributeApi;
165-
$this->assetAttributeOptionApi = $assetAttributeOptionApi;
166-
$this->assetMediaFileApi = $assetMediaFileApi;
167-
$this->productUuidApi = $productUuidApi;
168-
$this->productDraftUuidApi = $productDraftUuidApi;
169-
$this->appCatalogApi = $appCatalogApi;
170-
$this->appCatalogProductApi = $appCatalogProductApi;
53+
public function __construct(protected Authentication $authentication, protected ProductApiInterface $productApi, protected CategoryApiInterface $categoryApi, protected AttributeApiInterface $attributeApi, protected AttributeOptionApiInterface $attributeOptionApi, protected AttributeGroupApiInterface $attributeGroupApi, protected FamilyApiInterface $familyApi, protected MediaFileApiInterface $productMediaFileApi, protected LocaleApiInterface $localeApi, protected ChannelApiInterface $channelApi, protected CurrencyApiInterface $currencyApi, protected MeasureFamilyApiInterface $measureFamilyApi, private MeasurementFamilyApiInterface $measurementFamilyApi, protected AssociationTypeApiInterface $associationTypeApi, protected FamilyVariantApiInterface $familyVariantApi, protected ProductModelApiInterface $productModelApi, private ProductModelDraftApiInterface $productModelDraftApi, private PublishedProductApiInterface $publishedProductApi, private ProductDraftApiInterface $productDraftApi, private AssetApiInterface $assetApi, private AssetCategoryApiInterface $assetCategoryApi, private AssetTagApiInterface $assetTagApi, private AssetReferenceFileApiInterface $assetReferenceFileApi, private AssetVariationFileApiInterface $assetVariationFileApi, private ReferenceEntityRecordApiInterface $referenceEntityRecordApi, private ReferenceEntityMediaFileApiInterface $referenceEntityMediaFileApi, private ReferenceEntityAttributeApiInterface $referenceEntityAttributeApi, private ReferenceEntityAttributeOptionApiInterface $referenceEntityAttributeOptionApi, private ReferenceEntityApiInterface $referenceEntityApi, private AssetManagerApiInterface $assetManagerApi, private AssetFamilyApiInterface $assetFamilyApi, private AssetAttributeApiInterface $assetAttributeApi, private AssetAttributeOptionApiInterface $assetAttributeOptionApi, private AssetMediaFileApiInterface $assetMediaFileApi, private ProductUuidApiInterface $productUuidApi, private ProductDraftUuidApiInterface $productDraftUuidApi, private AppCatalogApiInterface $appCatalogApi, private AppCatalogProductApiInterface $appCatalogProductApi)
54+
{
17155
}
17256

17357
/**

src/AkeneoPimClientBuilder.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
*/
7171
class AkeneoPimClientBuilder
7272
{
73-
/** @var string */
74-
protected $baseUri;
75-
7673
/** @var ClientInterface */
7774
protected $httpClient;
7875

@@ -92,9 +89,8 @@ class AkeneoPimClientBuilder
9289
/**
9390
* @param string $baseUri Base uri to request the API
9491
*/
95-
public function __construct(string $baseUri, array $options = [])
92+
public function __construct(protected string $baseUri, array $options = [])
9693
{
97-
$this->baseUri = $baseUri;
9894
$this->options = Options::fromArray($options);
9995
}
10096

@@ -130,10 +126,6 @@ public function setStreamFactory(StreamFactoryInterface $streamFactory): self
130126

131127
/**
132128
* Allows to define another implementation than LocalFileSystem
133-
*
134-
* @param FileSystemInterface $fileSystem
135-
*
136-
* @return AkeneoPimClientBuilder
137129
*/
138130
public function setFileSystem(FileSystemInterface $fileSystem): self
139131
{
@@ -149,8 +141,6 @@ public function setFileSystem(FileSystemInterface $fileSystem): self
149141
* @param string $secret Secret associated to the client
150142
* @param string $username Username to use for the authentication
151143
* @param string $password Password associated to the username
152-
*
153-
* @return AkeneoPimClientInterface
154144
*/
155145
public function buildAuthenticatedByPassword(string $clientId, string $secret, string $username, string $password): AkeneoPimClientInterface
156146
{
@@ -173,8 +163,6 @@ public function buildAuthenticatedByAppToken(string $token): AkeneoPimClientInte
173163
* @param string $secret Secret associated to the client
174164
* @param string $token Token to use for the authentication
175165
* @param string $refreshToken Token to use to refresh the access token
176-
*
177-
* @return AkeneoPimClientInterface
178166
*/
179167
public function buildAuthenticatedByToken(string $clientId, string $secret, string $token, string $refreshToken): AkeneoPimClientInterface
180168
{
@@ -205,16 +193,11 @@ public function disableCache(): self
205193
return $this;
206194
}
207195

208-
/**
209-
* @param Authentication $authentication
210-
*
211-
* @return AkeneoPimClientInterface
212-
*/
213196
protected function buildAuthenticatedClient(Authentication $authentication): AkeneoPimClientInterface
214197
{
215198
[$resourceClient, $pageFactory, $cursorFactory, $fileSystem] = $this->setUp($authentication);
216199

217-
$resourceClientWithCache = !$this->cacheEnabled ? $resourceClient : new CachedResourceClient($resourceClient, new LRUCache());
200+
$resourceClientWithCache = $this->cacheEnabled ? new CachedResourceClient($resourceClient, new LRUCache()) : $resourceClient;
218201

219202
return new AkeneoPimClient(
220203
$authentication,
@@ -258,11 +241,6 @@ protected function buildAuthenticatedClient(Authentication $authentication): Ake
258241
);
259242
}
260243

261-
/**
262-
* @param Authentication $authentication
263-
*
264-
* @return array
265-
*/
266244
protected function setUp(Authentication $authentication): array
267245
{
268246
$uriGenerator = new UriGenerator($this->baseUri);

src/Api/AppCatalog/AppCatalogApi.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,8 @@ class AppCatalogApi implements AppCatalogApiInterface
2020
public const APP_CATALOGS_URI = 'api/rest/v1/catalogs';
2121
public const APP_CATALOG_URI = 'api/rest/v1/catalogs/%s';
2222

23-
protected ResourceClientInterface $resourceClient;
24-
protected PageFactoryInterface $pageFactory;
25-
protected ResourceCursorFactoryInterface $cursorFactory;
26-
27-
public function __construct(
28-
ResourceClientInterface $resourceClient,
29-
PageFactoryInterface $pageFactory,
30-
ResourceCursorFactoryInterface $cursorFactory
31-
) {
32-
$this->resourceClient = $resourceClient;
33-
$this->pageFactory = $pageFactory;
34-
$this->cursorFactory = $cursorFactory;
23+
public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory)
24+
{
3525
}
3626

3727
public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface

src/Api/AppCatalog/AppCatalogProductApi.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@ class AppCatalogProductApi implements AppCatalogProductApiInterface
1717
{
1818
public const APP_CATALOG_PRODUCT_URI = '/api/rest/v1/catalogs/%s/product-uuids';
1919

20-
protected ResourceClientInterface $resourceClient;
21-
protected PageFactoryInterface $pageFactory;
22-
protected ResourceCursorFactoryInterface $cursorFactory;
23-
24-
public function __construct(
25-
ResourceClientInterface $resourceClient,
26-
PageFactoryInterface $pageFactory,
27-
ResourceCursorFactoryInterface $cursorFactory
28-
) {
29-
$this->resourceClient = $resourceClient;
30-
$this->pageFactory = $pageFactory;
31-
$this->cursorFactory = $cursorFactory;
20+
public function __construct(protected ResourceClientInterface $resourceClient, protected PageFactoryInterface $pageFactory, protected ResourceCursorFactoryInterface $cursorFactory)
21+
{
3222
}
3323

3424
/**

src/Api/AssetApi.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@ class AssetApi implements AssetApiInterface
2525
public const ASSETS_URI = '/api/rest/v1/assets';
2626
public const ASSET_URI = '/api/rest/v1/assets/%s';
2727

28-
/** @var ResourceClientInterface */
29-
private $resourceClient;
30-
31-
/** @var PageFactoryInterface */
32-
private $pageFactory;
33-
34-
/** @var ResourceCursorFactoryInterface */
35-
private $cursorFactory;
36-
37-
public function __construct(
38-
ResourceClientInterface $resourceClient,
39-
PageFactoryInterface $pageFactory,
40-
ResourceCursorFactoryInterface $cursorFactory
41-
) {
42-
$this->resourceClient = $resourceClient;
43-
$this->pageFactory = $pageFactory;
44-
$this->cursorFactory = $cursorFactory;
28+
public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory)
29+
{
4530
}
4631

4732
/**

src/Api/AssetCategoryApi.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,8 @@ class AssetCategoryApi implements AssetCategoryApiInterface
2525
public const ASSET_CATEGORIES_URI = '/api/rest/v1/asset-categories';
2626
public const ASSET_CATEGORY_URI = '/api/rest/v1/asset-categories/%s';
2727

28-
/** @var ResourceClientInterface */
29-
private $resourceClient;
30-
31-
/** @var PageFactoryInterface */
32-
private $pageFactory;
33-
34-
/** @var ResourceCursorFactoryInterface */
35-
private $cursorFactory;
36-
37-
public function __construct(
38-
ResourceClientInterface $resourceClient,
39-
PageFactoryInterface $pageFactory,
40-
ResourceCursorFactoryInterface $cursorFactory
41-
) {
42-
$this->resourceClient = $resourceClient;
43-
$this->pageFactory = $pageFactory;
44-
$this->cursorFactory = $cursorFactory;
28+
public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory)
29+
{
4530
}
4631

4732
/**

src/Api/AssetManager/AssetApi.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,8 @@ class AssetApi implements AssetApiInterface
1414
public const ASSET_URI= 'api/rest/v1/asset-families/%s/assets/%s';
1515
public const ASSETS_URI = 'api/rest/v1/asset-families/%s/assets';
1616

17-
/** @var ResourceClientInterface */
18-
private $resourceClient;
19-
20-
/** @var PageFactoryInterface */
21-
private $pageFactory;
22-
23-
/** @var ResourceCursorFactoryInterface */
24-
private $cursorFactory;
25-
26-
public function __construct(
27-
ResourceClientInterface $resourceClient,
28-
PageFactoryInterface $pageFactory,
29-
ResourceCursorFactoryInterface $cursorFactory
30-
) {
31-
$this->resourceClient = $resourceClient;
32-
$this->pageFactory = $pageFactory;
33-
$this->cursorFactory = $cursorFactory;
17+
public function __construct(private ResourceClientInterface $resourceClient, private PageFactoryInterface $pageFactory, private ResourceCursorFactoryInterface $cursorFactory)
18+
{
3419
}
3520

3621
/**

src/Api/AssetManager/AssetAttributeApi.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ class AssetAttributeApi implements AssetAttributeApiInterface
1111
public const ASSET_ATTRIBUTE_URI = 'api/rest/v1/asset-families/%s/attributes/%s';
1212
public const ASSET_ATTRIBUTES_URI = 'api/rest/v1/asset-families/%s/attributes';
1313

14-
/** @var ResourceClientInterface */
15-
private $resourceClient;
16-
17-
public function __construct(ResourceClientInterface $resourceClient)
14+
public function __construct(private ResourceClientInterface $resourceClient)
1815
{
19-
$this->resourceClient = $resourceClient;
2016
}
2117

2218
/**

0 commit comments

Comments
 (0)