Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Column often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Column, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 44 | class Column |
||
| 45 | { |
||
| 46 | use Column\HasHeader; |
||
| 47 | |||
| 48 | const SELECT_COLUMN_NAME = '__row_selector__'; |
||
| 49 | |||
| 50 | const ACTION_COLUMN_NAME = '__actions__'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var Grid |
||
| 54 | */ |
||
| 55 | protected $grid; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Name of column. |
||
| 59 | * |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | protected $name; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Label of column. |
||
| 66 | * |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | protected $label; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Original value of column. |
||
| 73 | * |
||
| 74 | * @var mixed |
||
| 75 | */ |
||
| 76 | protected $original; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Attributes of column. |
||
| 80 | * |
||
| 81 | * @var array |
||
| 82 | */ |
||
| 83 | protected $attributes = []; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Relation name. |
||
| 87 | * |
||
| 88 | * @var bool |
||
| 89 | */ |
||
| 90 | protected $relation = false; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Relation column. |
||
| 94 | * |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | protected $relationColumn; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Original grid data. |
||
| 101 | * |
||
| 102 | * @var Collection |
||
| 103 | */ |
||
| 104 | protected static $originalGridModels; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var []Closure |
||
| 108 | */ |
||
| 109 | protected $displayCallbacks = []; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Displayers for grid column. |
||
| 113 | * |
||
| 114 | * @var array |
||
| 115 | */ |
||
| 116 | public static $displayers = [ |
||
| 117 | 'editable' => Displayers\Editable::class, |
||
| 118 | 'switch' => Displayers\SwitchDisplay::class, |
||
| 119 | 'switchGroup' => Displayers\SwitchGroup::class, |
||
| 120 | 'select' => Displayers\Select::class, |
||
| 121 | 'image' => Displayers\Image::class, |
||
| 122 | 'label' => Displayers\Label::class, |
||
| 123 | 'button' => Displayers\Button::class, |
||
| 124 | 'link' => Displayers\Link::class, |
||
| 125 | 'badge' => Displayers\Badge::class, |
||
| 126 | 'progressBar' => Displayers\ProgressBar::class, |
||
| 127 | 'progress' => Displayers\ProgressBar::class, |
||
| 128 | 'radio' => Displayers\Radio::class, |
||
| 129 | 'checkbox' => Displayers\Checkbox::class, |
||
| 130 | 'orderable' => Displayers\Orderable::class, |
||
| 131 | 'table' => Displayers\Table::class, |
||
| 132 | 'expand' => Displayers\Expand::class, |
||
| 133 | 'modal' => Displayers\Modal::class, |
||
| 134 | 'carousel' => Displayers\Carousel::class, |
||
| 135 | 'downloadable' => Displayers\Downloadable::class, |
||
| 136 | 'copyable' => Displayers\Copyable::class, |
||
| 137 | 'qrcode' => Displayers\QRCode::class, |
||
| 138 | 'prefix' => Displayers\Prefix::class, |
||
| 139 | 'suffix' => Displayers\Suffix::class, |
||
| 140 | 'secret' => Displayers\Secret::class, |
||
| 141 | 'limit' => Displayers\Limit::class, |
||
| 142 | 'belongsTo' => Displayers\BelongsTo::class, |
||
| 143 | 'belongsToMany' => Displayers\BelongsToMany::class, |
||
| 144 | ]; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Defined columns. |
||
| 148 | * |
||
| 149 | * @var array |
||
| 150 | */ |
||
| 151 | public static $defined = []; |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @var array |
||
| 155 | */ |
||
| 156 | protected static $htmlAttributes = []; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @var array |
||
| 160 | */ |
||
| 161 | protected static $rowAttributes = []; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @var Model |
||
| 165 | */ |
||
| 166 | protected static $model; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @var bool |
||
| 170 | */ |
||
| 171 | protected $searchable = false; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @param string $name |
||
| 175 | * @param string $label |
||
| 176 | */ |
||
| 177 | public function __construct($name, $label) |
||
| 178 | { |
||
| 179 | $this->name = $name; |
||
| 180 | |||
| 181 | $this->label = $this->formatLabel($label); |
||
| 182 | |||
| 183 | $this->initAttributes(); |
||
| 184 | } |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Initialize column attributes. |
||
| 188 | */ |
||
| 189 | protected function initAttributes() |
||
| 190 | { |
||
| 191 | $name = str_replace('.', '-', $this->name); |
||
| 192 | |||
| 193 | $this->setAttributes(['class' => "column-{$name}"]); |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Extend column displayer. |
||
| 198 | * |
||
| 199 | * @param $name |
||
| 200 | * @param $displayer |
||
| 201 | */ |
||
| 202 | public static function extend($name, $displayer) |
||
| 203 | { |
||
| 204 | static::$displayers[$name] = $displayer; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Define a column globally. |
||
| 209 | * |
||
| 210 | * @param string $name |
||
| 211 | * @param mixed $definition |
||
| 212 | */ |
||
| 213 | public static function define($name, $definition) |
||
| 214 | { |
||
| 215 | static::$defined[$name] = $definition; |
||
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * Set grid instance for column. |
||
| 220 | * |
||
| 221 | * @param Grid $grid |
||
| 222 | */ |
||
| 223 | public function setGrid(Grid $grid) |
||
| 224 | { |
||
| 225 | $this->grid = $grid; |
||
| 226 | |||
| 227 | $this->setModel($grid->model()->eloquent()); |
||
|
|
|||
| 228 | } |
||
| 229 | |||
| 230 | /** |
||
| 231 | * Set model for column. |
||
| 232 | * |
||
| 233 | * @param $model |
||
| 234 | */ |
||
| 235 | public function setModel($model) |
||
| 236 | { |
||
| 237 | if (is_null(static::$model) && ($model instanceof BaseModel)) { |
||
| 238 | static::$model = $model->newInstance(); |
||
| 239 | } |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * Set original data for column. |
||
| 244 | * |
||
| 245 | * @param Collection $collection |
||
| 246 | */ |
||
| 247 | public static function setOriginalGridModels(Collection $collection) |
||
| 248 | { |
||
| 249 | static::$originalGridModels = $collection; |
||
| 250 | } |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Set column attributes. |
||
| 254 | * |
||
| 255 | * @param array $attributes |
||
| 256 | * |
||
| 257 | * @return $this |
||
| 258 | */ |
||
| 259 | public function setAttributes($attributes = [], $key = null) |
||
| 260 | { |
||
| 261 | if ($key) { |
||
| 262 | static::$rowAttributes[$this->name][$key] = array_merge( |
||
| 263 | Arr::get(static::$rowAttributes, "{$this->name}.{$key}", []), |
||
| 264 | $attributes |
||
| 265 | ); |
||
| 266 | |||
| 267 | return $this; |
||
| 268 | } |
||
| 269 | |||
| 270 | static::$htmlAttributes[$this->name] = array_merge( |
||
| 271 | Arr::get(static::$htmlAttributes, $this->name, []), |
||
| 272 | $attributes |
||
| 273 | ); |
||
| 274 | |||
| 275 | return $this; |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Get column attributes. |
||
| 280 | * |
||
| 281 | * @param string $name |
||
| 282 | * |
||
| 283 | * @return mixed |
||
| 284 | */ |
||
| 285 | public static function getAttributes($name, $key = null) |
||
| 286 | { |
||
| 287 | $rowAttributes = []; |
||
| 288 | |||
| 289 | if ($key && Arr::has(static::$rowAttributes, "{$name}.{$key}")) { |
||
| 290 | $rowAttributes = Arr::get(static::$rowAttributes, "{$name}.{$key}", []); |
||
| 291 | } |
||
| 292 | |||
| 293 | $columnAttributes = Arr::get(static::$htmlAttributes, $name, []); |
||
| 294 | |||
| 295 | return array_merge($rowAttributes, $columnAttributes); |
||
| 296 | } |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Format attributes to html. |
||
| 300 | * |
||
| 301 | * @return string |
||
| 302 | */ |
||
| 303 | public function formatHtmlAttributes() |
||
| 304 | { |
||
| 305 | $attrArr = []; |
||
| 306 | foreach (static::getAttributes($this->name) as $name => $val) { |
||
| 307 | $attrArr[] = "$name=\"$val\""; |
||
| 308 | } |
||
| 309 | |||
| 310 | return implode(' ', $attrArr); |
||
| 311 | } |
||
| 312 | |||
| 313 | /** |
||
| 314 | * Set style of this column. |
||
| 315 | * |
||
| 316 | * @param string $style |
||
| 317 | * |
||
| 318 | * @return $this |
||
| 319 | */ |
||
| 320 | public function style($style) |
||
| 321 | { |
||
| 322 | return $this->setAttributes(compact('style')); |
||
| 323 | } |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Set the width of column. |
||
| 327 | * |
||
| 328 | * @param int $width |
||
| 329 | * |
||
| 330 | * @return $this |
||
| 331 | */ |
||
| 332 | public function width(int $width) |
||
| 333 | { |
||
| 334 | return $this->style("width: {$width}px;max-width: {$width}px;word-wrap: break-word;word-break: normal;"); |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Set the color of column. |
||
| 339 | * |
||
| 340 | * @param string $color |
||
| 341 | * |
||
| 342 | * @return $this |
||
| 343 | */ |
||
| 344 | public function color($color) |
||
| 345 | { |
||
| 346 | return $this->style("color:$color;"); |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * Get original column value. |
||
| 351 | * |
||
| 352 | * @return mixed |
||
| 353 | */ |
||
| 354 | public function getOriginal() |
||
| 355 | { |
||
| 356 | return $this->original; |
||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * Get name of this column. |
||
| 361 | * |
||
| 362 | * @return mixed |
||
| 363 | */ |
||
| 364 | public function getName() |
||
| 365 | { |
||
| 366 | return $this->name; |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @return string |
||
| 371 | */ |
||
| 372 | public function getClassName() |
||
| 373 | { |
||
| 374 | $name = str_replace('.', '-', $this->getName()); |
||
| 375 | |||
| 376 | return "column-{$name}"; |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Format label. |
||
| 381 | * |
||
| 382 | * @param $label |
||
| 383 | * |
||
| 384 | * @return mixed |
||
| 385 | */ |
||
| 386 | protected function formatLabel($label) |
||
| 387 | { |
||
| 388 | if ($label) { |
||
| 389 | return $label; |
||
| 390 | } |
||
| 391 | |||
| 392 | $label = ucfirst($this->name); |
||
| 393 | |||
| 394 | return __(str_replace(['.', '_'], ' ', $label)); |
||
| 395 | } |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Get label of the column. |
||
| 399 | * |
||
| 400 | * @return mixed |
||
| 401 | */ |
||
| 402 | public function getLabel() |
||
| 403 | { |
||
| 404 | return $this->label; |
||
| 405 | } |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Set relation. |
||
| 409 | * |
||
| 410 | * @param string $relation |
||
| 411 | * @param string $relationColumn |
||
| 412 | * |
||
| 413 | * @return $this |
||
| 414 | */ |
||
| 415 | public function setRelation($relation, $relationColumn = null) |
||
| 416 | { |
||
| 417 | $this->relation = $relation; |
||
| 418 | $this->relationColumn = $relationColumn; |
||
| 419 | |||
| 420 | return $this; |
||
| 421 | } |
||
| 422 | |||
| 423 | /** |
||
| 424 | * If this column is relation column. |
||
| 425 | * |
||
| 426 | * @return bool |
||
| 427 | */ |
||
| 428 | protected function isRelation() |
||
| 429 | { |
||
| 430 | return (bool) $this->relation; |
||
| 431 | } |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Mark this column as sortable. |
||
| 435 | * |
||
| 436 | * @param null|string $cast |
||
| 437 | * |
||
| 438 | * @return Column|string |
||
| 439 | */ |
||
| 440 | public function sortable($cast = null) |
||
| 441 | { |
||
| 442 | return $this->addSorter($cast); |
||
| 443 | } |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Set cast name for sortable. |
||
| 447 | * |
||
| 448 | * @return $this |
||
| 449 | * |
||
| 450 | * @deprecated Use `$column->sortable($cast)` instead. |
||
| 451 | */ |
||
| 452 | public function cast($cast) |
||
| 453 | { |
||
| 454 | $this->cast = $cast; |
||
| 455 | |||
| 456 | return $this; |
||
| 457 | } |
||
| 458 | |||
| 459 | /** |
||
| 460 | * Set help message for column. |
||
| 461 | * |
||
| 462 | * @param string $help |
||
| 463 | * |
||
| 464 | * @return $this|string |
||
| 465 | */ |
||
| 466 | public function help($help = '') |
||
| 467 | { |
||
| 468 | return $this->addHelp($help); |
||
| 469 | } |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Set column filter. |
||
| 473 | * |
||
| 474 | * @param mixed|null $builder |
||
| 475 | * |
||
| 476 | * @return $this |
||
| 477 | */ |
||
| 478 | public function filter($builder = null) |
||
| 479 | { |
||
| 480 | return $this->addFilter(...func_get_args()); |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Set column as searchable. |
||
| 485 | * |
||
| 486 | * @return $this |
||
| 487 | */ |
||
| 488 | public function searchable() |
||
| 489 | { |
||
| 490 | $this->searchable = true; |
||
| 491 | |||
| 492 | $name = $this->getName(); |
||
| 493 | $query = request()->query(); |
||
| 494 | |||
| 495 | $this->prefix(function ($_, $original) use ($name, $query) { |
||
| 496 | Arr::set($query, $name, $original); |
||
| 497 | |||
| 498 | $url = request()->fullUrlWithQuery($query); |
||
| 499 | |||
| 500 | return "<a href=\"{$url}\"><i class=\"fa fa-search\"></i></a>"; |
||
| 501 | }, ' '); |
||
| 502 | |||
| 503 | return $this; |
||
| 504 | } |
||
| 505 | |||
| 506 | /** |
||
| 507 | * Bind search query to grid model. |
||
| 508 | * |
||
| 509 | * @param Model $model |
||
| 510 | */ |
||
| 511 | public function bindSearchQuery(Model $model) |
||
| 512 | { |
||
| 513 | if ($this->searchable && ($value = request($this->getName())) != '') { |
||
| 514 | $model->where($this->getName(), $value); |
||
| 515 | } |
||
| 516 | } |
||
| 517 | |||
| 518 | /** |
||
| 519 | * Add a display callback. |
||
| 520 | * |
||
| 521 | * @param Closure $callback |
||
| 522 | * |
||
| 523 | * @return $this |
||
| 524 | */ |
||
| 525 | public function display(Closure $callback) |
||
| 531 | |||
| 532 | /** |
||
| 533 | * Display using display abstract. |
||
| 534 | * |
||
| 535 | * @param string $abstract |
||
| 536 | * @param array $arguments |
||
| 537 | * |
||
| 538 | * @return $this |
||
| 539 | */ |
||
| 540 | public function displayUsing($abstract, $arguments = []) |
||
| 553 | |||
| 554 | /** |
||
| 555 | * Display column using array value map. |
||
| 556 | * |
||
| 557 | * @param array $values |
||
| 558 | * @param null $default |
||
| 559 | * |
||
| 560 | * @return $this |
||
| 561 | */ |
||
| 562 | View Code Duplication | public function using(array $values, $default = null) |
|
| 572 | |||
| 573 | /** |
||
| 574 | * Replace output value with giving map. |
||
| 575 | * |
||
| 576 | * @param array $replacements |
||
| 577 | * |
||
| 578 | * @return $this |
||
| 579 | */ |
||
| 580 | public function replace(array $replacements) |
||
| 590 | |||
| 591 | /** |
||
| 592 | * Render this column with the given view. |
||
| 593 | * |
||
| 594 | * @param string $view |
||
| 595 | * |
||
| 596 | * @return $this |
||
| 597 | */ |
||
| 598 | public function view($view) |
||
| 606 | |||
| 607 | /** |
||
| 608 | * Hide this column by default. |
||
| 609 | * |
||
| 610 | * @return $this |
||
| 611 | */ |
||
| 612 | public function hide() |
||
| 618 | |||
| 619 | /** |
||
| 620 | * Add column to total-row. |
||
| 621 | * |
||
| 622 | * @param null $display |
||
| 623 | * |
||
| 624 | * @return $this |
||
| 625 | */ |
||
| 626 | public function totalRow($display = null) |
||
| 632 | |||
| 633 | /** |
||
| 634 | * Convert file size to a human readable format like `100mb`. |
||
| 635 | * |
||
| 636 | * @return $this |
||
| 637 | */ |
||
| 638 | public function filesize() |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Display the fields in the email format as gavatar. |
||
| 647 | * |
||
| 648 | * @param int $size |
||
| 649 | * |
||
| 650 | * @return $this |
||
| 651 | */ |
||
| 652 | public function gravatar($size = 30) |
||
| 664 | |||
| 665 | /** |
||
| 666 | * Display field as a loading icon. |
||
| 667 | * |
||
| 668 | * @param array $values |
||
| 669 | * @param array $others |
||
| 670 | * |
||
| 671 | * @return $this |
||
| 672 | */ |
||
| 673 | public function loading($values = [], $others = []) |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Display column as an font-awesome icon based on it's value. |
||
| 688 | * |
||
| 689 | * @param array $setting |
||
| 690 | * @param string $default |
||
| 691 | * |
||
| 692 | * @return $this |
||
| 693 | */ |
||
| 694 | public function icon(array $setting, $default = '') |
||
| 708 | |||
| 709 | /** |
||
| 710 | * Return a human readable format time. |
||
| 711 | * |
||
| 712 | * @param null $locale |
||
| 713 | * |
||
| 714 | * @return $this |
||
| 715 | */ |
||
| 716 | public function diffForHumans($locale = null) |
||
| 726 | |||
| 727 | /** |
||
| 728 | * Returns a string formatted according to the given format string. |
||
| 729 | * |
||
| 730 | * @param string $format |
||
| 731 | * |
||
| 732 | * @return $this |
||
| 733 | */ |
||
| 734 | public function date($format) |
||
| 740 | |||
| 741 | /** |
||
| 742 | * Display column as boolean , `✓` for true, and `✗` for false. |
||
| 743 | * |
||
| 744 | * @param array $map |
||
| 745 | * @param bool $default |
||
| 746 | * |
||
| 747 | * @return $this |
||
| 748 | */ |
||
| 749 | public function bool(array $map = [], $default = false) |
||
| 757 | |||
| 758 | /** |
||
| 759 | * Display column as a default value if empty. |
||
| 760 | * |
||
| 761 | * @param string $default |
||
| 762 | * @return $this |
||
| 763 | */ |
||
| 764 | public function default($default = '-') |
||
| 765 | { |
||
| 766 | return $this->display(function ($value) use ($default) { |
||
| 767 | return $value ?: $default; |
||
| 768 | }); |
||
| 769 | } |
||
| 770 | |||
| 771 | /** |
||
| 772 | * Display column using a grid row action. |
||
| 773 | * |
||
| 774 | * @param string $action |
||
| 775 | * |
||
| 776 | * @return $this |
||
| 777 | */ |
||
| 778 | public function action($action) |
||
| 779 | { |
||
| 780 | if (!is_subclass_of($action, RowAction::class)) { |
||
| 781 | throw new \InvalidArgumentException("Action class [$action] must be sub-class of [Encore\Admin\Actions\GridAction]"); |
||
| 782 | } |
||
| 783 | |||
| 784 | $grid = $this->grid; |
||
| 797 | |||
| 798 | /** |
||
| 799 | * Add a `dot` before column text. |
||
| 800 | * |
||
| 801 | * @param array $options |
||
| 802 | * @param string $default |
||
| 803 | * |
||
| 804 | * @return $this |
||
| 805 | */ |
||
| 806 | public function dot($options = [], $default = '') |
||
| 818 | |||
| 819 | /** |
||
| 820 | * @param string $selectable |
||
| 821 | * |
||
| 822 | * @return $this |
||
| 823 | */ |
||
| 824 | View Code Duplication | public function belongsTo($selectable) |
|
| 832 | |||
| 833 | /** |
||
| 834 | * @param string $selectable |
||
| 835 | * |
||
| 836 | * @return $this |
||
| 837 | */ |
||
| 838 | View Code Duplication | public function belongsToMany($selectable) |
|
| 846 | |||
| 847 | /** |
||
| 848 | * If has display callbacks. |
||
| 849 | * |
||
| 850 | * @return bool |
||
| 851 | */ |
||
| 852 | protected function hasDisplayCallbacks() |
||
| 856 | |||
| 857 | /** |
||
| 858 | * Call all of the "display" callbacks column. |
||
| 859 | * |
||
| 860 | * @param mixed $value |
||
| 861 | * @param int $key |
||
| 862 | * |
||
| 863 | * @return mixed |
||
| 864 | */ |
||
| 865 | protected function callDisplayCallbacks($value, $key) |
||
| 883 | |||
| 884 | /** |
||
| 885 | * Set original grid data to column. |
||
| 886 | * |
||
| 887 | * @param Closure $callback |
||
| 888 | * @param int $key |
||
| 889 | * |
||
| 890 | * @return Closure |
||
| 891 | */ |
||
| 892 | protected function bindOriginalRowModel(Closure $callback, $key) |
||
| 898 | |||
| 899 | /** |
||
| 900 | * Fill all data to every column. |
||
| 901 | * |
||
| 902 | * @param array $data |
||
| 903 | * |
||
| 904 | * @return mixed |
||
| 905 | */ |
||
| 906 | public function fill(array $data) |
||
| 927 | |||
| 928 | /** |
||
| 929 | * If current column is a defined column. |
||
| 930 | * |
||
| 931 | * @return bool |
||
| 932 | */ |
||
| 933 | protected function isDefinedColumn() |
||
| 937 | |||
| 938 | /** |
||
| 939 | * Use a defined column. |
||
| 940 | * |
||
| 941 | * @throws \Exception |
||
| 942 | */ |
||
| 943 | protected function useDefinedColumn() |
||
| 970 | |||
| 971 | /** |
||
| 972 | * Convert characters to HTML entities recursively. |
||
| 973 | * |
||
| 974 | * @param array|string $item |
||
| 975 | * |
||
| 976 | * @return mixed |
||
| 977 | */ |
||
| 978 | protected function htmlEntityEncode($item) |
||
| 990 | |||
| 991 | /** |
||
| 992 | * Find a displayer to display column. |
||
| 993 | * |
||
| 994 | * @param string $abstract |
||
| 995 | * @param array $arguments |
||
| 996 | * |
||
| 997 | * @return $this |
||
| 998 | */ |
||
| 999 | protected function resolveDisplayer($abstract, $arguments) |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * Call Illuminate/Support displayer. |
||
| 1010 | * |
||
| 1011 | * @param string $abstract |
||
| 1012 | * @param array $arguments |
||
| 1013 | * |
||
| 1014 | * @return $this |
||
| 1015 | */ |
||
| 1016 | protected function callSupportDisplayer($abstract, $arguments) |
||
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Call Builtin displayer. |
||
| 1033 | * |
||
| 1034 | * @param string $abstract |
||
| 1035 | * @param array $arguments |
||
| 1036 | * |
||
| 1037 | * @return $this |
||
| 1038 | */ |
||
| 1039 | protected function callBuiltinDisplayer($abstract, $arguments) |
||
| 1061 | |||
| 1062 | /** |
||
| 1063 | * Passes through all unknown calls to builtin displayer or supported displayer. |
||
| 1064 | * |
||
| 1065 | * Allow fluent calls on the Column object. |
||
| 1066 | * |
||
| 1067 | * @param string $method |
||
| 1068 | * @param array $arguments |
||
| 1069 | * |
||
| 1070 | * @return $this |
||
| 1071 | */ |
||
| 1072 | public function __call($method, $arguments) |
||
| 1085 | } |
||
| 1086 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: