path = $path; $this->relative = ltrim( str_replace( '\\', '/', $relative ), '/' ); $this->size = $size; } /** * Absolute path. * * @return string */ public function path(): string { return $this->path; } /** * Archive path. * * @return string */ public function relative(): string { return $this->relative; } /** * Size in bytes. * * @return int */ public function size(): int { return $this->size; } /** * Serializable representation used in the manifest. * * @return array */ public function to_array(): array { return array( 'p' => $this->relative, 's' => $this->size, ); } /** * Build from a manifest line. * * @param array $data Decoded line. * @param string $root WordPress root. * @return self */ public static function from_array( array $data, string $root ): self { $relative = isset( $data['p'] ) ? (string) $data['p'] : ''; return new self( rtrim( $root, '/' ) . '/' . $relative, $relative, isset( $data['s'] ) ? (int) $data['s'] : 0 ); } }