Skip to content
Snippets Groups Projects
Verified Commit a72ecab5 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

refactor: extract common method for definition creation

parent b0dd9219
No related branches found
No related tags found
2 merge requests!3improve into wp-hook and some additional unfinished things,!21.x
...@@ -29,11 +29,15 @@ class ArrayBindingLoader implements BindingDefinitions { ...@@ -29,11 +29,15 @@ class ArrayBindingLoader implements BindingDefinitions {
foreach ( $bindings as $key => $value ) { foreach ( $bindings as $key => $value ) {
if ( is_array( $value ) ) { if ( is_array( $value ) ) {
foreach ( $value as $unit ) { foreach ( $value as $unit ) {
yield $this->factory->create( $unit, is_int( $key ) ? null : $key ); yield $this->create( $unit, $key );
} }
} else { } else {
yield $this->factory->create( $value, is_int( $key ) ? null : $key ); yield $this->create( $value, $key );
} }
} }
} }
private function create( $value, $hook ) {
return $this->factory->create( $value, is_int( $hook ) ? null : $hook );
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment