trimDeep() public static method

Trim recursively
public static trimDeep ( mixed $value ) : array | string
$value mixed
return array | string
 /**
  * For this helper the controller has to be passed as reference
  * for manual startup with $disableStartup = true (requires this to be called prior to any other method)
  *
  * @param \Cake\Event\Event $event
  * @return void
  */
 public function startup(Event $event)
 {
     // Data preparation
     if (!empty($this->Controller->request->data) && !Configure::read('DataPreparation.notrim')) {
         $this->Controller->request->data = Utility::trimDeep($this->Controller->request->data);
     }
     if (!empty($this->Controller->request->query) && !Configure::read('DataPreparation.notrim')) {
         $this->Controller->request->query = Utility::trimDeep($this->Controller->request->query);
     }
     if (!empty($this->Controller->request->params['pass']) && !Configure::read('DataPreparation.notrim')) {
         $this->Controller->request->params['pass'] = Utility::trimDeep($this->Controller->request->params['pass']);
     }
 }
Example #2
0
 /**
  * UtilityTest::testDeep()
  *
  * @covers ::trimDeep
  * @return void
  */
 public function testDeep()
 {
     $is = ['f some', 'e 49r ' => 'rf r ', 'er' => [['ee' => ['rr ' => ' tt ']]]];
     $expected = ['f some', 'e 49r ' => 'rf r', 'er' => [['ee' => ['rr ' => 'tt']]]];
     //$this->assertSame($expected, $is);
     $res = Utility::trimDeep($is);
     $this->assertSame($expected, $res);
     //$res = CommonComponent::trimDeep($is);
     //$this->assertSame($expected, $res);
 }