Skip to content

Commit

Permalink
Aspect-Oriented Package to allow AOP approach to some problems using …
Browse files Browse the repository at this point in the history
…annotations, for example logging, injection of request object, etc.
  • Loading branch information
DaGhostman committed Sep 20, 2015
1 parent 0f4ec6b commit 9dc5d60
Show file tree
Hide file tree
Showing 17 changed files with 1,126 additions and 3 deletions.
41 changes: 41 additions & 0 deletions src/Wave/Framework/Annotations/Controller/Request.php
@@ -0,0 +1,41 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\Controller;

use Doctrine\Common\Annotations\Annotation;

/**
* Class Request
* @package Wave\Framework\Annotations\Controller
*
* @Annotation
* @Annotation\Target("METHOD")
*/
class Request extends Annotation
{}
42 changes: 42 additions & 0 deletions src/Wave/Framework/Annotations/Controller/Template.php
@@ -0,0 +1,42 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\Controller;

use Doctrine\Common\Annotations\Annotation;

/**
* Class Template
* @package Wave\Framework\Annotations\Controller
*
* @Annotation
* @Annotation\Target("METHOD")
*/
class Template extends Annotation
{
}
90 changes: 90 additions & 0 deletions src/Wave/Framework/Annotations/General/Catchable.php
@@ -0,0 +1,90 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\General;


use Doctrine\Common\Annotations\Annotation;

/**
* Class Catchable
* @package Wave\Framework\Annotations\General
* @Annotation
* @Annotation\Target("METHOD")
*/
class Catchable extends Annotation
{
/**
* @var array
*/
public $map = [];

/**
* @return array
*/
public function getMap()
{
return $this->map;
}

/**
* @param $exception
* @return string
*/
public function getExceptionSeverity($exception)
{
if (!array_key_exists($exception, $this->map)) {
return 'emergency';
}

return $this->map[$exception]['severity'];
}

/**
* @param $exception
* @return string
*/
public function getExceptionMessage($exception)
{
if (!array_key_exists($exception, $this->map)) {
return <<<MESSAGE
Call of {class}:{method} resulted in "{exception}" exception with message {message} @ {file}:{line} \n\r
Arguments: {arguments}
MESSAGE;
}

if (!array_key_exists('message', $this->map[$exception])) {
return <<<MESSAGE
Call of {class}:{method} resulted in "{exception}" exception with message {message} @ {file}:{line} \n\r
Arguments: {arguments}
MESSAGE;
}

return $this->map[$exception]['message'];
}
}
54 changes: 54 additions & 0 deletions src/Wave/Framework/Annotations/Http/Headers.php
@@ -0,0 +1,54 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\Http;

use Doctrine\Common\Annotations\Annotation;

/**
* Class Headers
* @package Wave\Framework\Annotations\Http
*
* @Annotation
* @Annotation\Target("METHOD")
*/
class Headers extends Annotation
{
/**
* @var array
*/
protected $headers = [];

/**
* @return array
*/
public function getHeaders()
{
return $this->headers;
}
}
67 changes: 67 additions & 0 deletions src/Wave/Framework/Annotations/Http/Response.php
@@ -0,0 +1,67 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\Http;

use Doctrine\Common\Annotations\Annotation;

/**
* Class Response
* @package Wave\Framework\Annotations\Http
*
* @Annotation
* @Annotation\Target("METHOD")
*/
class Response extends Annotation
{
/**
* @var int
*/
protected $status = 200;

/**
* @var array
*/
protected $headers = [];

/**
* @return int
*/
public function getStatus()
{
return $this->status;
}

/**
* @return array
*/
public function getHeaders()
{
return $this->headers;
}
}
55 changes: 55 additions & 0 deletions src/Wave/Framework/Annotations/Http/Status.php
@@ -0,0 +1,55 @@
<?php
/**
* @author Dimitar
* @copyright 2015 Dimitar Dimitrov <daghostman.dimitrov@gmail.com>
* @package codewave
* @license MIT
*
* MIT LICENSE
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace Wave\Framework\Annotations\Http;


use Doctrine\Common\Annotations\Annotation;

/**
* Class Status
* @package Wave\Framework\Annotations\Http
*
* @Annotation
* @Annotation\Target("Method")
*/
class Status extends Annotation
{
/**
* @var int
*/
public $status;

/**
* @return int
*/
public function getStatus()
{
return $this->status;
}
}

0 comments on commit 9dc5d60

Please sign in to comment.