Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
d9bbc189
Commit
d9bbc189
authored
Sep 02, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented analysis responseparsers and result classes
parent
2915f8cc
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
873 additions
and
2 deletions
+873
-2
library/Solarium/Client.php
library/Solarium/Client.php
+14
-0
library/Solarium/Client/ResponseParser/Analysis/Document.php
library/Solarium/Client/ResponseParser/Analysis/Document.php
+65
-0
library/Solarium/Client/ResponseParser/Analysis/Field.php
library/Solarium/Client/ResponseParser/Analysis/Field.php
+131
-0
library/Solarium/Query/Analysis/Document.php
library/Solarium/Query/Analysis/Document.php
+1
-1
library/Solarium/Query/Analysis/Field.php
library/Solarium/Query/Analysis/Field.php
+1
-1
library/Solarium/Result/Analysis/Document.php
library/Solarium/Result/Analysis/Document.php
+155
-0
library/Solarium/Result/Analysis/Field.php
library/Solarium/Result/Analysis/Field.php
+138
-0
library/Solarium/Result/Analysis/Item.php
library/Solarium/Result/Analysis/Item.php
+175
-0
library/Solarium/Result/Analysis/List.php
library/Solarium/Result/Analysis/List.php
+111
-0
library/Solarium/Result/Analysis/Types.php
library/Solarium/Result/Analysis/Types.php
+82
-0
No files found.
library/Solarium/Client.php
View file @
d9bbc189
...
...
@@ -607,6 +607,20 @@ class Solarium_Client extends Solarium_Configurable
return
$this
->
execute
(
$query
);
}
/**
* Execute an analysis query
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param Solarium_Query_Analysis_Document|Solarium_Query_Analysis_Field $query
* @return Solarium_Result_Analysis_Document|Solarium_Result_Analysis_Field
*/
public
function
analyze
(
$query
)
{
return
$this
->
execute
(
$query
);
}
/**
* Create a query instance
*
...
...
library/Solarium/Client/ResponseParser/Analysis/Document.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/
/**
* Parse document analysis response data
*
* @package Solarium
* @subpackage Client
*/
class
Solarium_Client_ResponseParser_Analysis_Document
extends
Solarium_Client_ResponseParser_Analysis_Field
{
/**
* Parse implementation
*
* @param array $data
* @return array
*/
protected
function
_parseAnalysis
(
$data
)
{
$documents
=
array
();
foreach
(
$data
as
$documentKey
=>
$documentData
)
{
$fields
=
$this
->
_parseTypes
(
$documentData
);
$documents
[]
=
new
Solarium_Result_Analysis_List
(
$documentKey
,
$fields
);
}
return
$documents
;
}
}
\ No newline at end of file
library/Solarium/Client/ResponseParser/Analysis/Field.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/
/**
* Parse document analysis response data
*
* @package Solarium
* @subpackage Client
*/
class
Solarium_Client_ResponseParser_Analysis_Field
extends
Solarium_Client_ResponseParser
{
/**
* Parse response data
*
* @param Solarium_Result_Update $result
* @return array
*/
public
function
parse
(
$result
)
{
$data
=
$result
->
getData
();
if
(
isset
(
$data
[
'analysis'
]))
{
$items
=
$this
->
_parseAnalysis
(
$data
[
'analysis'
]);
}
else
{
$items
=
array
();
}
return
array
(
'status'
=>
$data
[
'responseHeader'
][
'status'
],
'queryTime'
=>
$data
[
'responseHeader'
][
'QTime'
],
'items'
=>
$items
);
}
/**
* Parser
*
* @param array $data
* @return array
*/
protected
function
_parseAnalysis
(
$data
)
{
$types
=
array
();
foreach
(
$data
as
$documentKey
=>
$documentData
)
{
$fields
=
$this
->
_parseTypes
(
$documentData
);
$types
[]
=
new
Solarium_Result_Analysis_List
(
$documentKey
,
$fields
);
}
return
$types
;
}
/**
* Parse analysis types and items
*
* @param array $typeData
* @return array
*/
protected
function
_parseTypes
(
$typeData
)
{
$results
=
array
();
foreach
(
$typeData
as
$fieldKey
=>
$fieldData
)
{
$types
=
array
();
foreach
(
$fieldData
as
$typeKey
=>
$typeData
)
{
// fix for extra level for key fields
if
(
count
(
$typeData
)
==
1
){
$typeData
=
current
(
$typeData
);
}
$counter
=
0
;
$classes
=
array
();
while
(
isset
(
$typeData
[
$counter
])
&&
isset
(
$typeData
[
$counter
+
1
]))
{
$class
=
$typeData
[
$counter
];
$analysis
=
$typeData
[
$counter
+
1
];
$items
=
array
();
foreach
(
$analysis
AS
$itemData
)
{
$items
[]
=
new
Solarium_Result_Analysis_Item
(
$itemData
);
}
$classes
[]
=
new
Solarium_Result_Analysis_List
(
$class
,
$items
);
$counter
+=
2
;
}
$types
[]
=
new
Solarium_Result_Analysis_List
(
$typeKey
,
$classes
);
}
$results
[]
=
new
Solarium_Result_Analysis_Types
(
$fieldKey
,
$types
);
}
return
$results
;
}
}
\ No newline at end of file
library/Solarium/Query/Analysis/Document.php
View file @
d9bbc189
...
...
@@ -58,7 +58,7 @@ class Solarium_Query_Analysis_Document extends Solarium_Query_Analysis
* @var array
*/
protected
$_options
=
array
(
'handler'
=>
'analysis'
,
'handler'
=>
'analysis
/document
'
,
'resultclass'
=>
'Solarium_Result_Analysis_Document'
,
);
...
...
library/Solarium/Query/Analysis/Field.php
View file @
d9bbc189
...
...
@@ -51,7 +51,7 @@ class Solarium_Query_Analysis_Field extends Solarium_Query_Analysis
* @var array
*/
protected
$_options
=
array
(
'handler'
=>
'analysis'
,
'handler'
=>
'analysis
/field
'
,
'resultclass'
=>
'Solarium_Result_Analysis_Field'
,
);
...
...
library/Solarium/Result/Analysis/Document.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Analysis document query result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Analysis_Document
extends
Solarium_Result_QueryType
implements
IteratorAggregate
,
Countable
{
/**
* Document instances array
*
* @var array
*/
protected
$_items
;
/**
* Status code returned by Solr
*
* @var int
*/
protected
$_status
;
/**
* Solr index queryTime
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @var int
*/
protected
$_queryTime
;
/**
* Get Solr status code
*
* This is not the HTTP status code! The normal value for success is 0.
*
* @return int
*/
public
function
getStatus
()
{
$this
->
_parseResponse
();
return
$this
->
_status
;
}
/**
* Get Solr query time
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @return int
*/
public
function
getQueryTime
()
{
$this
->
_parseResponse
();
return
$this
->
_queryTime
;
}
/**
* Get all documents
*
* @return array
*/
public
function
getDocuments
()
{
$this
->
_parseResponse
();
return
$this
->
_items
;
}
/**
* IteratorAggregate implementation
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
$this
->
_parseResponse
();
return
new
ArrayIterator
(
$this
->
_items
);
}
/**
* Countable implementation
*
* @return int
*/
public
function
count
()
{
$this
->
_parseResponse
();
return
count
(
$this
->
_items
);
}
/**
* Get a document by uniquekey value
*
* @param string $key
* @return Solarium_Result_Analysis_List|null
*/
public
function
getDocument
(
$key
)
{
$this
->
_parseResponse
();
if
(
isset
(
$this
->
_items
[
$key
]))
{
return
$this
->
_items
[
$key
];
}
else
{
return
null
;
}
}
}
\ No newline at end of file
library/Solarium/Result/Analysis/Field.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Analysis field query result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Analysis_Field
extends
Solarium_Result_QueryType
implements
IteratorAggregate
,
Countable
{
/**
* List instances array
*
* @var array
*/
protected
$_items
;
/**
* Status code returned by Solr
*
* @var int
*/
protected
$_status
;
/**
* Solr index queryTime
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @var int
*/
protected
$_queryTime
;
/**
* Get Solr status code
*
* This is not the HTTP status code! The normal value for success is 0.
*
* @return int
*/
public
function
getStatus
()
{
$this
->
_parseResponse
();
return
$this
->
_status
;
}
/**
* Get Solr query time
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @return int
*/
public
function
getQueryTime
()
{
$this
->
_parseResponse
();
return
$this
->
_queryTime
;
}
/**
* Get all lists
*
* @return array
*/
public
function
getLists
()
{
$this
->
_parseResponse
();
return
$this
->
_items
;
}
/**
* IteratorAggregate implementation
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
$this
->
_parseResponse
();
return
new
ArrayIterator
(
$this
->
_items
);
}
/**
* Countable implementation
*
* @return int
*/
public
function
count
()
{
$this
->
_parseResponse
();
return
count
(
$this
->
_items
);
}
}
\ No newline at end of file
library/Solarium/Result/Analysis/Item.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Analysis item
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Analysis_Item
{
/**
* @var string
*/
protected
$_text
;
/**
* @var string
*/
protected
$_rawText
;
/**
* @var int
*/
protected
$_start
;
/**
* @var int
*/
protected
$_end
;
/**
* @var int
*/
protected
$_position
;
/**
* @var array
*/
protected
$_positionHistory
;
/**
* @var string
*/
protected
$_type
;
/**
* Constructor
*
* @param array $analysis
*/
public
function
__construct
(
$analysis
)
{
$this
->
_text
=
$analysis
[
'text'
];
$this
->
_start
=
$analysis
[
'start'
];
$this
->
_end
=
$analysis
[
'end'
];
$this
->
_position
=
$analysis
[
'position'
];
$this
->
_positionHistory
=
$analysis
[
'positionHistory'
];
$this
->
_type
=
$analysis
[
'type'
];
if
(
isset
(
$analysis
[
'raw_text'
]))
{
$this
->
_rawText
=
$analysis
[
'raw_text'
];
}
}
/**
* Get text value
*
* @return string
*/
public
function
getText
()
{
return
$this
->
_text
;
}
/**
* Get raw text value
*
* This values is not available in all cases
*
* @return string
*/
public
function
getRawText
()
{
return
$this
->
_rawText
;
}
/**
* Get start value
*
* @return int
*/
public
function
getStart
()
{
return
$this
->
_start
;
}
/**
* Get end value
*
* @return int
*/
public
function
getEnd
()
{
return
$this
->
_end
;
}
/**
* Get postion value
*
* @return int
*/
public
function
getPosition
()
{
return
$this
->
_position
;
}
/**
* Get position history value
*
* @return array
*/
public
function
getPositionHistory
()
{
return
$this
->
_positionHistory
;
}
/**
* Get type value
*
* @return string
*/
public
function
getType
()
{
return
$this
->
_type
;
}
}
\ No newline at end of file
library/Solarium/Result/Analysis/List.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Analysis list result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Analysis_List
implements
IteratorAggregate
,
Countable
{
/**
* @var string
*/
protected
$_name
;
/**
* @var array
*/
protected
$_items
;
/**
* Constructor
*
* @param string $name
* @param array $items
*/
public
function
__construct
(
$name
,
$items
)
{
$this
->
_name
=
$name
;
$this
->
_items
=
$items
;
}
/**
* Get type value
*
* @return string
*/
public
function
getName
()
{
return
$this
->
_name
;
}
/**
* Get all items
*
* @return array
*/
public
function
getItems
()
{
return
$this
->
_items
;
}
/**
* IteratorAggregate implementation
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
_items
);
}
/**
* Countable implementation
*
* @return int
*/
public
function
count
()
{
return
count
(
$this
->
_items
);
}
}
\ No newline at end of file
library/Solarium/Result/Analysis/Types.php
0 → 100644
View file @
d9bbc189
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Analysis types result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Analysis_Types
extends
Solarium_Result_Analysis_List
{
/**
* Get index analysis list
*
* @return Solarium_Result_Analysis_List|null
*/
public
function
getIndexAnalysis
()
{
foreach
(
$this
->
_items
AS
$item
)
{
if
(
$item
->
getName
()
==
'index'
)
{
return
$item
;
}
}
return
null
;
}
/**
* Get query analysis list
*
* @return Solarium_Result_Analysis_List|null
*/
public
function
getQueryAnalysis
()
{
foreach
(
$this
->
_items
AS
$item
)
{
if
(
$item
->
getName
()
==
'query'
)
{
return
$item
;
}
}
return
null
;
}
}
\ No newline at end of file
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