public static function mapList( $list, $map, ?string $key = null ): array {

    if( !static::is( $list, true ) ) throw new \TypeError( 'The $list must be iterable' );
    else {

      $_list = [];
      foreach( $list as $index => $item ) {

        if( !static::is( $item, false, true ) ) throw new \TypeError( 'All $list element must be arraylike' );
        else {

          $_key = $key ? $item[ $key ] : $index;
          if( !static::is( $map, true, true ) ) $_list[ $_key ] = $item[ $map ] ?? null;
          else $_list[ $_key ] = static::map( $item, [], $map );
        }
      }

      return $_list;
    }
  }
public static function mapList( $list, $map, ?string $key = null ): array {

    if( !static::is( $list, true ) ) throw new \TypeError( 'The $list must be iterable' );
    else {

      $_list = [];
      foreach( $list as $index => $item ) {

        if( !static::is( $item, false, true ) ) throw new \TypeError( 'All $list element must be arraylike' );
        else {

          $_key = $key ? $item[ $key ] : $index;
          if( !static::is( $map, true, true ) ) $_list[ $_key ] = $item[ $map ] ?? null;
          else $_list[ $_key ] = static::map( $item, [], $map );
        }
      }

      return $_list;
    }
  }
public static function mapList ( $ list , $ map , ? string $ key = null ) : array { if ( ! static :: is ( $ list , true ) ) throw new \ TypeError ( 'The $list must be iterable' ) ; else { $ _list = [ ] ; foreach ( $ list as $ index => $ item ) { if ( ! static :: is ( $ item , false , true ) ) throw new \ TypeError ( 'All $list element must be arraylike' ) ; else { $ _key = $ key ? $ item [ $ key ] : $ index ; if ( ! static :: is ( $ map , true , true ) ) $ _list [ $ _key ] = $ item [ $ map ] ?? null ; else $ _list [ $ _key ] = static :: map ( $ item , [ ] , $ map ) ; } } return $ _list ; } }
Re-map an array of arraylikes into a new array

@param array[]              $list
@param string|array|array[] $map
@param string|null          $key

@return array[]
Re - map an array of arraylikes into a new array