input: from typing import List
  
  
  def solve_maze(grid: List[List[int]]) -> List[int]:
      """
      Given a 2D grid representing a maze where '1' indicates a valid path cell and '0' indicates a wall,
      find the shortest path from the top-left corner to the bottom-right corner using an object-oriented approach.
      
      The maze is represented as a list of lists of integers, where:
      1. The starting point is always at position (0, 0).
      2. The ending point is always at position (n-1, m-1), where n is the number of rows and m is the number of columns.
  
      The function uses an internal class `Maze` to handle the maze solving logic.
  
      >>> solve_maze([[1, 0, 1], [1, 1, 1], [1, 1, 1]])
      [7]
      >>> solve_maze([[1, 1, 1], [1, 0, 1], [1, 1, 1]])
      [4]
      >>> solve_maze([[1, 0, 0], [1, 1, 0], [0, 1, 1]])
      [7]
      """
      class Maze:
          def __init__(self, grid: List[List[int]]):
              self._grid = grid
              self._n, self._m = len(grid), len(grid[0])
  
          def solve_maze(self) -> List[int]:
              result, found = [], False
              start, end = (0, 0), (self._n-1, self._m-1)
  
              for i in range(self._n):
                  for j in range(self._m):
                      if self._grid[i][j] == 1:
                          value = 0
                          self._find_omega(i, j, value, result, start, end, found)
                          return result
  
          def _find_omega(self, i: int, j: int, value: int, result: List[int], start: tuple, end: tuple, found: bool):
              rowNbr, colNbr = [-1, 0, 0, 1], [0, -1, 1, 0]
  
              if (i, j) == end:
                  found = True
                  result.append(value)
                  return
  
              if found:
                  return
  
              self._grid[i][j] = 0
              for k in range(4):
                  if self._on_board(i + rowNbr[k], j + colNbr[k]):
                      self._find_omega(i + rowNbr[k], j + colNbr[k], value + 1, result, start, end, found)
  
          def _on_board(self, i: int, j: int) -> bool:
              return 0 <= i < self._n and 0 <= j < self._m and self._grid[i][j] == 1
  
      maze = Maze(grid)
      return maze.solve_maze()
output:     
              result, found = [], False
              start, end = (0, 0), (self._n-1, self._m-1)
  
              for i in range(self._n):
                  for j in range(self._m):
                      if self._grid[i][j] == 1:
                          value = 0
                          self._find_omega(i, j, value, result, start, end, found)
                          return result
  
          def _find_omega(self, i: int, j: int, value: int, result: List[int], start: tuple, end: tuple, found: bool):
              rowNbr, colNbr = [-1, 0, 0, 1], [0, -1, 1, 0]
  
              if (i, j) == end:
                  found = True
                  result.append(value)
                  return
  
              if found:
                  return
  
              self._grid[i][j] = 0
              for k in range(4):
                  if self._on_board(i + rowNbr[k], j + colNbr[k]):
                      self._find_omega(i + rowNbr[k], j + colNbr[k], value + 1, result, start, end, found)
  
          def _on_board(self, i: int, j: int) -> bool:
              return 0 <= i < self._n and 0 <= j < self._m and self._grid[i][j] == 1
  
      maze = Maze(grid)
      return maze.solve_maze()
  