diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index 984bae118d04d3f29fa8c19314b620161ed83dec..c53625790b57c44990ec666b6bf400cff330fbba 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -7,17 +7,17 @@ * @author Jacob Christiansen, WAYF * @package SimpleSAMLphp */ -class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_ProcessingFilter { - +class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_ProcessingFilter +{ /** * Should the pattern found be replaced? */ - private $replace = FALSE; + private $replace = false; /** * Should the value found be removed? */ - private $remove = FALSE; + private $remove = false; /** * Pattern to search for. @@ -27,7 +27,7 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing /** * String to replace the pattern found with. */ - private $replacement = FALSE; + private $replacement = false; /** * Attribute to search in @@ -46,7 +46,8 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing * @param mixed $reserved For future use. * @throws SimpleSAML_Error_Exception In case of invalid configuration. */ - public function __construct($config, $reserved) { + public function __construct($config, $reserved) + { parent::__construct($config, $reserved); assert(is_array($config)); @@ -55,33 +56,25 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing foreach ($config as $name => $value) { if (is_int($name)) { // check if this is an option - if($value === '%replace') { - $this->replace = TRUE; + if ($value === '%replace') { + $this->replace = true; } elseif ($value === '%remove') { - $this->remove = TRUE; + $this->remove = true; } else { - throw new SimpleSAML_Error_Exception('Unknown flag : ' . var_export($value, TRUE)); + throw new SimpleSAML_Error_Exception('Unknown flag : ' . var_export($value, true)); } continue; - } - - // Set pattern - if ($name === 'pattern') { + } elseif ($name === 'pattern') { + // Set pattern $this->pattern = $value; - } - - // Set replacement - if ($name === 'replacement') { + } elseif ($name === 'replacement') { + // Set replacement $this->replacement = $value; - } - - // Set subject - if ($name === 'subject') { + } elseif ($name === 'subject') { + // Set subject $this->subject = $value; - } - - // Set target - if ($name === 'target') { + } elseif ($name === 'target') { + // Set target $this->target = $value; } } @@ -166,12 +159,19 @@ class sspmod_core_Auth_Process_AttributeAlter extends SimpleSAML_Auth_Processing } } else { // replace only the part that matches if ($this->subject === $this->target) { - $attributes[$this->target] = preg_replace($this->pattern, $this->replacement, - $attributes[$this->subject]); + $attributes[$this->target] = preg_replace( + $this->pattern, $this->replacement, + $attributes[$this->subject] + ); } else { - $attributes[$this->target] = array_diff(preg_replace($this->pattern, $this->replacement, - $attributes[$this->subject]), - $attributes[$this->subject]); + $attributes[$this->target] = array_diff( + preg_replace( + $this->pattern, + $this->replacement, + $attributes[$this->subject] + ), + $attributes[$this->subject] + ); } } }