Skip to content

Commit

Permalink
Adds array helper & processor docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Mar 31, 2023
1 parent febb0be commit c33838c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/Helpers/Array_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function after( array $subject, int $position ): array {
* @return array
*/
public static function before( array $subject, int $position ): array {
return Array_Helper::diff( Array_Helper::after( $subject, $position ) );
return Array_Helper::diff( Array_Helper::after( $subject, $position ), $subject );
}

/**
Expand Down Expand Up @@ -438,7 +438,7 @@ public static function flip( $array ): array {
* @return array The normalized array
* @throws \ReflectionException
*/
public static function normalize( array $array, $convert_colsures = true, $recursive = true ): array {
public static function normalize(array $array, $convert_closures = true, $recursive = true ): array {

foreach ( $array as $key => $value ) {
// Normalize recursively.
Expand All @@ -449,7 +449,7 @@ public static function normalize( array $array, $convert_colsures = true, $recur
}

// If closures need converted, and this is a closure, transform this into an identifiable string.
if ( true === $convert_colsures && $value instanceof Closure ) {
if (true === $convert_closures && $value instanceof Closure ) {
$array[ $key ] = self::convert_closure( $value );
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Helpers/Processors/Array_Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function merge( array ...$defaults ): static {
* @return $this
*/
public function replace_recursive( array ...$items ): static {
$this->subject = Array_Helper::merge( $this->subject, ...$items );
$this->subject = Array_Helper::replace_recursive( $this->subject, ...$items );

return $this;
}
Expand All @@ -165,7 +165,7 @@ public function replace_recursive( array ...$items ): static {
* @return $this
*/
public function replace( array ...$items ): static {
$this->subject = Array_Helper::merge( $this->subject, ...$items );
$this->subject = Array_Helper::replace( $this->subject, ...$items );

return $this;
}
Expand Down Expand Up @@ -205,8 +205,8 @@ public function append( ...$items ): static {
*
* @throws ReflectionException
*/
public function normalize( $convert_colsures = true, $recursive = true ): static {
$this->subject = Array_Helper::normalize( $this->subject, $convert_colsures, $recursive );
public function normalize($convert_closures = true, $recursive = true ): static {
$this->subject = Array_Helper::normalize( $this->subject, $convert_closures, $recursive );

return $this;
}
Expand Down

0 comments on commit c33838c

Please sign in to comment.