fork download
  1. <?php
  2.  
  3. class Chujnia {
  4. private $attrs;
  5. private $attributes_whitelist = [
  6. 'mode',
  7. 'activateoncreate',
  8. 'showerror',
  9. 'columns_field',
  10. 'values_field',
  11. 'primary_field'
  12. ];
  13.  
  14. public function __construct($attrs) {
  15. $this->attrs = $attrs;
  16. }
  17.  
  18. public function rozjebac() {
  19. return array_reduce($this->attributes_whitelist, function ($acc, $attr) {
  20. return (isset($this->attrs[$attr]) ? "$acc $attr=\"{$this->attrs[$attr]}\"" : $acc);
  21. }, '');
  22. }
  23. }
  24.  
  25. $chujnia = new Chujnia([
  26. 'mode' => 0xFF,
  27. 'activateoncreate' => 'false',
  28. 'columns_field' => 'twoja stara'
  29. ]);
  30. echo $chujnia->rozjebac();
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
 mode="255" activateoncreate="false" columns_field="twoja stara"