unavailable = true; $result->errors[] = $reason; return $result; } /** * @param int $bytes * @return $this */ public function add( int $items, int $bytes ): self { $this->items += $items; $this->bytes += $bytes; return $this; } /** * @return $this */ public function add_dirs( int $dirs ): self { $this->dirs += $dirs; return $this; } /** * @return $this */ public function fail( string $message ): self { $this->errors[] = $message; return $this; } /** * @return $this */ public function stopped_on_budget(): self { $this->incomplete = true; return $this; } public function merge( TaskResult $other ): self { $this->items += $other->items; $this->dirs += $other->dirs; $this->bytes += $other->bytes; $this->errors = array_merge( $this->errors, $other->errors ); $this->incomplete = $this->incomplete || $other->incomplete; $this->unavailable = $this->unavailable || $other->unavailable; return $this; } public function to_array(): array { return [ 'items' => $this->items, 'dirs' => $this->dirs, 'bytes' => $this->bytes, 'errors' => array_values( $this->errors ), 'incomplete' => $this->incomplete, 'unavailable' => $this->unavailable, ]; } }