Maintain local ⭤ remote in sync with automatic AT Protocol parity for Laravel (alpha & unstable)
at dev 1.1 kB view raw
1<?php 2 3namespace SocialDept\AtpParity\Export; 4 5/** 6 * Value object representing the result of an export operation. 7 */ 8readonly class ExportResult 9{ 10 public function __construct( 11 public bool $success, 12 public ?string $path = null, 13 public ?int $size = null, 14 public ?string $error = null, 15 ) {} 16 17 /** 18 * Check if the export operation succeeded. 19 */ 20 public function isSuccess(): bool 21 { 22 return $this->success; 23 } 24 25 /** 26 * Check if the export operation failed. 27 */ 28 public function isFailed(): bool 29 { 30 return ! $this->success; 31 } 32 33 /** 34 * Create a successful result. 35 */ 36 public static function success(string $path, int $size): self 37 { 38 return new self( 39 success: true, 40 path: $path, 41 size: $size, 42 ); 43 } 44 45 /** 46 * Create a failed result. 47 */ 48 public static function failed(string $error): self 49 { 50 return new self( 51 success: false, 52 error: $error, 53 ); 54 } 55}