input: Write a function to create an object-oriented structure in Python to solve a maze. The function should define a class 'Maze' with methods to initialize the maze, solve it, and determine if a position is within the maze boundaries. If the maze is solvable, the function should return the path length from the start to the end.
  
  assert Maze(3, 3)._solve_maze() == [4]
  assert Maze(2, 2)._solve_maze() == [2]
  assert Maze(4, 4)._solve_maze() == [6]
  assert Maze(1, 1)._solve_maze() == [0]
  assert Maze(5, 5)._solve_maze() == [8]
output: class Maze:
      def __init__(self, rows, cols):
          self.rows = rows
          self.cols = cols
          self.maze = [[0 for _ in range(cols)] for _ in range(rows)]
          self.start = (0, 0)
          self.end = (rows-1, cols-1)
  
      def _is_valid(self, pos):
          return 0 <= pos[0] < self.rows and 0 <= pos[1] < self.cols
  
      def _solve_maze(self):
          queue = [(self.start, 0)]
          visited = set()
          directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
          
          while queue:
              (current_pos, path_length) = queue.pop(0)
              if current_pos == self.end:
                  return [path_length]
              if current_pos in visited:
                  continue
              visited.add(current_pos)
              for direction in directions:
                  next_pos = (current_pos[0] + direction[0], current_pos[1] + direction[1])
                  if self._is_valid(next_pos):
                      queue.append((next_pos, path_length + 1))