Skip to content

Commit

Permalink
force call method with lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
HillLiu committed Apr 12, 2022
1 parent b3e8c27 commit 8a1a922
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/Subject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
use SplObserver;
use SplObjectStorage;
use PMVC;
use PMVC\Alias;

class Subject implements SplSubject
{
/**
* Alias
*/
use PMVC\Alias {
use Alias {
getTypeOfAlias as private _getTypeOfAlias;
}

Expand All @@ -19,8 +20,8 @@ class Subject implements SplSubject

public function __construct($name)
{
$this->_name = $name;
$this->setDefaultAlias(new SplObjectStorage());
$this->_name = $name;
$this->setDefaultAlias(new SplObjectStorage());
}

#[\ReturnTypeWillChange]
Expand All @@ -45,22 +46,22 @@ public function notify()
$this->setDefaultAlias($tmp);
}
#[\ReturnTypeWillChange]
public function attach ( SplObserver $observer )
public function attach(SplObserver $observer)
{
$observer = $this->_getThis($observer);
$this->defaultAlias->attach($observer);
$this->defaultAlias->attach($observer);
}

#[\ReturnTypeWillChange]
public function detach ( SplObserver $observer )
public function detach(SplObserver $observer)
{
$observer = $this->_getThis($observer);
$this->defaultAlias->detach($observer);
$this->defaultAlias->detach($observer);
}

public function getName()
{
return $this->_name;
return strtolower($this->_name);
}

public function setDoClean($bool)
Expand All @@ -70,29 +71,28 @@ public function setDoClean($bool)

private function _getThis(SplObserver $observer)
{
return \PMVC\get($observer, \PMVC\THIS, function() use($observer) { return $observer; });
return \PMVC\get($observer, \PMVC\THIS, function () use ($observer) {
return $observer;
});
}

public function contains ( SplObserver $observer )
public function contains(SplObserver $observer)
{
$observer = $this->_getThis($observer);
return $this->defaultAlias->contains($observer);
return $this->defaultAlias->contains($observer);
}

public function removeAll ( $object=null )
public function removeAll($object = null)
{
if(empty($object)){
if (empty($object)) {
$object = $this->defaultAlias;
}
$this->defaultAlias->removeAll($object);
}

protected function getTypeOfAlias()
{
$arr = $this->_getTypeOfAlias();
$arr = $this->_getTypeOfAlias();
return [$arr['aliasAsDefault']];
}
}



0 comments on commit 8a1a922

Please sign in to comment.