original_string: public function childCount(EntityInterface $node, $direct = false)
      {
          $config = $this->getConfig();
          $parent = $this->_table->aliasField($config['parent']);
  
          if ($direct) {
              return $this->_scope($this->_table->find())
                  ->where([$parent => $node->get($this->_getPrimaryKey())])
                  ->count();
          }
  
          $this->_ensureFields($node);
  
          return ($node->get($config['right']) - $node->get($config['left']) - 1) / 2;
      }
code: public function childCount(EntityInterface $node, $direct = false)
      {
          $config = $this->getConfig();
          $parent = $this->_table->aliasField($config['parent']);
  
          if ($direct) {
              return $this->_scope($this->_table->find())
                  ->where([$parent => $node->get($this->_getPrimaryKey())])
                  ->count();
          }
  
          $this->_ensureFields($node);
  
          return ($node->get($config['right']) - $node->get($config['left']) - 1) / 2;
      }
code_tokens: public function childCount ( EntityInterface $ node , $ direct = false ) { $ config = $ this -> getConfig ( ) ; $ parent = $ this -> _table -> aliasField ( $ config [ 'parent' ] ) ; if ( $ direct ) { return $ this -> _scope ( $ this -> _table -> find ( ) ) -> where ( [ $ parent => $ node -> get ( $ this -> _getPrimaryKey ( ) ) ] ) -> count ( ) ; } $ this -> _ensureFields ( $ node ) ; return ( $ node -> get ( $ config [ 'right' ] ) - $ node -> get ( $ config [ 'left' ] ) - 1 ) / 2 ; }
docstring: Get the number of children nodes.
  
  @param \Cake\Datasource\EntityInterface $node The entity to count children for
  @param bool $direct whether to count all nodes in the subtree or just
  direct children
  @return int Number of children nodes.
docstring_tokens: Get the number of children nodes .