original_string: public function load($categories)
      {
          if (is_string($categories)) {
              $categories = [$categories];
          }
  
          foreach ($categories as $idx => $category) {
              if (isset($this->items[$category])) {
                  unset($categories[$idx]);
              } else {
                  $this->items[$category] = [];
              }
          }
  
          if (empty($categories)) {
              return;
          }
  
          $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([
              'category' => $categories
          ])->all();
  
          foreach ($result as $row) {
              try {
                  $this->items[$row['category']][$row['key']] = Json::decode($row['value']);
              } catch (InvalidParamException $ex) {
                  $this->items[$row['category']][$row['key']] = $row['value'];
              }
          }
      }
code: public function load($categories)
      {
          if (is_string($categories)) {
              $categories = [$categories];
          }
  
          foreach ($categories as $idx => $category) {
              if (isset($this->items[$category])) {
                  unset($categories[$idx]);
              } else {
                  $this->items[$category] = [];
              }
          }
  
          if (empty($categories)) {
              return;
          }
  
          $result = (new Query())->select(['category', 'key', 'value'])->from('setting')->where([
              'category' => $categories
          ])->all();
  
          foreach ($result as $row) {
              try {
                  $this->items[$row['category']][$row['key']] = Json::decode($row['value']);
              } catch (InvalidParamException $ex) {
                  $this->items[$row['category']][$row['key']] = $row['value'];
              }
          }
      }
code_tokens: public function load ( $ categories ) { if ( is_string ( $ categories ) ) { $ categories = [ $ categories ] ; } foreach ( $ categories as $ idx => $ category ) { if ( isset ( $ this -> items [ $ category ] ) ) { unset ( $ categories [ $ idx ] ) ; } else { $ this -> items [ $ category ] = [ ] ; } } if ( empty ( $ categories ) ) { return ; } $ result = ( new Query ( ) ) -> select ( [ 'category' , 'key' , 'value' ] ) -> from ( 'setting' ) -> where ( [ 'category' => $ categories ] ) -> all ( ) ; foreach ( $ result as $ row ) { try { $ this -> items [ $ row [ 'category' ] ] [ $ row [ 'key' ] ] = Json :: decode ( $ row [ 'value' ] ) ; } catch ( InvalidParamException $ ex ) { $ this -> items [ $ row [ 'category' ] ] [ $ row [ 'key' ] ] = $ row [ 'value' ] ; } } }
docstring: Loads settings from category or multiple categories
  @param array|string $categories Category name
docstring_tokens: Loads settings from category or multiple categories