name = $name; } public function isGenerated(): bool { return $this->generated; } public function setGenerated(bool $generated): self { $this->generated = $generated; return $this; } /** * Code to execute when this pivot table is unset(). */ public function __destruct() { $this->worksheet = null; } public function getName(): string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getWorksheet(): ?Worksheet { return $this->worksheet; } public function setWorksheet(?Worksheet $worksheet): self { $this->worksheet = $worksheet; return $this; } public function getLocation(): string { return $this->location; } public function setLocation(string $location): self { $this->location = $location; return $this; } public function getCacheDefinition(): ?PivotCacheDefinition { return $this->cacheDefinition; } public function setCacheDefinition(?PivotCacheDefinition $cacheDefinition): self { $this->cacheDefinition = $cacheDefinition; return $this; } /** * @return PivotField[] */ public function getFields(): array { return $this->fields; } public function addField(PivotField $field): self { $this->fields[] = $field; return $this; } /** * Return only the fields placed on the row axis, in order. * * @return PivotField[] */ public function getRowFields(): array { return $this->getFieldsOnAxis(PivotField::AXIS_ROW); } /** * Return only the fields placed on the column axis, in order. * * @return PivotField[] */ public function getColumnFields(): array { return $this->getFieldsOnAxis(PivotField::AXIS_COLUMN); } /** * Return only the fields placed on the page/filter axis, in order. * * @return PivotField[] */ public function getPageFields(): array { return $this->getFieldsOnAxis(PivotField::AXIS_PAGE); } /** * Return only the value/data fields, in order. * * @return PivotField[] */ public function getDataFields(): array { return array_values( array_filter( $this->fields, static fn (PivotField $field): bool => $field->isDataField() ) ); } /** * @return PivotField[] */ private function getFieldsOnAxis(string $axis): array { return array_values( array_filter( $this->fields, static fn (PivotField $field): bool => $field->getAxis() === $axis ) ); } public function __toString(): string { return $this->name; } }