$value ) { $row[ $key ] = $value instanceof \BackedEnum ? $value->value : $value; } return self::of( array( 'course' => $row, 'post' => null === $post ? null : array( $post->post_status, $post->post_title, $post->post_name, $post->post_modified_gmt ), ) ); } public static function is_stale( string $sent, string $current ): bool { return '' !== $sent && ! hash_equals( $current, $sent ); } public static function stale( string $current, $value = null ): \WP_Error { $data = array( 'status' => 409, 'rev' => $current, ); if ( null !== $value ) { $data['value'] = $value; } return new \WP_Error( self::STALE, __( 'Someone else changed this since you opened it.', 'rooster-lms' ), $data ); } private static function canonical( $data ) { if ( ! is_array( $data ) ) { return $data; } if ( ! array_is_list( $data ) ) { ksort( $data ); } return array_map( array( self::class, 'canonical' ), $data ); } }