/**
  * Manipulates a Token
  *
  * @param \PHP\Manipulator\Token $token
  * @param mixed $params
  */
 public function manipulate(Token $token, $params = null)
 {
     $value = $token->getValue();
     if (substr($value, 0, 2) === "\r\n") {
         $token->setValue(substr($value, 2));
     } elseif (substr($value, 0, 1) === "\n") {
         $token->setValue(substr($value, 1));
     } elseif (substr($value, 0, 1) === "\r") {
         $token->setValue(substr($value, 1));
     }
 }
示例#2
0
 /**
  * @covers \PHP\Manipulator\Token::setValue
  * @covers \PHP\Manipulator\Token::getValue
  */
 public function testSetValueAndGetValue()
 {
     $token = new Token('foo');
     $this->assertEquals('foo', $token->getValue(), 'wrong value');
     $fluent = $token->setValue('bla');
     $this->assertSame($fluent, $token, 'No fluent interface');
     $this->assertEquals('bla', $token->getValue(), 'wrong value');
 }
 /**
  * Lowercase for tokens value
  *
  * @param \PHP\Manipulator\Token $token
  * @param mixed $params
  */
 public function manipulate(Token $token, $params = null)
 {
     $token->setValue(strtolower($token->getValue()));
 }
示例#4
0
 /**
  * @param \PHP\Manipulator\Token $whitespaceToken
  */
 protected function _indentWhitespace(Token $whitespaceToken)
 {
     $newValue = $whitespaceToken->getValue() . $this->getIndention($this->getIndentionLevel());
     $whitespaceToken->setValue($newValue);
 }