Skip to content

Commit

Permalink
Fluent methods (#1601)
Browse files Browse the repository at this point in the history
Co-authored-by: Michi Hoffmann <[email protected]>
  • Loading branch information
stayallive and cleptric authored Oct 30, 2023
1 parent fc5853f commit 5cc49b3
Show file tree
Hide file tree
Showing 22 changed files with 430 additions and 171 deletions.
7 changes: 4 additions & 3 deletions UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
- The `IgnoreErrorsIntegration` integration was removed. Use the `ignore_errors` option instead.
- `Sentry\Exception\InvalidArgumentException` was removed. Use `\InvalidArgumentException` instead.
- `Sentry\Exception/ExceptionInterface` was removed.
- Removed `ClientBuilderInterface::setSerializer()`
- Removed `ClientBuilder::setSerializer()`
- Removed `ClientBuilderInterface::setSerializer()`.
- Removed `ClientBuilder::setSerializer()`.
- Removed `Client::__construct()` param SerializerInterface $serializer.
- Change return type of `Dsn:: getProjectId()` to string
- Change return type of `Dsn:: getProjectId()` to string.
- Most setters now return `$this` instead of `void`.
24 changes: 18 additions & 6 deletions src/CheckIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,47 @@ public function getMonitorSlug(): string
return $this->monitorSlug;
}

public function setMonitorSlug(string $monitorSlug): void
public function setMonitorSlug(string $monitorSlug): self
{
$this->monitorSlug = $monitorSlug;

return $this;
}

public function getStatus(): CheckInStatus
{
return $this->status;
}

public function setStatus(CheckInStatus $status): void
public function setStatus(CheckInStatus $status): self
{
$this->status = $status;

return $this;
}

public function getRelease(): ?string
{
return $this->release;
}

public function setRelease(string $release): void
public function setRelease(string $release): self
{
$this->release = $release;

return $this;
}

public function getEnvironment(): ?string
{
return $this->environment;
}

public function setEnvironment(string $environment): void
public function setEnvironment(string $environment): self
{
$this->environment = $environment;

return $this;
}

/**
Expand All @@ -126,18 +134,22 @@ public function getDuration()
/**
* @param int|float|null $duration The duration of the check-in in seconds
*/
public function setDuration($duration): void
public function setDuration($duration): self
{
$this->duration = $duration;

return $this;
}

public function getMonitorConfig(): ?MonitorConfig
{
return $this->monitorConfig;
}

public function setMonitorConfig(?MonitorConfig $monitorConfig): void
public function setMonitorConfig(?MonitorConfig $monitorConfig): self
{
$this->monitorConfig = $monitorConfig;

return $this;
}
}
14 changes: 7 additions & 7 deletions src/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(?Options $options = null)
/**
* @param array<string, mixed> $options The client options, in naked array form
*/
public static function create(array $options = []): ClientBuilder
public static function create(array $options = []): self
{
return new self(new Options($options));
}
Expand All @@ -85,28 +85,28 @@ public function getOptions(): Options
return $this->options;
}

public function setRepresentationSerializer(RepresentationSerializerInterface $representationSerializer): ClientBuilder
public function setRepresentationSerializer(RepresentationSerializerInterface $representationSerializer): self
{
$this->representationSerializer = $representationSerializer;

return $this;
}

public function setLogger(LoggerInterface $logger): ClientBuilder
public function setLogger(LoggerInterface $logger): self
{
$this->logger = $logger;

return $this;
}

public function setSdkIdentifier(string $sdkIdentifier): ClientBuilder
public function setSdkIdentifier(string $sdkIdentifier): self
{
$this->sdkIdentifier = $sdkIdentifier;

return $this;
}

public function setSdkVersion(string $sdkVersion): ClientBuilder
public function setSdkVersion(string $sdkVersion): self
{
$this->sdkVersion = $sdkVersion;

Expand All @@ -118,7 +118,7 @@ public function getTransport(): TransportInterface
return $this->transport;
}

public function setTransport(TransportInterface $transport): ClientBuilder
public function setTransport(TransportInterface $transport): self
{
$this->transport = $transport;

Expand All @@ -130,7 +130,7 @@ public function getHttpClient(): HttpClientInterface
return $this->httpClient;
}

public function setHttpClient(HttpClientInterface $httpClient): ClientBuilder
public function setHttpClient(HttpClientInterface $httpClient): self
{
$this->httpClient = $httpClient;

Expand Down
Loading

0 comments on commit 5cc49b3

Please sign in to comment.