Skip to content

Commit

Permalink
Fix all files with php-cs-fixer v3.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Smolevich committed May 26, 2023
1 parent e964eaf commit ae75313
Show file tree
Hide file tree
Showing 25 changed files with 296 additions and 149 deletions.
15 changes: 10 additions & 5 deletions examples/common-part.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
use Reindexer\LoggerInterface;
use Reindexer\Response;

class Configuration {
class Configuration
{
protected $api;
protected $config;

public function __construct(array $config = []) {
public function __construct(array $config = [])
{
$this->config = $config;
}

public function getApi(): Api {
public function getApi(): Api
{
if (empty($this->api)) {
$this->api = new Api($this->config['endpoint'], $this->config['client_config']);
$this->api->setLogger(new ApiLogger());
Expand All @@ -22,8 +25,10 @@ public function getApi(): Api {
}
}

class ApiLogger implements LoggerInterface {
public function logResponse(Response $response): void {
class ApiLogger implements LoggerInterface
{
public function logResponse(Response $response): void
{
echo sprintf(
'==== api request info ===='.PHP_EOL.
'Content-Type: %s'.PHP_EOL.
Expand Down
4 changes: 2 additions & 2 deletions examples/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"endpoint": "http://localhost:9088",
"endpoint": "http://reindexer:9088",
"client_config": {
"http_errors": 0
}
}
}
15 changes: 10 additions & 5 deletions src/Reindexer/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Reindexer\Client\BaseApi;

abstract class BaseService {
abstract class BaseService
{
protected BaseApi $client;
protected string $version = 'v1';
protected $mapJsonFields = [];
Expand All @@ -13,23 +14,27 @@ abstract class BaseService {
'Content-Type' => 'application/json;charset=utf-8'
];

public function __construct(BaseApi $client) {
public function __construct(BaseApi $client)
{
$this->client = $client;
}

public function setVersion(string $version): self {
public function setVersion(string $version): self
{
$this->version = $version;

return $this;
}

public function setHeaders(array $headers): self {
public function setHeaders(array $headers): self
{
$this->defaultHeaders = $headers;

return $this;
}

public function addHeaders(array $headers): self {
public function addHeaders(array $headers): self
{
$this->defaultHeaders = array_merge($this->defaultHeaders, $headers);

return $this;
Expand Down
18 changes: 12 additions & 6 deletions src/Reindexer/Client/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,36 @@
use Reindexer\LoggerInterface;
use Reindexer\Response;

class Api extends BaseApi {
class Api extends BaseApi
{
protected $client;
protected $info;
protected $logger;
protected $error;

public function __construct(string $host, array $config = []) {
public function __construct(string $host, array $config = [])
{
parent::__construct($host);
$this->client = new Client($config);
}

public function setLogger(LoggerInterface $logger): void {
public function setLogger(LoggerInterface $logger): void
{
$this->logger = $logger;
}

public function getClient(): Client {
public function getClient(): Client
{
return $this->client;
}

public function setClient(Client $client): void {
public function setClient(Client $client): void
{
$this->client = $client;
}

public function request(string $method, string $uri, string $body = null, array $headers = []): Response {
public function request(string $method, string $uri, string $body = null, array $headers = []): Response
{
$instance = $this;
$request = new Request($method, $this->host . $uri, $headers);

Expand Down
12 changes: 8 additions & 4 deletions src/Reindexer/Client/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@

use Reindexer\Response;

abstract class BaseApi {
abstract class BaseApi
{
protected $host;
protected $config;

public function __construct(string $host, array $config = []) {
public function __construct(string $host, array $config = [])
{
$this->host = $host;
$this->config = $config;
}

public function getHost(): string {
public function getHost(): string
{
return $this->host;
}

public function setHost(string $host) {
public function setHost(string $host)
{
$this->host = $host;
}

Expand Down
9 changes: 6 additions & 3 deletions src/Reindexer/Entities/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

use \ReflectionProperty;

abstract class Entity {
public function getBody(): array {
abstract class Entity
{
public function getBody(): array
{
return $this->parseValue($this);
}

protected function parseValue($instance): array {
protected function parseValue($instance): array
{
$result = [];
$reflectionClass = new \ReflectionClass($instance);
$properties = $reflectionClass->getProperties(ReflectionProperty::IS_PRIVATE);
Expand Down
63 changes: 42 additions & 21 deletions src/Reindexer/Entities/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Reindexer\Entities;

class Index extends Entity {
class Index extends Entity
{
private $name;
private $jsonPaths;
private $fieldType;
Expand All @@ -27,101 +28,121 @@ class Index extends Entity {
'sortOrderLetters' => 'sort_order_letters',
];

public function getName() {
public function getName()
{
return $this->name;
}

public function setName(string $name) {
public function setName(string $name)
{
$this->name = $name;

return $this;
}

public function getJsonPaths(): array {
public function getJsonPaths(): array
{
return $this->jsonPaths ?? [];
}

public function setJsonPaths(array $jsonPaths): self {
public function setJsonPaths(array $jsonPaths): self
{
$this->jsonPaths = $jsonPaths;

return $this;
}

public function getFieldType(): string {
public function getFieldType(): string
{
return $this->fieldType;
}

public function setFieldType($fieldType): self {
public function setFieldType($fieldType): self
{
$this->fieldType = $fieldType;

return $this;
}

public function isPk() {
public function isPk()
{
return $this->isPk;
}

public function setIsPk(bool $isPk) {
public function setIsPk(bool $isPk)
{
$this->isPk = $isPk;

return $this;
}

public function isArray(): bool {
public function isArray(): bool
{
return $this->isArray;
}

public function setIsArray(bool $isArray): self {
public function setIsArray(bool $isArray): self
{
$this->isArray = $isArray;

return $this;
}

public function isDense(): bool {
public function isDense(): bool
{
return $this->isDense;
}

public function setIsDense(bool $isDense): self {
public function setIsDense(bool $isDense): self
{
$this->isDense = $isDense;

return $this;
}

public function isAppendable(): bool {
public function isAppendable(): bool
{
return $this->isAppendable;
}

public function setIsAppendable(bool $isAppendable): self {
public function setIsAppendable(bool $isAppendable): self
{
$this->isAppendable = $isAppendable;

return $this;
}

public function getCollateMode(): string {
public function getCollateMode(): string
{
return $this->collateMode;
}

public function setCollateMode(string $collateMode): self {
public function setCollateMode(string $collateMode): self
{
$this->collateMode = $collateMode;

return $this;
}

public function getSortOrderLetters(): string {
public function getSortOrderLetters(): string
{
return $this->sortOrderLetters;
}

public function setSortOrderLetters(string $sortOrderLetters): self {
public function setSortOrderLetters(string $sortOrderLetters): self
{
$this->sortOrderLetters = $sortOrderLetters;

return $this;
}

public function getIndexType(): string {
public function getIndexType(): string
{
return $this->indexType;
}

public function setIndexType(string $indexType): self {
public function setIndexType(string $indexType): self
{
$this->indexType = $indexType;

return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Reindexer/Entities/SdlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Reindexer\Entities;

class SdlQuery extends Entity {
class SdlQuery extends Entity
{
protected $namespace;
protected $limit;
protected $offset;
Expand Down
3 changes: 2 additions & 1 deletion src/Reindexer/Enum/CollateMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Reindexer\Enum;

class CollateMode {
class CollateMode
{
const NONE = 'none';
const ASCII = 'ascii';
const UTF8 = 'utf8';
Expand Down
3 changes: 2 additions & 1 deletion src/Reindexer/Enum/FieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Reindexer\Enum;

class FieldType {
class FieldType
{
const INT = 'int';
const INT64 = 'int64';
const DOUBLE = 'double';
Expand Down
3 changes: 2 additions & 1 deletion src/Reindexer/Enum/IndexType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Reindexer\Enum;

class IndexType {
class IndexType
{
const HASH = 'hash';
const TREE = 'tree';
const TEXT = 'text';
Expand Down
3 changes: 2 additions & 1 deletion src/Reindexer/LoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Reindexer;

interface LoggerInterface {
interface LoggerInterface
{
public function logResponse(Response $response);
}
Loading

0 comments on commit ae75313

Please sign in to comment.