@@ -12,65 +12,65 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class DirectForeignKeyMethodDescriptor implements MethodDescriptorInterface |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var ForeignKeyConstraint |
|
| 17 | - */ |
|
| 18 | - private $fk; |
|
| 19 | - |
|
| 20 | - private $useAlternateName = false; |
|
| 21 | - /** |
|
| 22 | - * @var Table |
|
| 23 | - */ |
|
| 24 | - private $mainTable; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @param ForeignKeyConstraint $fk The foreign key pointing to our bean |
|
| 28 | - * @param Table $mainTable The main table that is pointed to |
|
| 29 | - */ |
|
| 30 | - public function __construct(ForeignKeyConstraint $fk, Table $mainTable) |
|
| 31 | - { |
|
| 32 | - $this->fk = $fk; |
|
| 33 | - $this->mainTable = $mainTable; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Returns the name of the method to be generated. |
|
| 38 | - * |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public function getName() : string |
|
| 42 | - { |
|
| 43 | - if (!$this->useAlternateName) { |
|
| 44 | - return 'get'.TDBMDaoGenerator::toCamelCase($this->fk->getLocalTableName()); |
|
| 45 | - } else { |
|
| 46 | - $methodName = 'get'.TDBMDaoGenerator::toCamelCase($this->fk->getLocalTableName()).'By'; |
|
| 47 | - |
|
| 48 | - $camelizedColumns = array_map([TDBMDaoGenerator::class, 'toCamelCase'], $this->fk->getLocalColumns()); |
|
| 49 | - |
|
| 50 | - $methodName .= implode('And', $camelizedColumns); |
|
| 51 | - |
|
| 52 | - return $methodName; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Requests the use of an alternative name for this method. |
|
| 58 | - */ |
|
| 59 | - public function useAlternativeName() |
|
| 60 | - { |
|
| 61 | - $this->useAlternateName = true; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Returns the code of the method. |
|
| 66 | - * |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 69 | - public function getCode() : string |
|
| 70 | - { |
|
| 71 | - $code = ''; |
|
| 72 | - |
|
| 73 | - $getterCode = ' /** |
|
| 15 | + /** |
|
| 16 | + * @var ForeignKeyConstraint |
|
| 17 | + */ |
|
| 18 | + private $fk; |
|
| 19 | + |
|
| 20 | + private $useAlternateName = false; |
|
| 21 | + /** |
|
| 22 | + * @var Table |
|
| 23 | + */ |
|
| 24 | + private $mainTable; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param ForeignKeyConstraint $fk The foreign key pointing to our bean |
|
| 28 | + * @param Table $mainTable The main table that is pointed to |
|
| 29 | + */ |
|
| 30 | + public function __construct(ForeignKeyConstraint $fk, Table $mainTable) |
|
| 31 | + { |
|
| 32 | + $this->fk = $fk; |
|
| 33 | + $this->mainTable = $mainTable; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Returns the name of the method to be generated. |
|
| 38 | + * |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public function getName() : string |
|
| 42 | + { |
|
| 43 | + if (!$this->useAlternateName) { |
|
| 44 | + return 'get'.TDBMDaoGenerator::toCamelCase($this->fk->getLocalTableName()); |
|
| 45 | + } else { |
|
| 46 | + $methodName = 'get'.TDBMDaoGenerator::toCamelCase($this->fk->getLocalTableName()).'By'; |
|
| 47 | + |
|
| 48 | + $camelizedColumns = array_map([TDBMDaoGenerator::class, 'toCamelCase'], $this->fk->getLocalColumns()); |
|
| 49 | + |
|
| 50 | + $methodName .= implode('And', $camelizedColumns); |
|
| 51 | + |
|
| 52 | + return $methodName; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Requests the use of an alternative name for this method. |
|
| 58 | + */ |
|
| 59 | + public function useAlternativeName() |
|
| 60 | + { |
|
| 61 | + $this->useAlternateName = true; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Returns the code of the method. |
|
| 66 | + * |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | + public function getCode() : string |
|
| 70 | + { |
|
| 71 | + $code = ''; |
|
| 72 | + |
|
| 73 | + $getterCode = ' /** |
|
| 74 | 74 | * Returns the list of %s pointing to this bean via the %s column. |
| 75 | 75 | * |
| 76 | 76 | * @return %s[]|AlterableResultIterator |
@@ -82,55 +82,55 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | '; |
| 84 | 84 | |
| 85 | - $beanClass = TDBMDaoGenerator::getBeanNameFromTableName($this->fk->getLocalTableName()); |
|
| 86 | - $code .= sprintf($getterCode, |
|
| 87 | - $beanClass, |
|
| 88 | - implode(', ', $this->fk->getColumns()), |
|
| 89 | - $beanClass, |
|
| 90 | - $this->getName(), |
|
| 91 | - var_export($this->fk->getLocalTableName(), true), |
|
| 92 | - var_export($this->fk->getName(), true), |
|
| 93 | - var_export($this->fk->getLocalTableName(), true), |
|
| 94 | - $this->getFilters($this->fk) |
|
| 95 | - ); |
|
| 96 | - |
|
| 97 | - return $code; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - private function getFilters(ForeignKeyConstraint $fk) : string |
|
| 101 | - { |
|
| 102 | - $counter = 0; |
|
| 103 | - $parameters = []; |
|
| 104 | - |
|
| 105 | - $pkColumns = $this->mainTable->getPrimaryKeyColumns(); |
|
| 106 | - |
|
| 107 | - foreach ($fk->getLocalColumns() as $columnName) { |
|
| 108 | - $pkColumn = $pkColumns[$counter]; |
|
| 109 | - $parameters[] = sprintf('%s => $this->get(%s, %s)', var_export($fk->getLocalTableName().'.'.$columnName, true), var_export($pkColumn, true), var_export($this->fk->getForeignTableName(), true)); |
|
| 110 | - ++$counter; |
|
| 111 | - } |
|
| 112 | - $parametersCode = '['.implode(', ', $parameters).']'; |
|
| 113 | - |
|
| 114 | - return $parametersCode; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Returns an array of classes that needs a "use" for this method. |
|
| 119 | - * |
|
| 120 | - * @return string[] |
|
| 121 | - */ |
|
| 122 | - public function getUsedClasses() : array |
|
| 123 | - { |
|
| 124 | - return [TDBMDaoGenerator::getBeanNameFromTableName($this->fk->getForeignTableName())]; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * Returns the code to past in jsonSerialize. |
|
| 129 | - * |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public function getJsonSerializeCode() : string |
|
| 133 | - { |
|
| 134 | - return ''; |
|
| 135 | - } |
|
| 85 | + $beanClass = TDBMDaoGenerator::getBeanNameFromTableName($this->fk->getLocalTableName()); |
|
| 86 | + $code .= sprintf($getterCode, |
|
| 87 | + $beanClass, |
|
| 88 | + implode(', ', $this->fk->getColumns()), |
|
| 89 | + $beanClass, |
|
| 90 | + $this->getName(), |
|
| 91 | + var_export($this->fk->getLocalTableName(), true), |
|
| 92 | + var_export($this->fk->getName(), true), |
|
| 93 | + var_export($this->fk->getLocalTableName(), true), |
|
| 94 | + $this->getFilters($this->fk) |
|
| 95 | + ); |
|
| 96 | + |
|
| 97 | + return $code; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + private function getFilters(ForeignKeyConstraint $fk) : string |
|
| 101 | + { |
|
| 102 | + $counter = 0; |
|
| 103 | + $parameters = []; |
|
| 104 | + |
|
| 105 | + $pkColumns = $this->mainTable->getPrimaryKeyColumns(); |
|
| 106 | + |
|
| 107 | + foreach ($fk->getLocalColumns() as $columnName) { |
|
| 108 | + $pkColumn = $pkColumns[$counter]; |
|
| 109 | + $parameters[] = sprintf('%s => $this->get(%s, %s)', var_export($fk->getLocalTableName().'.'.$columnName, true), var_export($pkColumn, true), var_export($this->fk->getForeignTableName(), true)); |
|
| 110 | + ++$counter; |
|
| 111 | + } |
|
| 112 | + $parametersCode = '['.implode(', ', $parameters).']'; |
|
| 113 | + |
|
| 114 | + return $parametersCode; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Returns an array of classes that needs a "use" for this method. |
|
| 119 | + * |
|
| 120 | + * @return string[] |
|
| 121 | + */ |
|
| 122 | + public function getUsedClasses() : array |
|
| 123 | + { |
|
| 124 | + return [TDBMDaoGenerator::getBeanNameFromTableName($this->fk->getForeignTableName())]; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * Returns the code to past in jsonSerialize. |
|
| 129 | + * |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public function getJsonSerializeCode() : string |
|
| 133 | + { |
|
| 134 | + return ''; |
|
| 135 | + } |
|
| 136 | 136 | } |
@@ -7,99 +7,99 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class PivotTableMethodsDescriptor implements MethodDescriptorInterface |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * @var Table |
|
| 12 | - */ |
|
| 13 | - private $pivotTable; |
|
| 14 | - |
|
| 15 | - private $useAlternateName = false; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * @var ForeignKeyConstraint |
|
| 19 | - */ |
|
| 20 | - private $localFk; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var ForeignKeyConstraint |
|
| 24 | - */ |
|
| 25 | - private $remoteFk; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @param Table $pivotTable The pivot table |
|
| 29 | - * @param ForeignKeyConstraint $localFk |
|
| 30 | - * @param ForeignKeyConstraint $remoteFk |
|
| 31 | - */ |
|
| 32 | - public function __construct(Table $pivotTable, ForeignKeyConstraint $localFk, ForeignKeyConstraint $remoteFk) |
|
| 33 | - { |
|
| 34 | - $this->pivotTable = $pivotTable; |
|
| 35 | - $this->localFk = $localFk; |
|
| 36 | - $this->remoteFk = $remoteFk; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Requests the use of an alternative name for this method. |
|
| 41 | - */ |
|
| 42 | - public function useAlternativeName() |
|
| 43 | - { |
|
| 44 | - $this->useAlternateName = true; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Returns the name of the method to be generated. |
|
| 49 | - * |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function getName() : string |
|
| 53 | - { |
|
| 54 | - if (!$this->useAlternateName) { |
|
| 55 | - return 'get'.TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()); |
|
| 56 | - } else { |
|
| 57 | - return 'get'.TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Returns the plural name. |
|
| 63 | - * |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - private function getPluralName() : string |
|
| 67 | - { |
|
| 68 | - if (!$this->useAlternateName) { |
|
| 69 | - return TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()); |
|
| 70 | - } else { |
|
| 71 | - return TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Returns the singular name. |
|
| 77 | - * |
|
| 78 | - * @return string |
|
| 79 | - */ |
|
| 80 | - private function getSingularName() : string |
|
| 81 | - { |
|
| 82 | - if (!$this->useAlternateName) { |
|
| 83 | - return TDBMDaoGenerator::toCamelCase(TDBMDaoGenerator::toSingular($this->remoteFk->getForeignTableName())); |
|
| 84 | - } else { |
|
| 85 | - return TDBMDaoGenerator::toCamelCase(TDBMDaoGenerator::toSingular($this->remoteFk->getForeignTableName())).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Returns the code of the method. |
|
| 91 | - * |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function getCode() : string |
|
| 95 | - { |
|
| 96 | - $singularName = $this->getSingularName(); |
|
| 97 | - $pluralName = $this->getPluralName(); |
|
| 98 | - $remoteBeanName = TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName()); |
|
| 99 | - $variableName = '$'.TDBMDaoGenerator::toVariableName($remoteBeanName); |
|
| 100 | - $pluralVariableName = $variableName.'s'; |
|
| 101 | - |
|
| 102 | - $str = ' /** |
|
| 10 | + /** |
|
| 11 | + * @var Table |
|
| 12 | + */ |
|
| 13 | + private $pivotTable; |
|
| 14 | + |
|
| 15 | + private $useAlternateName = false; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * @var ForeignKeyConstraint |
|
| 19 | + */ |
|
| 20 | + private $localFk; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var ForeignKeyConstraint |
|
| 24 | + */ |
|
| 25 | + private $remoteFk; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @param Table $pivotTable The pivot table |
|
| 29 | + * @param ForeignKeyConstraint $localFk |
|
| 30 | + * @param ForeignKeyConstraint $remoteFk |
|
| 31 | + */ |
|
| 32 | + public function __construct(Table $pivotTable, ForeignKeyConstraint $localFk, ForeignKeyConstraint $remoteFk) |
|
| 33 | + { |
|
| 34 | + $this->pivotTable = $pivotTable; |
|
| 35 | + $this->localFk = $localFk; |
|
| 36 | + $this->remoteFk = $remoteFk; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Requests the use of an alternative name for this method. |
|
| 41 | + */ |
|
| 42 | + public function useAlternativeName() |
|
| 43 | + { |
|
| 44 | + $this->useAlternateName = true; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Returns the name of the method to be generated. |
|
| 49 | + * |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function getName() : string |
|
| 53 | + { |
|
| 54 | + if (!$this->useAlternateName) { |
|
| 55 | + return 'get'.TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()); |
|
| 56 | + } else { |
|
| 57 | + return 'get'.TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Returns the plural name. |
|
| 63 | + * |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + private function getPluralName() : string |
|
| 67 | + { |
|
| 68 | + if (!$this->useAlternateName) { |
|
| 69 | + return TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()); |
|
| 70 | + } else { |
|
| 71 | + return TDBMDaoGenerator::toCamelCase($this->remoteFk->getForeignTableName()).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Returns the singular name. |
|
| 77 | + * |
|
| 78 | + * @return string |
|
| 79 | + */ |
|
| 80 | + private function getSingularName() : string |
|
| 81 | + { |
|
| 82 | + if (!$this->useAlternateName) { |
|
| 83 | + return TDBMDaoGenerator::toCamelCase(TDBMDaoGenerator::toSingular($this->remoteFk->getForeignTableName())); |
|
| 84 | + } else { |
|
| 85 | + return TDBMDaoGenerator::toCamelCase(TDBMDaoGenerator::toSingular($this->remoteFk->getForeignTableName())).'By'.TDBMDaoGenerator::toCamelCase($this->pivotTable->getName()); |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Returns the code of the method. |
|
| 91 | + * |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function getCode() : string |
|
| 95 | + { |
|
| 96 | + $singularName = $this->getSingularName(); |
|
| 97 | + $pluralName = $this->getPluralName(); |
|
| 98 | + $remoteBeanName = TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName()); |
|
| 99 | + $variableName = '$'.TDBMDaoGenerator::toVariableName($remoteBeanName); |
|
| 100 | + $pluralVariableName = $variableName.'s'; |
|
| 101 | + |
|
| 102 | + $str = ' /** |
|
| 103 | 103 | * Returns the list of %s associated to this bean via the %s pivot table. |
| 104 | 104 | * |
| 105 | 105 | * @return %s[] |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | '; |
| 112 | 112 | |
| 113 | - $getterCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $pluralName, var_export($this->remoteFk->getLocalTableName(), true)); |
|
| 113 | + $getterCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $pluralName, var_export($this->remoteFk->getLocalTableName(), true)); |
|
| 114 | 114 | |
| 115 | - $str = ' /** |
|
| 115 | + $str = ' /** |
|
| 116 | 116 | * Adds a relationship with %s associated to this bean via the %s pivot table. |
| 117 | 117 | * |
| 118 | 118 | * @param %s %s |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | '; |
| 125 | 125 | |
| 126 | - $adderCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 126 | + $adderCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 127 | 127 | |
| 128 | - $str = ' /** |
|
| 128 | + $str = ' /** |
|
| 129 | 129 | * Deletes the relationship with %s associated to this bean via the %s pivot table. |
| 130 | 130 | * |
| 131 | 131 | * @param %s %s |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | '; |
| 138 | 138 | |
| 139 | - $removerCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 139 | + $removerCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 140 | 140 | |
| 141 | - $str = ' /** |
|
| 141 | + $str = ' /** |
|
| 142 | 142 | * Returns whether this bean is associated with %s via the %s pivot table. |
| 143 | 143 | * |
| 144 | 144 | * @param %s %s |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | '; |
| 152 | 152 | |
| 153 | - $hasCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 153 | + $hasCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $variableName, $singularName, $remoteBeanName, $variableName, var_export($this->remoteFk->getLocalTableName(), true), $variableName); |
|
| 154 | 154 | |
| 155 | - $str = ' /** |
|
| 155 | + $str = ' /** |
|
| 156 | 156 | * Sets all relationships with %s associated to this bean via the %s pivot table. |
| 157 | 157 | * Exiting relationships will be removed and replaced by the provided relationships. |
| 158 | 158 | * |
@@ -164,38 +164,38 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | '; |
| 166 | 166 | |
| 167 | - $setterCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $pluralVariableName, $pluralName, $pluralVariableName, var_export($this->remoteFk->getLocalTableName(), true), $pluralVariableName); |
|
| 168 | - |
|
| 169 | - $code = $getterCode.$adderCode.$removerCode.$hasCode.$setterCode; |
|
| 170 | - |
|
| 171 | - return $code; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Returns an array of classes that needs a "use" for this method. |
|
| 176 | - * |
|
| 177 | - * @return string[] |
|
| 178 | - */ |
|
| 179 | - public function getUsedClasses() : array |
|
| 180 | - { |
|
| 181 | - return [TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName())]; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Returns the code to past in jsonSerialize. |
|
| 186 | - * |
|
| 187 | - * @return string |
|
| 188 | - */ |
|
| 189 | - public function getJsonSerializeCode() : string |
|
| 190 | - { |
|
| 191 | - $remoteBeanName = TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName()); |
|
| 192 | - $variableName = '$'.TDBMDaoGenerator::toVariableName($remoteBeanName); |
|
| 193 | - |
|
| 194 | - return ' if (!$stopRecursion) { |
|
| 167 | + $setterCode = sprintf($str, $remoteBeanName, $this->pivotTable->getName(), $remoteBeanName, $pluralVariableName, $pluralName, $pluralVariableName, var_export($this->remoteFk->getLocalTableName(), true), $pluralVariableName); |
|
| 168 | + |
|
| 169 | + $code = $getterCode.$adderCode.$removerCode.$hasCode.$setterCode; |
|
| 170 | + |
|
| 171 | + return $code; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Returns an array of classes that needs a "use" for this method. |
|
| 176 | + * |
|
| 177 | + * @return string[] |
|
| 178 | + */ |
|
| 179 | + public function getUsedClasses() : array |
|
| 180 | + { |
|
| 181 | + return [TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName())]; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Returns the code to past in jsonSerialize. |
|
| 186 | + * |
|
| 187 | + * @return string |
|
| 188 | + */ |
|
| 189 | + public function getJsonSerializeCode() : string |
|
| 190 | + { |
|
| 191 | + $remoteBeanName = TDBMDaoGenerator::getBeanNameFromTableName($this->remoteFk->getForeignTableName()); |
|
| 192 | + $variableName = '$'.TDBMDaoGenerator::toVariableName($remoteBeanName); |
|
| 193 | + |
|
| 194 | + return ' if (!$stopRecursion) { |
|
| 195 | 195 | $array[\''.lcfirst($this->getPluralName()).'\'] = array_map(function ('.$remoteBeanName.' '.$variableName.') { |
| 196 | 196 | return '.$variableName.'->jsonSerialize(true); |
| 197 | 197 | }, $this->'.$this->getName().'()); |
| 198 | 198 | } |
| 199 | 199 | '; |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | } |
@@ -14,274 +14,274 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class AlterableResultIterator implements Result, \ArrayAccess, \JsonSerializable |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var \Iterator|null |
|
| 19 | - */ |
|
| 20 | - private $resultIterator; |
|
| 17 | + /** |
|
| 18 | + * @var \Iterator|null |
|
| 19 | + */ |
|
| 20 | + private $resultIterator; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Key: the object to alter in the result set. |
|
| 24 | - * Value: "add" => the object will be added to the resultset (if it is not found in it) |
|
| 25 | - * "delete" => the object will be removed from the resultset (if found). |
|
| 26 | - * |
|
| 27 | - * @var \SplObjectStorage |
|
| 28 | - */ |
|
| 29 | - private $alterations; |
|
| 22 | + /** |
|
| 23 | + * Key: the object to alter in the result set. |
|
| 24 | + * Value: "add" => the object will be added to the resultset (if it is not found in it) |
|
| 25 | + * "delete" => the object will be removed from the resultset (if found). |
|
| 26 | + * |
|
| 27 | + * @var \SplObjectStorage |
|
| 28 | + */ |
|
| 29 | + private $alterations; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The result array from the result set. |
|
| 33 | - * |
|
| 34 | - * @var array|null |
|
| 35 | - */ |
|
| 36 | - private $resultArray; |
|
| 31 | + /** |
|
| 32 | + * The result array from the result set. |
|
| 33 | + * |
|
| 34 | + * @var array|null |
|
| 35 | + */ |
|
| 36 | + private $resultArray; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param \Iterator|null $resultIterator |
|
| 40 | - */ |
|
| 41 | - public function __construct(\Iterator $resultIterator = null) |
|
| 42 | - { |
|
| 43 | - $this->resultIterator = $resultIterator; |
|
| 44 | - $this->alterations = new \SplObjectStorage(); |
|
| 45 | - } |
|
| 38 | + /** |
|
| 39 | + * @param \Iterator|null $resultIterator |
|
| 40 | + */ |
|
| 41 | + public function __construct(\Iterator $resultIterator = null) |
|
| 42 | + { |
|
| 43 | + $this->resultIterator = $resultIterator; |
|
| 44 | + $this->alterations = new \SplObjectStorage(); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Sets a new iterator as the base iterator to be altered. |
|
| 49 | - * |
|
| 50 | - * @param \Iterator $resultIterator |
|
| 51 | - */ |
|
| 52 | - public function setResultIterator(\Iterator $resultIterator) |
|
| 53 | - { |
|
| 54 | - $this->resultIterator = $resultIterator; |
|
| 55 | - $this->resultArray = null; |
|
| 56 | - } |
|
| 47 | + /** |
|
| 48 | + * Sets a new iterator as the base iterator to be altered. |
|
| 49 | + * |
|
| 50 | + * @param \Iterator $resultIterator |
|
| 51 | + */ |
|
| 52 | + public function setResultIterator(\Iterator $resultIterator) |
|
| 53 | + { |
|
| 54 | + $this->resultIterator = $resultIterator; |
|
| 55 | + $this->resultArray = null; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Returns the non altered result iterator (or null if none exist). |
|
| 60 | - * |
|
| 61 | - * @return \Iterator|null |
|
| 62 | - */ |
|
| 63 | - public function getUnderlyingResultIterator() |
|
| 64 | - { |
|
| 65 | - return $this->resultIterator; |
|
| 66 | - } |
|
| 58 | + /** |
|
| 59 | + * Returns the non altered result iterator (or null if none exist). |
|
| 60 | + * |
|
| 61 | + * @return \Iterator|null |
|
| 62 | + */ |
|
| 63 | + public function getUnderlyingResultIterator() |
|
| 64 | + { |
|
| 65 | + return $this->resultIterator; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Adds an additional object to the result set (if not already available). |
|
| 70 | - * |
|
| 71 | - * @param $object |
|
| 72 | - */ |
|
| 73 | - public function add($object) |
|
| 74 | - { |
|
| 75 | - $this->alterations->attach($object, 'add'); |
|
| 68 | + /** |
|
| 69 | + * Adds an additional object to the result set (if not already available). |
|
| 70 | + * |
|
| 71 | + * @param $object |
|
| 72 | + */ |
|
| 73 | + public function add($object) |
|
| 74 | + { |
|
| 75 | + $this->alterations->attach($object, 'add'); |
|
| 76 | 76 | |
| 77 | - if ($this->resultArray !== null) { |
|
| 78 | - $foundKey = array_search($object, $this->resultArray, true); |
|
| 79 | - if ($foundKey === false) { |
|
| 80 | - $this->resultArray[] = $object; |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - } |
|
| 77 | + if ($this->resultArray !== null) { |
|
| 78 | + $foundKey = array_search($object, $this->resultArray, true); |
|
| 79 | + if ($foundKey === false) { |
|
| 80 | + $this->resultArray[] = $object; |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Removes an object from the result set. |
|
| 87 | - * |
|
| 88 | - * @param $object |
|
| 89 | - */ |
|
| 90 | - public function remove($object) |
|
| 91 | - { |
|
| 92 | - $this->alterations->attach($object, 'delete'); |
|
| 85 | + /** |
|
| 86 | + * Removes an object from the result set. |
|
| 87 | + * |
|
| 88 | + * @param $object |
|
| 89 | + */ |
|
| 90 | + public function remove($object) |
|
| 91 | + { |
|
| 92 | + $this->alterations->attach($object, 'delete'); |
|
| 93 | 93 | |
| 94 | - if ($this->resultArray !== null) { |
|
| 95 | - $foundKey = array_search($object, $this->resultArray, true); |
|
| 96 | - if ($foundKey !== false) { |
|
| 97 | - unset($this->resultArray[$foundKey]); |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 94 | + if ($this->resultArray !== null) { |
|
| 95 | + $foundKey = array_search($object, $this->resultArray, true); |
|
| 96 | + if ($foundKey !== false) { |
|
| 97 | + unset($this->resultArray[$foundKey]); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Casts the result set to a PHP array. |
|
| 104 | - * |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function toArray() |
|
| 108 | - { |
|
| 109 | - if ($this->resultArray === null) { |
|
| 110 | - if ($this->resultIterator !== null) { |
|
| 111 | - $this->resultArray = iterator_to_array($this->resultIterator); |
|
| 112 | - } else { |
|
| 113 | - $this->resultArray = []; |
|
| 114 | - } |
|
| 102 | + /** |
|
| 103 | + * Casts the result set to a PHP array. |
|
| 104 | + * |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function toArray() |
|
| 108 | + { |
|
| 109 | + if ($this->resultArray === null) { |
|
| 110 | + if ($this->resultIterator !== null) { |
|
| 111 | + $this->resultArray = iterator_to_array($this->resultIterator); |
|
| 112 | + } else { |
|
| 113 | + $this->resultArray = []; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - foreach ($this->alterations as $obj) { |
|
| 117 | - $action = $this->alterations->getInfo(); // return, if exists, associated with cur. obj. data; else NULL |
|
| 116 | + foreach ($this->alterations as $obj) { |
|
| 117 | + $action = $this->alterations->getInfo(); // return, if exists, associated with cur. obj. data; else NULL |
|
| 118 | 118 | |
| 119 | - $foundKey = array_search($obj, $this->resultArray, true); |
|
| 119 | + $foundKey = array_search($obj, $this->resultArray, true); |
|
| 120 | 120 | |
| 121 | - if ($action === 'add' && $foundKey === false) { |
|
| 122 | - $this->resultArray[] = $obj; |
|
| 123 | - } elseif ($action === 'delete' && $foundKey !== false) { |
|
| 124 | - unset($this->resultArray[$foundKey]); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 121 | + if ($action === 'add' && $foundKey === false) { |
|
| 122 | + $this->resultArray[] = $obj; |
|
| 123 | + } elseif ($action === 'delete' && $foundKey !== false) { |
|
| 124 | + unset($this->resultArray[$foundKey]); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return array_values($this->resultArray); |
|
| 130 | - } |
|
| 129 | + return array_values($this->resultArray); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * Whether a offset exists. |
|
| 134 | - * |
|
| 135 | - * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
| 136 | - * |
|
| 137 | - * @param mixed $offset <p> |
|
| 138 | - * An offset to check for. |
|
| 139 | - * </p> |
|
| 140 | - * |
|
| 141 | - * @return bool true on success or false on failure. |
|
| 142 | - * </p> |
|
| 143 | - * <p> |
|
| 144 | - * The return value will be casted to boolean if non-boolean was returned |
|
| 145 | - * |
|
| 146 | - * @since 5.0.0 |
|
| 147 | - */ |
|
| 148 | - public function offsetExists($offset) |
|
| 149 | - { |
|
| 150 | - return isset($this->toArray()[$offset]); |
|
| 151 | - } |
|
| 132 | + /** |
|
| 133 | + * Whether a offset exists. |
|
| 134 | + * |
|
| 135 | + * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
|
| 136 | + * |
|
| 137 | + * @param mixed $offset <p> |
|
| 138 | + * An offset to check for. |
|
| 139 | + * </p> |
|
| 140 | + * |
|
| 141 | + * @return bool true on success or false on failure. |
|
| 142 | + * </p> |
|
| 143 | + * <p> |
|
| 144 | + * The return value will be casted to boolean if non-boolean was returned |
|
| 145 | + * |
|
| 146 | + * @since 5.0.0 |
|
| 147 | + */ |
|
| 148 | + public function offsetExists($offset) |
|
| 149 | + { |
|
| 150 | + return isset($this->toArray()[$offset]); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Offset to retrieve. |
|
| 155 | - * |
|
| 156 | - * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
| 157 | - * |
|
| 158 | - * @param mixed $offset <p> |
|
| 159 | - * The offset to retrieve. |
|
| 160 | - * </p> |
|
| 161 | - * |
|
| 162 | - * @return mixed Can return all value types |
|
| 163 | - * |
|
| 164 | - * @since 5.0.0 |
|
| 165 | - */ |
|
| 166 | - public function offsetGet($offset) |
|
| 167 | - { |
|
| 168 | - return $this->toArray()[$offset]; |
|
| 169 | - } |
|
| 153 | + /** |
|
| 154 | + * Offset to retrieve. |
|
| 155 | + * |
|
| 156 | + * @link http://php.net/manual/en/arrayaccess.offsetget.php |
|
| 157 | + * |
|
| 158 | + * @param mixed $offset <p> |
|
| 159 | + * The offset to retrieve. |
|
| 160 | + * </p> |
|
| 161 | + * |
|
| 162 | + * @return mixed Can return all value types |
|
| 163 | + * |
|
| 164 | + * @since 5.0.0 |
|
| 165 | + */ |
|
| 166 | + public function offsetGet($offset) |
|
| 167 | + { |
|
| 168 | + return $this->toArray()[$offset]; |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - /** |
|
| 172 | - * Offset to set. |
|
| 173 | - * |
|
| 174 | - * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
| 175 | - * |
|
| 176 | - * @param mixed $offset <p> |
|
| 177 | - * The offset to assign the value to. |
|
| 178 | - * </p> |
|
| 179 | - * @param mixed $value <p> |
|
| 180 | - * The value to set. |
|
| 181 | - * </p> |
|
| 182 | - * |
|
| 183 | - * @since 5.0.0 |
|
| 184 | - */ |
|
| 185 | - public function offsetSet($offset, $value) |
|
| 186 | - { |
|
| 187 | - throw new TDBMInvalidOperationException('You can set values in a TDBM result set, even in an alterable one. Use the add method instead.'); |
|
| 188 | - } |
|
| 171 | + /** |
|
| 172 | + * Offset to set. |
|
| 173 | + * |
|
| 174 | + * @link http://php.net/manual/en/arrayaccess.offsetset.php |
|
| 175 | + * |
|
| 176 | + * @param mixed $offset <p> |
|
| 177 | + * The offset to assign the value to. |
|
| 178 | + * </p> |
|
| 179 | + * @param mixed $value <p> |
|
| 180 | + * The value to set. |
|
| 181 | + * </p> |
|
| 182 | + * |
|
| 183 | + * @since 5.0.0 |
|
| 184 | + */ |
|
| 185 | + public function offsetSet($offset, $value) |
|
| 186 | + { |
|
| 187 | + throw new TDBMInvalidOperationException('You can set values in a TDBM result set, even in an alterable one. Use the add method instead.'); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * Offset to unset. |
|
| 192 | - * |
|
| 193 | - * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
| 194 | - * |
|
| 195 | - * @param mixed $offset <p> |
|
| 196 | - * The offset to unset. |
|
| 197 | - * </p> |
|
| 198 | - * |
|
| 199 | - * @since 5.0.0 |
|
| 200 | - */ |
|
| 201 | - public function offsetUnset($offset) |
|
| 202 | - { |
|
| 203 | - throw new TDBMInvalidOperationException('You can unset values in a TDBM result set, even in an alterable one. Use the delete method instead.'); |
|
| 204 | - } |
|
| 190 | + /** |
|
| 191 | + * Offset to unset. |
|
| 192 | + * |
|
| 193 | + * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
|
| 194 | + * |
|
| 195 | + * @param mixed $offset <p> |
|
| 196 | + * The offset to unset. |
|
| 197 | + * </p> |
|
| 198 | + * |
|
| 199 | + * @since 5.0.0 |
|
| 200 | + */ |
|
| 201 | + public function offsetUnset($offset) |
|
| 202 | + { |
|
| 203 | + throw new TDBMInvalidOperationException('You can unset values in a TDBM result set, even in an alterable one. Use the delete method instead.'); |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * @param int $offset |
|
| 208 | - * |
|
| 209 | - * @return \Porpaginas\Page |
|
| 210 | - */ |
|
| 211 | - public function take($offset, $limit) |
|
| 212 | - { |
|
| 213 | - // TODO: replace this with a class implementing the map method. |
|
| 214 | - return new ArrayPage(array_slice($this->toArray(), $offset, $limit), $offset, $limit, count($this->toArray())); |
|
| 215 | - } |
|
| 206 | + /** |
|
| 207 | + * @param int $offset |
|
| 208 | + * |
|
| 209 | + * @return \Porpaginas\Page |
|
| 210 | + */ |
|
| 211 | + public function take($offset, $limit) |
|
| 212 | + { |
|
| 213 | + // TODO: replace this with a class implementing the map method. |
|
| 214 | + return new ArrayPage(array_slice($this->toArray(), $offset, $limit), $offset, $limit, count($this->toArray())); |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * Return the number of all results in the paginatable. |
|
| 219 | - * |
|
| 220 | - * @return int |
|
| 221 | - */ |
|
| 222 | - public function count() |
|
| 223 | - { |
|
| 224 | - return count($this->toArray()); |
|
| 225 | - } |
|
| 217 | + /** |
|
| 218 | + * Return the number of all results in the paginatable. |
|
| 219 | + * |
|
| 220 | + * @return int |
|
| 221 | + */ |
|
| 222 | + public function count() |
|
| 223 | + { |
|
| 224 | + return count($this->toArray()); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * Return an iterator over all results of the paginatable. |
|
| 229 | - * |
|
| 230 | - * @return Iterator |
|
| 231 | - */ |
|
| 232 | - public function getIterator() |
|
| 233 | - { |
|
| 234 | - if ($this->alterations->count() === 0) { |
|
| 235 | - if ($this->resultIterator !== null) { |
|
| 236 | - return $this->resultIterator; |
|
| 237 | - } else { |
|
| 238 | - return new \ArrayIterator([]); |
|
| 239 | - } |
|
| 240 | - } else { |
|
| 241 | - return new \ArrayIterator($this->toArray()); |
|
| 242 | - } |
|
| 243 | - } |
|
| 227 | + /** |
|
| 228 | + * Return an iterator over all results of the paginatable. |
|
| 229 | + * |
|
| 230 | + * @return Iterator |
|
| 231 | + */ |
|
| 232 | + public function getIterator() |
|
| 233 | + { |
|
| 234 | + if ($this->alterations->count() === 0) { |
|
| 235 | + if ($this->resultIterator !== null) { |
|
| 236 | + return $this->resultIterator; |
|
| 237 | + } else { |
|
| 238 | + return new \ArrayIterator([]); |
|
| 239 | + } |
|
| 240 | + } else { |
|
| 241 | + return new \ArrayIterator($this->toArray()); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** |
|
| 246 | - * Specify data which should be serialized to JSON. |
|
| 247 | - * |
|
| 248 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 249 | - * |
|
| 250 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 251 | - * which is a value of any type other than a resource |
|
| 252 | - * |
|
| 253 | - * @since 5.4.0 |
|
| 254 | - */ |
|
| 255 | - public function jsonSerialize() |
|
| 256 | - { |
|
| 257 | - return $this->toArray(); |
|
| 258 | - } |
|
| 245 | + /** |
|
| 246 | + * Specify data which should be serialized to JSON. |
|
| 247 | + * |
|
| 248 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
| 249 | + * |
|
| 250 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
| 251 | + * which is a value of any type other than a resource |
|
| 252 | + * |
|
| 253 | + * @since 5.4.0 |
|
| 254 | + */ |
|
| 255 | + public function jsonSerialize() |
|
| 256 | + { |
|
| 257 | + return $this->toArray(); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * Returns only one value (the first) of the result set. |
|
| 262 | - * Returns null if no value exists. |
|
| 263 | - * |
|
| 264 | - * @return mixed|null |
|
| 265 | - */ |
|
| 266 | - public function first() |
|
| 267 | - { |
|
| 268 | - $page = $this->take(0, 1); |
|
| 269 | - foreach ($page as $bean) { |
|
| 270 | - return $bean; |
|
| 271 | - } |
|
| 260 | + /** |
|
| 261 | + * Returns only one value (the first) of the result set. |
|
| 262 | + * Returns null if no value exists. |
|
| 263 | + * |
|
| 264 | + * @return mixed|null |
|
| 265 | + */ |
|
| 266 | + public function first() |
|
| 267 | + { |
|
| 268 | + $page = $this->take(0, 1); |
|
| 269 | + foreach ($page as $bean) { |
|
| 270 | + return $bean; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - return; |
|
| 274 | - } |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * Returns a new iterator mapping any call using the $callable function. |
|
| 278 | - * |
|
| 279 | - * @param callable $callable |
|
| 280 | - * |
|
| 281 | - * @return MapIterator |
|
| 282 | - */ |
|
| 283 | - public function map(callable $callable) |
|
| 284 | - { |
|
| 285 | - return new MapIterator($this->getIterator(), $callable); |
|
| 286 | - } |
|
| 276 | + /** |
|
| 277 | + * Returns a new iterator mapping any call using the $callable function. |
|
| 278 | + * |
|
| 279 | + * @param callable $callable |
|
| 280 | + * |
|
| 281 | + * @return MapIterator |
|
| 282 | + */ |
|
| 283 | + public function map(callable $callable) |
|
| 284 | + { |
|
| 285 | + return new MapIterator($this->getIterator(), $callable); |
|
| 286 | + } |
|
| 287 | 287 | } |