Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Pôle IS
Bundles Symfony 2
plantuml-bundle
Commits
3fe87e8e
Commit
3fe87e8e
authored
Jul 04, 2019
by
Guillaume Perréal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CS et correction d'un bug dans les filters.
parent
6b09c22c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
18 deletions
+81
-18
src/Model/Filter/AbstractListFilter.php
src/Model/Filter/AbstractListFilter.php
+18
-7
src/Model/Filter/ClassFilter.php
src/Model/Filter/ClassFilter.php
+15
-3
src/Model/Filter/DirectoryFilter.php
src/Model/Filter/DirectoryFilter.php
+22
-3
src/Model/Filter/NamespaceFilter.php
src/Model/Filter/NamespaceFilter.php
+12
-3
src/Model/Graph.php
src/Model/Graph.php
+14
-2
No files found.
src/Model/Filter/AbstractListFilter.php
View file @
3fe87e8e
...
...
@@ -34,16 +34,25 @@ abstract class AbstractListFilter implements ClassFilterInterface
private
$allowed
=
[];
/**
* @var bool
ena
* @var bool
*/
private
$notFound
;
/**
* AbstractListFilter constructor.
* @param array $allowed
* @param bool $notFound
*/
public
function
__construct
(
array
$allowed
,
$notFound
=
false
)
{
$this
->
allowed
=
array_map
([
$this
,
'normalize'
],
$allowed
);
$this
->
notFound
=
$notFound
;
}
/**
* @param ReflectionClass $class
* @return bool
*/
public
function
accept
(
ReflectionClass
$class
)
{
$tested
=
$this
->
normalize
(
$this
->
extract
(
$class
));
...
...
@@ -56,6 +65,9 @@ abstract class AbstractListFilter implements ClassFilterInterface
return
$this
->
notFound
;
}
/**
* @param array $conf
*/
public
function
toConfig
(
array
&
$conf
)
{
$key
=
$this
->
notFound
?
'exclude'
:
'include'
;
...
...
@@ -70,21 +82,20 @@ abstract class AbstractListFilter implements ClassFilterInterface
*
* @return string
*/
abstract
protected
function
normalize
(
$value
);
abstract
protected
function
normalize
(
$value
)
:
string
;
/**
* @param ReflectionClass $class
*
* @return string
*/
abstract
protected
function
extract
(
ReflectionClass
$class
);
abstract
protected
function
extract
(
ReflectionClass
$class
)
:
string
;
/**
* @param string $value
* @param mixed $tested
* @param mixed $reference
*
* @return bool
*/
abstract
protected
function
matches
(
$tested
,
$reference
);
abstract
protected
function
matches
(
$tested
,
$reference
)
:
bool
;
}
src/Model/Filter/ClassFilter.php
View file @
3fe87e8e
...
...
@@ -27,19 +27,31 @@ use ReflectionClass;
*/
class
ClassFilter
extends
AbstractListFilter
{
/**
* @var string
*/
public
const
CONF_TYPE
=
'classes'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
return
$class
->
getName
();
}
protected
function
matches
(
$tested
,
$reference
)
/**
* {@inheritDoc}
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
return
$tested
===
$reference
;
}
protected
function
normalize
(
$className
)
/**
* {@inheritDoc}
*/
protected
function
normalize
(
$className
):
string
{
return
trim
(
$className
,
'\\'
);
}
...
...
src/Model/Filter/DirectoryFilter.php
View file @
3fe87e8e
...
...
@@ -27,19 +27,38 @@ use ReflectionClass;
*/
class
DirectoryFilter
extends
AbstractListFilter
{
/**
* @var string
*/
public
const
CONF_TYPE
=
'directories'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
$filename
=
$class
->
getFileName
();
if
(
$filename
===
false
)
{
return
''
;
}
return
dirname
(
$class
->
getFileName
());
}
protected
function
matches
(
$tested
,
$reference
)
/**
* @param mixed $tested
* @param mixed $reference
* @return bool
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
return
strpos
(
$tested
,
$reference
)
===
0
;
}
protected
function
normalize
(
$path
)
/**
* @param string $path
* @return string
*/
protected
function
normalize
(
$path
):
string
{
return
rtrim
(
strtr
(
$path
,
'/\\'
,
DIRECTORY_SEPARATOR
),
DIRECTORY_SEPARATOR
)
.
DIRECTORY_SEPARATOR
;
}
...
...
src/Model/Filter/NamespaceFilter.php
View file @
3fe87e8e
...
...
@@ -29,17 +29,26 @@ class NamespaceFilter extends AbstractListFilter
{
public
const
CONF_TYPE
=
'namespaces'
;
protected
function
extract
(
ReflectionClass
$class
)
/**
* {@inheritDoc}
*/
protected
function
extract
(
ReflectionClass
$class
):
string
{
return
$class
->
getNamespaceName
();
}
protected
function
matches
(
$tested
,
$reference
)
/**
* {@inheritDoc}
*/
protected
function
matches
(
$tested
,
$reference
):
bool
{
return
strpos
(
$tested
,
$reference
)
===
0
;
}
protected
function
normalize
(
$namespace
)
/**
* {@inheritDoc}
*/
protected
function
normalize
(
$namespace
):
string
{
return
trim
(
$namespace
,
'\\'
)
.
'\\'
;
}
...
...
src/Model/Graph.php
View file @
3fe87e8e
...
...
@@ -38,20 +38,32 @@ class Graph implements GraphInterface
*/
private
$finder
;
/**
* Graph constructor.
* @param ClassVisitorInterface $visitor
* @param FinderInterface $finder
*/
public
function
__construct
(
ClassVisitorInterface
$visitor
,
FinderInterface
$finder
)
{
$this
->
visitor
=
$visitor
;
$this
->
finder
=
$finder
;
}
public
function
visitAll
()
/**
*
*/
public
function
visitAll
():
void
{
foreach
(
$this
->
finder
->
getIterator
()
as
$class
)
{
$this
->
visitor
->
visitClass
(
$class
);
}
}
public
function
writeTo
(
WriterInterface
$writer
)
/**
* @param WriterInterface $writer
* @return $this
*/
public
function
writeTo
(
WriterInterface
$writer
):
self
{
$writer
->
write
(
"@startuml@
\n
"
);
$this
->
visitor
->
writeTo
(
$writer
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment