Skip to content

Commit

Permalink
Basic pointcut matching of method, class, within
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Aug 26, 2013
1 parent 1a502bf commit f835108
Show file tree
Hide file tree
Showing 16 changed files with 898 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/ClassAnnotateWithMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class ClassAnnotateWithMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

public function matches(Kdyby\Aop\Pointcut\Method $method)
{

}

}
43 changes: 43 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/ClassMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class ClassMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

/**
* @var string
*/
private $class;



public function __construct($class)
{
$this->class = str_replace('\\*', '.*', preg_quote($class));
}



public function matches(Kdyby\Aop\Pointcut\Method $method)
{
return preg_match('~^' . $this->class . '\z~i', $method->getClassName());
}

}
29 changes: 29 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/EvaluateMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class EvaluateMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

public function matches(Kdyby\Aop\Pointcut\Method $method)
{

}

}
29 changes: 29 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/FilterMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class FilterMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

public function matches(Kdyby\Aop\Pointcut\Method $method)
{

}

}
29 changes: 29 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/MethodAnnotateWithMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class MethodAnnotateWithMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

public function matches(Kdyby\Aop\Pointcut\Method $method)
{

}

}
46 changes: 46 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/MethodMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class MethodMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

/**
* @var string
*/
private $method;



/**
* @todo visibility
*/
public function __construct($method)
{
$this->method = str_replace('\\*', '.*', preg_quote($method));
}



public function matches(Kdyby\Aop\Pointcut\Method $method)
{
return preg_match('~^' . $this->method . '\z~i', $method->getName());
}

}
29 changes: 29 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/SettingMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class SettingMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

public function matches(Kdyby\Aop\Pointcut\Method $method)
{

}

}
43 changes: 43 additions & 0 deletions src/Kdyby/Aop/Pointcut/Matcher/WithinMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/

namespace Kdyby\Aop\Pointcut\Matcher;

use Kdyby;
use Nette;



/**
* @author Filip Procházka <[email protected]>
*/
class WithinMatcher extends Nette\Object implements Kdyby\Aop\Pointcut\Rule
{

/**
* @var string
*/
private $type;



public function __construct($type)
{
$this->type = Nette\Reflection\ClassType::from($type)->getName();
}



public function matches(Kdyby\Aop\Pointcut\Method $method)
{
return isset($method->typesWithin[$this->type]);
}

}
Loading

0 comments on commit f835108

Please sign in to comment.