original_string: public function getLevel($entity)
      {
          $primaryKey = $this->_getPrimaryKey();
          $id = $entity;
          if ($entity instanceof EntityInterface) {
              $id = $entity->get($primaryKey);
          }
          $config = $this->getConfig();
          $entity = $this->_table->find('all')
              ->select([$config['left'], $config['right']])
              ->where([$primaryKey => $id])
              ->first();
  
          if ($entity === null) {
              return false;
          }
  
          $query = $this->_table->find('all')->where([
              $config['left'] . ' <' => $entity[$config['left']],
              $config['right'] . ' >' => $entity[$config['right']],
          ]);
  
          return $this->_scope($query)->count();
      }
code: public function getLevel($entity)
      {
          $primaryKey = $this->_getPrimaryKey();
          $id = $entity;
          if ($entity instanceof EntityInterface) {
              $id = $entity->get($primaryKey);
          }
          $config = $this->getConfig();
          $entity = $this->_table->find('all')
              ->select([$config['left'], $config['right']])
              ->where([$primaryKey => $id])
              ->first();
  
          if ($entity === null) {
              return false;
          }
  
          $query = $this->_table->find('all')->where([
              $config['left'] . ' <' => $entity[$config['left']],
              $config['right'] . ' >' => $entity[$config['right']],
          ]);
  
          return $this->_scope($query)->count();
      }
code_tokens: public function getLevel ( $ entity ) { $ primaryKey = $ this -> _getPrimaryKey ( ) ; $ id = $ entity ; if ( $ entity instanceof EntityInterface ) { $ id = $ entity -> get ( $ primaryKey ) ; } $ config = $ this -> getConfig ( ) ; $ entity = $ this -> _table -> find ( 'all' ) -> select ( [ $ config [ 'left' ] , $ config [ 'right' ] ] ) -> where ( [ $ primaryKey => $ id ] ) -> first ( ) ; if ( $ entity === null ) { return false ; } $ query = $ this -> _table -> find ( 'all' ) -> where ( [ $ config [ 'left' ] . ' <' => $ entity [ $ config [ 'left' ] ] , $ config [ 'right' ] . ' >' => $ entity [ $ config [ 'right' ] ] , ] ) ; return $ this -> _scope ( $ query ) -> count ( ) ; }
docstring: Returns the depth level of a node in the tree.
  
  @param int|string|\Cake\Datasource\EntityInterface $entity The entity or primary key get the level of.
  @return int|bool Integer of the level or false if the node does not exist.
docstring_tokens: Returns the depth level of a node in the tree .